/*
This Code is write by Seachaos.
Welcome mail to ilmsilms@yahoo.com.tw.
Copyrights 2010 Seachaos, all rights reserved.
http://www.airweb.tw
*/

function DOMID(id){
	return document.getElementById(id);
}
function seaAX(){
	this.aj = new Object();
	this.text="none";this.doing=false;
	this.baseURL= "";
	this.postData = "";
	this.FLAG_BUSY = false;
	this.rXML = false;
	this.create=function(){
		this.FLAG_BUSY = false;
		this.doing=false;this.aj = new XMLHttpRequest();this.aj.onreadystatechange=this.change;
	}
	this.successRun = function(){
	}
	this.getValueByDOM = function(dom,name){
		return dom.getElementsByTagName(name)[0].childNodes[0].nodeValue;
	}
	this.getFirstValueByName = function(name){
		if(this.rXML){
			if(nodes = this.rXML.getElementsByTagName(name)){
				return nodes[0].childNodes[0].nodeValue;
			}else{
				return false;
			}
		}else{
			return false;
		}
	}
	this.return_success=function(){
		this.father.rText = this.father.aj.responseText;
		this.father.rXML = this.father.aj.responseXML;
		this.father.successRun();
		this.father.create();
	}
	this.return_failed=function(){
		//alert("Failed");
		this.father.create();
	}
	this.change=function(){
		try{
			if(this.readyState==4){if(this.status==200){this.return_success();}else{
				//alert("Page Error:"+this.status);
				this.return_failed();
			}this.father.create();}
		}catch(e){
			//alert("change:"+e);
		}
	}
	this.send_post=function(){
		if(!this.FLAG_BUSY){
			try{
				this.FLAG_BUSY = true;
				var postValue = this.postData;
				var url = this.baseURL;
				this.final_setting();
				this.aj.open("POST",url,true);
				this.aj.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
				this.aj.send(postValue);
			}catch(e){
				//alert("conn_get:"+e);
			}
		}
	}
	this.final_setting=function(){
		this.aj.father=this;this.aj.return_success=this.return_success;this.aj.return_failed=this.return_failed;
	}
	this.create();
}
