var ajaxObj = new Array();
var isIE = false;
function ajax(){
	this.xmlhttp;
	this.formElement;
	this.requestFile;
	this.URLString;
	this.useStatus;
	this.innerDivID;
	this.method 		= 'GET';
	this.responseType 	= 'Text'; /*Text , XML*/
	this.async = true;
	this.useStatusSeq = false;
	this.onCompletion 	= function() { };
	this.onProcess 		= function() { };
	this.showStatus = function(){ };
	this.hideStatus = function() { };
	this.ConnXmlHttp = function(){
		try {
			// Firefox, Opera 8.0+, Safari
			xmlhttp=new XMLHttpRequest();
		} catch (e) {
			// Internet Explorer
			try {
				xmlhttp=new ActiveXObject("Msxml2.XMLHTTP");
				isIE = true;
			} catch (e) {
				try {
					xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
					isIE = true;
				} catch (e) {
					alert("Your browser does not support AJAX!");
					return false;
				}
			}
		}
		return xmlhttp;

	}
	this.getRequestBody = function(myForm) {
		var aParams = new Array();  
		
			for (var i=0 ; i < myForm.elements.length; i++) {
				
				var formElement = myForm.elements[i];
				if(formElement.type=='checkbox' && !formElement.checked){ continue;} 
            	var sParam = encodeURIComponent(myForm.elements[i].name);
               	sParam += "=";
               	sParam += encodeURIComponent(myForm.elements[i].value);
               	aParams.push(sParam);
           	}     
			
           	return aParams.join("&");        
	}
	this.loadXMLDoc = function() {
		var self = this;
		this.xmlhttp = this.ConnXmlHttp();	
		if (this.method == "GET") {
			this.xmlhttp.open(this.method, this.requestFile, this.async);
		}else{
			this.URLString = this.getRequestBody(this.formElement);
			this.xmlhttp.open(this.method,this.requestFile, this.async);
		}
		if (this.method == "POST"){
  			try {
				this.xmlhttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');  
				//this.xmlhttp.setRequestHeader("Content-length", this.URLString.length);
				//this.xmlhttp.setRequestHeader("Connection", "close");
			} catch (e) {}
		}
		this.xmlhttp.onreadystatechange = function(){
			try
			{
				if(self.xmlhttp.readyState==4){
					if (self.xmlhttp.status == 200) {
						if (self.useStatus)
						{
							if (self.useStatusSeq)
							{
								cThread++;
							} else {
								self.hideStatus();
							}
						}		
						if(self.responseType == "Text"){
							self.response = self.xmlhttp.responseText;
						}else{
							self.response = self.xmlhttp.responseXML;
						}	
						
						self.onCompletion();
					}
				}else{
					if (self.useStatus)
					{
						self.showStatus();
					}
					
				}	
			}
			catch (e)
			{
				
				return false;
			}

		}
		this.xmlhttp.send(this.URLString);
	}
	
}
function showLoading() {
	showBackgroundLoading();
	showLoadingMessage();
} 
function hideLoading() {
	hideLoadingMessage();
	hideBackgroundLoading();
} 
function showLoadingMessage() {
	width=200;
	height=100;
	divStatusName = "status1";
	window.onscroll = showLoadingMessage;
	window.onresize = showLoadingMessage;
	divStatusLayer = document.getElementById(divStatusName);
	if( typeof( window.innerWidth ) == 'number' ) {
		//Non-IE
		myWidth = window.innerWidth;
		myHeight = window.innerHeight;
	  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
		//IE 6+ in 'standards compliant mode'
		myWidth = document.documentElement.clientWidth;
		myHeight = document.documentElement.clientHeight;
	  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
		//IE 4 compatible
		myWidth = document.body.clientWidth;
		myHeight = document.body.clientHeight;
	  }
	leftPosition =parseInt((myWidth/2) - (width/2));
	topPosition =  parseInt((myHeight/2) - (height/2)); 	
	divStatusLayer.style.position = 'absolute';
	divStatusLayer.style.left = parseInt((document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft) + leftPosition) + 'px';
	divStatusLayer.style.top = parseInt((document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop) + topPosition) + 'px';
	divStatusLayer.style.visibility="visible";
	divStatusLayer.style.display="block";	
}
function hideLoadingMessage() {
	window.onscroll = null;
	window.onresize = null;
	divStatusName = "status1";
	divStatusLayer = document.getElementById(divStatusName);
	divStatusLayer.style.visibility = "hidden";
	divStatusLayer.style.display="none";
	
}
function showBackgroundLoading() {
	document.getElementById('sLayer').style.display = 'block';
	if ( document.body.scrollHeight < 2500)
	{
		document.getElementById('sLayer').style.height = 2500 +'px';
	} else {
		document.getElementById('sLayer').style.height = document.body.scrollHeight + 'px';
	}

	
	if (document.body.scrollWidth > 1300)
	{
		document.getElementById('sLayer').style.width = document.body.scrollWidth + 'px';
	} else {
		document.getElementById('sLayer').style.width = '1300px';
	}

	hideObject();
	
	//document.getElementById('sLayer').style.width = '100%'; 
}
function hideBackgroundLoading() {
	document.getElementById("sLayer").style.display="none";
	document.getElementById('sLayer').style.height = 0+'px';
	showObject();

}


function hideObject() {
	var obj = document.getElementsByTagName('body')[0].getElementsByTagName('object');
	for (var i = 0;i < obj.length ; i++)
	{
		obj[i].style.display = 'none'; 
	}
}
function showObject() {
	var obj = document.getElementsByTagName('body')[0].getElementsByTagName('object');
	for (var i = 0;i < obj.length ; i++)
	{
		obj[i].style.display = 'block'; 
	}
}