
function WBE_AjaxClass()
{this.parameters=new Array();this.httpReq;this.url="NO_OUTPUT.wbe";this.xml_resource="XML_DOCUMENT.wbe";this.params;this.async=false;this.hasErrors=(!this.httpReq||this.httpReq.status!=200);this.waitResponseHandler=function(){};this.clear=function(){this.parameters=new Array();}
this.addPostParameter=function(sName,sValue){if(sName!=null&&sValue!=null){this.parameters[this.parameters.length]=sName+"="+encodeURIComponent(sValue);}}
this.getXMLNodeValue=function(oXMLNode,sTagName){var value=oXMLNode.getElementsByTagName(sTagName);return(value!=null&&value.length>0&&value[0].firstChild!=null)?value[0].firstChild.nodeValue:'';}
this.call=function(){if(window.XMLHttpRequest){this.httpReq=new XMLHttpRequest();if(this.async)
this.httpReq.onreadystatechange=this.waitResponseHandler;}else if(window.ActiveXObject){try{this.httpReq=new ActiveXObject("Msxml2.XMLHTTP");if(this.async)
this.httpReq.onload=this.waitResponseHandler;}catch(e){try{this.httpReq=new ActiveXObject("Microsoft.XMLHTTP");if(this.async)
this.httpReq.onreadystatechange=this.waitResponseHandler;}catch(e){}}}
if(!this.httpReq){alert('No puedo crear una instancia AJAX');return false;}
this.url=this.url.replace('#','');this.httpReq.open("POST",this.url,this.async);this.httpReq.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");this.httpReq.send(this.params);if(!this.async)
this.responseText=this.httpReq.responseText;};this.throwEvent=function(sEvent,asParams,bDoXmlOutput,sUrl)
{var xmlDoc;if(sUrl)this.url=sUrl;this.params="event="+sEvent;if(asParams){for(var i=0;i<asParams.length;i++)
this.params+="&"+asParams[i];}
this.call();if(!bDoXmlOutput)return this.responseText;if(this.responseText=="")return null;if(document.implementation&&document.implementation.createDocument)
{xmlDoc=document.implementation.createDocument("","",null);xmlDoc.async=false;xmlDoc.onload=function(){return(xmlDoc.readyState==4);};this.LoadXMLMozilla(xmlDoc,this.responseText);}else{if(window.ActiveXObject){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;xmlDoc.onreadystatechange=function(){return(xmlDoc.readyState==4);};xmlDoc.loadXML(this.responseText);}}
return xmlDoc.documentElement;};this.throwCall2=function(sUrl){var xmlDoc;if(sUrl)this.url=sUrl;this.params="";for(var i=0;i<this.parameters.length;i++){if(this.params!="")this.params+="&";if(this.parameters[i]!=undefined)this.params+=this.parameters[i];}
this.call();}
this.throwEventXML=function(sEvent){return this.throwEvent2(sEvent,true,this.xml_resource);}
this.throwEvent2=function(sEvent,bDoXmlOutput,sUrl)
{this.addPostParameter("event",sEvent);this.throwCall2(sUrl);if(!bDoXmlOutput)return this.responseText;if(this.responseText=="")return null;if(document.implementation&&document.implementation.createDocument)
{xmlDoc=document.implementation.createDocument("","",null);xmlDoc.async=false;xmlDoc.onload=function(){return(xmlDoc.readyState==4);};this.LoadXMLMozilla(xmlDoc,this.responseText);}else{if(window.ActiveXObject){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;xmlDoc.onreadystatechange=function(){return(xmlDoc.readyState==4);};xmlDoc.loadXML(this.responseText);}}
return xmlDoc.documentElement;};this.LoadXMLMozilla=function(oDoc,s)
{var doc2=(new DOMParser()).parseFromString(s,"text/xml");while(oDoc.hasChildNodes())
oDoc.removeChild(this.lastChild);for(var i=0;i<doc2.childNodes.length;i++){oDoc.appendChild(oDoc.importNode(doc2.childNodes[i],true));}};this.throwCall=function(asParams,bDoXmlOutput,sUrl)
{var xmlDoc;if(sUrl)this.url=sUrl;if(asParams){for(var i=0;i<asParams.length;i++)
this.params+="&"+asParams[i];}else{this.params="";for(var i=0;i<this.parameters.length;i++){if(this.params!="")this.params+="&";if(this.parameters[i]!=undefined)this.params+=this.parameters[i];}}
this.call();if(!bDoXmlOutput)return this.responseText;if(this.responseText=="")return null;if(document.implementation&&document.implementation.createDocument)
{xmlDoc=document.implementation.createDocument("","",null);xmlDoc.async=false;xmlDoc.onload=function(){return(xmlDoc.readyState==4);};this.LoadXMLMozilla(xmlDoc,this.responseText);}else{if(window.ActiveXObject){xmlDoc=new ActiveXObject("Microsoft.XMLDOM");xmlDoc.async=false;xmlDoc.onreadystatechange=function(){return(xmlDoc.readyState==4);};xmlDoc.loadXML(this.responseText);}}
return xmlDoc.documentElement;};};