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;

	if(t.indexOf('||')>0){
		t = t.split('||') ;  
		getResult(t);
	}else{
		obj = document.getElementById(a);
		obj.innerHTML = t ;
	}
}	
function getResult(a){	
	for(i=0;i<a.length;i++){	
		obj=document.getElementById('tab'+i);
		obj.innerHTML=a[i];
		if(i==(a.length-1)) return;
		if(i==1){
			obj=document.getElementById('tabs'+i);
			if(obj != null) obj.innerHTML=a[i];
		}
	}
	
}
function goPages(town, kind, key, lng, word){
	var links = "VN/"+town+"/"+kind+"/"+word+"/1/" ;
	location.href='search'+lng+'.php?/'+links ;
}
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("Hello. Tritigi") ;
		window.open(url,"","");
	}
}
function _getTown(_id, _ids, lng){
	
	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;
		}
	}
}
function kodau(str) {  
	str= str.toLowerCase();  
	str= str.replace(/à|á|ạ|ả|ã|â|ầ|ấ|ậ|ẩ|ẫ|ă|ằ|ắ|ặ|ẳ|ẵ/g,"a");  
	str= str.replace(/è|é|ẹ|ẻ|ẽ|ê|ề|ế|ệ|ể|ễ/g,"e");  
	str= str.replace(/ì|í|ị|ỉ|ĩ/g,"i");  
	str= str.replace(/ò|ó|ọ|ỏ|õ|ô|ồ|ố|ộ|ổ|ỗ|ơ|ờ|ớ|ợ|ở|ỡ/g,"o");  
	str= str.replace(/ù|ú|ụ|ủ|ũ|ư|ừ|ứ|ự|ử|ữ/g,"u");  
	str= str.replace(/ỳ|ý|ỵ|ỷ|ỹ/g,"y");  
	str= str.replace(/đ/g,"d");  
	/* tìm và thay thế các kí tự đặc biệt trong chuỗi sang kí tự - */ 
	//str= str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\|\[|\]|~|$|_/g,"-"); 
	str= str.replace(/!|@|%|\^|\*|\(|\)|\+|\=|\<|\>|\?|\/|,|\.|\:|\;|\'| |\"|\&|\|\[|\]|~|$|_|-/g,"");
	//cắt bỏ ký tự - ở đầu và cuối chuỗi  
	str= str.replace(/-+-/g,"-"); //thay thế 2- thành 1- 
	str= str.replace(/^\-+|\-+$/g,"");  
	return str;  
}   
function town(s)
{
	document.getElementById("txtlocation").value = s;
	document.getElementById("txtlocation1").value = s;
}
function disableEnterKey(e) 
{ 
     var key; 
     if(window.event) 
          key = window.event.keyCode;//IE 
     else 
          key = e.which;//firefox 
     if(key == 13)
	 {
		  if(document.getElementById("txtclass").value == "")
			 return false; 
          WebForm_OnSubmit();
	 }
} 
