That should be like this
echo "<script>
pathArr = window.location.pathname.split('/');
path = window.location.protocol + '//' + window.location.host+'/';
for (i=1;i<pathArr.length-1;i++) path += pathArr[i]+'/';
GB_showCenter('ECR', path+'ecrframe-qty.php' , 800, 600)";
echo "</script>";