mesa.Ajax={};mesa.Ajax.type={NONE:null,EDIT:"edit",LOAD:"load"};mesa.Ajax.cachePolicy={NO:0,SHORT:5,HOUR:60,DAY:1440,YEAR:525600};mesa.Ajax.crossDomainCallback={};mesa.Ajax.crossDomainCallbackIndex=0;mesa.Ajax.Request=function(url,param,successCallback,failCallback){var thisReq=this;var crossDomain=(location.href.indexOf(pageContext.basePath)!=0);var xmlHttpRequest;var scriptNode;var success,errorCode,returnValue,errorMessage;if(!param){param={}}var sentCount=0;function xmlHttpRequestLoad(){if(xmlHttpRequest.readyState==4&&xmlHttpRequest.status==200){handleResult(eval("("+xmlHttpRequest.responseText+")"))}}function handleResult(result){success=result.success;errorCode=result.errorCode;returnValue=result.result;errorMessage=result.errorMessage;if(result.success&&successCallback){successCallback(result.result)}else{if(!result.success&&failCallback){failCallback(result.errorMessage)}}}this.setParameter=function(_param){param=_param};this.send=function(){if(crossDomain){scriptNode=document.createElement("script")}else{if(window.XMLHttpRequest){xmlHttpRequest=new XMLHttpRequest()}else{if(window.ActiveXObject){xmlHttpRequest=new ActiveXObject("Microsoft.XMLHTTP")}}if(mesa.WebUtils.isFF()){xmlHttpRequest.onload=xmlHttpRequestLoad}else{xmlHttpRequest.onreadystatechange=xmlHttpRequestLoad}}if(crossDomain){param.callbackName="mesa.Ajax.crossDomainCallback._"+mesa.Ajax.crossDomainCallbackIndex;mesa.Ajax.crossDomainCallback["_"+mesa.Ajax.crossDomainCallbackIndex]=function(result){handleResult(result);document.getElementsByTagName("head")[0].removeChild(scriptNode)};mesa.Ajax.crossDomainCallbackIndex++}if(url.indexOf("/")!=0&&url.indexOf("http")!=0){url=pageContext.basePath+url}var paramStr=$H(param).toQueryString();if(crossDomain){if(paramStr.length>1900){alert("Unable to call crossdomain Ajax because of parameter length")}else{scriptNode.setAttribute("type","text/javascript");scriptNode.setAttribute("src",url+"?"+paramStr);document.getElementsByTagName("head")[0].appendChild(scriptNode)}}else{if(paramStr.length>1900){xmlHttpRequest.open("POST",url,true);xmlHttpRequest.setRequestHeader("Content-type","application/x-www-form-urlencoded");xmlHttpRequest.setRequestHeader("Content-length",paramStr.length);xmlHttpRequest.send(paramStr)}else{xmlHttpRequest.open("GET",url+(paramStr.length>0?"?"+paramStr:""),true);xmlHttpRequest.setRequestHeader("If-Modified-Since","0");xmlHttpRequest.send(null)}}sentCount++};this.getSuccess=function(){return success};this.getErrorCode=function(){return errorCode};this.getResult=function(){return returnValue};this.getErrorMessage=function(){return errorMessage};this.getType=function(){return type};this.getUrl=function(){return url};this.getParam=function(){return param}};mesa.Ajax.inlineType={SINGLELINE:"singleLine",MULTILINE:"multiLine",SELECT:"select"};mesa.Ajax.InlineEditor=function(e,f,g,c,r){if(g==null){g=""}if(typeof(g)=="number"){g=""+g}if(typeof(g)=="string"){g=g.strip()}var o=g;var b,q,j;var l,d,n;function p(t,s,v){l="view";d=t;n=v?v:{};b=(typeof(s)=="string"?$(s):s);b.innerHTML="";if(n.title){b.title=n.title}if(!b.title){b.title="Click to edit"}b.onmouseover=function(){b.style.backgroundColor="#DDDDFF"};b.onmouseout=function(){b.style.backgroundColor=""};b.onclick=function(){if(l=="view"){h()}};q=document.createElement("span");b.appendChild(q);if(d==mesa.Ajax.inlineType.SINGLELINE||d==mesa.Ajax.inlineType.MULTILINE){a(o)}else{if(d==mesa.Ajax.inlineType.SELECT){var w=false;for(var u=0;u<n.options.length&&n.options[u];++u){if(n.options[u].value==o){a(n.options[u].text);w=true;break}}if(!w){a()}}}}function a(u){if(u&&u.length>0){var s=u.escapeHTML();if(n.maxDisplayChars&&s.length>n.maxDisplayChars){s=s.truncate(n.maxDisplayChars)}q.innerHTML=mesa.WebUtils.nl2br(s);q.style.color=""}else{q.innerHTML=b.title.escapeHTML();q.style.color="#ccc"}}function k(u){var s={};for(var t in f){if(typeof(f[t])!="function"){s[t]=f[t];if(s[t]==null){s[t]=u}}}return s}function m(){if(d==mesa.Ajax.inlineType.SINGLELINE){j=document.createElement("input");j.type="text";j.style.border="thin solid #cccccc";j.value=o?o:"";if(n.maxChars){j.maxLength=n.maxChars}if(n.onchangeListener){j.onchange=j.onkeyup=function(){n.onchangeListener(j.value)}}b.appendChild(j);if(n.autoCompleter){n.autoCompleter.getSetting().text=o;n.autoCompleter.getSetting().valueSelected=function(u,t){new mesa.Ajax.Request(e,k(t),function(v){i();o=t;a(u);if(c){c(v)}},function(v){i();if(r){r(v)}},mesa.Ajax.type.EDIT,mesa.Ajax.cachePolicy.NO).send()};n.autoCompleter.init(j)}else{j.onkeydown=function(t){t=t||window.event;if(t.keyCode==13){j.blur()}}}}else{if(d==mesa.Ajax.inlineType.MULTILINE){j=document.createElement("textarea");j.value=o?o:"";j.onchange=j.onkeyup=function(){if(n.maxChars){if(j.value.length>n.maxChars){j.value=j.value.substring(0,n.maxChars)}}if(n.onchangeListener){n.onchangeListener(j.value)}};b.appendChild(j)}else{if(d==mesa.Ajax.inlineType.SELECT){j=document.createElement("select");for(var s=0;s<n.options.length&&n.options[s];++s){j.options[s]=new Option(n.options[s].text,n.options[s].value);if(j.options[s].value==o){j.selectedIndex=s}}j.onchange=function(){j.blur()};b.appendChild(j)}}}if(n.width){j.style.width=(typeof(n.width)=="number"?n.width+"px":n.width)}j.onblur=function(){if(l=="edit"){if(n.autoCompleter){return}var t=j.value.strip();if(n.valueFixer){t=n.valueFixer(t)}if(t!=o){if(t==""&&n.noEmpty){mesa.Popup.alert("This field cannot be empty",3000)}else{if(n.maxChars&&t.length>n.maxChars){mesa.Popup.alert("You have inputted "+t.length+" characters. This field allows only "+n.maxChars+" characters. ",3000)}else{if(n.validityChecker&&!n.validityChecker(t)){}else{new mesa.Ajax.Request(e,k(t),function(u){i();if(d==mesa.Ajax.inlineType.SELECT){o=t;a(j.options[j.selectedIndex].text)}else{o=t;a(o);j.value=o}if(c){c(u)}},function(u){try{j.value=o}catch(v){}i();if(r){r(u)}},mesa.Ajax.type.EDIT,mesa.Ajax.cachePolicy.NO).send()}}}}else{i()}}}}function i(){l="view";q.style.display="inline";j.style.display="none";b.onmouseover=function(){b.style.backgroundColor="#DDDDFF"};b.onmouseout=function(){b.style.backgroundColor=""};if(n.onFinishEditingListener){n.onFinishEditingListener()}}function h(){l="edit";q.style.display="none";if(!j){m()}j.style.display="inline";j.focus();try{if(j.select){j.select()}}catch(s){}b.style.backgroundColor="";b.onmouseover=b.onmouseout=null;if(n.onStartEditingListener){n.onStartEditingListener()}}this.getValue=function(){return o};this.initSingleLine=function(t,s){p(mesa.Ajax.inlineType.SINGLELINE,t,s);return this};this.initMultiLine=function(t,s){p(mesa.Ajax.inlineType.MULTILINE,t,s);return this};this.initSelect=function(t,s){p(mesa.Ajax.inlineType.SELECT,t,s);return this};this.initCheck=function(u,t){if(!t){t={}}b=(typeof(u)=="string"?$(u):u);b.innerHTML="";if(t.title){b.title=t.title}if(!b.title){b.title="Click to edit"}j=document.createElement("input");j.type="checkbox";b.appendChild(j);var s=document.createElement("span");s.innerHTML=t.title;b.appendChild(s);j.checked=o;j.onclick=function(){var x=j.checked;var v={};for(var w in f){if(typeof(f[w])!="function"){v[w]=f[w];if(v[w]==null){v[w]=x}}}new mesa.Ajax.Request(e,v,function(y){o=x;if(c){c(y)}},function(y){j.checked=o;if(r){r(y)}},mesa.Ajax.type.EDIT,mesa.Ajax.cachePolicy.NO).send()};return this}};