
<!--
var $ID=function(tagName){return document.getElementById(tagName);}
var oevent=new Function('e','if (!e) e = window.event;return e')
var checknowleft=function(z){return (z);}
var chkleft=function(z){return ((z<11.875)?0:((z%23.75>11.875)?z+23.75-z%23.75:z-z%23.75));}
function killErrors() {
return true;
}
window.onerror =killErrors;
//var p_step=15;


function Move_obj(obj,barid,p_step,str){
	var x,y,z,drag_=false;
	var hb,hbnum;
    hbnum=100/parseFloat(str.substr(str.indexOf("~")+1));
    hb=Trim(str.substr(str.indexOf("-")+1,str.indexOf("~")-str.indexOf("-")-1));
    
	obj.onmousedown=function(e){
	
		drag_=true;
		with(this){
			var temp0=style.left.replace("px","")*1;
			
			var temp1=offsetLeft;
			var temp2=offsetTop;
			x=oevent(e).clientX;y=oevent(e).clientY;
			document.onmousemove=function(e){
				if(!drag_)return false;
				with(this){
					z = temp0 + oevent(e).clientX-x;
					outxx="out"+eval(barid+1);
					//alert("out2");
					pleft=$ID(outxx).value.replace("px","")*1/p_step;
					
					if (z>pleft-1){z=pleft-1;drag_=false;}
					if (z<0){z=0;drag_=false;}
					if (z>189){z=189;}
					
					$ID("TB_"+barid).style.left=z+1;
					
					$ID("TB_"+barid).style.width=189-z-(189-pleft)+7;
					style.left=z+"px";
					$ID("out"+barid).value =(z)*p_step;
					//if (barid!=3)
					   // $ID("outlb"+barid).innerText = Math.floor((z)*p_step);
				       // else
				    if (hb!="HKD" && barid==3)
                        {
                        $ID("outlb"+barid).innerText=formatCurrency(z*p_step*hbnum);
                            
                        }
                        else
    				    $ID("outlb"+barid).innerText = formatCurrency(z*p_step);
				    //$ID("outlb"+barid).innerText = formatCurrency(z*p_step);
					

				}
			}
			document.onmouseup=function(e){
				drag_ = false;
				var nowleft = checknowleft(z);
				style.left=nowleft+"px";
				$ID("out"+barid).value = Math.floor((z)*p_step);
				//if (barid!=3)
				//$ID("outlb"+barid).innerText = Math.floor((z)*p_step);
				//else
				if (hb!="HKD" && barid==3)
                        {
                        $ID("outlb"+barid).innerText=formatCurrency(z*p_step*hbnum);
                            
                        }
                        else
    				    $ID("outlb"+barid).innerText = formatCurrency(z*p_step);
			}
		}
	}
}

function set_obj(barid,p_step,str)
{	               
                     var hb,hbnum;
                    hbnum=100/parseFloat(str.substr(str.indexOf("~")+1));
                    hb=Trim(str.substr(str.indexOf("-")+1,str.indexOf("~")-str.indexOf("-")-1));

					
					$ID("mobj"+barid).style.left=$ID("out"+barid).value/p_step;
					$ID("TB_"+barid).style.left=$ID("out"+barid).value/p_step;
					//alert($ID("mobj"+barid).style.left)
					//$ID("TB_"+barid).style.width=199-($ID("out"+barid).value/p_step)+5;
					//if (barid!=3)
					//$ID("outlb"+barid).innerText = $ID("out"+barid).value;
					//else
					if (barid==3 && hb!="HKD")
					    {
					    $ID("outlb"+barid).innerText = formatCurrency(parseFloat($ID("out"+barid).value)*hbnum);
					    hb=Trim(hb);
					    //alert($ID("hblb").innerText);
                        $ID("hblb").innerText=Trim(hb);
                         
					    }
					 else
					 $ID("outlb"+barid).innerText = formatCurrency($ID("out"+barid).value);
					 
					outxx=eval(barid+1);
					$ID("mobj"+outxx).style.left=$ID("out"+outxx).value/p_step;
					$ID("TB_"+barid).style.left=$ID("out"+barid).value/p_step;
					pleft=$ID("out"+barid).value.replace("px","")*1/p_step;
					$ID("TB_"+barid).style.width=($ID("out"+outxx).value/p_step)-($ID("out"+barid).value/p_step)+12;
					//alert($ID("TB_"+barid).style.width)
					//if (barid!=4)
					if (outxx==4 && hb!="HKD")
					    {
					    $ID("outlb"+outxx).innerText = formatCurrency( parseFloat($ID("out"+outxx).value)*hbnum);
					    }
					else
					$ID("outlb"+outxx).innerText = formatCurrency( $ID("out"+outxx).value);
					//alert(formatCurrency( $ID("out"+outxx).value))
					

}



function Move_obj1(obj,barid,p_step,str){
	var x,y,z,drag_=false;
	var hb,hbnum;
    hbnum=100/parseFloat(str.substr(str.indexOf("~")+1));
    hb=Trim(str.substr(str.indexOf("-")+1,str.indexOf("~")-str.indexOf("-")-1));
    
	obj.onmousedown=function(e){
		drag_=true;
		with(this){
			var temp0=style.left.replace("px","")*1;
			if (temp0=="") temp0=189;
			//alert(style.left.replace("px",""));
			var temp1=offsetLeft;
			
			var temp2=offsetTop;
			x=oevent(e).clientX;y=oevent(e).clientY;
			document.onmousemove=function(e){
				if(!drag_)return false;
				with(this){
					z = temp0 + oevent(e).clientX-x;
					outxx="out"+eval(barid-1);
					//alert(outxx);
					pleft=$ID(outxx).value.replace("px","")*1/p_step;
					
					if (z<pleft){z=pleft;drag_=false;}
					if (z<0){z=0;}
					if (z>189){z=189;drag_=false;}
					style.left=z+"px";
					$ID("TB_"+eval(barid-1)).style.width=z-pleft+7;
					//out=eval("out"+string(barid));
					$ID("out"+barid).value = (z+1)*p_step;
					//if (barid!=4)
					//$ID("outlb"+barid).innerText = Math.floor((z+1)*p_step);
					//else
					if (hb!="HKD" && barid==4)
                        {
                        $ID("outlb"+barid).innerText=formatCurrency(z*p_step*hbnum);
                        }
                        else
					$ID("outlb"+barid).innerText =formatCurrency((z+1)*p_step);
					
				}
			}
			document.onmouseup=function(e){
				drag_ = false;
				var nowleft = checknowleft(z);
				style.left=nowleft+"px";
				$ID("out"+barid).value = Math.floor((z+1)*p_step);
				//if (barid!=4)
					//$ID("outlb"+barid).innerText = Math.floor((z+1)*p_step);
					//else
					if (hb!="HKD" && barid==4)
                        {
                        $ID("outlb"+barid).innerText=formatCurrency(z*p_step*hbnum);
                        }
                        else
					$ID("outlb"+barid).innerText =formatCurrency((z+1)*p_step);
			}
		}
	}
}



function set_obj1(barid,p_step)
{

					
					$ID("mobj"+barid).style.left=$ID("out"+barid).value*p_step;
					$ID("TB_"+barid).style.left=$ID("out"+barid).value*p_step;
					//$ID("TB_"+barid).style.width=199-($ID("out"+barid).value/p_step)+5;
					if($ID("out"+barid).value==0)
					    $ID("outlb"+barid).innerText='Studio';
					else
					    $ID("outlb"+barid).innerText = $ID("out"+barid).value;
					outxx=eval(barid+1);
					if($ID("out"+outxx).value==10) 
					$ID("mobj"+outxx).style.left=$ID("out"+outxx).value*p_step;
					else
					$ID("mobj"+outxx).style.left=$ID("out"+outxx).value*p_step;
					
					$ID("TB_"+barid).style.left=$ID("out"+barid).value*p_step;
					pleft=$ID("out"+barid).value.replace("px","")*1*p_step;
		
					$ID("TB_"+barid).style.width=($ID("out"+outxx).value*p_step+6)-($ID("out"+barid).value*p_step)+6;
					$ID("outlb"+outxx).innerText = $ID("out"+outxx).value;
					


}


function M_obj(obj,barid,p_step)
{
var x,y,z,drag_=false;
	obj.onmousedown=function(e){
		drag_=true;
		with(this){
			var temp0=style.left.replace("px","")*1;var temp1=offsetLeft;var temp2=offsetTop;
			x=oevent(e).clientX;y=oevent(e).clientY;
			document.onmousemove=function(e){
				if(!drag_)return false;
				with(this){
					z = temp0 + oevent(e).clientX-x;
					outxx="out"+eval(barid+1);
					pleft=$ID(outxx).value.replace("px","")*1*23.75;
					if(z>pleft-1){z=pleft;}
					if (z<0){z=0;drag_=false;}
					if (z>189){z=189;}
					style.left=z+"px";
					$ID("TB_"+barid).style.left=z+1;
					$ID("TB_"+barid).style.width=(pleft-z)+7+6;
					var nowleft = chkleft(z);
					$ID("outlb"+barid).innerText =((nowleft)/23.75);
				}
			}
			document.onmouseup=function(e){
				drag_ = false;
				var nowleft = chkleft(z);
				if (nowleft==189)
				 style.left=nowleft+0;
				else
				style.left=nowleft;
                $ID("TB_"+barid).style.left=nowleft+6+1;
                //alert(nowleft)
                $ID("TB_"+barid).style.width=(pleft+6-nowleft);
				$ID("out"+barid).value = nowleft/23.75;
				if((nowleft/23.75)==0)
				$ID("outlb"+barid).innerText='Studio';
				else
				$ID("outlb"+barid).innerText =((nowleft)/23.75);
			}
		}
	}
}

function M_obj1(obj,barid,p_step){
var x,y,z,drag_=false;
	obj.onmousedown=function(e){
		drag_=true;
		with(this){
			var temp0=style.left.replace("px","")*1;
			if (temp0=="")temp0=189;
			
			var temp1=offsetLeft;var temp2=offsetTop;
			x=oevent(e).clientX;y=oevent(e).clientY;
			document.onmousemove=function(e){
				if(!drag_)return false;
				with(this){
					z = temp0 + oevent(e).clientX-x;
					outxx="out"+eval(barid-1);
					pleft=$ID(outxx).value.replace("px","")*1*23.75;
					if(z<pleft+1){z=pleft;}
					if (z<0){z=0;drag_=false;}
					if (z>189){z=189;}
					style.left=z+"px";
					$ID("TB_"+(barid-1)).style.left=pleft+1;
					$ID("TB_"+(barid-1)).style.width=z-pleft+7;
					var nowleft = chkleft(z);
					$ID("outlb"+barid).innerText =((nowleft/23.75));
				}
			}
			document.onmouseup=function(e){
				drag_ = false;
				var nowleft = chkleft(z);
				if (nowleft==189)
				style.left=nowleft+6;
				else
				style.left=nowleft;
				
				$ID("TB_"+(barid-1)).style.width=189-(189-nowleft-6)-pleft+7;
				$ID("out"+barid).value = (nowleft/23.75);
				if((nowleft/23.75)==0)
				$ID("outlb"+barid).innerText='Studio';
				else
				$ID("outlb"+barid).innerText =((nowleft/23.75));
			}
		}
	}
	
}




function formatCurrency(num) {
num = num.toString().replace(/\$|\,/g,'');
if(isNaN(num))
num = "0";
sign = (num == (num = Math.abs(num)));
num = Math.floor(num*100+0.50000000001);
cents = num%100;
num = Math.floor(num/100).toString();
if(cents<10)
cents = "0" + cents;
for (var i = 0; i < Math.floor((num.length-(1+i))/3); i++)
num = num.substring(0,num.length-(4*i+3))+','+
num.substring(num.length-(4*i+3));
return (((sign)?'':'-')  + num );
}

function LTrim(str)
{
    var i;
    for(i=0;i<str.length;i++)
    {
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;
    }
    str=str.substring(i,str.length);
    return str;
}
function RTrim(str)
{
    var i;
    for(i=str.length-1;i>=0;i--)
    {
        if(str.charAt(i)!=" "&&str.charAt(i)!=" ")break;
    }
    str=str.substring(0,i+1);
    return str;
}
function Trim(str)
{
    return LTrim(RTrim(str));
}

function testfun(str)
{
var hb,hbnum;
hbnum=100/parseFloat(str.substr(str.indexOf("~")+1));
hb=str.substr(str.indexOf("-")+1,str.indexOf("~")-str.indexOf("-")-1);
hb=Trim(hb);
$ID("hblb").innerText=Trim(hb);
if (hb!="HKD")
    {
        hbout3=$ID("out3").value*hbnum;
        hbout4=$ID("out4").value*hbnum;
        
    }
    else
    {
        hbout3=$ID("out3").value;
        hbout4=$ID("out4").value;
    }
    $ID("outlb3").innerText=formatCurrency(hbout3)
    $ID("outlb4").innerText=formatCurrency(hbout4)

}
//  End -->



