/******************************************************************

	httpreq.js
	----------
	
	Author:		Ashley Meadows
	Created:	26/02/2009
	Copyright:	© Ashley Meadows 2008-2009.
	Version:	1.0.0
	
	Description
	-----------
	
	ajax module (asynchronous javascript and xml) package, made
	to allow the developer to easily create transmissions between
	the current page and server scripts.
	
 ******************************************************************/
function httpreq(o){this.config={errorMsg:["Error: Invalid method attempted, valid methods are GET or POST."],datatype:["content-type", "application/x-www-form-urlencoded"],goMethod:["get", "post"]};this.URI=function(s,a,m){if((a!=null) && (a.length>0)){return ((!m)?s+"?"+(new Date()).getTime()+"&"+a.join("&"):encodeURI((new Date()).getTime()+"&"+a.join("&")));}else{return ((!m)?s+"?"+(new Date()).getTime():encodeURI((new Date()).getTime()));};};this.httpXML=function(){if(window.XMLHttpRequest){return (new XMLHttpRequest());}else if(window.ActiveXObject){try{return (new ActiveXObject("Msxml2.XMLHTTP"));}catch(e){try{return (new ActiveXObject("Microsoft.XMLHTTP"));}catch(e){return null;};};};};if((o.method!=null) && (o.method.toLowerCase()==this.config.goMethod[0])){var x=this.httpXML(), m="";x.open(this.config.goMethod[0], this.URI(o.script, o.get_vars, false));x.onreadystatechange=function(){if((o.debug==true) && (x.readyState==4)){if(o.script!=null){m+="script:\n"+o.script+"\n\n";};if(o.method!=null){m+="method:\n"+o.method+"\n\n";};if(o.get_vars!=null){m+="GET vars:\n"+o.get_vars.join("&")+"\n\n";};if(o.post_vars!=null){m+="POST vars:\n"+o.post_vars.join("&")+"\n\n";};m+="state:\n"+x.readyState+"\n\n";m+="status:\n"+x.status+"\n\n";m+="response:\n"+x.responseText;alert("-- Debug --\n\n"+m);}else{if((x.readyState==4) && (x.status==200) && (o.callback!=null)){eval(o.callback(x.responseText));};};};x.send(null);}else if((o.method!=null) && (o.method.toLowerCase()==this.config.goMethod[1])){var x=this.httpXML(), m="";x.open(this.config.goMethod[1], this.URI(o.script, o.get_vars, false));x.setRequestHeader(this.config.datatype[0], this.config.datatype[1]);x.onreadystatechange=function(){if((o.debug==true) && (x.readyState==4)){if(o.script!=null){m+="script:\n"+o.script+"\n\n";};if(o.method!=null){m+="method:\n"+o.method+"\n\n";};if(o.get_vars!=null){m+="GET vars:\n"+o.get_vars.join("&")+"\n\n";};if(o.post_vars!=null){m+="POST vars:\n"+o.post_vars.join("&")+"\n\n";};m+="state:\n"+x.readyState+"\n\n";m+="status:\n"+x.status+"\n\n";m+="response:\n"+x.responseText;alert("-- Debug --\n\n"+m);}else{if((x.readyState==4) && (x.status==200) && (o.callback!=null)){eval(o.callback(x.responseText));};};};x.send(this.URI(null, o.post_vars, true));}else{if(o.debug==true){alert(this.config.errorMsg[0]);};};};function $(o, type){switch(type){case "-t":return document.getElementsByTagName(o);break;case "-n":return document.getElementsByName(o);break;default:return document.getElementById(o);};};
