//ham dieu chinh ngay thang 

					

function choseyearmonth(obj,m,y)

{

	

	var t;

	t=obj.selectedIndex;						

	obj.options.length=1;

	var ngay=0;

	switch(m)

	{

		case "4":	

		case "6":

		case "9":	

		case "11":

			ngay=30; 

		break;

		case "2":

		if(eval(y)%4==0)							

		{

			ngay=29;

		}

		else

		{

			ngay=28;

		}

		break;

		default:

		ngay=31;

	}						

	for (var i=1; i<=ngay;i++){						

	obj.options.add(new Option(i,i));

	}

	if(t<=ngay)

	{

		obj.options[t].selected=true;

	}

}







// ham kiem tra xem xau co phai la nhap o dang so hay khong

function isNubers(str)

{

var isOK=true;

for(var i=0;i<str.length;i++)

	{

		if(str.charAt(i)<'0' || str.charAt(i)>'9')

			{

				isOK=false;

				break;

			}

	}

	return isOK;	

}

// ham kiem tra xau xem co phai la xau rong hay ko

function isWhitespace (s)

{   

	var whitespace = " \t\n\r";

	var i;

	var j=0;

  for (i = 0; i < s.length; i++)

  {   

    var c = s.charAt(i);

	if (c==' ')

	{j++;

	}

	else{

    if (whitespace.indexOf(c) == -1) return false;

	}



  }

  if (j!=s.length)

  {return false;

  }

  return true;

}





function get_object(idname)



{



	if (document.getElementById)



	{



		return document.getElementById(idname);



	}



	else if (document.all)



	{



		return document.all[idname];



	}



	else if (document.layers)



	{



		return document.layers[idname];



	}



	else



	{



		return null;



	}



}







function get_tags(parentobj, tag)



{



	if (typeof parentobj.getElementsByTagName != 'undefined')



	{



		return parentobj.getElementsByTagName(tag);



	}



	else if (parentobj.all && parentobj.all.tags)



	{



		return parentobj.all.tags(tag);



	}



	else



	{



		return null;



	}



}











var xmlHttp;



function createXMLHttpRequest() {



	if (window.ActiveXObject) {



		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");



	}



	else if (window.XMLHttpRequest) {



		xmlHttp = new XMLHttpRequest();



	}



}







function startRequestHTML(strUrl, strDivName) {



	createXMLHttpRequest();



	



	xmlHttp.onreadystatechange = function(){



		if(xmlHttp.readyState == 4) {



			if(xmlHttp.status == 200) {



				get_object(strDivName).innerHTML = xmlHttp.responseText;



			}



		}



	};



	xmlHttp.open("GET",strUrl, true);



	xmlHttp.send(null);



	return false;



}







function openWin(strUrl, strName, strFeatures)



{



	var objWin = window.open(strUrl, strName, strFeatures);



	if(!objWin) {



		alert("L×i: Không thÃ mß cía sÕ éng dång!\nB¡n vui lòng t¯t chéc nng ch·n popup cça trình duyÇt và thí l¡i.")



		return false;



	}



	return true;



}











function advClick(strURL)



{



	return openWin(strURL,"_blank","scrollbars=yes, toolbar=yes, menubar=yes, status=yes, resizable=yes");



}







function checkEmail(checkStr) 



{



	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(checkStr))



	{



		return (true)



	}



	return (false)



}







function getAllQuery() {



  var strURL = document.location.href;



  var query = strURL.substr(strURL.indexOf("#")+1);



  return query;



}







function getQuery(variable) {



  var strURL = document.location.href;



  var query = strURL.substr(strURL.indexOf("#")+1);



  var vars = query.split("&");



  for (var i=0;i<vars.length;i++) {



    var pair = vars[i].split("=");



    if (pair[0] == variable) {



      return pair[1];



    }



  }



  return "";



}









var xmlHttp;



function createXMLHttpRequest() {



	if (window.ActiveXObject) {



		xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");



	}



	else if (window.XMLHttpRequest) {



		xmlHttp = new XMLHttpRequest();



	}



}







function startRequest(strUrl, strDivName, strObj) {



	createXMLHttpRequest();



	



	if (strObj!=null && strObj!="")



		strUrl = strUrl + document.getElementById(strObj).value;



	xmlHttp.onreadystatechange = function(){



		if(xmlHttp.readyState == 4) {



			if(xmlHttp.status == 200) {



				document.getElementById(strDivName).innerHTML = xmlHttp.responseText;



			}



		}



		else



			document.getElementById(strDivName).innerHTML = "<br><p align=\"center\"><img border=\"0\" src=\"images/loading.gif\"></p><br>";



	};



	xmlHttp.open("GET",strUrl, true);



	xmlHttp.send(null);



}







function startPostRequest(strUrl, strDivName, strObj) {



	createXMLHttpRequest();



	



	if (strObj!=null && strObj!="")



		strUrl = strUrl + document.getElementById(strObj).value;



	xmlHttp.onreadystatechange = function(){



		if(xmlHttp.readyState == 4) {



			if(xmlHttp.status == 200) {



				document.getElementById(strDivName).innerHTML = xmlHttp.responseText;



			}



			endProcess();



		}



		else



			startProcess();



	};



	var strQuery = strUrl.substr(strUrl.indexOf('?')+1,strUrl.length);



	xmlHttp.open("POST",strUrl, true);



	xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded;");



	xmlHttp.send(strQuery);



}







function startSearch(strDivName) {



	createXMLHttpRequest();



	



	var intFeatures = document.getElementById('cbFeatures').value;



	var strPriceFrom = document.getElementById('txtPriceFrom').value;



	var strPriceTo = document.getElementById('txtPriceTo').value;



	var blnSearchPro = document.getElementById('rSearchWhat').checked;



	var strSearchWhat;



	if (!blnSearchPro)



		strSearchWhat = "news";



	else



		strSearchWhat = "prod";







	var intCondition = document.getElementById('cbCondition').value;



	var intSearchIn;



	if (strSearchWhat=="news")



		intSearchIn = document.getElementById('cbSearchInNews').value;



	else



		intSearchIn = document.getElementById('cbSearchInPro').value;



	var strByDate = "";



	if (document.getElementById('cbMonth')!=null){	



		var intMonth = document.getElementById('cbMonth').value;



		var intDate = document.getElementById('cbDate').value;



		var intYear = document.getElementById('cbYear').value;



		strByDate = intMonth+"/"+intDate+"/"+intYear;



	}



	var intPerPage = document.getElementById('cbPerPage').value;



	var strKeyword = document.getElementById('txtKeyword').value;



	



	var strQuery = "search.asp?features="+intFeatures+"&pricefrom="+strPriceFrom+"&priceto="+strPriceTo;



		strQuery = strQuery+"&searchwhat="+strSearchWhat+"&intcondition="+intCondition+"&keyword="+strKeyword;



		strQuery = strQuery+"&searchin="+intSearchIn+"&bydate="+strByDate+"&perpage="+intPerPage;



	strUrl = strQuery;



	



	xmlHttp.onreadystatechange = function(){



		if(xmlHttp.readyState == 4) {



			if(xmlHttp.status == 200) {



				document.getElementById(strDivName).innerHTML = xmlHttp.responseText;



			}



			endProcess();



		}



		else



			startProcess();



	};



	xmlHttp.open("GET",strUrl, true);



	xmlHttp.send(null);



}







function bookmarksite(title, url){



	if (document.all)



		window.external.AddFavorite(url, title);



	else if (window.sidebar)



		window.sidebar.addPanel(title, url, "")



}







function chkFrmRegMail(){



	var strRegName = document.frmRegReceivePrice.txtMailName.value;



	var strRegMail = document.frmRegReceivePrice.txtMailAddress.value;







	if(strRegName=="")



	{



		alert("B¡n ch°a nh­p hÍ tên.");



		document.frmRegReceivePrice.txtMailName.focus();



		return false;



	}



	if(strRegMail=="")



	{



		alert("B¡n ch°a nh­p Ëa chÉ email.");



		document.frmRegReceivePrice.txtMailAddress.focus();



		return false;



	}



	if (strRegMail.indexOf('@',0)==-1 || strRegMail.indexOf('.')==-1)



	{



		alert ("Ëa chÉ email nh­p sai quy cách.");



		document.frmRegReceivePrice.txtMailAddress.focus();



		return false;



	}



	else



	{



		var strQuery = "regNewsLetter.asp?hoten="+strRegName+"&email="+strRegMail;



    	strQuery = strQuery.replace(/ /g,"[sPaCe]")



    	strQuery = strQuery.replace(/\n/g,"[nEwLiNe]")



    	startPostRequest(strQuery,'BodyContent','');



	}



}



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 CheckFrmContact() {



    //Initialise variables



    var errorMsg = "";



    //Check for a value



    var strSID = document.frmContact.txtSID.value;



    var strHoten = document.frmContact.txtName.value;



    var strAdd = document.frmContact.txtAddress.value;



    var strTel = document.frmContact.txtTel.value;



    var strEmail = document.frmContact.txtEmail.value;



    var strSubject = document.frmContact.txtSubject.value;



    var strContent = document.frmContact.txtContent.value;



        



    if (strHoten == ''){



            errorMsg += "\n\t- Ban chua nhap Ho ten";



    }



    if (strEmail == ''){



            errorMsg += "\n\t- Ban chua nhap E-mail cua ban";



    }



    if (strSubject == ''){



            errorMsg += "\n\t- Ban chua nhap Chu de";



    }



    if (strContent == ''){



            errorMsg += "\n\t- Ban chua nhap Noi dung";



    }



    if (strContent.length > 3800){



            errorMsg += "\n\t- Noi dung khong duoc vuot qua 4000 chu.";



    }







    //If there is aproblem with the form then display an error



    if (errorMsg != ""){



            msg = "Co loi voi du lieu nhap vao cua ban.\n";



            msg += "__________________________________________________\n\n";



            msg += "Co loi o cac phan sau:\n";



            errorMsg += alert(msg + errorMsg);



    }



	else



	{



		var strQuery = "contactAct.asp?hoten="+strHoten+"&diachi="+strAdd+"&tel="+strTel+"&email="+strEmail+"&chude="+strSubject+"&noidung="+strContent+"&sid="+strSID;



    	strQuery = strQuery.replace(/ /g,"[sPaCe]")



    	strQuery = strQuery.replace(/\n/g,"[nEwLiNe]")



    	startPostRequest(strQuery,'BodyContent','');



    }



}







function playMedia(fID,blnVideo,height,width,lang)

{

	window.open('playMedia.asp?fID='+fID+'&blnVideo='+blnVideo+'&ln='+lang,'win','height='+height+',width='+width+',scrollbars=no,menubar=no,toolbar=no,top=100,left=100')

}







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=Tahoma 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=40} 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>');



}












function ddInit(e){



  topDog=isIE ? "BODY" : "HTML";



  whichDog=isIE ? document.all.theLayer : document.getElementById("theLayer");  



  hotDog=isIE ? event.srcElement : e.target;  



  while (hotDog.id!="titleBar"&&hotDog.tagName!=topDog){



    hotDog=isIE ? hotDog.parentElement : hotDog.parentNode;



  }  



  if (hotDog.id=="titleBar"){



    offsetx=isIE ? event.clientX : e.clientX;



    offsety=isIE ? event.clientY : e.clientY;



    nowX=parseInt(whichDog.style.left);



    nowY=parseInt(whichDog.style.top);



    ddEnabled=true;



    document.onmousemove=dd;



  }



  



	if (isIE&&event.srcElement.id=="dragbar"||isNN&&e.target.id=="dragbar"){



		offsetx=isIE? event.clientX : e.clientX



		offsety=isIE? event.clientY : e.clientY



		



		tempx=parseInt(crossobj.style.left)



		tempy=parseInt(crossobj.style.top)



		



		ddEnabled=true



		document.onmousemove=drag_drop



	}







}







function dd(e){



  if (!ddEnabled) return;



  whichDog.style.left=isIE ? nowX+event.clientX-offsetx : nowX+e.clientX-offsetx; 



  whichDog.style.top=isIE ? nowY+event.clientY-offsety : nowY+e.clientY-offsety;



  return false;  



}







function ddN4(whatDog){



  if (!isN4) return;



  N4=eval(whatDog);



  N4.captureEvents(Event.MOUSEDOWN|Event.MOUSEUP);



  N4.onmousedown=function(e){



    N4.captureEvents(Event.MOUSEMOVE);



    N4x=e.x;



    N4y=e.y;



  }



  N4.onmousemove=function(e){



    if (isHot){



      N4.moveBy(e.x-N4x,e.y-N4y);



      return false;



    }



  }



  N4.onmouseup=function(){



    N4.releaseEvents(Event.MOUSEMOVE);



  }



}







function moveCenter()



{



	obj = document.getElementById("theLayer");



	obj.style.left=(document.body.scrollLeft+parseInt((document.body.clientWidth-350)/2))+"px";



	obj.style.top=(document.body.scrollTop+parseInt((document.body.clientHeight-250)/2))+"px";







}



function show_hide()



{



	if (isIE||isNN)



	{



		if (whichDog.style.visibility=="hidden")



		{



			whichDog.style.visibility="visible";



			moveCenter();



		}



		else



		{



			whichDog.style.visibility="hidden";



		}



	}



	else if (isN4)



	{



		if (document.theLayer.visibility=="hide")



		{		



			document.theLayer.visibility="show";



			moveCenter();



		}



		else



		{



			document.theLayer.visibility="hide";



		}



	}



}







function zoomImg(obj,intType)



{



	var wObj = document.getElementById(obj);



	if(intType==0)



		objW = eval(wObj.width - 50);



	else



		objW = eval(wObj.width + 50);



	//alert(objW);



	wObj.width = objW;



}







function ietruebody(){



	return (document.compatMode && document.compatMode!="BackCompat" && !window.opera)? document.documentElement : document.body



}







function enlarge(title, which, e, position, imgwidth, imgheight){



	if (isIE||isNN){



		crossobj=document.getElementById? document.getElementById("showimage") : document.all.showimage



		if (position=="center"){



			pgyoffset=isNN? parseInt(pageYOffset) : parseInt(ietruebody().scrollTop)



			horzpos=isNN? pageXOffset+window.innerWidth/2-imgwidth/2 : ietruebody().scrollLeft+ietruebody().clientWidth/2-imgwidth/2



			vertpos=isNN? pgyoffset+window.innerHeight/2-imgheight/2 : pgyoffset+ietruebody().clientHeight/2-imgheight/2



			if (window.opera && window.innerHeight) //compensate for Opera toolbar



			vertpos=pgyoffset+window.innerHeight/2-imgheight/2



			vertpos=Math.max(pgyoffset, vertpos)



		}



		else{



			var horzpos=isNN? pageXOffset+e.clientX : ietruebody().scrollLeft+event.clientX



			var vertpos=isNN? pageYOffset+e.clientY : ietruebody().scrollTop+event.clientY



		}



		crossobj.style.left=horzpos+"px"



		crossobj.style.top=vertpos+"px"



		var strHTML = '<table border="0" cellpadding="0" style="border-collapse: collapse">'



		strHTML = strHTML + '<tr><td><table border="0" cellpadding="0" style="border-collapse: collapse" width=100%>'



		strHTML = strHTML + '<tr><td id="dragbar">&nbsp;'+title+'</td><td width="20" align="center" id="closetext" onClick="closepreview()"><img alt="Close" border="0" src="images/i_close.gif" width="16" height="16"></td></tr></td></tr></table>'



		strHTML = strHTML + '<tr><td title="Close" onClick="closepreview()"><img src="'+which+'"></td></tr></table>'







		crossobj.innerHTML= strHTML



		crossobj.style.visibility="visible"



		document.getElementById("divOpacity").style.width = document.body.scrollWidth;



		document.getElementById("divOpacity").style.height = document.body.scrollHeight;



		document.getElementById("divOpacity").style.visibility="visible";



		return false



	}



	else //if NOT IE 4+ or NS 6+, simply display image in full browser window



		return true



}







function closepreview(){



	crossobj.style.visibility="hidden"



	document.getElementById("divOpacity").style.width = 0;



	document.getElementById("divOpacity").style.height = 0;



	document.getElementById("divOpacity").style.visibility="hidden";



}







function drag_drop(e){



	if (isIE&&ddEnabled){



		crossobj.style.left=tempx+event.clientX-offsetx+"px"



		crossobj.style.top=tempy+event.clientY-offsety+"px"



	}



	else if (isNN&&ddEnabled){



		crossobj.style.left=tempx+e.clientX-offsetx+"px"



		crossobj.style.top=tempy+e.clientY-offsety+"px"



	}



	return false



}























