var PHP2Go={baseUrl:null,locale:null,included:{},loaded:false,uidCache:[0,{}],scriptRegExpAll:new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>','img'),scriptRegExpOne:new RegExp('<script[^>]*>([\\S\\s]*?)<\/script>','im'),nativeElementExtension:!!window.HTMLElement,include:function(lib,charset){if(!this.included[lib])document.write("<script type=\"text/javascript\""+(charset?" charset=\""+charset+"\"":"")+" src=\""+lib+"\"></script>");},load:function(){if(this.loaded)return;var mt,scripts=document.getElementsByTagName('script');for(var i=0;i<scripts.length;i++){if(scripts[i].src){this.included[scripts[i].src]=true;mt=scripts[i].src.match(/(.*)php2go\.js(\?locale=([^&]+)(&date=(.*))?(&charset=(.*))?)?/);if(mt){this.baseUrl=mt[1];break;}}else{mt=[];}}if(!mt[3])PHP2Go.raiseException("PHP2Go Javascript Framework needs a locale parameter: php2go.js?locale=locale_code");this.locale=mt[3];this.include(this.baseUrl+'structures.js');this.include(this.baseUrl+'dom.js');this.include(this.baseUrl+'compat.js');this.include(this.baseUrl+'locale.php?locale='+mt[3]+(mt[4]?mt[4]:''),(mt[7]?mt[7]:null));this.loaded=true;},raiseException:function(msg,name){if(Object.isFunc(window.Error)){var e=new Error(msg);if(!e.message)e.message=msg;if(name)e.name=name;throw e;}else if(Object.isString(msg)){throw msg;}},uid:function(pfx){var c=PHP2Go.uidCache;if(pfx){c[1][pfx]=(c[1][pfx]||0)+1;return pfx+String(c[1][pfx]);}else{return String(++c[0]);}},browser:function(){var bw={},ua=navigator.userAgent.toLowerCase();bw.ie=/msie/i.test(ua)&&!/opera/i.test(ua);bw.ie7=bw.ie&&/msie 7/i.test(ua);bw.ie6=bw.ie&&/msie 6/i.test(ua);bw.ie5=bw.ie&&/msie 5\.0/i.test(ua);bw.wch=bw.ie&&!bw.ie7;bw.opera=/opera/i.test(ua);bw.khtml=/konqueror|safari|webkit|khtml/i.test(ua);bw.safari=/safari|webkit/i.test(ua);bw.mozilla=!bw.ie&&!bw.opera&&!bw.khtml&&/mozilla/i.test(ua);bw.gecko=/gecko/i.test(ua);bw.windows=bw.linux=bw.mac=bw.unix=false;bw.os=(/windows/i.test(ua)?'windows':(/linux/i.test(ua)?'linux':(/mac/i.test(ua)?'mac':(/unix/i.test(ua)?'unix':'unknown'))));(bw.os!='unknown')&&(bw[bw.os]=true);return bw;}(),compare:function(a,b,op,type){type=type||'STRING';switch(type){case'INTEGER':a=parseInt(a,10),b=parseInt(b,10);break;case'FLOAT':a=parseFloat(a,10),b=parseFloat(b,10);break;case'CURRENCY':a=parseFloat(a,10),b=parseFloat(b,10);break;case'DATE':a=Date.toDays(a),b=Date.toDays(b);break;case'STRING':a=a||'',b=b||'';break;}switch(op){case'EQ':return(a==b);case'NEQ':return(a!=b);case'LT':return(a<b);case'LOET':return(a<=b);case'GT':return(a>b);case'GOET':return(a>=b);default:return false;}},eval:function(str){if(window.execScript)window.execScript(str);else if(this.browser.safari)window.setTimeout(str,0);else eval.call(window,str);},method:function(obj,method){if(!obj._methods)obj._methods={};if(!obj._methods[method])obj._methods[method]=function(){obj[method].apply(obj,arguments);};return obj._methods[method];}};try{PHP2Go.nativeEventExtension=(typeof(Event.prototype)!='undefined');}catch(e){PHP2Go.nativeEventExtension=false;}Object.extend=function(dst,src,ov){ov=Object.ifUndef(ov,true);for(p in src){if(!ov&&p in dst)continue;dst[p]=src[p];}return dst;};Object.serialize=function(obj){if(typeof(obj)=='undefined')return;if(typeof(obj)=='function')return;if(typeof(obj)=='boolean')return obj.toString();if(obj===null)return'null';if(obj.serialize)return obj.serialize();if(obj===window||obj===document)return;var buf=[];for(var p in obj){try{if(obj[p]=='')continue;if(obj[p]&&obj[p].ownerDocument===document)continue;var v=Object.serialize(obj[p]);if(typeof(v)!='undefined')buf.push(p+":"+v);}catch(e){}}return'{'+buf.join(', ')+'}';};Object.isUndef=function(obj){return(typeof obj=='undefined');};Object.ifUndef=function(obj,def){return(typeof obj=='undefined'?def:obj);};Object.isElement=function(obj){return(obj&&obj.nodeType==1);};Object.isArray=function(obj){return(obj&&obj.constructor===Array);};Object.isIterable=function(obj){if(!obj||Object.isUndef(obj))return false;if(Object.isString(obj)||Object.isFunc(obj)||Object.isNumber(obj))return false;if(Object.isArray(obj))return true;return(!Object.isUndef(obj.length)&&isFinite(obj.length)&&(!obj.tagName||obj.tagName.equalsIgnoreCase('form')));};Object.isFunc=function(obj){return(typeof obj=='function');};Object.isString=function(obj){return(typeof obj=='string');};Object.isNumber=function(obj){return(typeof obj=='number');};Object.toPixels=function(val){if(val&&val.slice(-2)=='px')return parseFloat(val,10);return 0;};if(!Function.prototype.apply){Function.prototype.apply=function(obj,args){var argStr=[],res=null;(!obj)&&(obj=window);(!args)&&(args=[]);for(var i=0;i<args.length;i++)argStr[i]='args['+i+']';obj.__f__=this;res=eval('obj.__f__('+argStr.join(',')+')');obj.__f__=null;return res;};}Function.prototype.bind=function(obj){var self=this;return function(){return self.apply(obj,arguments);}};Function.prototype.methodize=function(fn){if(this._methodized)return this._methodized;var self=this;return this._methodized=function(bind){(fn)&&(bind=fn(bind));return(bind?self.apply(bind,Array.prototype.slice.call(arguments,1)):null);};};Function.prototype.extend=function(parent,propName){if(Object.isFunc(parent)){var f=function(){};f.prototype=parent.prototype;this.prototype=new f();this.prototype.constructor=this;this.superclass=parent.prototype;if(propName)this.prototype[propName]=parent.prototype.constructor;if(parent.prototype.constructor==Object.prototype.constructor)parent.prototype.constructor=parent;}};Function.prototype.implement=function(){for(var i=0,l=arguments.length;i<l;i++)Object.extend(this.prototype,arguments[i],false);};Function.prototype.delay=function(){var self=this,args=$A(arguments),ms=args.shift();return window.setTimeout(function(){return self.apply(self,args);},ms);};String.leftTrim=/^\s*/;String.rightTrim=/\s*$/;String.blank=/^\s*$/;String.prototype.trim=function(){return this.replace(String.leftTrim,"").replace(String.rightTrim,"");};String.prototype.empty=function(){return String.blank.test(this);};String.prototype.find=function(str){return(this.indexOf(str)!=-1);};String.prototype.wrap=function(l,r){return(l||'')+this+(r||l||'');};String.prototype.cut=function(p1,p2){return this.substr(0,p1)+this.substr(p2||this.length);};String.prototype.insert=function(val,at){at=at||0;return this.substr(0,at)+val+this.substr(at);};String.prototype.splice=function(offset,len,replace){return this.cut(offset,offset+len).insert(replace,offset);};String.prototype.repeat=function(n){var res='',n=(n||0);while(n--)res+=this;return res;};String.prototype.pad=function(pad,len,type){if(len<0||len<=this.length)return this;pad=(pad?pad.charAt(0):' ');type=type||'left';if(type=='left')return pad.repeat(len-this.length)+this;else if(type=='right')return this+pad.repeat(len-this.length);else return pad.repeat(Math.ceil((len-this.length)/2))+this+pad.repeat(Math.floor((len-this.length)/2));};String.prototype.equalsIgnoreCase=function(str){return this.toLowerCase()==String(str).toLowerCase();};String.prototype.urlEncode=function(){if(window.encodeURIComponent)return encodeURIComponent(this);return escape(this);};String.prototype.camelize=function(){var res,tmp=this.split('-');if(tmp.length==1)return tmp[0];res=(this.indexOf('-')==0?tmp[0].charAt(0).toUpperCase()+tmp[0].substring(1):tmp[0]);for(var i=1;i<tmp.length;i++)res+=tmp[i].charAt(0).toUpperCase()+tmp[i].substring(1);return res;};String.prototype.capitalize=function(){var wl=this.split(/\s+/g);return $C(wl).map(function(w,idx){return w.charAt(0).toUpperCase()+w.substr(1).toLowerCase();}).join(' ');};String.prototype.escapeHTML=function(){var self=arguments.callee;self.text.data=this;return self.div.innerHTML;};Object.extend(String.prototype.escapeHTML,{div:document.createElement('div'),text:document.createTextNode('')});with(String.prototype.escapeHTML)div.appendChild(text);String.prototype.stripSpaces=function(){return this.replace(/\s+/g,' ');};String.prototype.stripTags=function(){return this.replace(/<\/?[^>]+>/gi,'');};String.prototype.stripScripts=function(){try{return this.replace(PHP2Go.scriptRegExpAll,'');}catch(e){var self=this,sp=this.indexOf("<script"),ep=0;while(sp!=-1){ep=self.substr(sp).indexOf("</script>");if(ep!=-1){self=(sp?self.substr(0,sp-1):'')+self.substr(sp).substr(ep+9);sp=self.indexOf("<script");}else{sp=-1;}}return self;}};String.prototype.evalScripts=function(){try{var ra=PHP2Go.scriptRegExpAll;var ro=PHP2Go.scriptRegExpOne;var matches=this.match(ra)||[];return $C(matches).map(function(item){var match=item.match(ro);if(match)PHP2Go.eval(match[1]);});}catch(e){var tmp,self=this,sp=this.indexOf("<script"),ep1=0,ep2=0;while(sp!=-1){tmp=self.substr(sp);ep1=tmp.indexOf(">");ep2=tmp.indexOf("</script>");if(ep1!=-1&&ep2!=-1){PHP2Go.eval(tmp.substr(ep1+1,ep2-ep1-1));self=(sp?self.substr(0,sp-1):'')+tmp.substr(ep2+9);sp=self.indexOf("<script");}else{sp=-1;}}return self;}};String.prototype.evalScriptsDelayed=function(t){var self=this,t=(t||10);if(PHP2Go.browser.ie5){window.timeoutArg=self;setTimeout("window.timeoutArg.evalScripts();window.timeoutArg=null;",t);}else{this.evalScripts.bind(this).delay(t);}};String.prototype.assignAll=function(){var a=$A(arguments),self=this;a.walk(function(item,idx){self=self.replace('%'+(idx+1),item);});return self;};String.prototype.serialize=function(){return"'"+this.replace('\\','\\\\').replace("'",'\\\'')+"'";};String.prototype.toArray=function(){return this.split('');};Date.fromString=function(str){var mt,dt=new Date();var loc=Locale.date,re=loc.regexp;if(mt=str.match(re)){dt.setDate(parseInt(mt[loc.matches[0]],10));dt.setMonth(parseInt(mt[loc.matches[1]],10)-1);dt.setYear(mt[loc.matches[2]]);(mt[7])&&(dt.setHours(parseInt(mt[7],10)));(mt[8])&&(dt.setMinutes(parseInt(mt[8],10)));(mt[9])&&(dt.setSeconds(parseInt(mt[9],10)));}return dt;};Date.toDays=function(date){var d,m,y,c;var loc=Locale.date;var re=loc.regexp;if(mt=date.match(re)){d=parseInt(mt[loc.matches[0]],10);m=parseInt(mt[loc.matches[1]],10);y=mt[loc.matches[2]];c=parseInt(y.substring(0,2),10);y=y.substring(2);if(m>2){m-=3;}else{m+=9;if(y){y--;}else{y=99;c--;}}return(Math.floor((146097*c)/4)+Math.floor((1461*y)/4)+Math.floor((153*m+2)/5)+d+1721119);}else{return 0;}};Math.truncate=function(num,prec){(isNaN(prec))&&(prec=0);return(Math.round(num*Math.pow(10,prec))/Math.pow(10,prec));};if(!Object.isFunc(window.isFinite)){window.isFinite=function(number){return(!isNaN(number)&&(number<=Math.POSITIVE_INFINITY||number>=Math.NEGATIVE_INFINITY));}}Number.prototype.toPaddedString=function(len,base){return this.toString(base||10).pad('0',len);};Number.prototype.serialize=function(){return(isFinite(this)?this.toString():'null');};var Cookie={get:function(name){var re=new RegExp("(^|;)\\s*"+escape(name)+"=([^;]+)");var res=document.cookie.match(re);if(res&&res[2])return unescape(res[2]);return null;},getAll:function(){var res=$H(),ck=document.cookie.split(';');var rn=new RegExp("^\s*([^=]+)"),rv=new RegExp("=(.*$)");for(var i=0;i<ck.length;i++){try{res.set(unescape(ck[i].match(rn)[1]),unescape(ck[i].match(rv)[1]));}catch(e){}}return res;},set:function(name,value,exp,path,domain,sec){name=escape(name),value=escape(value);exp=(exp&&!isNaN(exp)?parseInt(exp,10):0);var ck=name+"="+value;if(exp){var date=new Date();date.setTime(date.getTime()+(1000*parseInt(exp,10)));ck+=';expires='+date.toGMTString();}if(path)ck+=';path='+path;if(domain)ck+=';domain='+domain;if(!!sec)ck+=';secure';document.cookie=ck;},remove:function(name,path,domain){this.set(name,"",-3600,path,domain);},buildLifeTime:function(d,h,m,w){return((!isNaN(d)?(d*24*60*60):0)+(!isNaN(h)?(h*60*60):0)+(!isNaN(m)?(m*60):0)+(!isNaN(w)?(w*7*24*60*60):0));}};var Logger={initialize:function(){this.expanded=false;this.container=$N('div',document.body,{position:'absolute',left:'0px',top:'0px',width:'100px',height:'20px',textAlign:'left',fontFamily:'Courier',fontSize:'10px',color:'white',zIndex:2000 });var self=this;this.top=$N('div',this.container,{height:'20px'},"<button type='button' style='width:50px;height:20px;background-color:ButtonFace;border:1px solid black;padding:0;margin:1px'>toggle</button><button type='button' style='width:40px;height:20px;background-color:ButtonFace;border:1px solid black;padding:0;margin:1px'>clear</button>");this.top.firstChild.onclick=function(){var c=self.container,o=self.output;var e=self.expanded=!self.expanded;c.style.width=(e?'100%':'100px');c.style.height=(e?'200px':'20px');o.toggleDisplay();if(e&&o.lastChild)o.lastChild.scrollIntoView(false);};this.top.firstChild.nextSibling.onclick=function(){self.output.clear();};this.output=$N('div',this.container,{width:'98%',height:'160px',display:'none',position:'absolute',overflow:'auto',backgroundColor:'white',margin:'5px',padding:'4px',border:'1px solid black'});},log:function(text,color){(!this.container)&&(this.initialize());(!Object.isString(text))&&(text=Object.serialize(text));this.output.insert("<pre style='padding:0;margin:0;color:"+(color||'white')+"'>"+String(text).escapeHTML()+"</pre>","bottom");},info:function(text){this.log(text,'blue');},debug:function(text){this.log(text,'green');},warn:function(text){this.log(text,'orange');},error:function(text){this.log(text,'red');},exception:function(e){var info='['+e.name+'] - '+e.message;if(e.stack){info+="\n"+e.stack.split("\n").valid(function(item,idx){var where=item.split('@');if(where[1]&&where[1]!=':0')return'at '+where[1];return null;}).join("\n");}this.log(info,'red');}};var Window={open:function(url,wid,hei,x,y,type,tit,ret){wid=wid||screen.width,hei=hei||screen.availHeight;x=Math.abs(x),y=Math.abs(y);type=Object.ifUndef(type,255),ret=!!ret;var props=(type&1?'toolbar,':'')+(type&2?'location,':'')+(type&4?'directories,':'')+(type&8?'status,':'')+(type&16?'menubar,':'')+(type&32?'scrollbars,':'')+(type&64?'resizable,':'')+(type&128?'copyhistory,':'')+'width='+wid+',height='+hei+',left='+x+',top='+y;var wnd=window.open(url,tit,props);wnd.focus();if(ret)return wnd;},openCentered:function(url,wid,hei,type,tit,ret){wid=wid||800,hei=hei||600;var x=Math.floor((screen.availWidth-wid)/2);var y=Math.floor((screen.availHeight-hei)/2);return Window.open(url,wid,hei,x,y,type,tit,ret);},openFromEvent:function(e,url,wid,hei,type,tit,ret){e=$EV(e),wid=wid||800,hei=hei||600;var w=window,b=document.body,x,y;var el=e.target;var ep=el.getPosition();var ed=el.getDimensions();var ws=Window.scroll();if(!Object.isUndef(w.screenLeft)){x=(w.screenLeft+ep.x+ed.width)-ws.x;y=(w.screenTop+ep.y)-ws.y;}else{var sx=(w.screenX>=0?w.screenX:0);x=(sx+ep.x+ed.width)-ws.x;y=e.screenY-10;}return Window.open(url,wid,hei,x+2,y,type,tit,ret);},blank:function(wid,hei,x,y,type){return Window.open('about:blank',wid,hei,x,y,type,PHP2Go.uid('blank'),true);},write:function(wnd,html,close){close=Object.ifUndef(close,true);if(wnd.document){if(!wnd.writing){wnd.document.open();wnd.writing=true;}wnd.document.write(html);if(close){wnd.writing=false;wnd.document.close();}}},size:function(){var w=window,b=document.body,e=document.documentElement;return{width:(w.innerWidth||e.clientWidth||b.offsetWidth),height:(w.innerHeight||e.clientHeight||b.offsetHeight)};},position:function(){var w=window;return{x:(w.screenX||w.screenLeft),y:(w.screenY||w.screenTop)};},scroll:function(){var w=window,e=(document.documentElement||document.body);return{x:(w.pageXOffset||e.scrollLeft||0),y:(w.pageYOffset||e.scrollTop||0)};}};var IFrame={size:function(elm){try{if(elm=$(elm)){var b=(elm.contentDocument?elm.contentDocument.body:window.frames[elm.id].document.body);return{width:b.offsetWidth,height:b.offsetHeight};}}catch(e){}return{width:-1,height:-1};},scrollXTo:function(elm,x){elm=$(elm);var win=(elm?(elm.contentWindow||window.frames(elm.id)):null);if(window){var y=(win.scrollY||win.document.body.scrollTop);win.scrollTo(x,y);}},scrollYTo:function(elm,y){elm=$(elm);var win=(elm?(elm.contentWindow||window.frames(elm.id)):null);if(win){var x=(win.scrollX||win.document.body.scrollLeft);win.scrollTo(x,y);}},setUrl:function(elm,url){elm=$(elm);if(elm){if(elm.contentDocument)elm.setAttribute('src',url);else if(window.frames(elm.id)){window.frames(elm.id).location.replace(url);}}}};var Report={goToPage:function(frm,curr,total,handler){var pg,fld=frm.elements['page'];if(fld.value!=''){pg=parseInt(fld.value,10);if(pg>0&&pg<=total){if(Object.isFunc(handler))handler({from:curr,to:pg});if(frm.action.indexOf('?')==-1)frm.action=frm.action+'?page='+pg;else if(frm.action.indexOf('?')==frm.action.length-1)frm.action=frm.action+'page='+pg;else frm.action=frm.action+'&page='+pg;return true;}else{alert(Lang.report.invalidPage);fld.value='';fld.focus();}}return false;}};Observable=function(){this.addEventListener=function(name,func,scope,unshift){unshift=!!unshift,name=name.toLowerCase().replace(/^on/,'');this.listeners=this.listeners||{};this.listeners[name]=this.listeners[name]||[];this.listeners[name][(unshift?'unshift':'push')]([func,scope]);return this;};this.removeEventListener=function(name,func,scope){if(this.listeners&&this.listeners[name])this.listeners[name].remove([func,scope]);return this;};this.raiseEvent=function(name,args){this.listeners=this.listeners||{};var funcs=this.listeners[name]||[],args=args||[];for(var i=0,l=funcs.length;i<l;i++){if(funcs[i][0].apply(funcs[i][1]||this,args)===false)return false;}return true;};};Widget=function(attrs,func){this.attributes=(attrs?Object.extend({},attrs):{});if(Object.isFunc(func))func(this);};Widget.implement(new Observable);Widget.widgets=[];Widget.init=function(name,attrs,setupFunc){PHP2Go.include(PHP2Go.baseUrl+'widgets/'+name.toLowerCase()+'.js');this.widgets.push([name,attrs,setupFunc]);};Widget.prototype.hasAttributes=function(){for(var i=0;i<arguments.length;i++){if(Object.isUndef(this.attributes[arguments[i]]))return false;}return true;};$=function(){var elm,d=document,a=arguments;if(a.length==1){elm=a[0];if(typeof(elm)=='string')elm=$E(d.getElementById(elm));else elm=$E(elm);return elm;}for(var i=0,res=[],len=a.length;i<len;i++){elm=a[i];if(typeof(elm)=='string')elm=$E(d.getElementById(elm));else elm=$E(elm);res.push(elm);}return res;};$EF=function(){};$IF=function(x){return x;};PHP2Go.load();