// Drop-in content box- By Dynamic Drive
// For full source code and more DHTML scripts, visit http://www.dynamicdrive.com
// This credit MUST stay intact for use

var ie1=document.all
var dom1=document.getElementById
var ns4=document.layers
var calunits=document.layers? "" : "px"

var bouncelimit=32 //(must be divisible by 8)
var direction="up"

function initbox(){
if (!dom1&&!ie1&&!ns4)
return
crossobj=(dom1)?document.getElementById("dropin").style : ie1? document.all.dropin : document.dropin
scroll_top=(ie1)? truebody().scrollTop : window.pageYOffset
crossobj.top=scroll_top-250+calunits
crossobj.visibility=(dom1||ie1)? "visible" : "show"
dropstart=setInterval("dropin()",50)
}

function dropin(){
scroll_top=(ie1)? truebody().scrollTop : window.pageYOffset
if (parseInt(crossobj.top)<100+scroll_top)
crossobj.top=parseInt(crossobj.top)+40+calunits
else{
clearInterval(dropstart)
bouncestart=setInterval("bouncein()",50)
}
}

function bouncein(){
crossobj.top=parseInt(crossobj.top)-bouncelimit+calunits
if (bouncelimit<0)
bouncelimit+=8
bouncelimit=bouncelimit*-1
if (bouncelimit==0){
clearInterval(bouncestart)
}
}

function dismissbox(){
if (window.bouncestart) clearInterval(bouncestart)
crossobj.visibility="hidden";
document.getElementById("divMain").style.visibility="hidden";

//if IE4+
document.onselectstart=new Function ("return false")

//if NS6
if (window.sidebar){
document.onmousedown=disableselect;
document.onclick=reEnable;
}
}

function redo(){


	//if IE4+
	document.onselectstart=reEnable;

	//if NS6
	if (window.sidebar){
	document.onmousedown=reEnable;
	document.onclick=reEnable;
	}
	bouncelimit=32
	direction="up"
	initbox()
}

function truebody(){
return (document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}


//window.onload=initbox
function getPageSizeWithScroll()
{
    if (window.innerHeight && window.scrollMaxY) 
	{// Firefox         
		yWithScroll = window.innerHeight + window.scrollMaxY;
		xWithScroll = window.innerWidth + window.scrollMaxX;     
	}
	else if (document.body.scrollHeight > document.body.offsetHeight)
	{ // all but Explorer Mac         
		yWithScroll = document.body.scrollHeight;         
		xWithScroll = document.body.scrollWidth;     
	} else 
	{ // works in Explorer 6 Strict, Mozilla (not FF) and Safari         
	yWithScroll = document.body.offsetHeight;         
	xWithScroll = document.body.offsetWidth;       
	}
	
	document.getElementById("divMain").style.height = yWithScroll;
	if (!ie1)
	{
		var centerY = ( window.innerWidth - 599 ) / 2 ;
		document.getElementById("divPopup").style.left = centerY+"px";
	}
}
function AddGioHang( product_id, price )
{
	getPageSizeWithScroll();
	postajax( "divTotalGiohang", "add_giohang.php", "product_id="+product_id+"&price="+price );
	
	document.getElementById("divMain").style.visibility=(dom1||ie1)? "visible" : "show";
	redo();
}

function popupintro( act )
{
	if ( act == 'close' )
	{
		document.getElementById("divMain").style.visibility=(dom1||ie1)? "hidden" : "none";
		document.getElementById("divPopup").style.visibility=(dom1||ie1)? "hidden" : "none";
	}
	else
	{
		getPageSizeWithScroll();
		
		document.getElementById("divMain").style.visibility=(dom1||ie1)? "visible" : "show";
		document.getElementById("divPopup").style.visibility=(dom1||ie1)? "visible" : "show";
	}
}
function disableselect(e){
return false
}

function reEnable(){
return true
}
