// JavaScript Document

function check_themFile(obj)
{	
	
	if(obj.txtTitle.value == "")
	{
		alert("Chưa nh&#7853;p tên");
		obj.txtTitle.focus();
		return false;
	}
	
	if(obj.txtFile.value == "")
	{
		alert("Chưa ch&#7917;n File");
		obj.txtFile.focus();
		return false;
	}
		
	return true;
}

// Check trong khi them san pham
function check_ThemSanPham(obj)
{
	
	if(obj.txtProName.value == "")
	{
		alert("B&#7841;n chưa nh&#7853;p tiêu &#7917;");
		obj.txtProName.focus();
		return false;
	}
	
	
	if(obj.txtKichThuoc.value == "")
	{
		alert("Xu&#7845;t x&#7913;");
		obj.txtKichThuoc.focus();
		return false;
	}
	
	if(obj.txtTrongLuong.value == "")
	{
		alert("Tr&#7917;ng lư&#7917;ng");
		obj.txtTrongLuong.focus();
		return false;
	}
	
	if(obj.txtHangSX.value == "")
	{
		alert("Ch&#7845;t li&#7879;u");
		obj.txtHangSX.focus();
		return false;
	}
	
	if(((obj.txtGiaVNDcu.value == "" || obj.txtGiaVNDcu.value  == 0 || isNaN(obj.txtGiaVNDcu.value)) || (obj.txtGiaVNDmoi.value == "" || obj.txtGiaVNDmoi.value  == 0)) && (obj.txtGiaUSDcu == "" || parseInt(obj.txtGiaUSDcu.value) < 0 || isNaN(obj.txtGiaUSDcu.value) || (obj.txtGiaUSDmoi.value == "" || parseInt(obj.txtGiaUSDmoi.value) < 0 || isNaN(obj.txtGiaUSDmoi.value))))
	{
		alert("Nh&#7853;p giá USD");
		obj.txtGiaUSDcu.focus();
		return false;
	}
	
	if(obj.txtBaoHanh.value == "" || parseInt(obj.txtBaoHanh.value) < 0 || isNaN(obj.txtBaoHanh.value))
	{
		alert("Th&#7917;i gian b&#7843;o hành");
		obj.txtBaoHanh.focus();
		return false;
	}	
	
	return true;
}

// Check Edit nhom' hang`

function checkFrmNhomHang(the_frrm)
{
	if(obj.txtCatName.value=="")
	{
		alert("Ch&#7917;n nhóm hàng")
		obj.txtCatName.focus();
		return false;
	}

	return true;
}


function checkFrmLoaiHang(obj)
{
	if(obj.txtSubName.value=="")
	{
		alert("Nh&#7853;p tên m&#7917;c.")
		obj.txtSubName.focus();
		return false;
	}
	if(obj.cbSubCatID.value == 0)
	{
		alert("Ch&#7917;n nhóm.");
		obj.cbSubCatID.focus();
		return false;
	}
	return true;
}



// Them moi quan tri vien

function chkfrmAddUser(obj)
{
	if(obj.txtFullname.value==""){
		alert("H&#7917; và tên");
		obj.txtFullname.focus();
	return false;
	}

	if(obj.txtEmail.value==""){
		alert("Email");
		obj.txtEmail.focus();
	return false;
	}
	
	if (obj.txtEmail.value.indexOf('@',0)==-1 || obj.txtEmail.value.indexOf('.')==-1)
	{
		alert ("Email không h&#7917;p l&#7879;. \nVí d&#7917;: support@chotroi.com.vn");
		obj.txtEmail.focus();
		return false;
	}
	
	if(obj.txtUserName.value==""){
		alert("Tên ng nh&#7853;p");
		obj.txtUserName.focus();
	return false;
	}	
	
	if(obj.txtPassword.value!=obj.txtRePassword.value)
	{
		alert("M&#7853;t khẩu ph&#7843;i gi&#7889;ng nhau");
		obj.txtRePassword.focus();
	return false;
	}
	
	return true;
}


function chkFrmRegMail(obj){

	if(obj.txtMailName.value=="")

	{

		alert("H&#7917; và tên");

		obj.txtMailName.focus();

		return false;

	}

	if(obj.txtMailAddress.value=="")

	{

		alert("Nh&#7853;p Email");

		obj.txtMailAddress.focus();

		return false;

	}

	if (obj.txtMailAddress.value.indexOf('@',0)==-1 || obj.txtMailAddress.value.indexOf('.')==-1)

	{

		alert ("Email không h&#7917;p l&#7879;. \nVí d&#7917;: support@chotroi.com.vn");

		obj.txtMailAddress.focus();

		return false;

	}

	return true;

}

function sconfirm(strMess,strURL){

	var yn;

	yn=window.confirm(strMess);

	if (yn==true){

		document.location.href=strURL;

		}

}

function askconf(strMess){

	var yn;

	yn=window.confirm(strMess);

	if (yn==true){

		return true;

		}

	return false;

}

function openWin(theURL,winName,features) {

  	window.open(theURL,winName,features);

}

function winopen(url){

	window.open(url);

}



function insertStr(strValue,anh){



	window.opener.document.form1[anh].value=strValue;

}



function popupImage(src, note, title, css, border) {

var ppimgNW;

  if (border==null) border = 0;

  if (note==null) note = '';

  if (ppimgNW != null) ppimgNW.close();



  ppimgNW = window.open('','POPUPIMAGE','width=1,height=1');

  var doc = ppimgNW.document;

  doc.write('<html>');

  doc.write('<head>');



  if (title!=null) doc.write('<title>'+ title +'</title>');

  doc.write('<style> body {'+css+'} #ppImgText{'+ css +'} #ppImg{cursor:hand}</style></head>');

  doc.write('<body oncontextmenu="return false" leftmargin="0" topmargin="' + border + '">');

  doc.write('<div align="center">');

  doc.write('<img src="' + src + '" id="ppImg" onclick="self.close();" title="Close">');

  doc.write('</div>');

  doc.write('<div style="height:1; width:'+ border +'; font-size:4pt">');

  doc.write('</div>');

  doc.write('<div id="ppImgText" align="center">');

  doc.write('<Font face=Arial size=2>'+note+'</Font>');

  doc.write('</div>');

  doc.write('</body>');

  doc.write('</html>');



  doc.write('<' + 'script>');

  doc.write('var resized = false;');

  doc.write('function doResize() {');

  doc.write('  var imgW = ppImg.width, imgH = ppImg.height;');     

  if (note=='' || note==null) {addH=35} else {addH=60};

  doc.write('  window.resizeTo(imgW + 8 +' + border*2 +', imgH + ppImgText.offsetHeight + '+addH+' + '+ border*2 +');');

  doc.write('  setTimeout("doResize()",1000);');



  doc.write('}');

  doc.write('doResize(); ');

  doc.write('</' + 'script>');

}

var fBrw=(navigator.userAgent.indexOf('MSIE')!= -1 && navigator.userAgent.indexOf('Windows')!= -1);
var fDSp=(typeof(document.getElementById)!='undefined');


var strDomain = 'xteenphoto'
var sLocation = location.href;

var pos = sLocation.indexOf("xteenphoto")
if (typeof(PageHost) == 'undefined') var PageHost = '';

var objXML;
var aFlag=true;

function ItemMinimize(Name)
{
	if (!fDSp)
	{
		return;
	}

	var MItem=document.getElementById('IDM_'.concat(Name));
	var Image=document.getElementById('IDI_'.concat(Name));
	
	if (MItem.style.display!='')
	{
		//MItem.setAttribute('style','display:""');
		MItem.style.display='';
		Image.src='Images/min.gif';
	}
	else
	{
		//MItem.setAttribute('style','display:none');
		MItem.style.display='none';
		Image.src='Images/max.gif';
	}
}

function SetParameter(pFile, pName, pVal)
{
	if ((cPost=pFile.indexOf('&'.concat(pName).concat('=')))==-1)
		cPost=pFile.indexOf('?'.concat(pName).concat('='));

	if (cPost >= 0)
	{
		if ((pPost=pFile.indexOf('&', cPost + 1))==-1)
		{
			pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal);
		}
		else
		{
			pFile=pFile.substring(0, cPost + pName.length + 2).concat(pVal).concat(pFile.substr(pPost));
		}
	}
	else
	{
		if (pFile.indexOf('?')==-1)
		{
			pFile=pFile.concat('?').concat(pName).concat('=').concat(pVal);
		}
		else
		{
			pFile=pFile.concat('&').concat(pName).concat('=').concat(pVal);
		}
	}

	return pFile;
}
