
function getWidth() {
			var myWidth = 0;
	if( typeof( window.innerWidth ) == 'number' ) {
    	//Non-IE
   		myWidth = window.innerWidth;
  		}
	else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) )
	{
	    //IE 6+ in 'standards compliant mode'
	    myWidth = document.documentElement.clientWidth;
			}
	else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) 
	{
	    //IE 4 compatible
	    myWidth = document.body.clientWidth;
  	}
	//myWidth = 600;
	return myWidth;			
}


function toggle_pop(showtype)
{
	// GET popbox div from DOM
	if (document.getElementById){
		var popbox = document.getElementById('popbox');
	}
	else if (document.all)
	{
		var popbox = document.all.popbox;
	}
	
	// TOGLE
	if(popbox.style.visibility == "visible")
	{
		popbox.style.visibility = "hidden";
		popbox.style.display = "none";
	}
	else
	{
		popbox.style.display = "block";
		//popbox.style.top = popbox.offsetHeight/2;
		// popbox.style.top = (screen.availHeight - popbox.offsetHeight) /2;
		popbox.style.top = 100;;
		popbox.style.left = - popbox.offsetWidth;
		
		if(showtype == "static")
		{
			popbox.style.left = ((getWidth()/2) - 150);
		}
		popbox.style.visibility = "visible";
		
		if(showtype != "static")
		{
			poptimer = setInterval("mover()", 1);
		}
	}
}// end function

function static_pop()
{
	// GET popbox div from DOM
	if (document.getElementById){
		var popbox = document.getElementById('popbox');
	}
	else if (document.all)
	{
		var popbox = document.all.popbox;
	}
	
	// SHOW
	popbox.style.display = "block";
	popbox.style.visibility = "visible";

}// end function

function mover()
{
	var showfor = 20;
	if (document.getElementById){
		var divobj = document.getElementById('popbox');
	}
	else if (document.all)
	{
		var divobj = document.all.popbox;
	}
	var leftpos = parseInt( divobj.style.left.substring( 0 , divobj.style.left.length-2 ) );
	if( isNaN(leftpos) ){
		leftpos = 0;
	}
	// find center of screen and minus the width of the box
	var screen_center_w = (Math.round(((getWidth())/2)) - divobj.offsetWidth/2);

	if(  leftpos <= screen_center_w)
	{
		leftpos = leftpos + 20;
		divobj.style.left = leftpos;	
	}
	else
	{
		clearInterval(poptimer);
		setTimeout("poptimer2 = setInterval('moveback()',6)", showfor * 1000);
	}
	
	
}

function moveback()
{
	// GET popbox div from DOM
	if (document.getElementById){
		var divobj = document.getElementById('popbox');
	}
	else if (document.all)
	{
		var divobj = document.all.popbox;
	}
	
	
	var toppos = parseInt( divobj.style.top.substring( 0 , divobj.style.top.length-2 ) );
	
	if(  toppos >= - divobj.offsetHeight)
	{
		toppos = toppos - 20;
		divobj.style.top = toppos;
	}
	else
	{
		clearInterval(poptimer2);
	}
}
