/* AJAX Server request script 
						Zorion Media */

function sndReq(){
	this.resetData = function() {
		this.method = "GET";
		this.myurl = '';
		this.content = '';
		this.data = '';
		this.http = null;
		this.responseStatus = new Array(2);
		this.response = '';
  	};

	this.resetFunctions = function() {
  		this.onLoading = function() { };
  		this.onLoaded = function() { };
  		this.onInteractive = function() { };
  		this.onCompletion = function() { };
  		this.onError = function() { };
		this.onFail = function() { };
	};

	this.reset = function() {
		this.resetFunctions();
		this.resetData();
	};


	this.createRequestObject = function(){
    if(browser.ie) this.http = new ActiveXObject("Microsoft.XMLHTTP");
    else this.http = new XMLHttpRequest();
	}


	this.serverSlide = function(){
		curObject.push(this.content);
		//http.setRequestHeader("Content-Type", "image/jpg");
		//this.http.setRequestHeader("Accept", "image/jpg");
		if (this.http) {
			var self = this;//[a-zA-Z0-9]{1,4}
				var pop = '';
				fileurl = new RegExp(/([a-zA-Z0-9|/|:|_]+).(jpg|png|xml|gif)/);
				this.imgTrue = this.myurl.match(fileurl);
				if(!this.imgTrue){
				var htAcc = this.myurl.match('&');
				if(htAcc) var pop = '&pop=1';
				else var pop = '/pop';
				}

				this.http.onreadystatechange = function(){
				switch (self.http.readyState) {
						case 1:
							self.onLoading();
							break;
						case 2:
							self.onLoaded();
							break;
						case 3:
							self.onInteractive();
							break;
						case 4:
							//if (self.http.status == "200") 
							//else self.onError();
							//curObject.remove(self.content);
							//alert(self.content);
							self.onCompletion();
							
							//self.response = self.http.responseText;
							//self.responseXML = self.http.responseXML;
							//self.responseStatus[0] = self.http.status;
							//self.responseStatus[1] = self.http.statusText;
							
							
							
						break;
				}//end switch
			
			}




	
				if (this.method == "GET")  {

					this.http.open(this.method, this.myurl + pop, true);
					this.http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
					this.http.setRequestHeader('Connection', 'close');
					this.http.send(null);
				}
				if (this.method == "POST") {
					this.http.open(this.method, this.myurl + pop, true);
					this.http.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded; charset=UTF-8');
					this.http.setRequestHeader( 'Content-length', this.data.length );
					this.http.setRequestHeader('Connection', 'close');
					this.http.send(this.data); 
				}

	
			
	
		}//end http exists
		else alert('Not Ajax-capable, trying normal form-submit');
	}//end run serverrequest


this.reset();
this.createRequestObject();
}