

/////functions for the pop up window move///////
var startX;       //start x axis of the pop up window 
var startY = 0;
var verticalpos="fromtop"; //where to appear
var pin = 0;

function chkcompat(){
if (document.compatMode && document.compatMode!="BackCompat")
return document.documentElement;
else
return document.body;
}  ///chk compatibility FF IE


function adjuststartx()
{
if (document.body.offsetWidth - 800 >= 0)
startX = (document.body.offsetWidth - 800)/2;
else
startX = 0;
}

function adverpos(){

	barheight=document.getElementById("popup").offsetHeight
	var ns = (navigator.appName.indexOf("Netscape") != -1) || window.opera;

   function ml(id){
		var el=document.getElementById(id);
		
		if(document.layers)el.style=el;
	    el.sP=function(x,y){this.style.left=x+"px";this.style.top=y+"px";};
	    el.x = startX;
		if (verticalpos=="fromtop")
		el.y = startY;
		else{
		el.y = ns ? pageYOffset + innerHeight : chkcompat().scrollTop + chkcompat().clientHeight;
		el.y -= startY;
		}
		return el;
	}
	
	window.stayTopLeft=function(){
		if (verticalpos=="fromtop"){
		var pY = ns ? pageYOffset : chkcompat().scrollTop;
		ftlObj.y += (pY + startY - ftlObj.y)/8;
		}
		else{
		var pY = ns ? pageYOffset + innerHeight - barheight: chkcompat().scrollTop + chkcompat().clientHeight - barheight;
		ftlObj.y += (pY - startY - ftlObj.y)/8;
		}
	
		ftlObj.sP(ftlObj.x, ftlObj.y);
		
		if (pin == 0)
		 thistimer = setTimeout("stayTopLeft()", 10);
	   
	}
	ftlObj = ml("popup");
	stayTopLeft();
   }

/////adjust the position of the window when window resize

window.onresize = function changpos()
{
 adjuststartx();
  var el = document.getElementById("popup");
  el.x = startX;
}


////Pin the popup div ///
function pincontent()
{
    var child = document.getElementById("pin_pic");
     if (child.src.split("$_")[1] == "pin.jpg")
     {
        child.src = "images/$_Unpin.jpg";
		pin = 1;
        clearTimeout(thistimer);
     }
     else
     {
        child.src = "images/$_pin.jpg";
		pin = 0;
        adverpos();
     }
}


function contentdiv() ////display the content and the mask div
{
     document.getElementById("mask").style.height = document.body.scrollHeight;
     if (document.body.offsetWidth - 800 >= 0)
     startX = (document.body.offsetWidth - 800)/2;
     else
     startX = 0;
     var browser=navigator.appName;
     var b_version=navigator.appVersion;
    // document.getElementById("mask").style.display = "block"; 
	$("#mask").fadeIn("fast"); 
     if (browser == "Microsoft Internet Explorer")
     { 
       if (b_version.split("MSIE")[1].split(".")[0] == 6)
       document.getElementById("mask").style.display = "none"; 
	 }
       //document.getElementById("popup").style.display = "block"; 
	   $("#popup").slideDown("slow"); 
	   adverpos();
}


function discontentdiv() //Hide the content and the mask div
{
    //document.getElementById("mask").style.display = "none";  
    //document.getElementById("popup").style.display = "none";  
	$("#mask").fadeOut("fast"); 
	$("#popup").hide("slow");  
	//var child = document.getElementById("pin_pic");
	//child.src = "images/$_pin.jpg";
    pin = 0;
    clearTimeout(thistimer);
}

///////////////////////////////Insert Content for content div









/*---------
Popup window id: popup
Background mask id: mask
The pin window pic id: pin_pic
---------------*/

