
if(ajaxFactory)
{}
else
{var ajaxFactory=new Object();ajaxFactory.READY_STATE_UNINITIALIZED=0;ajaxFactory.READY_STATE_LOADING=1;ajaxFactory.READY_STATE_LOADED=2;ajaxFactory.READY_STATE_INTERACTIVE=3;ajaxFactory.READY_STATE_COMPLETE=4;}
ajaxFactory.ajaxRequest=function(url,displayArea,sendMethod,formName,onload,onerror,asynchron){this.url=url;this.req=null;this.displayArea=(displayArea)?displayArea:"displayArea";this.formName=(formName)?formName:"LANSA";this.sendMethod=(sendMethod)?sendMethod:"POST";this.asynchron=(asynchron==null)?true:asynchron;this.onload=(onload)?onload:this.defaultLoad;this.onerror=(onerror)?onerror:this.defaultError;this.onwait=null;this.postEventFunc=null;this.getExternalLink=false;this.additionalParmNames=null;this.additionalParmValues=null;this.headerNames=null;this.headerValues=null;this.eventOwner=null;this.XSLParmNames=null;this.XSLParmValues=null;this.reuseXML=null;}
ajaxFactory.ajaxRequest.prototype={setPostEventFunc:function(postEventFunc)
{this.postEventFunc=postEventFunc?postEventFunc:null;},setEventOwner:function(eventOwner)
{this.eventOwner=eventOwner;},setURL:function(url)
{this.url=url;},setSendMethod:function(sendMethod)
{this.sendMethod=(sendMethod)?sendMethod:"POST";},setFormName:function(formName)
{this.formName=(formName!=null)?formName:"LANSA";},setAsync:function(asynchron)
{this.asynchron=(asynchron==null)?true:asynchron;},setDisplayArea:function(displayArea)
{this.displayArea=(displayArea)?displayArea:"displayArea";},setOnLoad:function(onload)
{this.onload=(onload)?onload:this.defaultLoad;},setOnWait:function(onwait)
{this.onwait=(onwait)?onwait:null;},setOnError:function(onerror)
{this.onerror=(onerror)?onerror:this.defaultError;},addParm:function(parmName,parmValue)
{if(parmName&&parmValue&&parmName!="")
{if(this.additionalParmNames==null||this.additionalParmValues==null)
{this.additionalParmNames=new Array();this.additionalParmValues=new Array();}
this.additionalParmNames[this.additionalParmNames.length]=parmName;this.additionalParmValues[this.additionalParmValues.length]=parmValue;}},addRequestHeader:function(headerName,headerValue)
{if(headerName&&headerValue&&headerName!="")
{if(this.headerNames==null||this.headerValues==null)
{this.headerNames=new Array();this.headerValues=new Array();}
this.headerNames[this.headerNames.length]=headerName;this.headerValues[this.headerValues.length]=headerValue;}},_addFormData:function(formName,parmName)
{if(formName&&parmName&&formName!=""&&parmName!="")
{if(document.forms[formName])
{var thisForm=document.forms[formName];if(thisForm.elements[parmName])
{thisParm=thisForm.elements[parmName];if(thisParm.name&&thisParm.value)
{this.addParm(thisParm.name,thisParm.value);}}}}},_addXSLParms_:function(formName,parmName,parmValue)
{if(formName&&parmName&&parmValue&&formName!=""&&parmName!=""&&parmValue!="")
{if(document.forms[formName])
{var thisForm=document.forms[formName];if(thisForm.elements[parmValue])
{thisParm=thisForm.elements[parmValue];if(thisParm.name&&thisParm.value)
{this._addXSLParm(parmName,thisParm.value);}}}}},_addXSLParm:function(parmName,parmValue)
{if(parmName&&parmValue&&parmName!="")
{if(this.XSLParmNames==null||this.XSLParmValues==null)
{this.XSLParmNames=new Array();this.XSLParmValues=new Array();}
this.XSLParmNames[this.XSLParmNames.length]=parmName;this.XSLParmValues[this.XSLParmValues.length]=parmValue;}},sendRequest:function(){if(!this.url)
{alert("Error: no url specified for the AJAX request.");return false;}
if(window.XMLHttpRequest){this.req=new XMLHttpRequest();}else if(window.ActiveXObject){try{this.req=new ActiveXObject("Microsoft.XMLHTTP");}
catch(e)
{try{this.req=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{this.req=null;}}}
if(this.req==null)
{alert("Your browser does not support AJAX.");return false;}
else
{var queryString="";var frm=null;if(this.displayArea==null){this.displayArea="displayArea";}
if(this.formName==null){this.formName="LANSA";}
if(this.sendMethod==null){this.sendMethod="POST";}
if(this.asynchron==null){this.asynchron=true;}
if(this.onload==null){this.onload=this.defaultLoad;}
if(this.onerror==null){this.onerror=this.defaultError;}
if(this.formName&&this.formName!="")
{frm=document.forms[this.formName];}
if(frm&&frm.elements)
{var numberElements=frm.elements.length;for(var i=0;i<numberElements;i++){if(frm.elements[i].type!="button")
{if(i==numberElements){queryString+=frm.elements[i].name+"="+
encodeURIComponent(frm.elements[i].value);}else{queryString+=frm.elements[i].name+"="+
encodeURIComponent(frm.elements[i].value)+"&";}}}}
if(this.additionalParmNames&&this.additionalParmValues&&this.additionalParmNames.length==this.additionalParmValues.length)
{for(var i=0;i<this.additionalParmNames.length;i++){if(queryString=="")
{queryString=this.additionalParmNames[i]+"="+
encodeURIComponent(this.additionalParmValues[i]);}
else
{queryString+="&"+this.additionalParmNames[i]+"="+
encodeURIComponent(this.additionalParmValues[i]);}}}
try{var loader=this;this.req.onreadystatechange=function(){loader.onReadyState.call(loader);}
if(this.getExternalLink==false)
{this.req.open(this.sendMethod,this.url,this.asynchron);this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");if(this.headerNames&&this.headerValues&&this.headerNames.length==this.headerValues.length)
{for(var i=0;i<this.headerNames.length;i++)
{this.req.setRequestHeader(this.headerNames[i],this.headerValues[i]);}}
this.req.send(queryString);}
else if(this.getExternalLink==true&&this.sendMethod=="GET")
{this.url+="?"+queryString;this.req.open(this.sendMethod,this.url,this.asynchron);this.req.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");if(this.headerNames&&this.headerValues&&this.headerNames.length==this.headerValues.length)
{for(var i=0;i<this.headerNames.length;i++)
{this.req.setRequestHeader(this.headerNames[i],this.headerValues[i]);}}
this.req.send(null);}}catch(err){this.onerror.call(this);}}},onReadyState:function(){var req=this.req;var ready=req.readyState;if(ready==ajaxFactory.READY_STATE_COMPLETE){var httpStatus=req.status;if(httpStatus==200||httpStatus==0){this.onload.call(this);}else{this.onerror.call(this);}}
else
{if(this.onwait!=null)
{this.onwait.call(this);}}},defaultError:function(){var errMsg="Error on request to url: "+this.url;alert(errMsg);},defaultLoad:function(){if(this.displayArea)
{var hotspot=document.getElementById(this.displayArea);if(!hotspot)
{hotspot=document.createElement("div");hotspot.id="displayArea";document.body.appendChild(hotspot);}
if(hotspot)
{hotspot.innerHTML=this.req.responseText;if(this.postEventFunc!=null)
{this.postEventFunc.call(this);}}}
else
{alert("Data loaded: "+"\n\nreadyState:"+this.req.readyState+"\nstatus: "+this.req.status+"\nheaders: "+this.req.getAllResponseHeaders()+
this.req.responseText);}}}
function _buildURL(WAM,WebRoutine,techServ,actionRequest,partition,language,optProtocol,optSessionKey,optDebugMode)
{var url="";if(optProtocol!=null&&optProtocol.length>0)
{url+=optProtocol;if(optProtocol.search(new RegExp("//","g"))<0)
{url+="//"+window.location.host;}}
url+=actionRequest+"?webapp=";url+=WAM;url+="+webrtn=";url+=WebRoutine;url+="+ml="+techServ;url+="+partition="+partition+"+language="+language;if(optDebugMode!=null&&optDebugMode.length>0)
{url+="+debug="+optDebugMode;}
if(optSessionKey!=null)
{url+="+sid="+optSessionKey;}
return url;}
function __convertXML__(strXML)
{var _xmlDoc_=null;if(window.ActiveXObject)
{_xmlDoc_=new ActiveXObject("Microsoft.XMLDOM");_xmlDoc_.async=false;_xmlDoc_.loadXML(strXML);}
else
{var dp=new DOMParser();_xmlDoc_=dp.parseFromString(strXML,"text/xml");}
return _xmlDoc_;}
function __XSLTransform__(_xslDoc_,_xmlDoc_)
{var result="";if(_xslDoc_&&_xmlDoc_)
{if(window.ActiveXObject)
{result=_xmlDoc_.transformNode(_xslDoc_);}
else if(document.implementation&&document.implementation.createDocument)
{var xsltProcessor=new XSLTProcessor();xsltProcessor.importStylesheet(_xslDoc_);result=xsltProcessor.transformToFragment(_xmlDoc_,document);}
else
{alert('Your browser does not support client-side XSL transformations.');}
return result;}}
function __DynamicXSLTransform__(_xslDoc_,_xmlDoc_,_ParmNames_,_ParmValues_)
{var result="";if(_xslDoc_&&_xmlDoc_)
{if(window.ActiveXObject)
{var xslDoc=new ActiveXObject("MSXML2.FreeThreadedDOMDocument");xslDoc.load(_xslDoc_);var xslTemplate=new ActiveXObject("MSXML2.XSLTemplate");xslTemplate.stylesheet=xslDoc;var xslProc=xslTemplate.createProcessor();xslProc.input=_xmlDoc_;if(_ParmNames_&&_ParmValues_&&_ParmNames_.length==_ParmValues_.length)
{for(var i=0;i<_ParmNames_.length;i++){xslProc.addParameter(_ParmNames_[i],_ParmValues_[i]);}}
xslProc.transform();result=xslProc.output;}
else if(document.implementation&&document.implementation.createDocument)
{var xsltProcessor=new XSLTProcessor();xsltProcessor.importStylesheet(_xslDoc_);if(_ParmNames_&&_ParmValues_&&_ParmNames_.length==_ParmValues_.length)
{for(var i=0;i<_ParmNames_.length;i++){xsltProcessor.setParameter(null,_ParmNames_[i],_ParmValues_[i]);}}
result=xsltProcessor.transformToFragment(_xmlDoc_,document);}
else
{alert('Your browser does not support client-side XSL transformations.');}
return result;}}
