function Communication () {

this.createXmlHttpRequestObject = createXmlHttpRequestObject;
this.xmlHttp = this.createXmlHttpRequestObject();

var tmpJSONtxt = '';
var tmpJSONobj = null;

function createXmlHttpRequestObject() {
	
	// will store the reference to the XMLHttpRequest object
	var xmlHttp;
	// this should work for all browsers except IE6 and older
	try
	{
		// try to create XMLHttpRequest object
		xmlHttp = new XMLHttpRequest();
	}
	
	catch(e)
	{
		// assume IE6 or older
		var XmlHttpVersions = new Array("MSXML2.XMLHTTP.6.0",
		"MSXML2.XMLHTTP.5.0",
		"MSXML2.XMLHTTP.4.0",
		"MSXML2.XMLHTTP.3.0",
		"MSXML2.XMLHTTP",
		"Microsoft.XMLHTTP");
		// try every prog id until one works
		for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
		{
			try
			{
			// try to create XMLHttpRequest object
			xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
			}
			catch (e) {}
			}
		}
		
		// return the created object or display an error message
		if (!xmlHttp){
		
			alert("Error creating the XMLHttpRequest object.");
		} else {
			
			//alert ("xmlHTTP Created");
			return xmlHttp;
		}
	}

}//end class


CommService.prototype = new Communication();

function CommService() {

this.handler= handler;
this.processGet= processGet;
this.processPost = processPost;
this.procJSON = procJSON;
this.readyState= readyState;
this.processProtocol = processProtocol;
	

function processGet(url, xmlHttp) {
	// only continue if xmlHttp isn't void
	if (xmlHttp)
	{
	// try to connect to the server
		try
		{
			// initiate reading the async.txt file from the server
			xmlHttp.open("GET", url, true);
			xmlHttp.onreadystatechange = handleRequestStateChange;
			xmlHttp.send(null);
		}
		// display the error in case of failure
		catch (e)
		
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}
}//end function


function processPost(xmlHttp, url, param, func) {
	// only continue if xmlHttp isn't void
	var dat;
	
	if (xmlHttp)
	{
	// try to connect to the server
		try
		{
			xmlHttp.open("POST", url, true);
			xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
			xmlHttp.onreadystatechange = func;
			//xmlHttp.addEventListener("onreadystatechange", alert1, false); 
			//xmlHttp.send("param1=x&param2=y");
			//alert(param);
			xmlHttp.send(param);
			
		}
		// display the error in case of failure
		catch (e)
		
		{
			alert("Can't connect to server:\n" + e.toString());
		}
	}

}//end function


function handler (xmlHttp) {
		
		if (xmlHttp.readyState == 4 && xmlHttp.status == 200) {
			
			try {
				//document.write(xmlHttp.responseText);
				
				//document.getElementById("abstract").innerHTML =  xmlHttp.responseText;
				//rawData = document.getElementById("abstract").innerHTML;
				returnDat =   xmlHttp.responseText;
				
				
				//document.write(response);
			
			} 
			
			catch(e) {
				// display error message
				alert("Error reading the response: " + e.toString());
			} //end try
			
		}//end if 
		

}// end function


function procJSON (jsontxt) {


	return eval('(' + jsontxt + ')');
}// end function


function readyState (httpRequest) {
		
		 return ((httpRequest.readyState == 4 && httpRequest.status == 200) ? true : false) ;
	
}// end function

function processProtocol (url) {
		
		var protocol = "";
		
		var util = new Utilities();
		var results = util.regxStringSearch (url, /https/gi);
		
		if(results == -1) {
			
			return protocol = "http://";
		
		} else {
			
			return protocol = "https://";
		}
}
}//end class