

/***********************************************
* Drag and Drop Script: © Dynamic Drive (http://www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

 function get_ObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=get_ObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=get_ObjectByID(id,els[n]); if(el) return el; } }
 return null;
	}

 function FP_changeProp() {//v1.0
 var args=arguments,d=document,i,j,id=args[0],o=get_ObjectByID(id),s,ao,v,x;
 d.$cpe=new Array(); 
 if(o) for(i=2; i<args.length; i+=2) { 
 v=args[i+1]; s="o"; 
 ao=args[i].split("."); 
 for(j=0; j<ao.length; j++) { 
		s+="."+ao[j]; 
		if(null==eval(s)) { 
  		s=null; 
			break; 
			}
		} 
		x=new Object; 
		x.o=o; 
		x.n=new Array(); 
		x.v=new Array();
 x.n[x.n.length]=s; 
 eval("x.v[x.v.length]="+s); 
 d.$cpe[d.$cpe.length]=x;
 if(s) eval(s+"=v"); }
}


var dragobject={
z: 0, x: 0, y: 0, offsetx : null, offsety : null, targetobj : null, dragapproved : 0,
initialize:function(){
document.onmousedown=this.drag;
document.onmouseup=function(){this.dragapproved=0;}
},
drag:function(e){
var evtobj=window.event? window.event : e;
this.targetobj=window.event? event.srcElement : e.target;
if (this.targetobj.className=="drag"){
this.dragapproved=1;
if (isNaN(parseInt(this.targetobj.style.left))){this.targetobj.style.left=0;}
if (isNaN(parseInt(this.targetobj.style.top))){this.targetobj.style.top=0;}
this.offsetx=parseInt(this.targetobj.style.left);
this.offsety=parseInt(this.targetobj.style.top);
this.x=evtobj.clientX;
this.y=evtobj.clientY;
if (evtobj.preventDefault)
evtobj.preventDefault();
document.onmousemove=dragobject.moveit;
}
},
moveit:function(e){
var evtobj=window.event? window.event : e
if (this.dragapproved==1){
this.targetobj.style.left=this.offsetx+evtobj.clientX-this.x+"px"
this.targetobj.style.top=this.offsety+evtobj.clientY-this.y+"px"
return false
}
}
}

dragobject.initialize();

/**** myCode starts ****/

function init_popup() {
	/* backgroud layer */
	document.write("<div id='popup_window_background' style='background-color:#000000; ")
	document.write("filter:alpha(opacity=60); -moz-opacity: 0.6; opacity: 0.6; z-index:100; ");
	document.write("LEFT: 0px; VISIBILITY: hidden; WIDTH: 100%; POSITION: absolute; TOP: 0px; HEIGHT: 100%'></div>");
	/* draggable window layer */
	document.write("<DIV class='drag' id='popup_window' style='BORDER: #06F 2px groove; Z-INDEX: 1; FILTER: alpha(opacity=75);");
	document.write("VISIBILITY:hidden;POSITION: absolute; WIDTH: auto; HEIGHT: auto; TOP: 177px; LEFT: 195px; z-index:101;'>");
	document.write("<div class='Mid_Top_Bar' id='popup_window_content'></div></DIV>");	
	}

//init_popup();

function ShowPopup(pwName){
  centerIt(document.getElementById(pwName));
	FP_changeProp(pwName,0,'style.visibility','visible');	
	}
function ClosePopup(pwName){
  FP_changeProp(pwName,0,'style.visibility','hidden');	
}	

function ShowModalPopup(pwName) {
	FP_changeProp('popup_window_background',0,'style.visibility','visible');
	centerIt(document.getElementById(pwName));
	FP_changeProp(pwName,0,'style.visibility','visible');		
	}
function CloseModalPopup(pwName) {
	FP_changeProp('popup_window_background',0,'style.visibility','hidden');
	FP_changeProp(pwName,0,'style.visibility','hidden');		
	}
function moveIt(obj, mvTop, mvLeft) {
	obj.style.position = "absolute";
	obj.style.top = mvTop;
	obj.style.left = mvLeft;
}
function centerIt(obj) {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  var oWidth = 0, oHeight = 0;
  oWidth  = obj.offsetWidth;
  oHeight = obj.offsetHeight;
  moveIt(obj,(parseInt(myHeight/2)-parseInt(oHeight/2)) + "px", (parseInt(myWidth/2)-parseInt(oWidth/2)) + "px");
}

function waitScreen(show) {  
  if (show) {
    centerIt(document.getElementById("wait_logo"));
    FP_changeProp('popup_window_background',0,'style.visibility','visible');
	  FP_changeProp('wait_logo',0,'style.visibility','visible');
  } else {
    FP_changeProp('wait_logo',0,'style.visibility','hidden');
  }
}

function closeWaitScreen() { FP_changeProp('popup_window_background', 0, 'style.visibility', 'hidden'); FP_changeProp('wait_logo', 0, 'style.visibility', 'hidden'); }

function openTerms() {
  waitScreen(true);
  $.get("terms.html", function(data){
    var terms = document.getElementById("terms_window");
    centerIt(terms);
    terms.innerHTML = data;
    waitScreen(false);
    ShowModalPopup("terms_window"); 
  });  
}
