var menu_hide=false;                                        
var menu_id_current=null;     
var box_prd_description_hide=false;
var box_prd_description_id_current=null;   
//align: 0=top,1=right,2=bottom,3=left                                
function menu_popup(in_menu_id,in_main_menu_id,align)
{                                        
	var parent,top,left,menu_id,main_menu_id;
	top=0;left=0;
	
	if(typeof(in_menu_id)=="string")
		menu_id=document.getElementById(in_menu_id);
	else
		menu_id=in_menu_id;
		
	if(typeof(in_main_menu_id)=="string")
		main_menu_id=document.getElementById(in_main_menu_id);
	else
		main_menu_id=in_main_menu_id;


	var top_parent=main_menu_id.offsetTop;
	var left_parent=main_menu_id.offsetLeft;
	parent=main_menu_id.offsetParent;
	
	while(parent)
	{
		if(parent.tagName.toUpperCase()!="BODY");
		{
			top_parent+=parent.offsetTop;
			left_parent+=parent.offsetLeft;
		}
		parent=parent.offsetParent;
	}


	if((align==0)||(align==2))
	{

		top=top_parent+ main_menu_id.offsetHeight;
		left=left_parent;
	}
	else
	{
		top=top_parent;
		left=left_parent+main_menu_id.offsetWidth;
	}
        	
	if(menu_id_current)
	{   
		if(menu_id_current.style)                
			menu_id_current.style.visibility="hidden";                                   
	}
	if(menu_id.style)
	{
		if(top>=0)
			menu_id.style.top=top+"px";
		if(left>=0)
			menu_id.style.left=left+"px";
		if(window.ActiveXObject)
			menu_id.style.width=150+"px";
		menu_id.style.visibility="visible";   
	}
	menu_id_current=menu_id;			                                    
	menu_hide=false;                                        
}    
function menu_checkout(in_menu_id)                                        
{                                        
	var menu_id;
	if(typeof(in_menu_id)=="string")
		menu_id=document.getElementById(in_menu_id);
	else
		menu_id=in_menu_id;
	menu_hide=true;                                        
	window.setTimeout("menu_time()",500);                                        
	menu_id_current=menu_id;  
}                                        
				                                    
function menu_time()                                        
{                                        
	if (menu_hide)                                        
	{                                        
		if (menu_id_current)    
		{    
			if(menu_id_current.style)
				menu_id_current.style.visibility="hidden";    
		}    
		window.clearTimeout();    
	}                                        
}
function box_prd_show(box_prd_description_id,box_prd_id,prd_id)
{
	var parent,top,left;
	top=0;left=0;
	if(typeof(box_prd_description_id)=="string")
		box_prd_description_id=document.getElementById(box_prd_description_id);
	if(typeof(box_prd_id)=="string")
		box_prd_id=document.getElementById(box_prd_id);

	parent=box_prd_id.offsetParent;
	top_parent=box_prd_id.offsetTop;
	left_parent=box_prd_id.offsetLeft;
	while(parent)
	{
		if(parent.tagName.toUpperCase()!="BODY");
		{
			top_parent+=parent.offsetTop;
			left_parent+=parent.offsetLeft;
		}
		parent=parent.offsetParent;
	}

	top=box_prd_id.offsetHeight+top_parent;
	left=left_parent;
	box_prd_description_id.style.top=top+"px";
	if(left<=document.width/2)
		box_prd_description_id.style.left=left+"px";
	else
		box_prd_description_id.style.left=(left+box_prd_id.offsetWidth-400)+"px";
	
	box_prd_description_id.style.position="absolute";
	box_prd_description_id.style.visibility="visible";  
	box_prd_description_id_current=box_prd_description_id;	
	box_prd_description_id.innerHTML="<img src=\"images/cart-loading.gif\">";
	box_prd_description_id.style.width=400+"px";		                             
	box_prd_description_hide=false;    
	                                    
	ajaxLoad("pages/prd_description.php?prd_id="+prd_id,box_prd_description_id);
}    
function box_prd_time()
{
	if (box_prd_description_hide)                                        
	{                                        
		if (box_prd_description_id_current)    
		{    
			if(box_prd_description_id_current.style)
				box_prd_description_id_current.style.visibility="hidden";    
		}    
		box_prd_description_hide=false;
		window.clearTimeout();    
	}        
}
function box_prd_checkout(box_id)                                        
{                                        
	if(typeof(box_id)=="string")
		box_id=document.getElementById(box_id);
	box_prd_description_hide=true;                                        
	window.setTimeout("box_prd_time()",300);                                        
	box_prd_description_id_current=box_id;  
}
