function doUpdate(filename,id)
{
	if(id!='')
	{
		h=parseInt(window.screen.availHeight)-50;
		window.open('../admin/webapp/'+filename+'?todo=form&'+id,'','status=yes, scrollbars=no, resizable=yes, width=500, height='+h+', top=0, left=0');
	}
}

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.location=url+'&psort='+x+'&orderby='+orderby+'&orient='+orient;	
}

function popupWindow(url)
{
	//open(url,'','top=0,left=0,width=800,height=600,scrollbars=1,resizable=1,status=no');
	location=url;
}
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())	
	{
		document.theform.submit();
	}
	return false;
}
var idDIV="imgPopup";
var idDIVX="imgScreen";

function image_open(text,i)
{ 
	var img2=new Image();
	img2.src=text;		
	var width=img2.width;
	var height=img2.height
	var left=((parseInt(getWinX())- parseInt(width))/2)+parseInt(getScrX());
	var top=((parseInt(getWinY())- parseInt(height))/2)+parseInt(getScrY());	
	s='<img src="'+text+'" style="border:#dddddd 5px solid;cursor:pointer" onclick="hideDIV()" title="[X] Click to close" onload="adjustXY(this)">';	
	document.getElementById(idDIV).style.height = height+'px';
	document.getElementById(idDIV).style.width = width+'px';
   document.getElementById(idDIV).style.left = left+'px';
	document.getElementById(idDIV).style.top = top+'px';
   document.getElementById(idDIV).style.visibility = 'visible';	
	document.getElementById(idDIV).innerHTML=s;
	
	document.getElementById(idDIVX).style.height = parseInt(getWinY())+ parseInt(getScrY())+'px';
	document.getElementById(idDIVX).style.width = getWinX()+'px';
   document.getElementById(idDIVX).style.left = '0px';
	document.getElementById(idDIVX).style.top = '0px';
   document.getElementById(idDIVX).style.visibility = 'visible';

}
function hideDIV(id)
{
   document.getElementById(idDIV).style.height = '0px';
	document.getElementById(idDIV).style.width = '0px';
   document.getElementById(idDIV).style.left = '0px';
	document.getElementById(idDIV).style.top = '0px';
   document.getElementById(idDIV).style.visibility = 'hidden';	
   document.getElementById(idDIVX).style.height = '0px';
	document.getElementById(idDIVX).style.width = '0px';
   document.getElementById(idDIVX).style.visibility = 'hidden';	
}
function adjustXY(img2)
{	
	var width=img2.width;
	var height=img2.height;
	var left=((parseInt(getWinX())- parseInt(width))/2)+parseInt(getScrX());
	var top=((parseInt(getWinY())- parseInt(height))/2)+parseInt(getScrY());	
	document.getElementById(idDIV).style.left = left+'px';
	document.getElementById(idDIV).style.top = top+'px';
	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="background-image:url(\'../javascript/overlay.png\');position:absolute;visibility:hidden;z-index:10" onclick="hideDIV(\''+idDIV+'\')"></div>');
