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 + "/"+ key + "/1/" + word ; 

	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 close_explode(explode,start_parent)

{

	if(document.getElementById(explode).style.display == 'none')

	{
		//alert('explode');

		document.getElementById(explode).style.display = 'block';

		document.getElementById(start_parent).style.display = 'none';

	}else{
		
		//alert('start_parent');

		document.getElementById(start_parent).style.display = 'block';

		document.getElementById(explode).style.display = 'none';

	}

}



function WebForm_OnSubmit_bottom()
{
	var ok = false ;
	var ok2 = false ; 
	if(document.getElementById('txtclass1').value=='Nhập: Từ khóa, Ngành nghề...'){document.getElementById('txtclass1').value=''; }	else
	if(document.getElementById('txtclass1').value!=''){
			document.getElementById('txtclass').value = document.getElementById('txtclass1').value;
			ok = true ;
	}
	if(document.getElementById('txtlocation1').value=='Nhập: Tỉnh/TP hoặc Quận/Huyện...'){document.getElementById('txtlocation1').value=''; }else
	if(document.getElementById('txtlocation1').value!=''){
			document.getElementById('txtlocation').value = document.getElementById('txtlocation1').value;
			ok2 = true ;
	}
	if(ok){ return document.frmsearch.submit(); }
	if(ok2){ return document.frmsearch.submit();}
	return false;

}

function WebForm_OnSubmit_bottom_us()
{
	var ok = false ;
	var ok2 = false ; 
	if(document.getElementById('txtclass1').value=='bussiness or product or category...'){document.getElementById('txtclass1').value=''; }else
	if(document.getElementById('txtclass1').value!=''){
			document.getElementById('txtclass').value = document.getElementById('txtclass1').value;
			ok = true ;
	}
	if(document.getElementById('txtlocation1').value=='Input : Town/City or District...'){document.getElementById('txtlocation1').value=''; }else
	if(document.getElementById('txtlocation1').value!=''){
			document.getElementById('txtlocation').value = document.getElementById('txtlocation').value;
			ok2 = true ;
	}
	
	if(ok){ return document.frmsearch.submit(); }
	if(ok2){ return document.frmsearch.submit();}
	return false;

}
 

function WebForm_OnSubmit_bottom_cn()
{
	var ok = false ;
	var ok2 = false ; 
	if(document.getElementById('txtclass1').value=='新增：当然，专业...'){document.getElementById('txtclass1').value=''; }else
	if(document.getElementById('txtclass1').value!=''){
			document.getElementById('txtclass').value = document.getElementById('txtclass1').value;
			ok = true ;
	}
	if(document.getElementById('txtlocation1').value=='新增：镇/市或县/区...'){document.getElementById('txtlocation1').value=''; }else
	if(document.getElementById('txtlocation1').value!=''){
			document.getElementById('txtclass').value = document.getElementById('txtclass1').value;
			ok2 = true ;
	}
	if(ok){ return document.frmsearch.submit(); }
	if(ok2){ return document.frmsearch.submit();}
	return false;

} 

function WebForm_OnSubmit()

{

	var ok = false ;

	var ok2 = false ;

	if(document.getElementById('txtclass').value!=''){ok = true ;}

	if(document.getElementById('txtlocation').value!=''){ok2 = true ;}

	

	if(ok){ 

			return document.frmsearch.submit();

	}

	if(ok2){    

			return document.frmsearch.submit(); 

	}

	return false;

}



function WebForm_OnSubmit_us()

{

	var ok = false ;

	var ok2 = false ;

	if(document.getElementById('txtclass').value!=''){ok = true ;}

	if(document.getElementById('txtlocation').value!=''){ok2 = true ;}

	

	if(ok){ 

			return document.frmsearch.submit();

	}

	if(ok2){    

			return document.frmsearch.submit(); 

	}

	return false;

}



function WebForm_OnSubmit_cn()

{

	var ok = false ;

	var ok2 = false ;

	if(document.getElementById('txtclass').value!=''){ok = true ;}

	if(document.getElementById('txtlocation').value!=''){ok2 = true ;}

	

	if(ok){ 

			return document.frmsearch.submit();

	}

	if(ok2){    

			return document.frmsearch.submit(); 

	}

	return false;

}
