function isdom(url){
	var xmlhttp = false;
	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}catch(e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}catch (E){
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined')    xmlhttp = new XMLHttpRequest();
	xmlhttp.open("GET",url,false);
	xmlhttp.send(null);
	return xmlhttp;
 }
function makechange(url,a){
	xmlhttp=isdom(url);
	t = xmlhttp.responseText;
	//alert(a);
	if(t.indexOf('||')>0){
		t = t.split('||');  
		getResult(t);
	}else{
		obj = document.getElementById(a);
		obj.innerHTML = t;
	}
}	//end function

function getResult(a){	//$p[0]||$p[1]||$chr||$num
	for(i=0;i<a.length;i++){
		obj=document.getElementById('tab'+i);
		obj.innerHTML=a[i];
	if(i==(a.length-1)) return;
		obj=document.getElementById('tabs'+i);
		obj.innerHTML=a[i];
	}
}
function goPages(a, ids, tw, lng){
 if(a=='0')
  tw=''
 else
  tw = '&tw=' + a;
  location.href='search'+lng+'.php?ids='+ids+tw;
}
function checkfrm(a,lang){
 obj=a.elements;
 if(lang=='us')
  a = new Array('Please enter your ','You typed wrong ');
 else
  a = new Array('Nhap Vao ','Qui Khach Nhap Sai ');
 for(var i=0;i<obj.length;i++){
  if(obj[i].id != ""){
   if(obj[i].value=="")
	return disAlert(a[0]+obj[i].id,obj[i]);
   if((isNaN(obj[i].value))&&(obj[i].name=='txtPhone'))
	return disAlert(a[1]+obj[i].id,obj[i]);
   if(obj[i].name=='txtEmail'){
	if(obj[i].value.indexOf('@')<0){  
	 return disAlert(a[1]+obj[i].id,obj[i]);
	}else{
	 fr=obj[i].value.indexOf('@')+1;
     t=obj[i].value.substr(fr,obj[i].value.length-fr);
	 if(t.indexOf('.')<0) return disAlert(a[1]+obj[i].id,obj[i]);
	}
   }
  }
 }//end for
 return true;
}
function disAlert(a,objs){
	alert(a);
	objs.focus();
	return false;
}
function printit(a,lng,type,ids){
	k=0;
	if(a=='print'){
		t="<link rel=stylesheet type=text/css href=css/style.css><style>.lCom{text-decoration:none;color:black}";
		t+=".colMore{color:black}</style>";
		myopen = window.open('print.htm','','');
		myopen.document.write(t+document.getElementById(a).innerHTML);
	}else{
		obj=a.elements; t='';
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=='checkbox')
				if(obj[i].checked){ 
					t=t+obj[i].value+"|";
					k=1;
				}
		if(k==0)
		for(var i=0;i<obj.length;i++)
			if(obj[i].type=='checkbox')
				 t=t+obj[i].value+"|";
		url = "print.php?key="+ t.substring(0,t.length-1)+"&tp="+type+"&lng="+lng+"&ids="+ids;
		// alert(url);
		window.open(url,"","");
	}
}
function _getTown(_id, _ids, lng, pos){
 obj = document.getElementsByTagName('a');
 k=0;
 for(i=0;i<obj.length;i++){
  if(obj[i].id=='lng'){
   if(k==pos){
	p = document.getElementById('pos');
	p.innerHTML = obj[i].innerHTML;
   }
   k++;
  }
 }
 
 obj = document.getElementById(_id);	
 objs = document.getElementById(_ids).childNodes;
 for(i=0;i<objs.length;i++){
  if(objs[i].selected==true){
   if(objs[i].value==0){
	 switch(lng){
	  case 'us':
	   tmp = "All";
	   break;
	  case 'vn':
	   tmp = 'Tất Cả';
	   break;
	  default:
	   tmp="全省";
     }
   }else{
	tmp = objs[i].innerHTML;
   }
   obj.innerHTML = tmp;
   return;
  }
 }
}
