
var BINARY_FILE_TYPES=["gif","jpg","mp3"];var Form={serialize:function(form)
{var elements=Form.getElements($(form));var queryComponents=new Array();for(var i=0;i<elements.length;i++)
{var queryComponent=Form.Element.serialize(elements[i]);if(queryComponent)
queryComponents.push(queryComponent);}
var retVal=queryComponents.join("&");return retVal;},getElements:function(form)
{var form=$(form);var elements=new Array();for(tagName in Form.Element.Serializers)
{var tagElements=form.getElementsByTagName(tagName);for(var j=0;j<tagElements.length;j++)
elements.push(tagElements[j]);}
return elements;},getInputs:function(form,typeName,name)
{var form=$(form);var inputs=form.getElementsByTagName("input");if(!typeName&&!name)return inputs;var matchingInputs=new Array();for(var i=0;i<inputs.length;i++)
{var input=inputs[i];if((typeName&&input.type!=typeName)||(name&&input.name!=name))
continue;matchingInputs.push(input);}
return matchingInputs;},disable:function(form)
{var elements=Form.getElements(form);for(var i=0;i<elements.length;i++)
{var element=elements[i];element.blur();element.disabled="true";}},enable:function(form)
{var elements=Form.getElements(form);for(var i=0;i<elements.length;i++)
{var element=elements[i];element.disabled="";}},focusFirstElement:function(form)
{var form=$(form);var elements=Form.getElements(form);for(var i=0;i<elements.length;i++)
{var element=elements[i];if(element.type!="hidden"&&!element.disabled)
{Field.activate(element);break;}}},reset:function(form)
{$(form).reset();}}
Form.Element={serialize:function(element)
{var element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter)
return encodeURIComponent(parameter[0])+'='+encodeURIComponent(parameter[1]);},getValue:function(element)
{var element=$(element);var method=element.tagName.toLowerCase();var parameter=Form.Element.Serializers[method](element);if(parameter)
return parameter[1];}}
Form.Element.Serializers={input:function(element)
{switch(element.type.toLowerCase())
{case"submit":case"hidden":case"password":case"text":return Form.Element.Serializers.textarea(element);case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(element);}
return false;},inputSelector:function(element)
{if(element.checked)
return[element.name,element.value];},textarea:function(element)
{return[element.name,element.value];},select:function(element)
{var value="";if(element.type=="select-one")
{var index=element.selectedIndex;if(index>=0)
value=element.options[index].value||element.options[index].text;}
else
{value=new Array();for(var i=0;i<element.length;i++)
{var opt=element.options[i];if(opt.selected)
value.push(opt.value||opt.text);}}
return[element.name,value];}}
function AjaxLibrary()
{this.LOADING_IMG_ALT="Loading...";this.LOADING_IMG_CLASS="loadingImg";this.LOADING_IMG_URL="/img/loading.gif";this.MAX_HISTORY_SIZE=25;this.ReadyState={UNINITIALIZED:0,LOADING:1,LOADED:2,INTERACTIVE:3,COMPLETE:4};this.Status={OK:200,CREATED:201,ACCEPTED:202,NO_CONTENT:204,BAD_REQUEST:400,FORBIDDEN:403,NOT_FOUND:404,GONE:410,SERVER_ERROR:500};this.callback=function(){};this.callbackScope=null;this.cbArgs=[];this.postContent="";this.queue=[];this.requestHistory=[];this.sequentialQueue=[];this.init();}
var alprot=AjaxLibrary.prototype;alprot.addHistoryEntry=function(szURL)
{this.requestHistory.push(szURL);if(this.requestHistory.length>this.MAX_HISTORY_SIZE)
{var dumpHist=this.requestHistory.shift();}}
alprot.getHttpRequestObj=function()
{if(window.XMLHttpRequest)
{try{return new XMLHttpRequest();}
catch(e2){}}
else
{try{return new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){}
try{return new ActiveXObject("Microsoft.XMLHTTP");}
catch(e){}}};alprot.getResponseText=function()
{return this.xmlHttp.responseText;}
alprot.init=function()
{this.xmlHttp=this.getHttpRequestObj();};alprot.removeRequest=function(rRequest,isSequential)
{var rQueue=(isSequential)?this.sequentialQueue:this.queue;for(var r=0;r<rQueue.length;r++)
{if(rQueue[r]==rRequest)rQueue.splice(r,1);}};alprot.requestHistoryAlert=function()
{var alertString="Request History:\n";for(var a=0;a<this.requestHistory.length;a++)
{alertString+=(a+" | "+this.requestHistory[a]+"\n");}
alert(alertString);};alprot.open=function(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,pCallbackScope,isSequential)
{this.addHistoryEntry("URL: "+szURL);if(isSequential)
{var rRequest1=new SequentialRequest(this,szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,this.queue.length,pCallbackScope);this.sequentialQueue.push(rRequest1);return rRequest1;}
else
{var rRequest2=new ConcurrentRequest(this,szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,this.queue.length,pCallbackScope);this.queue.push(rRequest2);return rRequest2;}};alprot.openInsert=function(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,pInsertElem,szMode,noLoadingImg,pCallbackScope,isSequential){var rRequest=this.open(szMethod,szURL,ajax_insertCallback,[pInsertElem,szMode,pCallback,callbackArguments,pCallbackScope],szPostContent,forceRefresh,pCallbackScope,isSequential);rRequest.send();};alprot.openReplace=function(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,szReplaceElem,noLoadingImg,pCallbackScope,isSequential){var callArgsArray=[szReplaceElem,pCallback,callbackArguments,pCallbackScope];if(!noLoadingImg)this.showLoading(szReplaceElem);var rRequest=this.open(szMethod,szURL,ajax_replaceCallback,callArgsArray,szPostContent,forceRefresh,pCallbackScope,isSequential);rRequest.send();};alprot.postFieldsAndReplace=function(pFieldArray,szURL,pCallback,callbackArguments,forceRefresh,szReplaceElem,pCallbackScope,isSequential){var postContent="";for(var a=0;a<pFieldArray.length;a++)
{postContent+=Form.Element.serialize(pFieldArray[a])+"&";}
this.openReplace("POST",szURL,pCallback,callbackArguments,postContent,forceRefresh,szReplaceElem,null,pCallbackScope,isSequential);};alprot.showLoading=function(szElemId,appendMode){var pElem=$(szElemId);if(pElem!=null)
{if(appendMode)
{var pImg=window.document.createElement("img");pImg.setAttribute("src",window.GETPAGEURL+this.LOADING_IMG_URL);pImg.setAttribute("alt",this.LOADING_IMG_ALT);pImg.setAttribute("class",this.LOADING_IMG_CLASS);pElem.appendChild(pImg);}
else
{pElem.innerHTML="<img src=\""+window.GETPAGEURL+this.LOADING_IMG_URL+"\" alt=\""+this.LOADING_IMG_ALT+"\" class=\""+this.LOADING_IMG_CLASS+"\" />";}}};alprot.submitForm=function(szFormName,pCallbackFn,szFormAction,szMethod,callbackArgs,pCallbackScope,isSequential){if($(szFormName)!=null)
{var callback=(pCallbackFn==null)?function(){}:pCallbackFn;var formAction=(szFormAction==null)?$(szFormName).action:szFormAction;var serialized=($(szFormName))?Form.serialize(szFormName):"";var tempMethod=(szMethod==null)?"post":szMethod;var rRequest=this.open(tempMethod,formAction,callback,callbackArgs,serialized,null,pCallbackScope,isSequential);rRequest.send();}};var ajax2=new AjaxLibrary();function ConcurrentRequest(rAjaxLibrary,szMethod,sURL,fCallback,callbackArgs,szPostContent,bForceRefresh,nQueueIndex,pCallbackScope)
{this.ajaxLibrary=rAjaxLibrary;this.callbacks=new Array();this.forceRefresh=bForceRefresh;this.method="post";this.postContent=(szPostContent!=null)?szPostContent:"";;this.queueIndex=nQueueIndex;this.url=(sURL!=null)?((sURL.indexOf("?")!=-1)?sURL+"&ajax=true":sURL+"?ajax=true"):"";var oPostObj=scrapeGetParams(this.url);this.url=oPostObj.url;this.postContent+=oPostObj.postBody;this.isBinaryFile=BINARY_FILE_TYPES.contains(getURLFileExtension(this.url));if(fCallback!=null)
{this.addCallback(fCallback,pCallbackScope,callbackArgs);}
this.xmlHttp=this.ajaxLibrary.getHttpRequestObj();this.responseText="";}
var crprot=ConcurrentRequest.prototype;crprot.addCallback=function(fCallback,rScope,argsArray){if(fCallback!=null)
{this.callbacks.push({fn:fCallback,scope:rScope,args:argsArray});}};crprot.runCallbacks=function()
{for(var b=0;b<this.callbacks.length;b++)
{var pCallScope=(this.callbacks[b].scope==null)?window:this.callbacks[b].scope;this.callbacks[b].fn.apply(pCallScope,this.callbacks[b].args);}};crprot.send=function(){var that=this;if(this.url.indexOf("&refresh=")==-1&&(this.forceRefresh=="true"||this.forceRefresh))
{var forceString="&refresh="+Math.round(Math.random()*10000000);if(this.url.indexOf("?")==-1)forceString="?"+forceString;this.url+=forceString;}
for(var a=0;a<this.callbacks.length;a++)
{if(typeof this.callbacks[a].args=='undefined'||this.callbacks[a].args==null)
{this.callbacks[a].args=new Array();this.callbacks[a].args.push(this);}
else
{this.callbacks[a].args.unshift(this);}}
this.xmlHttp.open(this.method,this.url,true);this.xmlHttp.onreadystatechange=function()
{if(that.xmlHttp.readyState==that.ajaxLibrary.ReadyState.COMPLETE)
{if(!that.isBinaryFile)
{that.responseText=that.xmlHttp.responseText;}that.runCallbacks();that.xmlHttp=null;that.ajaxLibrary.removeRequest(that);}}
if(this.method=="post"||this.method=="POST")
{this.xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");}
this.xmlHttp.send(this.postContent);};function HttpRequest(rAjax2)
{this.ajax2=rAjax2;this.queue=ajax2.sequentialQueue;this.requestHistory=ajax2.requestHistory;this.xmlHttp=null;}
var htprot=HttpRequest.prototype;htprot.addHistoryEntry=function(sURL){this.ajax2.addHistoryEntry(sURL);}
htprot.getHttpRequestObj=function(){return this.ajax2.getHttpRequestObj();};htprot.getResponseText=function(){return this.ajax2.getResponseText;}
htprot.requestHistoryAlert=function(){this.ajax2.requestHistoryAlert();};htprot.open=function(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,pCallbackScope)
{return this.ajax2.open(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,pCallbackScope,true);};htprot.openInsert=function(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,pInsertElem,szMode,noLoadingImg,pCallbackScope)
{this.ajax2.openInsert(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,pInsertElem,szMode,noLoadingImg,pCallbackScope,true);};htprot.openReplace=function(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,szReplaceElem,noLoadingImg,pCallbackScope)
{this.ajax2.openReplace(szMethod,szURL,pCallback,callbackArguments,szPostContent,forceRefresh,szReplaceElem,noLoadingImg,pCallbackScope,true);};htprot.postFieldsAndReplace=function(pFieldArray,szURL,pCallback,callbackArguments,forceRefresh,szReplaceElem,pCallbackScope)
{this.ajax2.postFieldsAndReplace(pFieldArray,szURL,pCallback,callbackArguments,forceRefresh,szReplaceElem,pCallbackScope,true)};htprot.showLoading=function(szElemId,appendMode){this.ajax2.showLoading(szElemId,appendMode);};htprot.submitForm=function(szFormName,pCallbackFn,szFormAction,szMethod,callbackArgs,pCallbackScope)
{this.ajax2.submitForm(szFormName,pCallbackFn,szFormAction,szMethod,callbackArgs,pCallbackScope,true);};var httpRequest=new HttpRequest(ajax2);var ajax=httpRequest;function SequentialRequest(rAjaxLibrary,szMethod,sURL,fCallback,callbackArgs,szPostContent,bForceRefresh,nQueueIndex,pCallbackScope)
{this.ajaxLibrary=rAjaxLibrary;this.callbacks=new Array();this.forceRefresh=bForceRefresh;this.method="post";this.postContent=(szPostContent!=null)?szPostContent:"";this.queueIndex=nQueueIndex;this.url=(sURL!=null)?((sURL.indexOf("?")!=-1)?sURL+"&ajax=true":sURL+"?ajax=true"):"";var oPostObj=scrapeGetParams(this.url);this.url=oPostObj.url;this.postContent+=oPostObj.postBody;this.isBinaryFile=BINARY_FILE_TYPES.contains(getURLFileExtension(this.url));if(fCallback!=null)
{this.addCallback(fCallback,pCallbackScope,callbackArgs);}
this.xmlHttp=this.ajaxLibrary.getHttpRequestObj();ajax.xmlHttp=this.xmlHttp;this.responseText="";}
var seqprot=SequentialRequest.prototype;seqprot.addCallback=function(fCallback,rScope,argsArray){if(fCallback!=null)
{this.callbacks.push({fn:fCallback,scope:rScope,args:argsArray});}};seqprot.runCallbacks=function()
{for(var b=0;b<this.callbacks.length;b++)
{var pCallScope=(this.callbacks[b].scope==null)?window:this.callbacks[b].scope;this.callbacks[b].fn.apply(pCallScope,this.callbacks[b].args);}};seqprot.send=function(){var that=this;if(this.url.indexOf("&refresh=")==-1&&(this.forceRefresh=="true"||this.forceRefresh))
{var forceString="&refresh="+Math.round(Math.random()*10000000);if(this.url.indexOf("?")==-1)forceString="?"+forceString;this.url+=forceString;}
for(var a=0;a<this.callbacks.length;a++)
{if(typeof this.callbacks[a].args=='undefined'||this.callbacks[a].args==null)
{this.callbacks[a].args=new Array();this.callbacks[a].args.push(this);}
else
{if(this.callbacks[a].args[0]!=this)this.callbacks[a].args.unshift(this);}}
this.xmlHttp.open(this.method,this.url,true);this.xmlHttp.onreadystatechange=function()
{if(that.xmlHttp.readyState==that.ajaxLibrary.ReadyState.COMPLETE)
{if(!that.isBinaryFile)
{that.responseText=that.xmlHttp.responseText;}
that.runCallbacks();that.xmlHttp=null;that.ajaxLibrary.removeRequest(that,true);if(that.ajaxLibrary.sequentialQueue.length>0)
{that.ajaxLibrary.sequentialQueue[0].send();}}}
if(this.method=="post"||this.method=="POST")
{this.xmlHttp.setRequestHeader("Content-Type","application/x-www-form-urlencoded; charset=UTF-8");}
if(this.ajaxLibrary.sequentialQueue[0]==this)this.xmlHttp.send(this.postContent);};var forceString="&refresh="+Math.round(Math.random()*10000000);var $F=Form.Element.getValue;function evalAllScripts(pElem)
{if(pElem!=null)
{var pScripts=pElem.getElementsByTagName("script");for(var a=0;a<pScripts.length;a++)
{eval(pScripts[a].innerHTML);}}}
function getAllScripts(szResponseText)
{var pattern=/(?=<script.*?>)[\w\W]*?(?=<\/script>)/gi;var results1=szResponseText.match(pattern);var szJoin=results1!=null?results1.join("\n"):"";return szJoin.replace(/<script.*?>/gi,"");}
function getURLFileExtension(sURL)
{var qMarkSplit=sURL.split("?");var dotSplit=qMarkSplit[0].split(".");return dotSplit[dotSplit.length-1];}
function loadExtScripts(szResponseText)
{var scriptURLs=new Array();var pattern=/<script\s.*?\ssrc=".*?">/gi;var results1=szResponseText.match(pattern);if(results1!=null)
{for(var a=0;a<results1.length;a++)
{var aSplit1=results1[a].split(" ");var attribs=new Array();for(var b=0;b<aSplit1.length;b++)
{if(aSplit1[b].toLowerCase().indexOf("src=")!=-1)
{attribs=aSplit1[b].split("src=");attribs=attribs[1].split("\"");scriptURLs.push(attribs[1]);}}}}
for(var s=0;s<scriptURLs.length;s++)
{dynamicLoadScript(scriptURLs[s]);}}
function scrapeGetParams(sURL)
{var ret={postBody:"",url:sURL};if(sURL.indexOf("?")!=-1)
{var splitURL=sURL.split("?");ret.url=splitURL[0];ret.postBody+=("&"+splitURL[splitURL.length-1]);}
return ret;}
function dynamicLoadScript(sURL)
{var oScript=window.document.createElement("script");oScript.type="text/javascript";oScript.src=sURL;window.document.getElementsByTagName("head")[0].appendChild(oScript);}
function ajax_insertCallback(pAjax,szInsert,szMode,fCallback,callbackArgs,pCallbackScope)
{if(pAjax&&szInsert)
{if(isIE)$(szInsert).insertAdjacentHTML(szMode,pAjax.responseText);else $(szInsert).innerHTML+=pAjax.xmlHttp.responseText;eval(getAllScripts(pAjax.xmlHttp.responseText));}
if(fCallback)
{var pCallScope=(pCallbackScope==null)?window:pCallbackScope;fCallback.apply(pCallScope,[pAjax.xmlHttp,callbackArgs]);}}
function ajax_replaceCallback(pAjax,szReplace1,fCallback,callbackArgs,pCallbackScope)
{if(pAjax&&szReplace1)
{var pCallScope=((pCallbackScope!=null)&&(typeof pCallbackScope.location!="undefined"))?pCallbackScope:window;pCallScope.$(szReplace1).innerHTML=pAjax.xmlHttp.responseText;pCallScope.eval(getAllScripts(pAjax.xmlHttp.responseText));}
if(fCallback)
{var pCallScope=(pCallbackScope==null)?window:pCallbackScope;fCallback.apply(pCallScope,[pAjax.xmlHttp,callbackArgs]);}}
