function doSort(x,url)
{
	var orderby="product.product_isnew";
	var orient="desc";
	if(x==1)
	{
		orderby="product.product_price";
		orient="desc";
	}
	if(x==11)
	{
		orderby="product.product_price";
		orient="asc";
	}
	if(x==2)
	{
		orderby="product.product_hit";
		orient="desc";
	}
	if(x==22)
	{
		orderby="product.product_hit";
		orient="asc";
	}
	window.ifr.load_info1(url+'&psort='+x+'&orderby='+orderby+'&orient='+orient,'detail');	
}
function popupProduct(id)
{
	open('../product/product_popup.php?product_id='+id,'','top=0,left=0,width=520,height=600,scrollbars=yes,resizable,status=no');
}
function showCalendar(id)
{
	var date = showModalDialog("../javascript/popup_calendar.htm", "", "help: no; status: no; scroll: no;");
	if (date)
	{
		eval(id).value=date;
	}
}
function doContact(theform,thediv)
{
	checkTextField(document.tfcontact.name.value,"- Vui lòng nhập tên - (Please input your name)");
	checkTextField(document.tfcontact.address.value,"- Vui lòng nhập địa chỉ - (Please input address)");
	checkTextField(document.tfcontact.note.value,"- Vui lòng nhập nội dung - (Please input comment)");
	checkEmail(document.tfcontact.email.value,"- Vui lòng kiểm tra Email - (Please check Email)");
	checkTextField(document.tfcontact.contact_code.value,"- Vui lòng nhập mã bảo mật - (Please input security code)");
	if(checkAll())	
		submitForm(theform,thediv);
	return false;
}
var idDIV="imgPopup";
var idDIVX="imgScreen";
function image_open(text,i)
{ 
	hideDIV(idDIV);
	w = 200;                     
	border = "5px solid #eeeeee";   
	var img2=new Image();
	img2.src=text;	
	s = (border ? 'border:' + border + '; ' : '');
	t='<table bgcolor=#eeeeee cellpadding=0 cellspacing=0 title="Click to close" onclick="hideDIV(\''+idDIV+'\')" ' + (s ? ' style="' + s + '"' : '') + '><tr><td>';
	t+='<img src='+text+' style="border:1px solid #888888" onload="adjustXY(this)"></td><tr><td align=right><img src="../images/closelabel.gif"></td></tr></table>';	
	
	left=((parseInt(getWinX())- parseInt(img2.width))/2)+parseInt(getScrX());
	top1=((parseInt(getWinY())- parseInt(img2.height))/2)+parseInt(getScrY());
	document.getElementById(idDIV).style.left = left;
	document.getElementById(idDIV).style.top = top1;
	document.getElementById(idDIV).innerHTML= t;	
	//document.getElementById(idDIV).style.visibility = 'visible';
	
	document.getElementById(idDIVX).style.left = 0;
	document.getElementById(idDIVX).style.top = 0;
	document.getElementById(idDIVX).style.height = 1000+getScrY();
	document.getElementById(idDIVX).style.width = '100%';
	document.getElementById(idDIVX).style.backgroundImage="url(../javascript/overlay.png)";	
	document.getElementById(idDIVX).style.visibility = 'visible';
	
}
function hideDIV(id)
{
   document.getElementById(id).style.height = '0px';
	document.getElementById(id).style.width = '0px';
   document.getElementById(id).style.left = 0;
	document.getElementById(id).style.top = 0;
   document.getElementById(id).style.visibility = 'hidden';	
   document.getElementById(idDIVX).style.height = '0px';
	document.getElementById(idDIVX).style.width = '0px';
   document.getElementById(idDIVX).style.visibility = 'hidden';	
}
function adjustXY(img2)
{
	left=((parseInt(getWinX())- parseInt(img2.width))/2)+parseInt(getScrX());
	top1=((parseInt(getWinY())- parseInt(img2.height))/2)+parseInt(getScrY());
	document.getElementById(idDIV).style.left = left;
	document.getElementById(idDIV).style.top = top1;
	document.getElementById(idDIV).style.visibility = 'visible';
}
function getScrX() {
  var offset = 0;
  if(window.pageXOffset)
    offset = window.pageXOffset;
  else if(document.documentElement && document.documentElement.scrollLeft)
    offset = document.documentElement.scrollLeft;
  else if(document.body && document.body.scrollLeft)
    offset = document.body.scrollLeft;
  return offset;
}
function getScrY() {
  var offset = 0;
  if(window.pageYOffset)
    offset = window.pageYOffset;
  else if(document.documentElement && document.documentElement.scrollTop)
    offset = document.documentElement.scrollTop;
  else if(document.body && document.body.scrollTop)
    offset = document.body.scrollTop;
  return offset;
}
function getWinX() {
  var size = 0;
  if(window.innerWidth)
    size = window.innerWidth;
  else if(document.documentElement && document.documentElement.clientWidth)
    size = document.documentElement.clientWidth;
  else if(document.body && document.body.clientWidth)
    size = document.body.clientWidth;
  else size = screen.width;
  return size;
}
function getWinY() {
  var size = 0;
  if(window.innerHeight)
    size = window.innerHeight;
  else if(document.documentElement && document.documentElement.clientHeight)
    size = document.documentElement.clientHeight;
  else if(document.body && document.body.clientHeight)
    size = document.body.clientHeight;
  else size = screen.height;
  return size;
}
document.write('<div id="'+idDIV+'" style="position:absolute; visibility:hidden;z-index:100"></div>');
document.write('<div id="'+idDIVX+'" style="position:absolute; visibility:hidden;z-index:10" onclick="hideDIV(\''+idDIV+'\')"></div>');