var ServerQuery=function(type,url,data,callback){var that=this;var request;var construct=function(){validateParameters();callback=callback||function(){};if(type=="GET"&&data){if(url.indexOf("?")==-1){url+="?"}url+=data}request=new that.Request(type,url,data,callback)};this.stop=function(){request.stop()};var validateParameters=function(){var ERROR_MSG="ServerQuery: Could not instantiate ServerQuery because ";if(!type){throw new Error(ERROR_MSG+"the query type was not defined")}type=type.toUpperCase();if(type!="GET"&&type!="POST"){throw new Error(ERROR_MSG+"the query type '"+type+"' is not supported")}else if(!url){throw new Error(ERROR_MSG+"the "+type+" url was not defined")}};construct()};ServerQuery.prototype.Request=function(type,url,data,callback){var xmlhttp;this.stop=function(){if(xmlhttp){xmlhttp.abort()}};var createRequestObj=function(){if(window.XMLHttpRequest){xmlhttp=new XMLHttpRequest()}else{xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")}return xmlhttp};var setServerRequest=function(){xmlhttp.open(type,url,false);if(type=="POST"){xmlhttp.setRequestHeader("Content-type","application/x-www-form-urlencoded")}xmlhttp.onreadystatechange=function(){if(xmlhttp.readyState==4){callback(xmlhttp.responseText)}};xmlhttp.send(data)};createRequestObj();setServerRequest()};
