var _IS_MSIE=window.navigator&&navigator.userAgent.toLowerCase().indexOf("msie")!=-1&&navigator.userAgent.toLowerCase().indexOf("opera")==-1;var _IS_OPERA=window.navigator&&navigator.userAgent.toLowerCase().indexOf("opera")!=-1;var _IS_FIREFOX=window.navigator&&navigator.userAgent.toLowerCase().indexOf("firefox")!=-1;if(!String.prototype.trim){String.prototype.trim=function(){return this.replace(/^\s*(.*?)\s*$/,"$1")}}if(!Array.prototype.contains){Array.prototype.contains=function(b){for(var a in this){if(this[a]==b){return true}}return false}}if(!window.OM){var OM={}}if(!OM.event){OM.event={}}OM.event.listenerList=function(){this._listeners={}};OM.event.listenerList.prototype={set:function(a,b){this._listeners[a]=b},clear:function(){this._listeners.clear()},remove:function(a){delete this._listeners[a]}};OM.event.beforeSubmit=function(){};OM.event.beforeSubmit.prototype=new OM.event.listenerList();OM.event.beforeSubmit.prototype.action=function(b){for(var a in this._listeners){this._listeners[a](b)}};OM.event.afterResponse=function(){};OM.event.afterResponse.prototype=new OM.event.listenerList();OM.event.afterResponse.prototype.action=function(b){for(var a in this._listeners){this._listeners[a](b)}};OM.ajax={RENDER_ID_PARAM:"org.operamasks.faces.RenderId",getRequest:function(){if(window.XMLHttpRequest){return new XMLHttpRequest()}else{if(window.ActiveXObject){try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(a){return new ActiveXObject("Microsoft.XMLHTTP")}}}},requestParams:{},addRequestParameter:function(b,a){this.requestParams[b]=a},removeRequestParameter:function(a){delete this.requestParams[a]},addFieldParameter:function(f,e){if(!e.type){return}var d=encodeURIComponent(e.name);switch(e.type){case"checkbox":var a;if(e.checked){a=encodeURIComponent(e.value)}else{a="off"}f.push(d+"="+a);break;case"radio":if(e.checked){f.push(d+"="+encodeURIComponent(e.value))}break;case"select-multiple":for(var c=0;c<e.options.length;c++){var b=e.options[c];if(b.selected){f.push(d+"="+encodeURIComponent(b.value))}}break;case"button":case"submit":case"reset":break;case"hidden":if(e.name!="javax.faces.ViewState"){f.push(d+"="+encodeURIComponent(e.value))}break;default:f.push(d+"="+encodeURIComponent(e.value));break}},buildParameterList:function(h,c,f){var d=new Array();if(h){if(h instanceof Array){d=d.concat(h)}else{if(typeof h=="object"){for(var e in h){var i=h[e];i=(i==undefined)?"":encodeURIComponent(i);d.push(encodeURIComponent(e)+"="+i)}}}}if(c){var a=c.elements;if(a!=null){for(var b=0;b<a.length;b++){this.addFieldParameter(d,a[b])}}}else{if(f){var j=document.getElementById(f);if(typeof f=="string"&&j){this.addFieldParameter(d,j);var g=document.getElementById(f+"_value");if(g!=null&&(g.nodeName!=null&&g.nodeName.toLowerCase()=="input")&&(g.type=="hidden")){this.addFieldParameter(d,g)}}}}for(var e in this.requestParams){var i=this.requestParams[e];i=(i==undefined)?"":encodeURIComponent(i);d.push(encodeURIComponent(e)+"="+i)}return d},getParentForm:function(b){if(typeof b=="string"){b=document.getElementById(b)}var a=b;while(a&&a.nodeName.toLowerCase()!="form"){a=a.parentNode}return a},actionId:null,viewId:null,viewState:null,renderKitId:null,beforeSubmit:new OM.event.beforeSubmit(),afterResponse:new OM.event.afterResponse(),buildQuery:function(b,c,a){c=this.buildParameterList(c,b,a);if(this.viewId){c.push("javax.faces.ViewId="+encodeURIComponent(this.viewId))}if(this.viewState){c.push("javax.faces.ViewState="+this.viewState.replace(/\+/g,"%2b"))}if(this.renderKitId){c.push("javax.faces.RenderKitId="+this.renderKitId)}return c.join("&")},submit:function(a,b,h,e,i,l){var d=this.getParentForm(a);var f=null;if(d){f=d._callback;if(f&&f.inprogress){return false}if(f&&f.onsubmit&&f.onsubmit.call(d)===false){return false}if(!e&&d._validateBeforeSubmit&&!(this.validateForm(d)&this.validateGroupForms(d))){return false}if(l!=null){f.sw=l}if(!b){b=d.action}}else{if(!b){b=this.actionId}}this.beforeSubmit.action(l||a,b,h,d);if(typeof h=="object"){if(!(h instanceof Array)){var c=new Array();for(var g in h){var m=h[g];m=(m==undefined)?"":encodeURIComponent(m);c.push(encodeURIComponent(g)+"="+m)}h=c}if(typeof e!="undefined"){h.push("immediate="+e)}if(typeof i!="undefined"){h.push("sourceWidgetClientId="+i)}}var j=this.buildQuery(d,h,i);j=this.buildGroupParameterList(d,j);this.sendRequest(b,j,f);return false},clearSubmitStatus:function(c){var b=this.getParentForm(c);var a=null;if(b){a=b._callback;a.inprogress=false}},buildGroupParameterList:function(b,d){if(b&&b.groupId){for(var a=0;a<document.forms.length;a++){if(b.groupId==document.forms[a].groupId&&b!=document.forms[a]){var c=this.buildParameterList({},document.forms[a]);d+="&"+c.join("&")}}}return d},action:function(e,d,h,b,c,a,g){var f=[encodeURIComponent(h)+"="];if(typeof g=="object"&&g instanceof Array){f=f.concat(g)}if(c||c==null){window.setTimeout(function(){OM.ajax.submit(e,d,f,b,a)},50)}else{OM.ajax.submit(e,d,f,b,a)}},sendRequest:function(c,f,a){if(window.LOG){LOG.clear();LOG.debug("AJAX request ("+f.length+")",f)}if(a){if(a.onbeforerequest&&a.onbeforerequest.call(a.scope||a,a)==false){return}a.inprogress=true}var g="";var d=f.indexOf(this.RENDER_ID_PARAM);if(d!=-1){d+=this.RENDER_ID_PARAM.length+1;var b=f.indexOf("&",d);if(b==-1){b=f.length}g=f.substring(d,b)}var e=this.getRequest();e.onreadystatechange=function(){OM.ajax._onStateChange(g,e,a)};this.updateStatus(g,true);e.open("POST",c,true);e.setRequestHeader("X-Requested-By","XMLHttpRequest");e.setRequestHeader("Content-Type","application/x-www-form-urlencoded;charset=UTF-8");e.send(f)},_onStateChange:function(renderId,req,cb){if(req.readyState==4){var sw=null;if(cb&&cb.sw){sw=cb.sw}this.afterResponse.action(sw,req);if(cb&&cb.handleResponse){try{cb.handleResponse.call(cb.scope||cb,cb,req)}finally{cb.inprogress=false;req.onreadystatechange=function(){};this.updateStatus(renderId,false)}return}var success=true;try{var status=req.status;var response=req.responseText;var scriptAndServerLog=response.split("[__OM_$serverLog_$separator]");response=scriptAndServerLog[0];var serverLog=null;if(scriptAndServerLog[1]){serverLog=scriptAndServerLog[1]}if(status==200){var header=req.getResponseHeader("Content-Type");if((header||"").match(/^text\/javascript/i)){if(window.LOG){LOG.debug("AJAX response ("+response.length+")",response);LOG.debug("eval script: ",response);eval(response);if(serverLog){LOG.debug("server log: ",serverLog)}}else{eval(response)}}else{this.showPage(response)}}else{if(status==301||status==302){window.location=req.getResponseHeader("Location")}else{success=false;this.showPage(response)}}}catch(e){success=false;if(window.LOG){LOG.error(e.message)}else{throw e}}finally{req.onreadystatechange=function(){};this.updateStatus(renderId,false);if(cb){cb.inprogress=false;if(success&&cb.onsuccess){cb.onsuccess.call(cb.scope||cb,cb)}else{if(!success&&cb.onfailure){cb.onfailure.call(cb.scope||cb,cb)}}if(cb.oncomplete){cb.oncomplete.call(cb.scope||cb,cb)}}}}},showPage:function(a){window.setTimeout(function(){if(_IS_MSIE){var b=window.onerror;document.open("text/html");window.onerror=function(){return true};document.write(a);window.onerror=b;document.close();window.location.reload(false)}else{document.open("text/html");document.write(a);document.close()}},50)},initForm:function(b,c,a){if(c){c.scope=b;b._callback=c}b.nonAjaxSubmit=b.submit;b.submit=function(){return OM.ajax.submit(b)};b.onsubmit=function(){return OM.ajax.submit(b,b.action,c.params,true)};if(a){b.groupId=a}},initValidation:function(c,e,d){var a=document.forms[c]._validators;if(a){for(var b=0;b<a.length;b++){if(a[b]._id==e){a[b].srcField=d}}}},_statusTargets:new Array(),addStatusTarget:function(d,a){if(d==null){d=""}for(var b=0;b<this._statusTargets.length;b++){var c=this._statusTargets[b];if(c.renderId==d){c.observers.push(a);return}}var c=new Object();c.count=0;c.renderId=d;c.observers=[a];this._statusTargets.push(c)},updateStatus:function(c,d){for(var a=0;a<this._statusTargets.length;a++){var b=this._statusTargets[a];if(b.renderId==""||b.renderId==c){b.count+=d?1:-1;this._updateStatusTargets(b)}}},_updateStatusTargets:function(c){var b=(c.count>0)?"onstart":"onstop";for(var a=0;a<c.observers.length;a++){var d=c.observers[a];if(typeof d[b]=="function"){d[b]()}}},_loadedUris:[],isScriptLoaded:function(e){if(this._loadedUris[e]){return true}var d=document.getElementsByTagName("head")[0];var c=d.getElementsByTagName("script");for(var b=0;b<c.length;b++){var f=c[b].src;if(f){var a=f.length-e.length;if(a>=0&&f.lastIndexOf(e)==a){this._loadedUris[e]=true;return true}}}return false},loadScript:function(uri){if(this.isScriptLoaded(uri)){return}var req=this.getRequest();req.open("GET",uri,false);req.send(null);var status=req.status;if(status!=200){var err=Error("Unable to load "+uri+", status:"+status);err.status=status;err.responseText=req.responseText;throw err}else{eval(req.responseText);this._loadedUris[uri]=true;if(window.LOG){LOG.debug("Loaded "+uri)}}},isStylesheetLoaded:function(f){var d=document.getElementsByTagName("head")[0];var c=d.getElementsByTagName("link");for(var b=0;b<c.length;b++){var e=c[b];if(e.rel=="stylesheet"&&e.type=="text/css"&&e.href){var a=e.href.length-f.length;if(a>=0&&e.href.lastIndexOf(f)==a){return true}}}return false},loadStylesheet:function(c,d,a){if(this.isStylesheetLoaded(c)){return}var b=document.createElement("link");b.setAttribute("rel","stylesheet");b.setAttribute("type","text/css");b.setAttribute("href",c);if(d){b.id=d}if(a){b.className=a}document.getElementsByTagName("head")[0].appendChild(b)},_showExceptions:true,_exceptions:new Array(),_END_:0};OM.ajax.beforeSubmit.set("disableButton",function(a){if(a&&a.disable&&typeof a.allowReEnter!=="undefiend"&&a.allowReEnter===false){a.disable()}});OM.ajax.afterResponse.set("disableButton",function(a){if(a&&a.enable&&!a.allowReEnter&&typeof a.allowReEnter!=="undefiend"&&a.allowReEnter===false){a.enable()}});OM.F=function(d,c,a){var b=document.getElementById(d);if(b){b[c]=a}};OM.S=function(c,a){var b=document.getElementById(c);if(b){b.style.cssText=a}};OM.T=function(c,a){var b=document.getElementById(c);if(b){b.innerHTML=a}};OM.H=function(id,html){var el=document.getElementById(id);if(!el){return}var inspId=id+"_"+new Date().getTime();html+="<span id='"+inspId+"'></span>";var timer=null;var count=0;var loadScripts=function(){var insp=document.getElementById(inspId);if(!insp){if(++count>10){if(timer){window.clearInterval(timer)}}return}insp.parentNode.removeChild(insp);if(timer){window.clearInterval(timer)}var re=/(?:<script(?:[^>]*)?>)(?:((\n|\r)*?)<!--)?((\n|\r|.)*?)(?:<\/script>)/img;var m;while(m=re.exec(html)){var s=m[3];if(s&&s.length>0){if(window.LOG){LOG.debug("eval script",s)}try{eval(s)}catch(e){if(window.LOG){LOG.error(e.message)}}}}};el.innerHTML=html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img,"");if(document.getElementById(inspId)){loadScripts()}else{timer=window.setInterval(loadScripts,500)}};OM.O=function(id,html){var el=document.getElementById(id);if(!el){return}var inspId=id+"_"+new Date().getTime();html+="<span id='"+inspId+"'></span>";var timer=null;var count=0;var loadScripts=function(){var insp=document.getElementById(inspId);if(!insp){if(++count>10){if(timer){window.clearInterval(timer)}}return}insp.parentNode.removeChild(insp);if(timer){window.clearInterval(timer)}var re=/(?:<script(?:[^>]*)?>)(?:((\n|\r)*?)<!--)?((\n|\r|.)*?)(?:<\/script>)/img;var m;while(m=re.exec(html)){var s=m[3];if(s&&s.length>0){if(window.LOG){LOG.debug("eval script",s)}try{eval(s)}catch(e){if(window.LOG){LOG.error(e.message)}}}}};if(_IS_MSIE){el.outerHTML=html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img,"")}else{var r=el.ownerDocument.createRange();r.setStartBefore(el);var df=r.createContextualFragment(html.replace(/(?:<script.*?>)((\n|\r|.)*?)(?:<\/script>)/img,""));el.parentNode.replaceChild(df,el)}if(document.getElementById(inspId)){loadScripts()}else{timer=window.setInterval(loadScripts,500)}};OM.SEL=function(e,a){var c=document.getElementById(e);if(c){c=c.firstChild}if(c&&c.options){var d=c.options;for(var b=0;b<d.length;b++){d[b].selected=false}for(var b=0;b<a.length;b++){d[a[b]].selected=true}}};OM.E=function(a){try{a()}catch(b){OM.ajax._exceptions[OM.ajax._exceptions.length]=b}};OM.L=function(){if(OM.ajax._exceptions.length==0||!OM.ajax._showExceptions){OM.ajax._exceptions=new Array();return}var a=document.createElement("div");a.className="x-errzone";a.id="x-errzone";document.body.appendChild(a);var b="<div class='x-err-close' onclick='OM.L.close()'></div><p class='x-errzone-title'>Exceptions occurred when executing javascript:</p>";for(idx in OM.ajax._exceptions){var c=OM.ajax._exceptions[idx];if(!(c instanceof Error)){continue}b+="<div class='x-err-item x-err-item-";b+=(idx%2==0)?"even":"odd";b+="'>";for(pro in c){if(pro=="stack"){c[pro]="<ul><li>"+c[pro].replace(/@/g,"</li><li>@")+"</li></ul>"}b+="<span class='x-err-"+pro+"'><label>"+pro+":</label>"+c[pro]+"</span>"}b+="</div>"}a.innerHTML=b;OM.ajax._exceptions=new Array()};OM.L.close=function(){document.getElementById("x-errzone").style.display="none"};OM.execClientScript=function(script,clientWindowHandle){if(!clientWindowHandle){clientWindowHandle=window}clientWindowHandle.eval(script)};OM.ajax.Updater=function(b,c,a){this.loaded=a;this.update=function(d){if(!(d&&this.loaded)){OM.ajax.submit(null,b,[OM.ajax.RENDER_ID_PARAM+"="+c],true);this.loaded=true}}};OM.ajax.Timer=function(e,c,b,d){this.id=e;this.url=c;this.delay=b;this.period=d;this.form=null;this.params=new Array();this.ontimeout=null;var a=this;this._callback=function(){a._onTimerEvent()}};OM.ajax.Timer.prototype={scheduled:false,cancelled:false,requested:false,addParameter:function(a,b){this.params.push(encodeURIComponent(a)+"="+encodeURIComponent(b))},schedule:function(){if(!this.scheduled&&!this.requested){this.cancelled=false;this.scheduled=true;window.setTimeout(this._callback,this.delay)}},cancel:function(){this.cancelled=true},_onTimerEvent:function(){this.scheduled=false;if(!this.cancelled){if(typeof this.ontimeout=="function"){this.cancelled=(this.ontimeout()==false)}if(!this.cancelled&&this.period>0){this.requested=true;this._sendRequest()}}},_sendRequest:function(){var b=new Array();b.push(encodeURIComponent(this.id)+"=");b=b.concat(this.params);var a=OM.ajax.buildQuery(this.form,b);OM.ajax.sendRequest(this.url,a,{scope:this,oncomplete:this._onComplete})},_onComplete:function(){this.requested=false;if(!this.cancelled&&this.period>0){this.scheduled=true;window.setTimeout(this._callback,this.period)}}};OM.ajax.Progress=function(c,b,a){this.id=c;this.url=b;this.interval=a||1000;this.params=new Array();this.state="stopped";this.phase=0;this.percentage=0;this.message=null;this._timer=null};OM.ajax.Progress.prototype.addParameter=function(a,b){this.params.push(encodeURIComponent(a)+"="+encodeURIComponent(b))};OM.ajax.Progress.prototype.setAutoStart=function(){var a=this;var b=function(){window.setTimeout(function(){a.start()},100)};if(window.addEventListener){window.addEventListener("load",b,false)}else{if(window.attachEvent){window.attachEvent("onload",b)}}};OM.ajax.Progress.prototype.isRunning=function(){return this.state=="running"};OM.ajax.Progress.prototype.isStopped=function(){return this.state=="stopped"};OM.ajax.Progress.prototype.isPaused=function(){return this.state=="paused"};OM.ajax.Progress.prototype.isCompleted=function(){return this.state=="completed"};OM.ajax.Progress.prototype.isFailed=function(){return this.state=="failed"};OM.ajax.Progress.prototype.start=function(){if(!this.isRunning()){this._sendRequest("start")}};OM.ajax.Progress.prototype.stop=function(){if(this.isRunning()||this.isPaused()){this._sendRequest("stop")}};OM.ajax.Progress.prototype.pause=function(){if(this.isRunning()){this._sendRequest("pause")}};OM.ajax.Progress.prototype.resume=function(){if(this.isPaused()){this._sendRequest("resume")}};OM.ajax.Progress.prototype.poll=function(){if(this.isRunning()){this._sendRequest("poll")}};OM.ajax.Progress.prototype._sendRequest=function(b){if(this._timer!=null){window.clearTimeout(this._timer)}var c=new Array();c.push(encodeURIComponent(this.id)+"="+b);c=c.concat(this.params);var a=OM.ajax.buildQuery(null,c);OM.ajax.sendRequest(this.url,a,null)};OM.ajax.Progress.prototype._handleResponse=function(b){this.state=b.state;this.phase=b.phase;this.percentage=b.percentage;this.message=b.message;if(typeof this.onstatechange=="function"){this.onstatechange()}if(this.isRunning()){var a=this;this._timer=window.setTimeout(function(){a.poll()},this.interval)}};OM.ajax.validateForm=function(e){var g=e._clientValidateFieldIds;if(!g){return true}for(var h=0;h<g.length;h++){var b=Ext.getCmp(g[h]);b.clearInvalid()}var a=true;var c=null;for(var h=0;h<g.length;h++){var b=Ext.getCmp(g[h]);var d=b.validate();if(d===false){a=false;if(c==null){c=b}}}if(c&&c.focus){c.focus()}return a};OM.ajax.validateGroupForms=function(c){var a=true;if(c&&c.groupId){for(var b=0;b<document.forms.length;b++){if(c.groupId==document.forms[b].groupId&&c!=document.forms[b]){a=this.validateForm(document.forms[b])&&a}}}return a};Validator=function(a){this._message=a};Validator.prototype._validate=function(a){return true};Validator.prototype.validate=function(a){if(this._validate(a)){return true}else{return this._message}};ClientValidator=function(b,a){this._message=b;this._validateFunc=a};ClientValidator.prototype=new Validator();ClientValidator.prototype._validate=function(b){var a=this._validateFunc.call(this,b);if(a===true){return true}if(a!==false){this._message=a}return false};IntegerValidator=function(a,b,c){this._message=a;this._minValue=b;this._maxValue=c};IntegerValidator.prototype=new Validator();IntegerValidator.prototype._validate=function(a){if(a.length==0){return true}if(!/^[-+]?\d+$/.test(a)){return false}if(this._minValue==null&&this._maxValue==null){return true}var b=parseInt(a);if(isNaN(b)){return false}if(this._minValue!=null&&b<this._minValue){return false}if(this._maxValue!=null&&b>this._maxValue){return false}return true};FloatValidator=function(a,b,c){this._message=a;this._minValue=b;this._maxValue=c};FloatValidator.prototype=new Validator();FloatValidator.prototype._validate=function(a){if(a.length==0){return true}if(!/^[-+]?(\d+|\d+\.\d*|\d*\.\d+)([eE][-+]?\d+)?$/.test(a)){return false}if(this._minValue==null&&this._maxValue==null){return true}var b=parseFloat(a);if(isNaN(b)){return false}if(this._minValue!=null&&b<this._minValue){return false}if(this._maxValue!=null&&b>this._maxValue){return false}return true};RequiredValidator=function(b,a){this._message=b;this._trim=a};RequiredValidator.prototype=new Validator();RequiredValidator.prototype._validate=function(a){if(this._trim){a=a.trim()}return a.length>0};LengthValidator=function(a,b,c){this._message=a;this._minimum=b;this._maximum=c};LengthValidator.prototype=new Validator();LengthValidator.prototype._validate=function(a){if(a.length==0){return true}if(this._minimum!=null&&a.length<this._minimum){return false}if(this._maximum!=null&&a.length>this._maximum){return false}return true};RegexpValidator=function(a,b){this._message=a;this._pattern=new RegExp(b)};RegexpValidator.prototype=new Validator();RegexpValidator.prototype._validate=function(a){return a.length==0||this._pattern.test(a)};DateValidator=function(a,b){this._message=a;this._format=b};DateValidator.prototype=new Validator();
