
function createXMLHttp() {
	   	
	if (typeof XMLHttpRequest != "undefined") {
		return new XMLHttpRequest();
	} 
	else if (window.ActiveXObject) {
	
		var aVersions = [ "MSXML2.XMLHttp.5.0", "MSXML2.XMLHttp.4.0", "MSXML2.XMLHttp.3.0","MSXML2.XMLHttp", "Microsoft.XMLHttp"];
		for (var i = 0; i < aVersions.length; i++) {

			try {
				var oXmlHttp = new ActiveXObject(aVersions[i]);
				return oXmlHttp;
			} catch (oError) {
			
			}
		 }
	}
		throw new Error("XMLHttp object could be created.");
}
 
var request = createXMLHttp();

function cgi(file,id,url_encode) {	
		
		request.open('post',file+'.php');
		request.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		request.onreadystatechange = outputPaging;
		request.send('curp='+id+'||'+url_encode);		
}

function outputPaging() {
			
	if(request.readyState == 1){
		document.getElementById('show_frm').innerHTML = '<div align="center">Loading ...</div>';
	}
	if(request.readyState == 4){
		var dataPaging = request.responseText;
		document.getElementById('show_frm').innerHTML = dataPaging;		
	}
}




//pop up

function popup(news_id){
	
	var winop;
  	winop = window.open("print.php?cgi="+news_id, "winop", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=730,height=450");
  	winop.focus();
}

function big_img(news_id){	
	var winop;
  	winop = window.open("big_img.php?cgi="+news_id, "winop", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=750,height=600");
  	winop.focus();
}

function popup_map(img_name){	
	var winop;
  	winop = window.open("popup_map.php?cgi="+img_name, "winop", "toolbar=no,location=no,directories=no,status=no, menubar=no,scrollbars=yes,resizable=no,copyhistory=yes,width=800,height=650");
  	winop.focus();
}
// form send mail

function showFormFriend(){
	
	if( document.getElementById("sendFriend").style.display=='none')  
		document.getElementById("sendFriend").style.display='';
	else  document.getElementById("sendFriend").style.display='none';	
}

var req = createXMLHttp();
		 
function post() {
	
	if(checkSend()){
			
		var f = document.frm_send;
		var tempuName 	= f.uName.value;
		var tempfName	= f.fName.value;
		var tempfEmail	= f.fEmail.value;
		var tempfTitle	= f.fTitle.value;
		var tempfContent= f.fContent.value;	
		
		req.open('post','send_friend.php');
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.onreadystatechange = output; 
		req.send('curpg='+tempuName+'='+tempfName+'='+tempfEmail+'='+tempfTitle+'='+tempfContent);	
	}
}


function blurContact(val){
	var f = document.frm_contact;
	document.getElementById(val).innerHTML='';
	f.cName.style.backgroundColor = '#FFFFFF';
	f.cEmail.style.backgroundColor = '#FFFFFF';
	f.cTel.style.backgroundColor = '#FFFFFF';
	f.cContent.style.backgroundColor = '#FFFFFF';
}

function blurContactUs(val){
	var f = document.frm_contactus;
	document.getElementById(val).innerHTML='';
	f.cName.style.backgroundColor = '#FFFFFF';
	f.cTel.style.backgroundColor = '#FFFFFF';
	f.cEmail.style.backgroundColor = '#FFFFFF';
	f.cMessage.style.backgroundColor = '#FFFFFF';
}

function postContact() {
	if(checkContact()){
			
		var f = document.frm_contact;
		var tempcName 	= f.cName.value;
		var tempcEmail	= f.cEmail.value;
		var tempcTel	= f.cTel.value;
		var tempcContent= f.cContent.value;
		
		document.getElementById("cName").value='';
		document.getElementById("cTel").value='';
		document.getElementById("cEmail").value='';		
		document.getElementById("cContent").value='';
		
		req.open('post','send_contact.php');
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.onreadystatechange = center_nd; 
		req.send('curpg='+tempcName+'||'+tempcEmail+'||'+tempcTel+'||'+tempcContent);	
	}	
}
//================================================
function center_nd() {
			
	if(req.readyState == 1){
		document.getElementById('center_nd').innerHTML = '<div align="center">Loading ...</div>';
	}
	if(req.readyState == 4){
		var ct = req.responseText;
		document.getElementById('center_nd').innerHTML = ct;		
	}
}
//==================================================
function postContactUs() {
	if(checkContactUs()){
			
		var f = document.frm_contactus;
		var tempcName 		= f.cName.value;
		var tempcTel		= f.cTel.value;
		var tempcEmail		= f.cEmail.value;
		var tempcMessage 	= f.cMessage.value;
		
		document.getElementById("cName").value='';
		document.getElementById("cTel").value='';
		document.getElementById("cEmail").value='';
		document.getElementById("cMessage").value='';
		
		//alert(tempcName+'|'+tempcTel+'|'+tempcEmail+'|'+tempcMessage);
		
		req.open('post','send_contactus.php');
		req.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		req.onreadystatechange = contactus; 
		req.send('curpg='+tempcName+'||'+tempcTel+'||'+tempcEmail+'||'+tempcMessage);	
	}	
}

function output() {
			
	if(req.readyState == 1){
		document.getElementById('sendFriend').innerHTML = '<div align="center">Loading ...</div>';
	}
	if(req.readyState == 4){
		var data = req.responseText;
		document.getElementById('sendFriend').innerHTML = data;		
	}
}

function contactus() {
			
	if(req.readyState == 1){
		document.getElementById('contact_us').innerHTML = '<div align="center">Loading ...</div>';
	}
	if(req.readyState == 4){
		var ct = req.responseText;
		document.getElementById('contact_us').innerHTML = ct;		
	}
}

function checkContact(){
	
	var f = document.frm_contact;
	if(f.cName.value=="") {
		document.getElementById("idcName").innerHTML='Nhập họ tên !';
		document.getElementById("idcName").style.color = "green";
		f.cName.style.backgroundColor = '#FFFFCC';
		f.cName.focus();
		f.cName.select();
		return false;
	}
	if(f.cEmail.value=="") {
		document.getElementById("idcEmail").innerHTML='Nhập email !';
		document.getElementById("idcEmail").style.color = "green";
		f.cEmail.style.backgroundColor = '#FFFFCC';
		f.cEmail.focus();
		f.cEmail.select();
		return false;
	}
	var aString 	= f.cEmail.value;
	var s 			= aString.lastIndexOf(".");
	var endEmail	= aString.substring(s+1, aString.length);
	if(f.cEmail.value.indexOf("@")<0 || f.cEmail.value.indexOf(".")<0 || (endEmail.length)<2) {
		document.getElementById("idcEmail").innerHTML='Email không hợp lệ !';
		document.getElementById("idcEmail").style.color = "green";
		f.cEmail.style.backgroundColor = '#FFFFCC';
		f.cEmail.focus();
		f.cEmail.select();
		return false;
	}	
	if(isNaN(f.cTel.value)) {
		document.getElementById("idcTel").innerHTML='Sộ điện thoại không hợp lệ !';
		document.getElementById("idcTel").style.color = "green";
		f.cTel.style.backgroundColor = '#FFFFCC';
		f.cTel.focus();
		f.cTel.select();
		return false;
	}
	if(f.cContent.value.indexOf("<")>=0 || f.cContent.value.indexOf("script")>=0 || f.cContent.value.indexOf(".php")>=0 || f.cContent.value.indexOf(".asp")>=0 || f.cContent.value.indexOf(".aspx")>=0 || f.cContent.value.indexOf(".jsp")>=0){
		document.getElementById("idcContent").innerHTML='Nội dung câu hỏi chưa ký tự đặc biệt';
		document.getElementById("idcContent").style.color="green";
		f.cContent.style.backgroundColor = '#FFFFCC';
		f.cContent.focus();
		f.cContent.select();
		return false;
	}
	return true;
}

function checkContactUs(){
	
	var f = document.frm_contactus;
	/*
	if(f.cName.value=="") {
		document.getElementById("idcName").innerHTML='Please enter your name !';
		document.getElementById("idcName").style.color = "green";
		f.cName.style.backgroundColor = '#FFFFCC';
		f.cName.focus();
		//f.cName.select();
		return false;
	} */
	if(f.cTel.value=="") {
		document.getElementById("idcTel").innerHTML='KH nhập số điện thoại !';
		document.getElementById("idcTel").style.color = "green";
		f.cTel.style.backgroundColor = '#FFFFCC';
		f.cTel.focus();
		return false;
	}
	
	if(isNaN(f.cTel.value)) {
		document.getElementById("idcTel").innerHTML='Số điện thoại không hợp lệ !';
		document.getElementById("idcTel").style.color = "green";
		f.cTel.style.backgroundColor = '#FFFFCC';
		f.cTel.focus();
		return false;
	}
	/*
	if(f.cEmail.value=="") {
		document.getElementById("idcEmail").innerHTML='Please enter your email !';
		document.getElementById("idcEmail").style.color = "green";
		f.cEmail.style.backgroundColor = '#FFFFCC';
		f.cEmail.focus();
		//f.cEmail.select();
		return false;
	}
	var aString 	= f.cEmail.value;
	var s 			= aString.lastIndexOf(".");
	var endEmail	= aString.substring(s+1, aString.length);
	if(f.cEmail.value.indexOf("@")<0 || f.cEmail.value.indexOf(".")<0 || (endEmail.length)<2) {
		document.getElementById("idcEmail").innerHTML='Invalid Email !';
		document.getElementById("idcEmail").style.color = "green";
		f.cEmail.style.backgroundColor = '#FFFFCC';
		f.cEmail.focus();
		//f.cEmail.select();
		return false;
	}*/
	if(f.cMessage.value.indexOf("<")>=0 || f.cMessage.value.indexOf("script")>=0 || f.cMessage.value.indexOf(".php")>=0 || f.cMessage.value.indexOf(".asp")>=0 || f.cMessage.value.indexOf(".aspx")>=0 || f.cMessage.value.indexOf(".jsp")>=0){
		document.getElementById("idcMessage").innerHTML='There are special symbols in message';
		document.getElementById("idcMessage").style.color = "green";
		f.cMessage.style.backgroundColor = '#FFFFCC';
		f.cMessage.focus();
		return false;
	}
	
	return true;
}

function checkForm(){
	var f = document.frm_landlord;
	if(f.cName.value=="") {
		document.getElementById("idcName").innerHTML='Nhập họ tên !';
		document.getElementById("idcName").style.color = "green";
		f.cName.style.backgroundColor = '#FFFFCC';
		f.cName.focus();
		f.cName.select();
		return false;
	}
	/*
	if(isNaN(f.cHome.value) || f.cHome.value=="") {
		document.getElementById("idcHome").innerHTML='Số điện thoại nhà không hợp lệ !';
		document.getElementById("idcHome").style.color = "green";
		f.cHome.style.backgroundColor = '#FFFFCC';
		f.cHome.focus();
		f.cHome.select();
		return false;
	}
	if(isNaN(f.cOffice.value) || f.cOffice.value=="") {
		document.getElementById("idcOffice").innerHTML='Số điện thoại văn phòng không hợp lệ !';
		document.getElementById("idcOffice").style.color = "green";
		f.cOffice.style.backgroundColor = '#FFFFCC';
		f.cOffice.focus();
		f.cOffice.select();
		return false;
	}
	if(isNaN(f.cMobile.value) || f.cMobile.value=="") {
		document.getElementById("idcMobile").innerHTML='Số điện thoại di động không hợp lệ !';
		document.getElementById("idcMobile").style.color = "green";
		f.cMobile.style.backgroundColor = '#FFFFCC';
		f.cMobile.focus();
		f.cMobile.select();
		return false;
	}
	*/
	if(f.cEmail.value=="") {
		document.getElementById("idcEmail").innerHTML='nhập địa chỉ email !';
		document.getElementById("idcEmail").style.color = "green";
		f.cEmail.style.backgroundColor = '#FFFFCC';
		f.cEmail.focus();
		f.cEmail.select();
		return false;
	}
	var aString 	= f.cEmail.value;
	var s 			= aString.lastIndexOf(".");
	var endEmail	= aString.substring(s+1, aString.length);
	if(f.cEmail.value.indexOf("@")<0 || f.cEmail.value.indexOf(".")<0 || (endEmail.length)<2) {
		document.getElementById("idcEmail").innerHTML='Email không hợp lệ !';
		document.getElementById("idcEmail").style.color = "green";
		f.cEmail.style.backgroundColor = '#FFFFCC';
		f.cEmail.focus();
		f.cEmail.select();
		return false;
	}
	if(f.cAddress.value=="") {
		document.getElementById("idcAddress").innerHTML='Nhập địa chỉ !';
		document.getElementById("idcAddress").style.color = "green";
		f.cAddress.style.backgroundColor = '#FFFFCC';
		f.cAddress.focus();
		f.cAddress.select();
		return false;
	}	
	if(f.cInformation.value.indexOf("<")>=0 || f.cInformation.value.indexOf("script")>=0 || f.cInformation.value.indexOf(".php")>=0 || f.cInformation.value.indexOf(".asp")>=0 || f.cInformation.value.indexOf(".aspx")>=0 || f.cInformation.value.indexOf(".jsp")>=0){
		document.getElementById("idcInformation").innerHTML='Nội dung thông tin chứa ký tự đặc biệt !';
		document.getElementById("idcInformation").style.color = "green";
		f.cInformation.style.backgroundColor = '#FFFFCC';
		f.cInformation.focus();
		f.cInformation.select();
		return false;
	}	
	if(f.secupicture.value != f.hsecupicture.value) {
		document.getElementById("idsecupicture").innerHTML='Mã ảnh không đúng !';
		document.getElementById("idsecupicture").style.color = "green";
		f.secupicture.style.backgroundColor = '#FFFFCC';
		f.secupicture.focus();
		f.secupicture.select();
		return false;
	}
	return true;
}

function Blur(val, component){
	var f = document.frm_landlord;
	document.getElementById(val).innerHTML = '';
}

function blurAll(val){
	var f = document.frm_send;
	document.getElementById(val).innerHTML='';
	f.uName.style.backgroundColor = '#FFFFFF';
	f.fName.style.backgroundColor = '#FFFFFF';
	f.fEmail.style.backgroundColor = '#FFFFFF';
	f.fTitle.style.backgroundColor = '#FFFFFF';
	f.fContent.style.backgroundColor = '#FFFFFF';
}

function checkSend(){	
	var f = document.frm_send;
	
	if(f.uName.value=="") {
		document.getElementById("iduName").innerHTML='Please enter your full name !';
		document.getElementById("iduName").style.color = 'green';
		f.uName.style.backgroundColor = '#FFFFCC';
		f.uName.focus();
		f.uName.select();
		return false;
	}
	if(f.fName.value=="") {
		document.getElementById("idfName").innerHTML='Please enter receiver\'s full name !';
		document.getElementById("idfName").style.color = 'green';
		f.fName.style.backgroundColor = '#FFFFCC';
		f.fName.focus();
		f.fName.select();
		return false;
	}
	if(f.fEmail.value=="") {
		document.getElementById("idfEmail").innerHTML='Please enter receiver\'s email !';
		document.getElementById("idfEmail").style.color = 'green';
		f.fEmail.style.backgroundColor = '#FFFFCC';
		f.fEmail.focus();
		f.fEmail.select();
		return false;
	}
	
	var aString 	= f.fEmail.value;
	var s 			= aString.lastIndexOf(".");
	var endEmail	= aString.substring(s+1, aString.length);
	if(f.fEmail.value.indexOf("@")<0 || f.fEmail.value.indexOf(".")<0 || (endEmail.length)<2) {
		document.getElementById("idfEmail").innerHTML='Invalid Email. Please try again !';
		document.getElementById("idfEmail").style.color='green';
		f.fEmail.style.backgroundColor = '#FFFFCC';
		f.fEmail.focus();
		f.fEmail.select();
		return false;
	}
	if(f.fContent.value.indexOf("<")>=0 || f.fContent.value.indexOf("script")>=0){
		document.getElementById("idfContent").innerHTML='Content have special symbol';
		document.getElementById("idfContent").style.color='green';
		f.fContent.style.backgroundColor = '#FFFFCC';
		f.fContent.focus();
		f.fContent.select();
		return false;
	}
	
	return true;
}



// paging per page
function gotopage($ipage){	 
		
	document.frm_page.curpg.value = $ipage ;
	document.frm_page.submit();
}

function pagesearch($ipage){
	
	document.search_detail.curpg.value = $ipage ;
	document.search_detail.submit();
}

function blurSearch(){
	var f=document.frm_search;
	f.txtSearch.style.backgroundColor = '#FFFFFF';
}
function searchValid(lang){
	
	var f=document.frm_search;
	var keyValue= f.txtSearch.value;
	if(keyValue=='' || keyValue=='Nhập ký tự tìm kiếm !' || keyValue=='Please enter characters!' || keyValue==' ') {
		if(lang == "vietnam")
		document.frm_search.txtSearch.value="Nhập ký tự tìm kiếm !";
		else
		document.frm_search.txtSearch.value="Please enter characters!";
		f.txtSearch.style.backgroundColor = '#FFFFCC';
		f.txtSearch.focus();
		f.txtSearch.select();
		return false;
	}
	
	var keyInvalid = [ "sexy","XXX","XX","girl","đồ má","x","địt mẹ","fuck"];
	for (var i=0; i<keyInvalid.length; i++) {
		
		var keyArr	= keyInvalid[i]
		if(keyValue.toUpperCase() == keyArr.toUpperCase()){
			f.txtSearch.value = '';
			if(lang == "vietnam")
			document.frm_search.txtSearch.value="Ký tự tìm kiếm không cho phép !";
			else
			document.frm_search.txtSearch.value="Characters are not allowed !";
			f.txtSearch.style.backgroundColor = '#FFFFCC';
			f.txtSearch.focus();
			f.txtSearch.select();
			return false;
		}
			
	}
	document.frm_search.submit();	
	return true;	
}

function forgotPass(){
		
		var f = document.frm_reg;
		
		if(f.txtemail.value == "") {
			document.getElementById("idEmail").innerHTML = '<font color="red">Nhập Email !</font>';
			f.txtemail.focus();
			return false;
		}	
		
		else if((f.txtemail.value != "") && (!isEmail(f.txtemail.value))) {
			document.getElementById("idEmail").innerHTML = '<font color="red">Email không hợp lệ !</font>';
			f.txtemail.focus();
			return false ;
		}	
		if(f.inputCode.value == ''){
		   document.getElementById("idInputCode").innerHTML = '<font color="red">Nhập mã ảnh !</font>';
		   f.inputCode.focus();
		   return false ;
		}
		
		if(f.charector_image.value==0){
			document.getElementById("idInputCode").innerHTML = '<font color="red">Mã ảnh không đúng !</font>';
		    f.inputCode.focus();
		    return false ;			
		}
		
		f.submut();
	}

function checkSearch(lang){
	var f=document.search_detail;
	var keyValue= f.txtSearch.value;
	
		if(keyValue=='' || keyValue==' ') {
			if(lang == "vietnam")
			document.getElementById("idtxtSearch").innerHTML='Nhập ký tự tìm kiếm !';
			else
			document.frm_search.txtSearch.value="Please enter characters!";
			document.getElementById("idtxtSearch").style.color="green";
			f.txtSearch.style.backgroundColor = '#FFFFCC';
			f.txtSearch.focus();
			f.txtSearch.select();			
			return false;
		}
	var keyInvalid = [ "sexy","XXX","XX","girl","đồ má","x","địt mẹ","fuck"];
	for (var i=0; i<keyInvalid.length; i++) {
		
		var keyArr	= keyInvalid[i]
		if(keyValue.toUpperCase() == keyArr.toUpperCase()){
			f.txtSearch.value = '';
			if(lang == "vietnam")
			document.getElementById("idtxtSearch").innerHTML='Ký tự tìm kiếm không cho phép !';
			else
			document.frm_search.txtSearch.value="Characters are not allowed !";
			document.getElementById("idtxtSearch").style.color="green";
			f.txtSearch.style.backgroundColor = '#FFFFCC';
			f.txtSearch.focus();
			f.txtSearch.select();
			return false;
		}
			
	}
	return true;
}

function blurS(){
	document.getElementById('idtxtSearch').innerHTML = ''; 
	document.search_detail.txtSearch.style.backgroundColor = '#FFFFFF';
}

function pagesearch($ipage){
	
	document.search_detail.curpg.value = $ipage ;
	document.search_detail.submit();
}	

// Trail Object
var w=1
var h=1

if (document.getElementById || document.all)
document.write('<div id="trailimageid" style="position:absolute;visibility:hidden;left:0px;top:-1000px;width:1px;height:1px;border:8px solid #E0E0E0;background:#DDDDDD;"><img id="ttimg" src="images/load.gif" /></div>')

function gettrailobj()
{
	if (document.getElementById) return document.getElementById("trailimageid").style
	else if (document.all) return document.all.trailimagid.style
}

function truebody()
{
	return (!window.opera && document.compatMode && document.compatMode!="BackCompat")? document.documentElement : document.body
}

function hidetrail() {
	document.onmousemove=""
	document.getElementById('ttimg').src='/images/load.gif'
	gettrailobj().visibility="hidden"
	gettrailobj().left=-1000
	gettrailobj().top=50
}


function showtrail(width,height,file)
{  
	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1) {
		w=width
		h=height
		var z_index=10;
		//followmouse()
	
		document.getElementById('ttimg').src=file
		document.onmousemove=followmouse
		gettrailobj().visibility="visible"
		gettrailobj().width=w+"px"
		gettrailobj().height=h+"px"
		gettrailobj().zIndex=100;
	}
}

function isEmail(string) {
			if (string.search(/^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/) != -1)
			return true;
			else
			return false;
	 } // isEmail
function checkEmail(){
		if(!isEmail(document.frm_reg.txtemail.value)) document.getElementById("idEmail").innerHTML = '<font color="red">Email không hợp lệ. </font>';
		else document.getElementById("idEmail").innerHTML = '';
	}
	
function followmouse(e){

	if(navigator.userAgent.toLowerCase().indexOf('opera') == -1) {

		var xcoord= 20;
		var ycoord= 40;

		if (typeof e != "undefined") {
			xcoord+=e.pageX
			ycoord+=e.pageY
		}
		else if (typeof window.event !="undefined") {
			xcoord+=truebody().scrollLeft+event.clientX
			ycoord+=truebody().scrollTop+event.clientY
		}

		var docwidth=document.all? truebody().scrollLeft+truebody().clientWidth : pageXOffset+window.innerWidth-15
		var docheight=document.all? Math.max(truebody().scrollHeight, truebody().clientHeight) : Math.max(document.body.offsetHeight, window.innerHeight)

		if (xcoord+w+150>docwidth)
		xcoord=xcoord-w-(20*2)

		if (ycoord-truebody().scrollTop+h+100>truebody().clientHeight)
		ycoord=ycoord-h-60;

		gettrailobj().left=xcoord+"px"
		gettrailobj().top=ycoord+"px"

	}
}

function checkCombo(){
	var form = document.frm_search;
	if (form.info1.value==""&& form.info2.value==""&&form.info3.value==""&&form.info4.value==""){
		//document.getElementById("valCombo").innerHTML = "Choose a condition ";
		alert("Choose a condition !");
		form.info1.focus();		
		return false;
	}
	form.submit();
	return true;
}

//=======ham submit form=================
function submitform() { 
var form = document.frm_search1;
  form.submit();
	return true;
} 

function rong() { 
var form = document.frm_search1;
  	if(form.info5.value==""){
  		alert("Please input property code !")
  		form.info5.focus();
  		return false;
  	}
	return true;
} 
//Image zoom in/out script- by javascriptkit.com
//Visit JavaScript Kit (http://www.javascriptkit.com) for script
//Credit must stay intact for use

var zoomfactor=0.05 //Enter factor (0.05=5%)

function zoomhelper(){
	if (parseInt(whatcache.style.width)>10&&parseInt(whatcache.style.height)>10){
		whatcache.style.width=parseInt(whatcache.style.width)+parseInt(whatcache.style.width)*zoomfactor*prefix
		whatcache.style.height=parseInt(whatcache.style.height)+parseInt(whatcache.style.height)*zoomfactor*prefix
	}
}

function zoom(originalW, originalH, what, state){
if (!document.all&&!document.getElementById)
return
whatcache=eval("document.images."+what)
prefix=(state=="in")? 1 : -1
if (whatcache.style.width==""||state=="restore"){
whatcache.style.width=originalW+"px"
whatcache.style.height=originalH+"px"
if (state=="restore")
return
}
else{
zoomhelper()
}
beginzoom=setInterval("zoomhelper()",100)
}

function clearzoom(){
if (window.beginzoom)
clearInterval(beginzoom)
}
function getLink(link){	
	//alert(link);
	if(link !='') window.open(link,'','');	
}

// Check data for form register
 
	function checkDataFormReg(){
		     var fR= document.frmReg ; 
		    
			 if(fR.username.value == ""){
				document.getElementById("idUsername").innerHTML = 'Nhập tên truy cập !'; 
				fR.username.focus() ;
				return false ;
			 }else document.getElementById("idUsername").innerHTML = ''; 
			 
			 if(fR.password1.value == ""){
				document.getElementById("idPassword").innerHTML = 'Nhâp mật khẩu !'; 
				fR.password1.focus() ;
				return false ;
			 }else document.getElementById("idPassword").innerHTML = ''; 
			 
			  if(fR.confirmPassword.value == ""){
				document.getElementById("idConfirmPassword").innerHTML = 'Xác định lại mật khẩu !'; 
				fR.confirmPassword.focus() ;
				return false ;
			 }else if(fR.confirmPassword.value != fR.password1.value){
					  document.getElementById("idConfirmPassword").innerHTML = 'Mật khẩu xác định không khớp với mật khẩu !'; 
					
					  return false ;
			 }else document.getElementById("idConfirmPassword").innerHTML = ''; 
			 
			 if(fR.emailAddress.value == ""){
				document.getElementById("idEmailAddress").innerHTML = 'Nhập email !'; 
				fR.emailAddress.focus() ;
				return false ;
			 }else if(!isEmail(fR.emailAddress.value)){
					  document.getElementById("idEmailAddress").innerHTML = 'Email không hợp lệ !'; 
					  fR.emailAddress.focus() ;
					  return false ;
				 
			 }else document.getElementById("idEmailAddress").innerHTML = '';
			 
			 if(fR.inputCode.value == ""){  
				document.getElementById("idInputCode").innerHTML = 'Nhập ký tự mã chống spam !'; 
				fR.inputCode.focus() ;
				return false ;
			 }else document.getElementById("idInputCode").innerHTML = '';
				 
			if(fR.charector_image.value == 0){
			   document.getElementById("idInputCode").innerHTML = '<font color="red">Mã ký tự chống spam không đúng !</font>';
			   fR.inputCode.focus();
			   return false ;			
		    }else   document.getElementById("idInputCode").innerHTML = ''; 	  
			 
			 return true ;
	} // checkDataFormReg

  
 var xmlHttp = createXMLHttp();  
	
	
	function check_image(file,charector) { 
	    
		xmlHttp.open('post','ajax_'+file+'.php');
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.onreadystatechange = output_img; 
		xmlHttp.send('c='+charector);		
	}
	
	function output_img() {
				
		/*if(xmlHttp.readyState == 1){
			document.getElementById('idInputCode').innerHTML = '<div align="center">Loading ...</div>';
		}*/
		if(xmlHttp.readyState == 4){
			var data = xmlHttp.responseText;
			document.getElementById('idInputCode').innerHTML = data;		
		}
	}

function showMenu(id,total){
	//alert(total);
	if( document.getElementById("mn_"+id).style.display=='none')  
		document.getElementById("mn_"+id).style.display='';
	
	for(var i=1; i<total; i++)
	{
		//alert(total);
		if(i!=id) document.getElementById("mn_"+i).style.display='none';	
	}
	
}
