// JavaScript Document
function over_menu(id,ele)
{
	set_all('menu_phu_span');	
	document.getElementById('menu_phu_'+id).style.display="block";

	padding_left=(document.body.clientWidth-998)/2;
	relative_left=tempX-padding_left;
	relative_right=document.body.clientWidth-2*padding_left-relative_left;
	
	if(relative_left<500)
	{
		document.getElementById('menu_phu_'+id).style.textAlign='left';
		document.getElementById('menu_phu_'+id).style.paddingRight='0px';
		document.getElementById('menu_phu_'+id).style.paddingLeft=relative_left/2+'px';
	}else
	{
		document.getElementById('menu_phu_'+id).style.textAlign='right';
		document.getElementById('menu_phu_'+id).style.paddingLeft='0px';
		document.getElementById('menu_phu_'+id).style.paddingRight=relative_right/2+'px';
	}
}

function set_all(className) 
  { 
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == className)
	  {
		arr[arr.length] = id;
		 elem.style.display="none";
	  }
	}
  }
  
  
function overthis(ele)
{
	ele.style.cursor = 'pointer';
	if(	ele.className == 'tab')
	{
		ele.className = 'hover_tab'
	}
} 

function outthis(ele)
{
	if(	ele.className == 'hover_tab')
	{
		ele.className = 'tab'
	}
} 

function change_tab(ele,tabele)
{
	document.getElementById('divtab').innerHTML=document.getElementById(ele).innerHTML;
	var arr = new Array(); 
	var elems = document.getElementsByTagName("*");
	for(var i = 0; i < elems.length; i++)
	{
	  var elem = elems[i];
	  var id = elem.getAttribute("id");
	  if (navigator.userAgent.indexOf("MSIE")>=0)
		{ var cls = elem.getAttribute("className");}
		else
		{ var cls = elem.getAttribute("class");	}
	  if(cls == 'current_tab')
	  {
		arr[arr.length] = id;
		 elem.className="tab";
	  }
	}
	tabele.className = 'current_tab'

} 

function sosanh(id)
{
	submit_form('','button'+id,'xml/sosanh.php?id='+id,'')
} 

function change_detail_pic(id,picnum,ext)
{
	document.getElementById('detail_pic').src="userfiles/products/"+id+"/"+picnum+"."+ext;
}

function setCookie(c_name,value,expiredays)
{
expiredays=0.11;
var exdate=new Date();
exdate.setDate(exdate.getDate()+expiredays);
document.cookie=c_name+ "=" +escape(value)+
((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function getCookie(c_name)
{
if (document.cookie.length>0)
  {
  c_start=document.cookie.indexOf(c_name + "=");
  if (c_start!=-1)
    { 
    c_start=c_start + c_name.length+1; 
    c_end=document.cookie.indexOf(";",c_start);
    if (c_end==-1) c_end=document.cookie.length;
    return unescape(document.cookie.substring(c_start,c_end));
    } 
  }
return "";
}


function check_product(id,checked)
{
	submit_form('test','','xml/check.php?id='+id+'&checked='+checked,'')
} 
function change_modem(id)
{
	submit_form('products_modem','','xml/change_modem.php?id='+id,'')
} 
function do_popup(id,width,height)
{
	url='popup.php?id='+id;
	var LeftPosition;
	var TopPosition;
	LeftPosition = (screen.width)/2-200;
	TopPosition = (screen.height)/2-200;
	newwindow=window.open(url,'name','height='+height+',width='+width+',top='+TopPosition+',left='+LeftPosition);
}