
function ajaxReady()
{
	var xmlhttp;
	try{
	xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
	}
	catch(e)
	{
		try{
			xmlhttp = new ActiveXObject('Msxml2.XMLHTTP');
			}
		catch(e)
		{
			try{ xmlhttp = new XMLHttpRequest();}
			catch(e){}
		}
	}
	return xmlhttp;					
}

function clearDiv(divid) {
	$(divid).innerHTML=""
}

function UnicodeValue(formname){
	data=$(formname).serialize();
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(formname).result.value=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('post','/unicode');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;
}


function URLEndec(formname){
	data=$(formname).serialize();
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(formname).result.value=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('post','/urlendec');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;	
}

function Pinyin(formname,result){
	data=$(formname).serialize();
	//alert(data);
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(result).innerHTML=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('post','/pinyin');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;	
}

function TimeDiff(formname,result){
	data=$(formname).serialize();
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(result).innerHTML=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('post','/datediff');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;	
}

function htmlValue(formname,result){
	try {
		$(result).innerHTML=$(formname).query.value;
	}
	catch(e) {}
}

function htmlColor(formname,result){
	try {
		$(result).innerHTML="<table width=700> \
		<tr><td bgcolor="+$(formname).query.value+"></td>\
		<td>"+$(formname).query.value+"</td></tr>\
		</table>";
	}
	catch(e) {}
}

function getAuthNum(divid) {
	//alert(divid);
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(divid).innerHTML=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('GET','/getauthnum');
	xhr.send(null);
	return false;
}

function getEntry(formname,result){
	data=$(formname).serialize();
	//alert(data);
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(result).innerHTML=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('POST','/getentry');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;
}

function setCity(formname,selectid) {
	select=$(selectid);
	data=$(formname).serialize();
	//alert(data);
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if (xhr.status == 200) {
				var restext = xhr.responseText;
				//alert(restext);
				json = eval('(' + restext + ')');
				select.options.length = 0;
				for (i = 0; i < json.length; i++) { 
					select.options.add(new Option(json[i], json[i]));
				}
			}
			else {
				alert(xhr.status);
			}
		}
	}
	xhr.open('POST','/getcity');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;
}

function getLatLng(formname,divid) {
	data=$(formname).serialize();
	//alert(data);
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if (xhr.status == 200) {
				var restext = xhr.responseText;
				//alert(restext);
				$(divid).innerHTML=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('POST','/getlatlng');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;	
}

function Base64Endec(formname){
	data=$(formname).serialize();
	xhr=ajaxReady();
	xhr.onreadystatechange=function(){
		if(xhr.readyState == 4) {
			if( xhr.status == 200 ) {	
				var restext = xhr.responseText;
				//alert(restext);
				$(formname).result.value=restext;
			}
			else {
				alert(xhr.status);
			}
		}	
	}
	xhr.open('post','/base64endec');
	xhr.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
	xhr.send(data);
	return false;	
}
