/// Connection class ///
// The location and server program are supplied for the myURL argument. The reqType defines
// where the request is a 'get' or a 'post'. If the reqType is 'get' then 'null' is the 
// value supplied for myData. If the reqType is 'post' then a string with the data to be
// posted to server is supplied. The format of myData for a POST is name=value&name1=value1 etc.
// The pgType defines where the result should be written. 

function getasyncdata(myURL,reqType,myData,pgType){

	this.myURL=myURL;
	this.reqType=reqType;
	this.myData=myData;
	this.pgType=pgType;

	this.getHTTPObject=function(){ 
  		var xmlhttp; 

  		if(window.XMLHttpRequest){ 
   		 	xmlhttp = new XMLHttpRequest(); 
 		} 
 		else if (window.ActiveXObject){ 
    			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
    			if (!xmlhttp){ 
        			xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    			} 
    
		} 


  		return xmlhttp; 

  
	} 

	var http=this.getHTTPObject();

	this.handleHttpResponse=function(){

       		 if (http.readyState == 4) { 
             		if(http.status==200) { 
                 		 var results=http.responseText;

				if(pgType=='loadAnn'){
					//addScrollers(results);
					document.getElementById("Announcements").innerHTML=results;
				} else { 

					if(pgType !='background'){
						document.getElementById(pgType).innerHTML=results;
					}else{
						document.body.style.backgroundImage="url(../../images/NavChart.gif)";

						//document.body.style.backgroundImage="url("+results+")";
					}

				}
				
             		} 
         	} 
	}
            
	this.requestInfo=function () {

		if(reqType=="get"){
		         
       	 		http.open("GET",this.myURL,true); 
        		http.onreadystatechange = this.handleHttpResponse; 

		} else {

			if(reqType =="get-false"){
				http.open("GET",this.myURL,false); 
        			http.onreadystatechange = this.handleHttpResponse; 

			} else {
			         
        			http.open("POST",this.myURL,true); 
				http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
        			http.onreadystatechange = this.handleHttpResponse;
			} 
     	
		} 

		http.send(this.myData);
	} 
}
