var Prototype={Version:"1.6.0",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement("div").__proto__&&document.createElement("div").__proto__!==document.createElement("form").__proto__},ScriptFragment:"<script[^>]*>([\\S\\s]*?)<\/script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(A){return A;}};if(Prototype.Browser.MobileSafari){Prototype.BrowserFeatures.SpecificElementExtensions=false;}if(Prototype.Browser.WebKit){Prototype.BrowserFeatures.XPath=false;}var Class={create:function(){var E=null,D=$A(arguments);if(Object.isFunction(D[0])){E=D.shift();}function A(){this.initialize.apply(this,arguments);}Object.extend(A,Class.Methods);A.superclass=E;A.subclasses=[];if(E){var B=function(){};B.prototype=E.prototype;A.prototype=new B;E.subclasses.push(A);}for(var C=0;C<D.length;C++){A.addMethods(D[C]);}if(!A.prototype.initialize){A.prototype.initialize=Prototype.emptyFunction;}A.prototype.constructor=A;return A;}};Class.Methods={addMethods:function(G){var C=this.superclass&&this.superclass.prototype;var B=Object.keys(G);if(!Object.keys({toString:true}).length){B.push("toString","valueOf");}for(var A=0,D=B.length;A<D;A++){var F=B[A],E=G[F];if(C&&Object.isFunction(E)&&E.argumentNames().first()=="$super"){var H=E,E=Object.extend((function(I){return function(){return C[I].apply(this,arguments);};})(F).wrap(H),{valueOf:function(){return H;},toString:function(){return H.toString();}});}this.prototype[F]=E;}return this;}};var Abstract={};Object.extend=function(A,C){for(var B in C){A[B]=C[B];}return A;};Object.extend(Object,{inspect:function(A){try{if(A===undefined){return"undefined";}if(A===null){return"null";}return A.inspect?A.inspect():A.toString();}catch(B){if(B instanceof RangeError){return"...";}throw B;}},toJSON:function(A){var C=typeof A;switch(C){case"undefined":case"function":case"unknown":return ;case"boolean":return A.toString();}if(A===null){return"null";}if(A.toJSON){return A.toJSON();}if(Object.isElement(A)){return ;}var B=[];for(var E in A){var D=Object.toJSON(A[E]);if(D!==undefined){B.push(E.toJSON()+": "+D);}}return"{"+B.join(", ")+"}";},toQueryString:function(A){return $H(A).toQueryString();},toHTML:function(A){return A&&A.toHTML?A.toHTML():String.interpret(A);},keys:function(A){var B=[];for(var C in A){B.push(C);}return B;},values:function(B){var A=[];for(var C in B){A.push(B[C]);}return A;},clone:function(A){return Object.extend({},A);},isElement:function(A){return A&&A.nodeType==1;},isArray:function(A){return A&&A.constructor===Array;},isHash:function(A){return A instanceof Hash;},isFunction:function(A){return typeof A=="function";},isString:function(A){return typeof A=="string";},isNumber:function(A){return typeof A=="number";},isUndefined:function(A){return typeof A=="undefined";}});Object.extend(Function.prototype,{argumentNames:function(){var A=this.toString().match(/^[\s\(]*function[^(]*\((.*?)\)/)[1].split(",").invoke("strip");return A.length==1&&!A[0]?[]:A;},bind:function(){if(arguments.length<2&&arguments[0]===undefined){return this;}var A=this,C=$A(arguments),B=C.shift();return function(){return A.apply(B,C.concat($A(arguments)));};},bindAsEventListener:function(){var A=this,C=$A(arguments),B=C.shift();return function(D){return A.apply(B,[D||window.event].concat(C));};},curry:function(){if(!arguments.length){return this;}var A=this,B=$A(arguments);return function(){return A.apply(this,B.concat($A(arguments)));};},delay:function(){var A=this,B=$A(arguments),C=B.shift()*1000;return window.setTimeout(function(){return A.apply(A,B);},C);},wrap:function(B){var A=this;return function(){return B.apply(this,[A.bind(this)].concat($A(arguments)));};},methodize:function(){if(this._methodized){return this._methodized;}var A=this;return this._methodized=function(){return A.apply(null,[this].concat($A(arguments)));};}});Function.prototype.defer=Function.prototype.delay.curry(0.01);Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+"-"+(this.getUTCMonth()+1).toPaddedString(2)+"-"+this.getUTCDate().toPaddedString(2)+"T"+this.getUTCHours().toPaddedString(2)+":"+this.getUTCMinutes().toPaddedString(2)+":"+this.getUTCSeconds().toPaddedString(2)+'Z"';};var Try={these:function(){var C;for(var B=0,D=arguments.length;B<D;B++){var A=arguments[B];try{C=A();break;}catch(E){}}return C;}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(A){return String(A).replace(/([.*+?^=!:${}()|[\]\/\\])/g,"\\$1");};var PeriodicalExecuter=Class.create({initialize:function(B,A){this.callback=B;this.frequency=A;this.currentlyExecuting=false;this.registerCallback();},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000);},execute:function(){this.callback(this);},stop:function(){if(!this.timer){return ;}clearInterval(this.timer);this.timer=null;},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute();}finally{this.currentlyExecuting=false;}}}});Object.extend(String,{interpret:function(A){return A==null?"":String(A);},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});Object.extend(String.prototype,{gsub:function(E,C){var A="",D=this,B;C=arguments.callee.prepareReplacement(C);while(D.length>0){if(B=D.match(E)){A+=D.slice(0,B.index);A+=String.interpret(C(B));D=D.slice(B.index+B[0].length);}else{A+=D,D="";}}return A;},sub:function(C,A,B){A=this.gsub.prepareReplacement(A);B=B===undefined?1:B;return this.gsub(C,function(D){if(--B<0){return D[0];}return A(D);});},scan:function(B,A){this.gsub(B,A);return String(this);},truncate:function(B,A){B=B||30;A=A===undefined?"...":A;return this.length>B?this.slice(0,B-A.length)+A:String(this);},strip:function(){return this.replace(/^\s+/,"").replace(/\s+$/,"");},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,"");},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"");},extractScripts:function(){var B=new RegExp(Prototype.ScriptFragment,"img");var A=new RegExp(Prototype.ScriptFragment,"im");return(this.match(B)||[]).map(function(C){return(C.match(A)||["",""])[1];});},evalScripts:function(){return this.extractScripts().map(function(script){return eval(script);});},escapeHTML:function(){var A=arguments.callee;A.text.data=this;return A.div.innerHTML;},unescapeHTML:function(){var A=new Element("div");A.innerHTML=this.stripTags();return A.childNodes[0]?(A.childNodes.length>1?$A(A.childNodes).inject("",function(B,C){return B+C.nodeValue;}):A.childNodes[0].nodeValue):"";},toQueryParams:function(B){var A=this.strip().match(/([^?#]*)(#.*)?$/);if(!A){return{};}return A[1].split(B||"&").inject({},function(E,F){if((F=F.split("="))[0]){var C=decodeURIComponent(F.shift());var D=F.length>1?F.join("="):F[0];if(D!=undefined){D=decodeURIComponent(D);}if(C in E){if(!Object.isArray(E[C])){E[C]=[E[C]];}E[C].push(D);}else{E[C]=D;}}return E;});},toArray:function(){return this.split("");},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1);},times:function(A){return A<1?"":new Array(A+1).join(this);},camelize:function(){var D=this.split("-"),A=D.length;if(A==1){return D[0];}var C=this.charAt(0)=="-"?D[0].charAt(0).toUpperCase()+D[0].substring(1):D[0];for(var B=1;B<A;B++){C+=D[B].charAt(0).toUpperCase()+D[B].substring(1);}return C;},capitalize:function(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();},underscore:function(){return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase();},dasherize:function(){return this.gsub(/_/,"-");},inspect:function(B){var A=this.gsub(/[\x00-\x1f\\]/,function(C){var D=String.specialChar[C[0]];return D?D:"\\u00"+C[0].charCodeAt().toPaddedString(2,16);});if(B){return'"'+A.replace(/"/g,'\\"')+'"';}return"'"+A.replace(/'/g,"\\'")+"'";},toJSON:function(){return this.inspect(true);},unfilterJSON:function(A){return this.sub(A||Prototype.JSONFilter,"#{1}");},isJSON:function(){var A=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(A);},evalJSON:function(sanitize){var json=this.unfilterJSON();try{if(!sanitize||json.isJSON()){return eval("("+json+")");}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect());},include:function(A){return this.indexOf(A)>-1;},startsWith:function(A){return this.indexOf(A)===0;},endsWith:function(A){var B=this.length-A.length;return B>=0&&this.lastIndexOf(A)===B;},empty:function(){return this=="";},blank:function(){return/^\s*$/.test(this);},interpolate:function(A,B){return new Template(this,B).evaluate(A);}});if(Prototype.Browser.WebKit||Prototype.Browser.IE){Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");},unescapeHTML:function(){return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");}});}String.prototype.gsub.prepareReplacement=function(B){if(Object.isFunction(B)){return B;}var A=new Template(B);return function(C){return A.evaluate(C);};};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});with(String.prototype.escapeHTML){div.appendChild(text);}var Template=Class.create({initialize:function(A,B){this.template=A.toString();this.pattern=B||Template.Pattern;},evaluate:function(A){if(Object.isFunction(A.toTemplateReplacements)){A=A.toTemplateReplacements();}return this.template.gsub(this.pattern,function(D){if(A==null){return"";}var F=D[1]||"";if(F=="\\"){return D[2];}var B=A,G=D[3];var E=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/,D=E.exec(G);if(D==null){return F;}while(D!=null){var C=D[1].startsWith("[")?D[2].gsub("\\\\]","]"):D[1];B=B[C];if(null==B||""==D[3]){break;}G=G.substring("["==D[3]?D[1].length:D[0].length);D=E.exec(G);}return F+String.interpret(B);}.bind(this));}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(C,B){var A=0;C=C.bind(B);try{this._each(function(E){C(E,A++);});}catch(D){if(D!=$break){throw D;}}return this;},eachSlice:function(D,C,B){C=C?C.bind(B):Prototype.K;var A=-D,E=[],F=this.toArray();while((A+=D)<F.length){E.push(F.slice(A,A+D));}return E.collect(C,B);},all:function(C,B){C=C?C.bind(B):Prototype.K;var A=true;this.each(function(E,D){A=A&&!!C(E,D);if(!A){throw $break;}});return A;},any:function(C,B){C=C?C.bind(B):Prototype.K;var A=false;this.each(function(E,D){if(A=!!C(E,D)){throw $break;}});return A;},collect:function(C,B){C=C?C.bind(B):Prototype.K;var A=[];this.each(function(E,D){A.push(C(E,D));});return A;},detect:function(C,B){C=C.bind(B);var A;this.each(function(E,D){if(C(E,D)){A=E;throw $break;}});return A;},findAll:function(C,B){C=C.bind(B);var A=[];this.each(function(E,D){if(C(E,D)){A.push(E);}});return A;},grep:function(D,C,B){C=C?C.bind(B):Prototype.K;var A=[];if(Object.isString(D)){D=new RegExp(D);}this.each(function(F,E){if(D.match(F)){A.push(C(F,E));}});return A;},include:function(A){if(Object.isFunction(this.indexOf)){if(this.indexOf(A)!=-1){return true;}}var B=false;this.each(function(C){if(C==A){B=true;throw $break;}});return B;},inGroupsOf:function(B,A){A=A===undefined?null:A;return this.eachSlice(B,function(C){while(C.length<B){C.push(A);}return C;});},inject:function(A,C,B){C=C.bind(B);this.each(function(E,D){A=C(A,E,D);});return A;},invoke:function(B){var A=$A(arguments).slice(1);return this.map(function(C){return C[B].apply(C,A);});},max:function(C,B){C=C?C.bind(B):Prototype.K;var A;this.each(function(E,D){E=C(E,D);if(A==undefined||E>=A){A=E;}});return A;},min:function(C,B){C=C?C.bind(B):Prototype.K;var A;this.each(function(E,D){E=C(E,D);if(A==undefined||E<A){A=E;}});return A;},partition:function(D,B){D=D?D.bind(B):Prototype.K;var C=[],A=[];this.each(function(F,E){(D(F,E)?C:A).push(F);});return[C,A];},pluck:function(B){var A=[];this.each(function(C){A.push(C[B]);});return A;},reject:function(C,B){C=C.bind(B);var A=[];this.each(function(E,D){if(!C(E,D)){A.push(E);}});return A;},sortBy:function(B,A){B=B.bind(A);return this.map(function(D,C){return{value:D,criteria:B(D,C)};}).sort(function(F,E){var D=F.criteria,C=E.criteria;return D<C?-1:D>C?1:0;}).pluck("value");},toArray:function(){return this.map();},zip:function(){var B=Prototype.K,A=$A(arguments);if(Object.isFunction(A.last())){B=A.pop();}var C=[this].concat(A).map($A);return this.map(function(E,D){return B(C.pluck(D));});},size:function(){return this.toArray().length;},inspect:function(){return"#<Enumerable:"+this.toArray().inspect()+">";}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(C){if(!C){return[];}if(C.toArray){return C.toArray();}var B=C.length,A=new Array(B);while(B--){A[B]=C[B];}return A;}if(Prototype.Browser.WebKit){function $A(C){if(!C){return[];}if(!(Object.isFunction(C)&&C=="[object NodeList]")&&C.toArray){return C.toArray();}var B=C.length,A=new Array(B);while(B--){A[B]=C[B];}return A;}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse){Array.prototype._reverse=Array.prototype.reverse;}Object.extend(Array.prototype,{_each:function(B){for(var A=0,C=this.length;A<C;A++){B(this[A]);}},clear:function(){this.length=0;return this;},first:function(){return this[0];},last:function(){return this[this.length-1];},compact:function(){return this.select(function(A){return A!=null;});},flatten:function(){return this.inject([],function(B,A){return B.concat(Object.isArray(A)?A.flatten():[A]);});},without:function(){var A=$A(arguments);return this.select(function(B){return !A.include(B);});},reverse:function(A){return(A!==false?this:this.toArray())._reverse();},reduce:function(){return this.length>1?this:this[0];},uniq:function(A){return this.inject([],function(D,C,B){if(0==B||(A?D.last()!=C:!D.include(C))){D.push(C);}return D;});},intersect:function(A){return this.uniq().findAll(function(B){return A.detect(function(C){return B===C;});});},clone:function(){return[].concat(this);},size:function(){return this.length;},inspect:function(){return"["+this.map(Object.inspect).join(", ")+"]";},toJSON:function(){var A=[];this.each(function(B){var C=Object.toJSON(B);if(C!==undefined){A.push(C);}});return"["+A.join(", ")+"]";}});if(Object.isFunction(Array.prototype.forEach)){Array.prototype._each=Array.prototype.forEach;}if(!Array.prototype.indexOf){Array.prototype.indexOf=function(C,A){A||(A=0);var B=this.length;if(A<0){A=B+A;}for(;A<B;A++){if(this[A]===C){return A;}}return -1;};}if(!Array.prototype.lastIndexOf){Array.prototype.lastIndexOf=function(B,A){A=isNaN(A)?this.length:(A<0?this.length+A:A)+1;var C=this.slice(0,A).reverse().indexOf(B);return(C<0)?C:A-C-1;};}Array.prototype.toArray=Array.prototype.clone;function $w(A){if(!Object.isString(A)){return[];}A=A.strip();return A?A.split(/\s+/):[];}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var E=[];for(var B=0,C=this.length;B<C;B++){E.push(this[B]);}for(var B=0,C=arguments.length;B<C;B++){if(Object.isArray(arguments[B])){for(var A=0,D=arguments[B].length;A<D;A++){E.push(arguments[B][A]);}}else{E.push(arguments[B]);}}return E;};}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16);},succ:function(){return this+1;},times:function(A){$R(0,this,true).each(A);return this;},toPaddedString:function(C,B){var A=this.toString(B||10);return"0".times(C-A.length)+A;},toJSON:function(){return isFinite(this)?this.toString():"null";}});$w("abs round ceil floor").each(function(A){Number.prototype[A]=Math[A].methodize();});function $H(A){return new Hash(A);}var Hash=Class.create(Enumerable,(function(){if(function(){var C=0,E=function(F){this.key=F;};E.prototype.key="foo";for(var D in new E("bar")){C++;}return C>1;}()){function B(E){var C=[];for(var D in this._object){var F=this._object[D];if(C.include(D)){continue;}C.push(D);var G=[D,F];G.key=D;G.value=F;E(G);}}}else{function B(D){for(var C in this._object){var E=this._object[C],F=[C,E];F.key=C;F.value=E;D(F);}}}function A(C,D){if(Object.isUndefined(D)){return C;}return C+"="+encodeURIComponent(String.interpret(D));}return{initialize:function(C){this._object=Object.isHash(C)?C.toObject():Object.clone(C);},_each:B,set:function(C,D){return this._object[C]=D;},get:function(C){return this._object[C];},unset:function(C){var D=this._object[C];delete this._object[C];return D;},toObject:function(){return Object.clone(this._object);},keys:function(){return this.pluck("key");},values:function(){return this.pluck("value");},index:function(D){var C=this.detect(function(E){return E.value===D;});return C&&C.key;},merge:function(C){return this.clone().update(C);},update:function(C){return new Hash(C).inject(this,function(D,E){D.set(E.key,E.value);return D;});},toQueryString:function(){return this.map(function(E){var D=encodeURIComponent(E.key),C=E.value;if(C&&typeof C=="object"){if(Object.isArray(C)){return C.map(A.curry(D)).join("&");}}return A(D,C);}).join("&");},inspect:function(){return"#<Hash:{"+this.map(function(C){return C.map(Object.inspect).join(": ");}).join(", ")+"}>";},toJSON:function(){return Object.toJSON(this.toObject());},clone:function(){return new Hash(this);}};})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(C,A,B){this.start=C;this.end=A;this.exclusive=B;},_each:function(A){var B=this.start;while(this.include(B)){A(B);B=B.succ();}},include:function(A){if(A<this.start){return false;}if(this.exclusive){return A<this.end;}return A<=this.end;}});var $R=function(C,A,B){return new ObjectRange(C,A,B);};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest();},function(){return new ActiveXObject("Msxml2.XMLHTTP");},function(){return new ActiveXObject("Microsoft.XMLHTTP");})||false;},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(A){this.responders._each(A);},register:function(A){if(!this.include(A)){this.responders.push(A);}},unregister:function(A){this.responders=this.responders.without(A);},dispatch:function(D,B,C,A){this.each(function(E){if(Object.isFunction(E[D])){try{E[D].apply(E,[B,C,A]);}catch(F){}}});}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++;},onComplete:function(){Ajax.activeRequestCount--;}});Ajax.Base=Class.create({initialize:function(A){this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:"",evalJSON:true,evalJS:true};Object.extend(this.options,A||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters)){this.options.parameters=this.options.parameters.toQueryParams();}}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,B,A){$super(A);this.transport=Ajax.getTransport();this.request(B);},request:function(B){this.url=B;this.method=this.options.method;var D=Object.clone(this.options.parameters);if(!["get","post"].include(this.method)){D["_method"]=this.method;this.method="post";}this.parameters=D;if(D=Object.toQueryString(D)){if(this.method=="get"){this.url+=(this.url.include("?")?"&":"?")+D;}else{if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){D+="&_=";}}}try{var A=new Ajax.Response(this);if(this.options.onCreate){this.options.onCreate(A);}Ajax.Responders.dispatch("onCreate",this,A);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous){this.respondToReadyState.bind(this).defer(1);}this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=="post"?(this.options.postBody||D):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType){this.onStateChange();}}catch(C){this.dispatchException(C);}},onStateChange:function(){var A=this.transport.readyState;if(A>1&&!((A==4)&&this._complete)){this.respondToReadyState(this.transport.readyState);}},setRequestHeaders:function(){var E={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,"Accept":"text/javascript, text/html, application/xml, text/xml, */*"};if(this.method=="post"){E["Content-type"]=this.options.contentType+(this.options.encoding?"; charset="+this.options.encoding:"");if(this.transport.overrideMimeType&&(navigator.userAgent.match(/Gecko\/(\d{4})/)||[0,2005])[1]<2005){E["Connection"]="close";}}if(typeof this.options.requestHeaders=="object"){var C=this.options.requestHeaders;if(Object.isFunction(C.push)){for(var B=0,D=C.length;B<D;B+=2){E[C[B]]=C[B+1];}}else{$H(C).each(function(F){E[F.key]=F.value;});}}for(var A in E){this.transport.setRequestHeader(A,E[A]);}},success:function(){var A=this.getStatus();return !A||(A>=200&&A<300);},getStatus:function(){try{return this.transport.status||0;}catch(A){return 0;}},respondToReadyState:function(A){var C=Ajax.Request.Events[A],B=new Ajax.Response(this);if(C=="Complete"){try{this._complete=true;(this.options["on"+B.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(B,B.headerJSON);}catch(D){this.dispatchException(D);}var E=B.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&E&&E.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i))){this.evalResponse();}}try{(this.options["on"+C]||Prototype.emptyFunction)(B,B.headerJSON);Ajax.Responders.dispatch("on"+C,this,B,B.headerJSON);}catch(D){this.dispatchException(D);}if(C=="Complete"){this.transport.onreadystatechange=Prototype.emptyFunction;}},getHeader:function(A){try{return this.transport.getResponseHeader(A);}catch(B){return null;}},evalResponse:function(){try{return eval((this.transport.responseText||"").unfilterJSON());}catch(e){this.dispatchException(e);}},dispatchException:function(A){(this.options.onException||Prototype.emptyFunction)(this,A);Ajax.Responders.dispatch("onException",this,A);}});Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];Ajax.Response=Class.create({initialize:function(C){this.request=C;var D=this.transport=C.transport,A=this.readyState=D.readyState;if((A>2&&!Prototype.Browser.IE)||A==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(D.responseText);this.headerJSON=this._getHeaderJSON();}if(A==4){var B=D.responseXML;this.responseXML=B===undefined?null:B;this.responseJSON=this._getResponseJSON();}},status:0,statusText:"",getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||"";}catch(A){return"";}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders();}catch(A){return null;}},getResponseHeader:function(A){return this.transport.getResponseHeader(A);},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders();},_getHeaderJSON:function(){var A=this.getHeader("X-JSON");if(!A){return null;}A=decodeURIComponent(escape(A));try{return A.evalJSON(this.request.options.sanitizeJSON);}catch(B){this.request.dispatchException(B);}},_getResponseJSON:function(){var A=this.request.options;if(!A.evalJSON||(A.evalJSON!="force"&&!(this.getHeader("Content-type")||"").include("application/json"))){return null;}try{return this.transport.responseText.evalJSON(A.sanitizeJSON);}catch(B){this.request.dispatchException(B);}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,A,C,B){this.container={success:(A.success||A),failure:(A.failure||(A.success?null:A))};B=B||{};var D=B.onComplete;B.onComplete=(function(E,F){this.updateContent(E.responseText);if(Object.isFunction(D)){D(E,F);}}).bind(this);$super(C,B);},updateContent:function(D){var C=this.container[this.success()?"success":"failure"],A=this.options;if(!A.evalScripts){D=D.stripScripts();}if(C=$(C)){if(A.insertion){if(Object.isString(A.insertion)){var B={};B[A.insertion]=D;C.insert(B);}else{A.insertion(C,D);}}else{C.update(D);}}if(this.success()){if(this.onComplete){this.onComplete.bind(this).defer();}}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,A,C,B){$super(B);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=A;this.url=C;this.start();},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent();},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments);},updateComplete:function(A){if(this.options.decay){this.decay=(A.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=A.responseText;}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency);},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options);}});function $(B){if(arguments.length>1){for(var A=0,D=[],C=arguments.length;A<C;A++){D.push($(arguments[A]));}return D;}if(Object.isString(B)){B=document.getElementById(B);}return Element.extend(B);}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(F,A){var C=[];var E=document.evaluate(F,$(A)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var B=0,D=E.snapshotLength;B<D;B++){C.push(Element.extend(E.snapshotItem(B)));}return C;};}if(!window.Node){var Node={};}if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12});}(function(){var A=this.Element;this.Element=function(D,C){C=C||{};D=D.toLowerCase();var B=Element.cache;if(Prototype.Browser.IE&&C.name){D="<"+D+' name="'+C.name+'">';delete C.name;return Element.writeAttribute(document.createElement(D),C);}if(!B[D]){B[D]=Element.extend(document.createElement(D));}return Element.writeAttribute(B[D].cloneNode(false),C);};Object.extend(this.Element,A||{});}).call(window);Element.cache={};Element.Methods={visible:function(A){return $(A).style.display!="none";},toggle:function(A){A=$(A);Element[Element.visible(A)?"hide":"show"](A);return A;},hide:function(A){$(A).style.display="none";return A;},show:function(A){$(A).style.display="";return A;},remove:function(A){A=$(A);A.parentNode.removeChild(A);return A;},update:function(A,B){A=$(A);if(B&&B.toElement){B=B.toElement();}if(Object.isElement(B)){return A.update().insert(B);}B=Object.toHTML(B);A.innerHTML=B.stripScripts();B.evalScripts.bind(B).defer();return A;},replace:function(B,C){B=$(B);if(C&&C.toElement){C=C.toElement();}else{if(!Object.isElement(C)){C=Object.toHTML(C);var A=B.ownerDocument.createRange();A.selectNode(B);C.evalScripts.bind(C).defer();C=A.createContextualFragment(C.stripScripts());}}B.parentNode.replaceChild(C,B);return B;},insert:function(C,E){C=$(C);if(Object.isString(E)||Object.isNumber(E)||Object.isElement(E)||(E&&(E.toElement||E.toHTML))){E={bottom:E};}var D,B,A;for(position in E){D=E[position];position=position.toLowerCase();B=Element._insertionTranslations[position];if(D&&D.toElement){D=D.toElement();}if(Object.isElement(D)){B.insert(C,D);continue;}D=Object.toHTML(D);A=C.ownerDocument.createRange();B.initializeRange(C,A);B.insert(C,A.createContextualFragment(D.stripScripts()));D.evalScripts.bind(D).defer();}return C;},wrap:function(B,C,A){B=$(B);if(Object.isElement(C)){$(C).writeAttribute(A||{});}else{if(Object.isString(C)){C=new Element(C,A);}else{C=new Element("div",C);}}if(B.parentNode){B.parentNode.replaceChild(C,B);}C.appendChild(B);return C;},inspect:function(B){B=$(B);var A="<"+B.tagName.toLowerCase();$H({"id":"id","className":"class"}).each(function(F){var E=F.first(),C=F.last();var D=(B[E]||"").toString();if(D){A+=" "+C+"="+D.inspect(true);}});return A+">";},recursivelyCollect:function(A,C){A=$(A);var B=[];while(A=A[C]){if(A.nodeType==1){B.push(Element.extend(A));}}return B;},ancestors:function(A){return $(A).recursivelyCollect("parentNode");},descendants:function(A){return $A($(A).getElementsByTagName("*")).each(Element.extend);},firstDescendant:function(A){A=$(A).firstChild;while(A&&A.nodeType!=1){A=A.nextSibling;}return $(A);},immediateDescendants:function(A){if(!(A=$(A).firstChild)){return[];}while(A&&A.nodeType!=1){A=A.nextSibling;}if(A){return[A].concat($(A).nextSiblings());}return[];},previousSiblings:function(A){return $(A).recursivelyCollect("previousSibling");},nextSiblings:function(A){return $(A).recursivelyCollect("nextSibling");},siblings:function(A){A=$(A);return A.previousSiblings().reverse().concat(A.nextSiblings());},match:function(B,A){if(Object.isString(A)){A=new Selector(A);}return A.match($(B));},up:function(B,D,A){B=$(B);if(arguments.length==1){return $(B.parentNode);}var C=B.ancestors();return D?Selector.findElement(C,D,A):C[A||0];},down:function(B,C,A){B=$(B);if(arguments.length==1){return B.firstDescendant();}var D=B.descendants();return C?Selector.findElement(D,C,A):D[A||0];},previous:function(B,D,A){B=$(B);if(arguments.length==1){return $(Selector.handlers.previousElementSibling(B));}var C=B.previousSiblings();return D?Selector.findElement(C,D,A):C[A||0];},next:function(C,D,B){C=$(C);if(arguments.length==1){return $(Selector.handlers.nextElementSibling(C));}var A=C.nextSiblings();return D?Selector.findElement(A,D,B):A[B||0];},select:function(){var A=$A(arguments),B=$(A.shift());return Selector.findChildElements(B,A);},adjacent:function(){var A=$A(arguments),B=$(A.shift());return Selector.findChildElements(B.parentNode,A).without(B);},identify:function(B){B=$(B);var C=B.readAttribute("id"),A=arguments.callee;if(C){return C;}do{C="anonymous_element_"+A.counter++;}while($(C));B.writeAttribute("id",C);return C;},readAttribute:function(C,A){C=$(C);if(Prototype.Browser.IE){var B=Element._attributeTranslations.read;if(B.values[A]){return B.values[A](C,A);}if(B.names[A]){A=B.names[A];}if(A.include(":")){return(!C.attributes||!C.attributes[A])?null:C.attributes[A].value;}}return C.getAttribute(A);},writeAttribute:function(E,C,F){E=$(E);var B={},D=Element._attributeTranslations.write;if(typeof C=="object"){B=C;}else{B[C]=F===undefined?true:F;}for(var A in B){var C=D.names[A]||A,F=B[A];if(D.values[A]){C=D.values[A](E,F);}if(F===false||F===null){E.removeAttribute(C);}else{if(F===true){E.setAttribute(C,C);}else{E.setAttribute(C,F);}}}return E;},getHeight:function(A){return $(A).getDimensions().height;},getWidth:function(A){return $(A).getDimensions().width;},classNames:function(A){return new Element.ClassNames(A);},hasClassName:function(A,B){if(!(A=$(A))){return ;}var C=A.className;return(C.length>0&&(C==B||new RegExp("(^|\\s)"+B+"(\\s|$)").test(C)));},addClassName:function(A,B){if(!(A=$(A))){return ;}if(!A.hasClassName(B)){A.className+=(A.className?" ":"")+B;}return A;},removeClassName:function(A,B){if(!(A=$(A))){return ;}A.className=A.className.replace(new RegExp("(^|\\s+)"+B+"(\\s+|$)")," ").strip();return A;},toggleClassName:function(A,B){if(!(A=$(A))){return ;}return A[A.hasClassName(B)?"removeClassName":"addClassName"](B);},cleanWhitespace:function(B){B=$(B);var C=B.firstChild;while(C){var A=C.nextSibling;if(C.nodeType==3&&!/\S/.test(C.nodeValue)){B.removeChild(C);}C=A;}return B;},empty:function(A){return $(A).innerHTML.blank();},descendantOf:function(D,C){D=$(D),C=$(C);if(D.compareDocumentPosition){return(D.compareDocumentPosition(C)&8)===8;}if(D.sourceIndex&&!Prototype.Browser.Opera){var E=D.sourceIndex,B=C.sourceIndex,A=C.nextSibling;if(!A){do{C=C.parentNode;}while(!(A=C.nextSibling)&&C.parentNode);}if(A){return(E>B&&E<A.sourceIndex);}}while(D=D.parentNode){if(D==C){return true;}}return false;},scrollTo:function(A){A=$(A);var B=A.cumulativeOffset();window.scrollTo(B[0],B[1]);return A;},getStyle:function(B,C){B=$(B);C=C=="float"?"cssFloat":C.camelize();var D=B.style[C];if(!D){var A=document.defaultView.getComputedStyle(B,null);D=A?A[C]:null;}if(C=="opacity"){return D?parseFloat(D):1;}return D=="auto"?null:D;},getOpacity:function(A){return $(A).getStyle("opacity");},setStyle:function(B,C){B=$(B);var E=B.style,A;if(Object.isString(C)){B.style.cssText+=";"+C;return C.include("opacity")?B.setOpacity(C.match(/opacity:\s*(\d?\.?\d*)/)[1]):B;}for(var D in C){if(D=="opacity"){B.setOpacity(C[D]);}else{E[(D=="float"||D=="cssFloat")?(E.styleFloat===undefined?"cssFloat":"styleFloat"):D]=C[D];}}return B;},setOpacity:function(A,B){A=$(A);A.style.opacity=(B==1||B==="")?"":(B<0.00001)?0:B;return A;},getDimensions:function(C){C=$(C);var G=$(C).getStyle("display");if(G!="none"&&G!=null){return{width:C.offsetWidth,height:C.offsetHeight};}var B=C.style;var F=B.visibility;var D=B.position;var A=B.display;B.visibility="hidden";B.position="absolute";B.display="block";var H=C.clientWidth;var E=C.clientHeight;B.display=A;B.position=D;B.visibility=F;return{width:H,height:E};},makePositioned:function(A){A=$(A);var B=Element.getStyle(A,"position");if(B=="static"||!B){A._madePositioned=true;A.style.position="relative";if(window.opera){A.style.top=0;A.style.left=0;}}return A;},undoPositioned:function(A){A=$(A);if(A._madePositioned){A._madePositioned=undefined;A.style.position=A.style.top=A.style.left=A.style.bottom=A.style.right="";}return A;},makeClipping:function(A){A=$(A);if(A._overflow){return A;}A._overflow=Element.getStyle(A,"overflow")||"auto";if(A._overflow!=="hidden"){A.style.overflow="hidden";}return A;},undoClipping:function(A){A=$(A);if(!A._overflow){return A;}A.style.overflow=A._overflow=="auto"?"":A._overflow;A._overflow=null;return A;},cumulativeOffset:function(B){var A=0,C=0;do{A+=B.offsetTop||0;C+=B.offsetLeft||0;B=B.offsetParent;}while(B);return Element._returnOffset(C,A);},positionedOffset:function(B){var A=0,D=0;do{A+=B.offsetTop||0;D+=B.offsetLeft||0;B=B.offsetParent;if(B){if(B.tagName=="BODY"){break;}var C=Element.getStyle(B,"position");if(C=="relative"||C=="absolute"){break;}}}while(B);return Element._returnOffset(D,A);},absolutize:function(B){B=$(B);if(B.getStyle("position")=="absolute"){return ;}var D=B.positionedOffset();var F=D[1];var E=D[0];var C=B.clientWidth;var A=B.clientHeight;B._originalLeft=E-parseFloat(B.style.left||0);B._originalTop=F-parseFloat(B.style.top||0);B._originalWidth=B.style.width;B._originalHeight=B.style.height;B.style.position="absolute";B.style.top=F+"px";B.style.left=E+"px";B.style.width=C+"px";B.style.height=A+"px";return B;},relativize:function(A){A=$(A);if(A.getStyle("position")=="relative"){return ;}A.style.position="relative";var C=parseFloat(A.style.top||0)-(A._originalTop||0);var B=parseFloat(A.style.left||0)-(A._originalLeft||0);A.style.top=C+"px";A.style.left=B+"px";A.style.height=A._originalHeight;A.style.width=A._originalWidth;return A;},cumulativeScrollOffset:function(B){var A=0,C=0;do{A+=B.scrollTop||0;C+=B.scrollLeft||0;B=B.parentNode;}while(B);return Element._returnOffset(C,A);},getOffsetParent:function(A){if(A.offsetParent){return $(A.offsetParent);}if(A==document.body){return $(A);}while((A=A.parentNode)&&A!=document.body){if(Element.getStyle(A,"position")!="static"){return $(A);}}return $(document.body);},viewportOffset:function(D){var A=0,C=0;var B=D;do{A+=B.offsetTop||0;C+=B.offsetLeft||0;if(B.offsetParent==document.body&&Element.getStyle(B,"position")=="absolute"){break;}}while(B=B.offsetParent);B=D;do{if(!Prototype.Browser.Opera||B.tagName=="BODY"){A-=B.scrollTop||0;C-=B.scrollLeft||0;}}while(B=B.parentNode);return Element._returnOffset(C,A);},clonePosition:function(B,D){var A=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});D=$(D);var E=D.viewportOffset();B=$(B);var F=[0,0];var C=null;if(Element.getStyle(B,"position")=="absolute"){C=B.getOffsetParent();F=C.viewportOffset();}if(C==document.body){F[0]-=document.body.offsetLeft;F[1]-=document.body.offsetTop;}if(A.setLeft){B.style.left=(E[0]-F[0]+A.offsetLeft)+"px";}if(A.setTop){B.style.top=(E[1]-F[1]+A.offsetTop)+"px";}if(A.setWidth){B.style.width=D.offsetWidth+"px";}if(A.setHeight){B.style.height=D.offsetHeight+"px";}return B;}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(!document.createRange||Prototype.Browser.Opera){Element.Methods.insert=function(E,G){E=$(E);if(Object.isString(G)||Object.isNumber(G)||Object.isElement(G)||(G&&(G.toElement||G.toHTML))){G={bottom:G};}var D=Element._insertionTranslations,F,B,H,C;for(B in G){F=G[B];B=B.toLowerCase();H=D[B];if(F&&F.toElement){F=F.toElement();}if(Object.isElement(F)){H.insert(E,F);continue;}F=Object.toHTML(F);C=((B=="before"||B=="after")?E.parentNode:E).tagName.toUpperCase();if(D.tags[C]){var A=Element._getContentFromAnonymousElement(C,F.stripScripts());if(B=="top"||B=="after"){A.reverse();}A.each(H.insert.curry(E));}else{E.insertAdjacentHTML(H.adjacency,F.stripScripts());}F.evalScripts.bind(F).defer();}return E;};}if(Prototype.Browser.Opera){Element.Methods._getStyle=Element.Methods.getStyle;Element.Methods.getStyle=function(A,B){switch(B){case"left":case"top":case"right":case"bottom":if(Element._getStyle(A,"position")=="static"){return null;}default:return Element._getStyle(A,B);}};Element.Methods._readAttribute=Element.Methods.readAttribute;Element.Methods.readAttribute=function(A,B){if(B=="title"){return A.title;}return Element._readAttribute(A,B);};}else{if(Prototype.Browser.IE){$w("positionedOffset getOffsetParent viewportOffset").each(function(A){Element.Methods[A]=Element.Methods[A].wrap(function(D,C){C=$(C);var B=C.getStyle("position");if(B!="static"){return D(C);}C.setStyle({position:"relative"});var E=D(C);C.setStyle({position:B});return E;});});Element.Methods.getStyle=function(A,B){A=$(A);B=(B=="float"||B=="cssFloat")?"styleFloat":B.camelize();var C=A.style[B];if(!C&&A.currentStyle){C=A.currentStyle[B];}if(B=="opacity"){if(C=(A.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){if(C[1]){return parseFloat(C[1])/100;}}return 1;}if(C=="auto"){if((B=="width"||B=="height")&&(A.getStyle("display")!="none")){return A["offset"+B.capitalize()]+"px";}return null;}return C;};Element.Methods.setOpacity=function(B,E){function F(G){return G.replace(/alpha\([^\)]*\)/gi,"");}B=$(B);var A=B.currentStyle;if((A&&!A.hasLayout)||(!A&&B.style.zoom=="normal")){B.style.zoom=1;}var D=B.getStyle("filter"),C=B.style;if(E==1||E===""){(D=F(D))?C.filter=D:C.removeAttribute("filter");return B;}else{if(E<0.00001){E=0;}}C.filter=F(D)+"alpha(opacity="+(E*100)+")";return B;};Element._attributeTranslations={read:{names:{"class":"className","for":"htmlFor"},values:{_getAttr:function(A,B){return A.getAttribute(B,2);},_getAttrNode:function(A,C){var B=A.getAttributeNode(C);return B?B.value:"";},_getEv:function(A,B){var B=A.getAttribute(B);return B?B.toString().slice(23,-2):null;},_flag:function(A,B){return $(A).hasAttribute(B)?B:null;},style:function(A){return A.style.cssText.toLowerCase();},title:function(A){return A.title;}}}};Element._attributeTranslations.write={names:Object.clone(Element._attributeTranslations.read.names),values:{checked:function(A,B){A.checked=!!B;},style:function(A,B){A.style.cssText=B?B:"";}}};Element._attributeTranslations.has={};$w("colSpan rowSpan vAlign dateTime accessKey tabIndex encType maxLength readOnly longDesc").each(function(A){Element._attributeTranslations.write.names[A.toLowerCase()]=A;Element._attributeTranslations.has[A.toLowerCase()]=A;});(function(A){Object.extend(A,{href:A._getAttr,src:A._getAttr,type:A._getAttr,action:A._getAttrNode,disabled:A._flag,checked:A._flag,readonly:A._flag,multiple:A._flag,onload:A._getEv,onunload:A._getEv,onclick:A._getEv,ondblclick:A._getEv,onmousedown:A._getEv,onmouseup:A._getEv,onmouseover:A._getEv,onmousemove:A._getEv,onmouseout:A._getEv,onfocus:A._getEv,onblur:A._getEv,onkeypress:A._getEv,onkeydown:A._getEv,onkeyup:A._getEv,onsubmit:A._getEv,onreset:A._getEv,onselect:A._getEv,onchange:A._getEv});})(Element._attributeTranslations.read.values);}else{if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(A,B){A=$(A);A.style.opacity=(B==1)?0.999999:(B==="")?"":(B<0.00001)?0:B;return A;};}else{if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(A,B){A=$(A);A.style.opacity=(B==1||B==="")?"":(B<0.00001)?0:B;if(B==1){if(A.tagName=="IMG"&&A.width){A.width++;A.width--;}else{try{var D=document.createTextNode(" ");A.appendChild(D);A.removeChild(D);}catch(C){}}}return A;};Element.Methods.cumulativeOffset=function(B){var A=0,C=0;do{A+=B.offsetTop||0;C+=B.offsetLeft||0;if(B.offsetParent==document.body){if(Element.getStyle(B,"position")=="absolute"){break;}}B=B.offsetParent;}while(B);return Element._returnOffset(C,A);};}}}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(B,C){B=$(B);if(C&&C.toElement){C=C.toElement();}if(Object.isElement(C)){return B.update().insert(C);}C=Object.toHTML(C);var A=B.tagName.toUpperCase();if(A in Element._insertionTranslations.tags){$A(B.childNodes).each(function(D){B.removeChild(D);});Element._getContentFromAnonymousElement(A,C.stripScripts()).each(function(D){B.appendChild(D);});}else{B.innerHTML=C.stripScripts();}C.evalScripts.bind(C).defer();return B;};}if(document.createElement("div").outerHTML){Element.Methods.replace=function(C,E){C=$(C);if(E&&E.toElement){E=E.toElement();}if(Object.isElement(E)){C.parentNode.replaceChild(E,C);return C;}E=Object.toHTML(E);var D=C.parentNode,B=D.tagName.toUpperCase();if(Element._insertionTranslations.tags[B]){var F=C.next();var A=Element._getContentFromAnonymousElement(B,E.stripScripts());D.removeChild(C);if(F){A.each(function(G){D.insertBefore(G,F);});}else{A.each(function(G){D.appendChild(G);});}}else{C.outerHTML=E.stripScripts();}E.evalScripts.bind(E).defer();return C;};}Element._returnOffset=function(B,C){var A=[B,C];A.left=B;A.top=C;return A;};Element._getContentFromAnonymousElement=function(C,B){var D=new Element("div"),A=Element._insertionTranslations.tags[C];D.innerHTML=A[0]+B+A[1];A[2].times(function(){D=D.firstChild;});return $A(D.childNodes);};Element._insertionTranslations={before:{adjacency:"beforeBegin",insert:function(A,B){A.parentNode.insertBefore(B,A);},initializeRange:function(B,A){A.setStartBefore(B);}},top:{adjacency:"afterBegin",insert:function(A,B){A.insertBefore(B,A.firstChild);},initializeRange:function(B,A){A.selectNodeContents(B);A.collapse(true);}},bottom:{adjacency:"beforeEnd",insert:function(A,B){A.appendChild(B);}},after:{adjacency:"afterEnd",insert:function(A,B){A.parentNode.insertBefore(B,A.nextSibling);},initializeRange:function(B,A){A.setStartAfter(B);}},tags:{TABLE:["<table>","</table>",1],TBODY:["<table><tbody>","</tbody></table>",2],TR:["<table><tbody><tr>","</tr></tbody></table>",3],TD:["<table><tbody><tr><td>","</td></tr></tbody></table>",4],SELECT:["<select>","</select>",1]}};(function(){this.bottom.initializeRange=this.top.initializeRange;Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD});}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(A,C){C=Element._attributeTranslations.has[C]||C;var B=$(A).getAttributeNode(C);return B&&B.specified;}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){window.HTMLElement={};window.HTMLElement.prototype=document.createElement("div").__proto__;Prototype.BrowserFeatures.ElementExtensions=true;}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions){return Prototype.K;}var A={},B=Element.Methods.ByTag;var C=Object.extend(function(F){if(!F||F._extendedByPrototype||F.nodeType!=1||F==window){return F;}var D=Object.clone(A),E=F.tagName,H,G;if(B[E]){Object.extend(D,B[E]);}for(H in D){G=D[H];if(Object.isFunction(G)&&!(H in F)){F[H]=G.methodize();}}F._extendedByPrototype=Prototype.emptyFunction;return F;},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(A,Element.Methods);Object.extend(A,Element.Methods.Simulated);}}});C.refresh();return C;})();Element.hasAttribute=function(A,B){if(A.hasAttribute){return A.hasAttribute(B);}return Element.Methods.Simulated.hasAttribute(A,B);};Element.addMethods=function(C){var I=Prototype.BrowserFeatures,D=Element.Methods.ByTag;if(!C){Object.extend(Form,Form.Methods);Object.extend(Form.Element,Form.Element.Methods);Object.extend(Element.Methods.ByTag,{"FORM":Object.clone(Form.Methods),"INPUT":Object.clone(Form.Element.Methods),"SELECT":Object.clone(Form.Element.Methods),"TEXTAREA":Object.clone(Form.Element.Methods)});}if(arguments.length==2){var B=C;C=arguments[1];}if(!B){Object.extend(Element.Methods,C||{});}else{if(Object.isArray(B)){B.each(H);}else{H(B);}}function H(F){F=F.toUpperCase();if(!Element.Methods.ByTag[F]){Element.Methods.ByTag[F]={};}Object.extend(Element.Methods.ByTag[F],C);}function A(L,K,F){F=F||false;for(var N in L){var M=L[N];if(!Object.isFunction(M)){continue;}if(!F||!(N in K)){K[N]=M.methodize();}}}function E(L){var F;var K={"OPTGROUP":"OptGroup","TEXTAREA":"TextArea","P":"Paragraph","FIELDSET":"FieldSet","UL":"UList","OL":"OList","DL":"DList","DIR":"Directory","H1":"Heading","H2":"Heading","H3":"Heading","H4":"Heading","H5":"Heading","H6":"Heading","Q":"Quote","INS":"Mod","DEL":"Mod","A":"Anchor","IMG":"Image","CAPTION":"TableCaption","COL":"TableCol","COLGROUP":"TableCol","THEAD":"TableSection","TFOOT":"TableSection","TBODY":"TableSection","TR":"TableRow","TH":"TableCell","TD":"TableCell","FRAMESET":"FrameSet","IFRAME":"IFrame"};if(K[L]){F="HTML"+K[L]+"Element";}if(window[F]){return window[F];}F="HTML"+L+"Element";if(window[F]){return window[F];}F="HTML"+L.capitalize()+"Element";if(window[F]){return window[F];}window[F]={};window[F].prototype=document.createElement(L).__proto__;return window[F];}if(I.ElementExtensions){A(Element.Methods,HTMLElement.prototype);A(Element.Methods.Simulated,HTMLElement.prototype,true);}if(I.SpecificElementExtensions){for(var J in Element.Methods.ByTag){var G=E(J);if(Object.isUndefined(G)){continue;}A(D[J],G.prototype);}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh();}Element.cache={};};document.viewport={getDimensions:function(){var A={};$w("width height").each(function(C){var B=C.capitalize();A[C]=self["inner"+B]||(document.documentElement["client"+B]||document.body["client"+B]);});return A;},getWidth:function(){return this.getDimensions().width;},getHeight:function(){return this.getDimensions().height;},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop);}};var Selector=Class.create({initialize:function(A){this.expression=A.strip();this.compileMatcher();},compileMatcher:function(){if(Prototype.BrowserFeatures.XPath&&!(/(\[[\w-]*?:|:checked)/).test(this.expression)){return this.compileXPathMatcher();}var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return ;}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],"");break;}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join("\n"));Selector._cache[this.expression]=this.matcher;},compileXPathMatcher:function(){var E=this.expression,F=Selector.patterns,B=Selector.xpath,D,A;if(Selector._cache[E]){this.xpath=Selector._cache[E];return ;}this.matcher=[".//*"];while(E&&D!=E&&(/\S/).test(E)){D=E;for(var C in F){if(A=E.match(F[C])){this.matcher.push(Object.isFunction(B[C])?B[C](A):new Template(B[C]).evaluate(A));E=E.replace(A[0],"");break;}}}this.xpath=this.matcher.join("");Selector._cache[this.expression]=this.xpath;},findElements:function(A){A=A||document;if(this.xpath){return document._getElementsByXPath(this.xpath,A);}return this.matcher(A);},match:function(H){this.tokens=[];var L=this.expression,A=Selector.patterns,E=Selector.assertions;var B,D,F;while(L&&B!==L&&(/\S/).test(L)){B=L;for(var I in A){D=A[I];if(F=L.match(D)){if(E[I]){this.tokens.push([I,Object.clone(F)]);L=L.replace(F[0],"");}else{return this.findElements(document).include(H);}}}}var K=true,C,J;for(var I=0,G;G=this.tokens[I];I++){C=G[0],J=G[1];if(!Selector.assertions[C](H,J)){K=false;break;}}return K;},toString:function(){return this.expression;},inspect:function(){return"#<Selector:"+this.expression.inspect()+">";}});Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(A){if(A[1]=="*"){return"";}return"[local-name()='"+A[1].toLowerCase()+"' or local-name()='"+A[1].toUpperCase()+"']";},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:"[@#{1}]",attr:function(A){A[3]=A[5]||A[6];return new Template(Selector.xpath.operators[A[2]]).evaluate(A);},pseudo:function(A){var B=Selector.xpath.pseudos[A[1]];if(!B){return"";}if(Object.isFunction(B)){return B(A);}return new Template(Selector.xpath.pseudos[A[1]]).evaluate(A);},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]","empty":"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]","checked":"[@checked]","disabled":"[@disabled]","enabled":"[not(@disabled)]","not":function(B){var H=B[6],G=Selector.patterns,A=Selector.xpath,E,B,C;var F=[];while(H&&E!=H&&(/\S/).test(H)){E=H;for(var D in G){if(B=H.match(G[D])){C=Object.isFunction(A[D])?A[D](B):new Template(A[D]).evaluate(B);F.push("("+C.substring(1,C.length-1)+")");H=H.replace(B[0],"");break;}}}return"[not("+F.join(" and ")+")]";},"nth-child":function(A){return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",A);},"nth-last-child":function(A){return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",A);},"nth-of-type":function(A){return Selector.xpath.pseudos.nth("position() ",A);},"nth-last-of-type":function(A){return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",A);},"first-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-of-type"](A);},"last-of-type":function(A){A[6]="1";return Selector.xpath.pseudos["nth-last-of-type"](A);},"only-of-type":function(A){var B=Selector.xpath.pseudos;return B["first-of-type"](A)+B["last-of-type"](A);},nth:function(E,C){var F,G=C[6],B;if(G=="even"){G="2n+0";}if(G=="odd"){G="2n+1";}if(F=G.match(/^(\d+)$/)){return"["+E+"= "+F[1]+"]";}if(F=G.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(F[1]=="-"){F[1]=-1;}var D=F[1]?Number(F[1]):1;var A=F[2]?Number(F[2]):0;B="[((#{fragment} - #{b}) mod #{a} = 0) and ((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(B).evaluate({fragment:E,a:D,b:A});}}}},criteria:{tagName:'n = h.tagName(n, r, "#{1}", c);   c = false;',className:'n = h.className(n, r, "#{1}", c); c = false;',id:'n = h.id(n, r, "#{1}", c);        c = false;',attrPresence:'n = h.attrPresence(n, r, "#{1}"); c = false;',attr:function(A){A[3]=(A[5]||A[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}"); c = false;').evaluate(A);},pseudo:function(A){if(A[6]){A[6]=A[6].replace(/"/g,'\\"');}return new Template('n = h.pseudo(n, "#{1}", "#{6}", r, c); c = false;').evaluate(A);},descendant:'c = "descendant";',child:'c = "child";',adjacent:'c = "adjacent";',laterSibling:'c = "laterSibling";'},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|(?=\s)|(?=:))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(A,B){return B[1].toUpperCase()==A.tagName.toUpperCase();},className:function(A,B){return Element.hasClassName(A,B[1]);},id:function(A,B){return A.id===B[1];},attrPresence:function(A,B){return Element.hasAttribute(A,B[1]);},attr:function(B,C){var A=Element.readAttribute(B,C[1]);return Selector.operators[C[2]](A,C[3]);}},handlers:{concat:function(B,A){for(var C=0,D;D=A[C];C++){B.push(D);}return B;},mark:function(A){for(var B=0,C;C=A[B];B++){C._counted=true;}return A;},unmark:function(A){for(var B=0,C;C=A[B];B++){C._counted=undefined;}return A;},index:function(A,D,G){A._counted=true;if(D){for(var B=A.childNodes,E=B.length-1,C=1;E>=0;E--){var F=B[E];if(F.nodeType==1&&(!G||F._counted)){F.nodeIndex=C++;}}}else{for(var E=0,C=1,B=A.childNodes;F=B[E];E++){if(F.nodeType==1&&(!G||F._counted)){F.nodeIndex=C++;}}}},unique:function(B){if(B.length==0){return B;}var D=[],E;for(var C=0,A=B.length;C<A;C++){if(!(E=B[C])._counted){E._counted=true;D.push(Element.extend(E));}}return Selector.handlers.unmark(D);},descendant:function(A){var D=Selector.handlers;for(var C=0,B=[],E;E=A[C];C++){D.concat(B,E.getElementsByTagName("*"));}return B;},child:function(A){var F=Selector.handlers;for(var E=0,D=[],G;G=A[E];E++){for(var B=0,C=[],H;H=G.childNodes[B];B++){if(H.nodeType==1&&H.tagName!="!"){D.push(H);}}}return D;},adjacent:function(A){for(var C=0,B=[],E;E=A[C];C++){var D=this.nextElementSibling(E);if(D){B.push(D);}}return B;},laterSibling:function(A){var D=Selector.handlers;for(var C=0,B=[],E;E=A[C];C++){D.concat(B,Element.nextSiblings(E));}return B;},nextElementSibling:function(A){while(A=A.nextSibling){if(A.nodeType==1){return A;}}return null;},previousElementSibling:function(A){while(A=A.previousSibling){if(A.nodeType==1){return A;}}return null;},tagName:function(B,A,E,H){E=E.toUpperCase();var D=[],F=Selector.handlers;if(B){if(H){if(H=="descendant"){for(var C=0,G;G=B[C];C++){F.concat(D,G.getElementsByTagName(E));}return D;}else{B=this[H](B);}if(E=="*"){return B;}}for(var C=0,G;G=B[C];C++){if(G.tagName.toUpperCase()==E){D.push(G);}}return D;}else{return A.getElementsByTagName(E);}},id:function(B,A,H,F){var G=$(H),D=Selector.handlers;if(!G){return[];}if(!B&&A==document){return[G];}if(B){if(F){if(F=="child"){for(var C=0,E;E=B[C];C++){if(G.parentNode==E){return[G];}}}else{if(F=="descendant"){for(var C=0,E;E=B[C];C++){if(Element.descendantOf(G,E)){return[G];}}}else{if(F=="adjacent"){for(var C=0,E;E=B[C];C++){if(Selector.handlers.previousElementSibling(G)==E){return[G];}}}else{B=D[F](B);}}}}for(var C=0,E;E=B[C];C++){if(E==G){return[G];}}return[];}return(G&&Element.descendantOf(G,A))?[G]:[];},className:function(B,A,C,D){if(B&&D){B=this[D](B);}return Selector.handlers.byClassName(B,A,C);},byClassName:function(C,B,F){if(!C){C=Selector.handlers.descendant([B]);}var H=" "+F+" ";for(var E=0,D=[],G,A;G=C[E];E++){A=G.className;if(A.length==0){continue;}if(A==F||(" "+A+" ").include(H)){D.push(G);}}return D;},attrPresence:function(C,B,A){if(!C){C=B.getElementsByTagName("*");}var E=[];for(var D=0,F;F=C[D];D++){if(Element.hasAttribute(F,A)){E.push(F);}}return E;},attr:function(A,H,G,I,B){if(!A){A=H.getElementsByTagName("*");}var J=Selector.operators[B],D=[];for(var E=0,C;C=A[E];E++){var F=Element.readAttribute(C,G);if(F===null){continue;}if(J(F,I)){D.push(C);}}return D;},pseudo:function(B,C,E,A,D){if(B&&D){B=this[D](B);}if(!B){B=A.getElementsByTagName("*");}return Selector.pseudos[C](B,E,A);}},pseudos:{"first-child":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(Selector.handlers.previousElementSibling(E)){continue;}C.push(E);}return C;},"last-child":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(Selector.handlers.nextElementSibling(E)){continue;}C.push(E);}return C;},"only-child":function(B,G,A){var E=Selector.handlers;for(var D=0,C=[],F;F=B[D];D++){if(!E.previousElementSibling(F)&&!E.nextElementSibling(F)){C.push(F);}}return C;},"nth-child":function(B,C,A){return Selector.pseudos.nth(B,C,A);},"nth-last-child":function(B,C,A){return Selector.pseudos.nth(B,C,A,true);},"nth-of-type":function(B,C,A){return Selector.pseudos.nth(B,C,A,false,true);},"nth-last-of-type":function(B,C,A){return Selector.pseudos.nth(B,C,A,true,true);},"first-of-type":function(B,C,A){return Selector.pseudos.nth(B,"1",A,false,true);},"last-of-type":function(B,C,A){return Selector.pseudos.nth(B,"1",A,true,true);},"only-of-type":function(B,D,A){var C=Selector.pseudos;return C["last-of-type"](C["first-of-type"](B,D,A),D,A);},getIndices:function(B,A,C){if(B==0){return A>0?[A]:[];}return $R(1,C).inject([],function(D,E){if(0==(E-A)%B&&(E-A)/B>=0){D.push(E);}return D;});},nth:function(A,L,N,K,C){if(A.length==0){return[];}if(L=="even"){L="2n+0";}if(L=="odd"){L="2n+1";}var J=Selector.handlers,I=[],B=[],E;J.mark(A);for(var H=0,D;D=A[H];H++){if(!D.parentNode._counted){J.index(D.parentNode,K,C);B.push(D.parentNode);}}if(L.match(/^\d+$/)){L=Number(L);for(var H=0,D;D=A[H];H++){if(D.nodeIndex==L){I.push(D);}}}else{if(E=L.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(E[1]=="-"){E[1]=-1;}var O=E[1]?Number(E[1]):1;var M=E[2]?Number(E[2]):0;var P=Selector.pseudos.getIndices(O,M,A.length);for(var H=0,D,F=P.length;D=A[H];H++){for(var G=0;G<F;G++){if(D.nodeIndex==P[G]){I.push(D);}}}}}J.unmark(A);J.unmark(B);return I;},"empty":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.tagName=="!"||(E.firstChild&&!E.innerHTML.match(/^\s*$/))){continue;}C.push(E);}return C;},"not":function(A,D,I){var G=Selector.handlers,J,C;var H=new Selector(D).findElements(I);G.mark(H);for(var F=0,E=[],B;B=A[F];F++){if(!B._counted){E.push(B);}}G.unmark(H);return E;},"enabled":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(!E.disabled){C.push(E);}}return C;},"disabled":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.disabled){C.push(E);}}return C;},"checked":function(B,F,A){for(var D=0,C=[],E;E=B[D];D++){if(E.checked){C.push(E);}}return C;}},operators:{"=":function(B,A){return B==A;},"!=":function(B,A){return B!=A;},"^=":function(B,A){return B.startsWith(A);},"$=":function(B,A){return B.endsWith(A);},"*=":function(B,A){return B.include(A);},"~=":function(B,A){return(" "+B+" ").include(" "+A+" ");},"|=":function(B,A){return("-"+B.toUpperCase()+"-").include("-"+A.toUpperCase()+"-");}},matchElements:function(F,G){var E=new Selector(G).findElements(),D=Selector.handlers;D.mark(E);for(var C=0,B=[],A;A=F[C];C++){if(A._counted){B.push(A);}}D.unmark(E);return B;},findElement:function(B,C,A){if(Object.isNumber(C)){A=C;C=false;}return Selector.matchElements(B,C||"*")[A||0];},findChildElements:function(E,G){var H=G.join(","),G=[];H.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(I){G.push(I[1].strip());});var D=[],F=Selector.handlers;for(var C=0,B=G.length,A;C<B;C++){A=new Selector(G[C].strip());F.concat(D,A.findElements(E));}return(B>1)?F.unique(D):D;}});function $$(){return Selector.findChildElements(document,$A(arguments));}var Form={reset:function(A){$(A).reset();return A;},serializeElements:function(G,B){if(typeof B!="object"){B={hash:!!B};}else{if(B.hash===undefined){B.hash=true;}}var C,F,A=false,E=B.submit;var D=G.inject({},function(H,I){if(!I.disabled&&I.name){C=I.name;F=$(I).getValue();if(F!=null&&(I.type!="submit"||(!A&&E!==false&&(!E||C==E)&&(A=true)))){if(C in H){if(!Object.isArray(H[C])){H[C]=[H[C]];}H[C].push(F);}else{H[C]=F;}}}return H;});return B.hash?D:Object.toQueryString(D);}};Form.Methods={serialize:function(B,A){return Form.serializeElements(Form.getElements(B),A);},getElements:function(A){return $A($(A).getElementsByTagName("*")).inject([],function(B,C){if(Form.Element.Serializers[C.tagName.toLowerCase()]){B.push(Element.extend(C));}return B;});},getInputs:function(G,C,D){G=$(G);var A=G.getElementsByTagName("input");if(!C&&!D){return $A(A).map(Element.extend);}for(var E=0,H=[],F=A.length;E<F;E++){var B=A[E];if((C&&B.type!=C)||(D&&B.name!=D)){continue;}H.push(Element.extend(B));}return H;},disable:function(A){A=$(A);Form.getElements(A).invoke("disable");return A;},enable:function(A){A=$(A);Form.getElements(A).invoke("enable");return A;},findFirstElement:function(B){var C=$(B).getElements().findAll(function(D){return"hidden"!=D.type&&!D.disabled;});var A=C.findAll(function(D){return D.hasAttribute("tabIndex")&&D.tabIndex>=0;}).sortBy(function(D){return D.tabIndex;}).first();return A?A:C.find(function(D){return["input","select","textarea"].include(D.tagName.toLowerCase());});},focusFirstElement:function(A){A=$(A);A.findFirstElement().activate();return A;},request:function(B,A){B=$(B),A=Object.clone(A||{});var D=A.parameters,C=B.readAttribute("action")||"";if(C.blank()){C=window.location.href;}A.parameters=B.serialize(true);if(D){if(Object.isString(D)){D=D.toQueryParams();}Object.extend(A.parameters,D);}if(B.hasAttribute("method")&&!A.method){A.method=B.method;}return new Ajax.Request(C,A);}};Form.Element={focus:function(A){$(A).focus();return A;},select:function(A){$(A).select();return A;}};Form.Element.Methods={serialize:function(A){A=$(A);if(!A.disabled&&A.name){var B=A.getValue();if(B!=undefined){var C={};C[A.name]=B;return Object.toQueryString(C);}}return"";},getValue:function(A){A=$(A);var B=A.tagName.toLowerCase();return Form.Element.Serializers[B](A);},setValue:function(A,B){A=$(A);var C=A.tagName.toLowerCase();Form.Element.Serializers[C](A,B);return A;},clear:function(A){$(A).value="";return A;},present:function(A){return $(A).value!="";},activate:function(A){A=$(A);try{A.focus();if(A.select&&(A.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(A.type))){A.select();}}catch(B){}return A;},disable:function(A){A=$(A);A.blur();A.disabled=true;return A;},enable:function(A){A=$(A);A.disabled=false;return A;}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(A,B){switch(A.type.toLowerCase()){case"checkbox":case"radio":return Form.Element.Serializers.inputSelector(A,B);default:return Form.Element.Serializers.textarea(A,B);}},inputSelector:function(A,B){if(B===undefined){return A.checked?A.value:null;}else{A.checked=!!B;}},textarea:function(A,B){if(B===undefined){return A.value;}else{A.value=B;}},select:function(D,A){if(A===undefined){return this[D.type=="select-one"?"selectOne":"selectMany"](D);}else{var C,F,G=!Object.isArray(A);for(var B=0,E=D.length;B<E;B++){C=D.options[B];F=this.optionValue(C);if(G){if(F==A){C.selected=true;return ;}}else{C.selected=A.include(F);}}}},selectOne:function(B){var A=B.selectedIndex;return A>=0?this.optionValue(B.options[A]):null;},selectMany:function(D){var A,E=D.length;if(!E){return null;}for(var C=0,A=[];C<E;C++){var B=D.options[C];if(B.selected){A.push(this.optionValue(B));}}return A;},optionValue:function(A){return Element.extend(A).hasAttribute("value")?A.value:A.text;}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,A,B,C){$super(C,B);this.element=$(A);this.lastValue=this.getValue();},execute:function(){var A=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(A)?this.lastValue!=A:String(this.lastValue)!=String(A)){this.callback(this.element,A);this.lastValue=A;}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element);}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element);}});Abstract.EventObserver=Class.create({initialize:function(A,B){this.element=$(A);this.callback=B;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=="form"){this.registerFormCallbacks();}else{this.registerCallback(this.element);}},onElementEvent:function(){var A=this.getValue();if(this.lastValue!=A){this.callback(this.element,A);this.lastValue=A;}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this);},registerCallback:function(A){if(A.type){switch(A.type.toLowerCase()){case"checkbox":case"radio":Event.observe(A,"click",this.onElementEvent.bind(this));break;default:Event.observe(A,"change",this.onElementEvent.bind(this));break;}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element);}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element);}});if(!window.Event){var Event={};}Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(B){var A;switch(B.type){case"mouseover":A=B.fromElement;break;case"mouseout":A=B.toElement;break;default:return null;}return Element.extend(A);}});Event.Methods=(function(){var A;if(Prototype.Browser.IE){var B={0:1,1:4,2:2};A=function(D,C){return D.button==B[C];};}else{if(Prototype.Browser.WebKit){A=function(D,C){switch(C){case 0:return D.which==1&&!D.metaKey;case 1:return D.which==1&&D.metaKey;default:return false;}};}else{A=function(D,C){return D.which?(D.which===C+1):(D.button===C);};}}return{isLeftClick:function(C){return A(C,0);},isMiddleClick:function(C){return A(C,1);},isRightClick:function(C){return A(C,2);},element:function(D){var C=Event.extend(D).target;return Element.extend(C.nodeType==Node.TEXT_NODE?C.parentNode:C);},findElement:function(D,E){var C=Event.element(D);return C.match(E)?C:C.up(E);},pointer:function(C){return{x:C.pageX||(C.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft)),y:C.pageY||(C.clientY+(document.documentElement.scrollTop||document.body.scrollTop))};},pointerX:function(C){return Event.pointer(C).x;},pointerY:function(C){return Event.pointer(C).y;},stop:function(C){Event.extend(C);C.preventDefault();C.stopPropagation();C.stopped=true;}};})();Event.extend=(function(){var A=Object.keys(Event.Methods).inject({},function(B,C){B[C]=Event.Methods[C].methodize();return B;});if(Prototype.Browser.IE){Object.extend(A,{stopPropagation:function(){this.cancelBubble=true;},preventDefault:function(){this.returnValue=false;},inspect:function(){return"[object Event]";}});return function(B){if(!B){return false;}if(B._extendedByPrototype){return B;}B._extendedByPrototype=Prototype.emptyFunction;var C=Event.pointer(B);Object.extend(B,{target:B.srcElement,relatedTarget:Event.relatedTarget(B),pageX:C.x,pageY:C.y});return Object.extend(B,A);};}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents").__proto__;Object.extend(Event.prototype,A);return Prototype.K;}})();Object.extend(Event,(function(){var B=Event.cache;function C(J){if(J._eventID){return J._eventID;}arguments.callee.id=arguments.callee.id||1;return J._eventID=++arguments.callee.id;}function G(J){if(J&&J.include(":")){return"dataavailable";}return J;}function A(J){return B[J]=B[J]||{};}function F(L,J){var K=A(L);return K[J]=K[J]||[];}function H(K,J,L){var O=C(K);var N=F(O,J);if(N.pluck("handler").include(L)){return false;}var M=function(P){if(!Event||!Event.extend||(P.eventName&&P.eventName!=J)){return false;}Event.extend(P);L.call(K,P);};M.handler=L;N.push(M);return M;}function I(M,J,K){var L=F(M,J);return L.find(function(N){return N.handler==K;});}function D(M,J,K){var L=A(M);if(!L[J]){return false;}L[J]=L[J].without(I(M,J,K));}function E(){for(var K in B){for(var J in B[K]){B[K][J]=null;}}}if(window.attachEvent){window.attachEvent("onunload",E);}return{observe:function(L,J,M){L=$(L);var K=G(J);var N=H(L,J,M);if(!N){return L;}if(L.addEventListener){L.addEventListener(K,N,false);}else{L.attachEvent("on"+K,N);}return L;},stopObserving:function(L,J,M){L=$(L);var O=C(L),K=G(J);if(!M&&J){F(O,J).each(function(P){L.stopObserving(J,P.handler);});return L;}else{if(!J){Object.keys(A(O)).each(function(P){L.stopObserving(P);});return L;}}var N=I(O,J,M);if(!N){return L;}if(L.removeEventListener){L.removeEventListener(K,N,false);}else{L.detachEvent("on"+K,N);}D(O,J,M);return L;},fire:function(L,K,J){L=$(L);if(L==document&&document.createEvent&&!L.dispatchEvent){L=document.documentElement;}if(document.createEvent){var M=document.createEvent("HTMLEvents");M.initEvent("dataavailable",true,true);}else{var M=document.createEventObject();M.eventType="ondataavailable";}M.eventName=K;M.memo=J||{};if(document.createEvent){L.dispatchEvent(M);}else{L.fireEvent(M.eventType,M);}return M;}};})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize()});(function(){var C,B=false;function A(){if(B){return ;}if(C){window.clearInterval(C);}document.fire("dom:loaded");B=true;}if(document.addEventListener){if(Prototype.Browser.WebKit){C=window.setInterval(function(){if(/loaded|complete/.test(document.readyState)){A();}},0);Event.observe(window,"load",A);}else{document.addEventListener("DOMContentLoaded",A,false);}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;A();}};}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(A,B){return Element.insert(A,{before:B});},Top:function(A,B){return Element.insert(A,{top:B});},Bottom:function(A,B){return Element.insert(A,{bottom:B});},After:function(A,B){return Element.insert(A,{after:B});}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0;},within:function(B,A,C){if(this.includeScrollOffsets){return this.withinIncludingScrolloffsets(B,A,C);}this.xcomp=A;this.ycomp=C;this.offset=Element.cumulativeOffset(B);return(C>=this.offset[1]&&C<this.offset[1]+B.offsetHeight&&A>=this.offset[0]&&A<this.offset[0]+B.offsetWidth);},withinIncludingScrolloffsets:function(B,A,D){var C=Element.cumulativeScrollOffset(B);this.xcomp=A+C[0]-this.deltaX;this.ycomp=D+C[1]-this.deltaY;this.offset=Element.cumulativeOffset(B);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+B.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+B.offsetWidth);},overlap:function(B,A){if(!B){return 0;}if(B=="vertical"){return((this.offset[1]+A.offsetHeight)-this.ycomp)/A.offsetHeight;}if(B=="horizontal"){return((this.offset[0]+A.offsetWidth)-this.xcomp)/A.offsetWidth;}},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(A){Position.prepare();return Element.absolutize(A);},relativize:function(A){Position.prepare();return Element.relativize(A);},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(B,C,A){A=A||{};return Element.clonePosition(C,B,A);}};if(!document.getElementsByClassName){document.getElementsByClassName=function(B){function A(C){return C.blank()?null:"[contains(concat(' ', @class, ' '), ' "+C+" ')]";}B.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(C,E){E=E.toString().strip();var D=/\s/.test(E)?$w(E).map(A).join(""):A(E);return D?document._getElementsByXPath(".//*"+D,C):[];}:function(E,F){F=F.toString().strip();var G=[],H=(/\s/.test(F)?$w(F):null);if(!H&&!F){return G;}var C=$(E).getElementsByTagName("*");F=" "+F+" ";for(var D=0,J,I;J=C[D];D++){if(J.className&&(I=" "+J.className+" ")&&(I.include(F)||(H&&H.all(function(K){return !K.toString().blank()&&I.include(" "+K+" ");})))){G.push(Element.extend(J));}}return G;};return function(D,C){return $(C||document.body).getElementsByClassName(D);};}(Element.Methods);}Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(A){this.element=$(A);},_each:function(A){this.element.className.split(/\s+/).select(function(B){return B.length>0;})._each(A);},set:function(A){this.element.className=A;},add:function(A){if(this.include(A)){return ;}this.set($A(this).concat(A).join(" "));},remove:function(A){if(!this.include(A)){return ;}this.set($A(this).without(A).join(" "));},toString:function(){return $A(this).join(" ");}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();
/*  Copyright Mihai Bazon, 2002-2005  |  www.bazon.net/mishoo
* -----------------------------------------------------------
*
* The DHTML Calendar, version 1.0 "It is happening again"
*
* Details and latest version at:
* www.dynarch.com/projects/calendar
*
* This script is developed by Dynarch.com.  Visit us at www.dynarch.com.
*
* This script is distributed under the GNU Lesser General Public License.
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*/
Calendar=function(firstDayOfWeek,dateStr,onSelected,onClose){this.activeDiv=null;this.currentDateEl=null;this.getDateStatus=null;this.getDateToolTip=null;this.getDateText=null;this.timeout=null;this.onSelected=onSelected||null;this.onClose=onClose||null;this.dragging=false;this.hidden=false;this.minYear=1970;this.maxYear=2050;this.dateFormat=Calendar._TT["DEF_DATE_FORMAT"];this.ttDateFormat=Calendar._TT["TT_DATE_FORMAT"];this.isPopup=true;this.weekNumbers=true;this.firstDayOfWeek=typeof firstDayOfWeek=="number"?firstDayOfWeek:Calendar._FD;this.showsOtherMonths=false;this.dateStr=dateStr;this.ar_days=null;this.showsTime=false;this.time24=true;this.yearStep=2;this.hiliteToday=true;this.multiple=null;this.table=null;this.element=null;this.tbody=null;this.firstdayname=null;this.monthsCombo=null;this.yearsCombo=null;this.hilitedMonth=null;this.activeMonth=null;this.hilitedYear=null;this.activeYear=null;this.dateClicked=false;if(typeof Calendar._SDN=="undefined"){if(typeof Calendar._SDN_len=="undefined")Calendar._SDN_len=3;var ar=new Array();for(var i=8;i>0;){ar[--i]=Calendar._DN[i].substr(0,Calendar._SDN_len);}Calendar._SDN=ar;if(typeof Calendar._SMN_len=="undefined")Calendar._SMN_len=3;ar=new Array();for(var i=12;i>0;){ar[--i]=Calendar._MN[i].substr(0,Calendar._SMN_len);}Calendar._SMN=ar;}};Calendar._C=null;Calendar.is_ie=(/msie/i.test(navigator.userAgent)&&!/opera/i.test(navigator.userAgent));Calendar.is_ie5=(Calendar.is_ie&&/msie 5\.0/i.test(navigator.userAgent));Calendar.is_opera=/opera/i.test(navigator.userAgent);Calendar.is_khtml=/Konqueror|Safari|KHTML/i.test(navigator.userAgent);Calendar.getAbsolutePos=function(el){var SL=0,ST=0;var is_div=/^div$/i.test(el.tagName);if(is_div&&el.scrollLeft)SL=el.scrollLeft;if(is_div&&el.scrollTop)ST=el.scrollTop;var r={x:el.offsetLeft-SL,y:el.offsetTop-ST};if(el.offsetParent){var tmp=this.getAbsolutePos(el.offsetParent);r.x+=tmp.x;r.y+=tmp.y;}return r;};Calendar.isRelated=function(el,evt){var related=evt.relatedTarget;if(!related){var type=evt.type;if(type=="mouseover"){related=evt.fromElement;}else if(type=="mouseout"){related=evt.toElement;}}while(related){if(related==el){return true;}related=related.parentNode;}return false;};Calendar.removeClass=function(el,className){if(!(el&&el.className)){return;}var cls=el.className.split(" ");var ar=new Array();for(var i=cls.length;i>0;){if(cls[--i]!=className){ar[ar.length]=cls[i];}}el.className=ar.join(" ");};Calendar.addClass=function(el,className){Calendar.removeClass(el,className);el.className+=" "+className;};Calendar.getElement=function(ev){var f=Calendar.is_ie?window.event.srcElement:ev.currentTarget;while(f.nodeType!=1||/^div$/i.test(f.tagName))f=f.parentNode;return f;};Calendar.getTargetElement=function(ev){var f=Calendar.is_ie?window.event.srcElement:ev.target;while(f.nodeType!=1)f=f.parentNode;return f;};Calendar.stopEvent=function(ev){ev||(ev=window.event);if(Calendar.is_ie){ev.cancelBubble=true;ev.returnValue=false;}else{ev.preventDefault();ev.stopPropagation();}return false;};Calendar.addEvent=function(el,evname,func){if(el.attachEvent){el.attachEvent("on"+evname,func);}else if(el.addEventListener){el.addEventListener(evname,func,true);}else{el["on"+evname]=func;}};Calendar.removeEvent=function(el,evname,func){if(el.detachEvent){el.detachEvent("on"+evname,func);}else if(el.removeEventListener){el.removeEventListener(evname,func,true);}else{el["on"+evname]=null;}};Calendar.createElement=function(type,parent){var el=null;if(document.createElementNS){el=document.createElementNS("http://www.w3.org/1999/xhtml",type);}else{el=document.createElement(type);}if(typeof parent!="undefined"){parent.appendChild(el);}return el;};Calendar._add_evs=function(el){with(Calendar){addEvent(el,"mouseover",dayMouseOver);addEvent(el,"mousedown",dayMouseDown);addEvent(el,"mouseout",dayMouseOut);if(is_ie){addEvent(el,"dblclick",dayMouseDblClick);el.setAttribute("unselectable",true);}}};Calendar.findMonth=function(el){if(typeof el.month!="undefined"){return el;}else if(typeof el.parentNode.month!="undefined"){return el.parentNode;}return null;};Calendar.findYear=function(el){if(typeof el.year!="undefined"){return el;}else if(typeof el.parentNode.year!="undefined"){return el.parentNode;}return null;};Calendar.showMonthsCombo=function(){var cal=Calendar._C;if(!cal){return false;}var cal=cal;var cd=cal.activeDiv;var mc=cal.monthsCombo;if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}if(cal.activeMonth){Calendar.removeClass(cal.activeMonth,"active");}var mon=cal.monthsCombo.getElementsByTagName("div")[cal.date.getMonth()];Calendar.addClass(mon,"active");cal.activeMonth=mon;var s=mc.style;s.display="block";if(cd.navtype<0)s.left=cd.offsetLeft+"px";else{var mcw=mc.offsetWidth;if(typeof mcw=="undefined")mcw=50;s.left=(cd.offsetLeft+cd.offsetWidth-mcw)+"px";}s.top=(cd.offsetTop+cd.offsetHeight)+"px";};Calendar.showYearsCombo=function(fwd){var cal=Calendar._C;if(!cal){return false;}var cal=cal;var cd=cal.activeDiv;var yc=cal.yearsCombo;if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}if(cal.activeYear){Calendar.removeClass(cal.activeYear,"active");}cal.activeYear=null;var Y=cal.date.getFullYear()+(fwd?1:-1);var yr=yc.firstChild;var show=false;for(var i=12;i>0;--i){if(Y>=cal.minYear&&Y<=cal.maxYear){yr.innerHTML=Y;yr.year=Y;yr.style.display="block";show=true;}else{yr.style.display="none";}yr=yr.nextSibling;Y+=fwd?cal.yearStep:-cal.yearStep;}if(show){var s=yc.style;s.display="block";if(cd.navtype<0)s.left=cd.offsetLeft+"px";else{var ycw=yc.offsetWidth;if(typeof ycw=="undefined")ycw=50;s.left=(cd.offsetLeft+cd.offsetWidth-ycw)+"px";}s.top=(cd.offsetTop+cd.offsetHeight)+"px";}};Calendar.tableMouseUp=function(ev){var cal=Calendar._C;if(!cal){return false;}if(cal.timeout){clearTimeout(cal.timeout);}var el=cal.activeDiv;if(!el){return false;}var target=Calendar.getTargetElement(ev);ev||(ev=window.event);Calendar.removeClass(el,"active");if(target==el||target.parentNode==el){Calendar.cellClick(el,ev);}var mon=Calendar.findMonth(target);var date=null;if(mon){date=new Date(cal.date);if(mon.month!=date.getMonth()){date.setMonth(mon.month);cal.setDate(date);cal.dateClicked=false;cal.callHandler();}}else{var year=Calendar.findYear(target);if(year){date=new Date(cal.date);if(year.year!=date.getFullYear()){date.setFullYear(year.year);cal.setDate(date);cal.dateClicked=false;cal.callHandler();}}}with(Calendar){removeEvent(document,"mouseup",tableMouseUp);removeEvent(document,"mouseover",tableMouseOver);removeEvent(document,"mousemove",tableMouseOver);cal._hideCombos();_C=null;return stopEvent(ev);}};Calendar.tableMouseOver=function(ev){var cal=Calendar._C;if(!cal){return;}var el=cal.activeDiv;var target=Calendar.getTargetElement(ev);if(target==el||target.parentNode==el){Calendar.addClass(el,"hilite active");Calendar.addClass(el.parentNode,"rowhilite");}else{if(typeof el.navtype=="undefined"||(el.navtype!=50&&(el.navtype==0||Math.abs(el.navtype)>2)))Calendar.removeClass(el,"active");Calendar.removeClass(el,"hilite");Calendar.removeClass(el.parentNode,"rowhilite");}ev||(ev=window.event);if(el.navtype==50&&target!=el){var pos=Calendar.getAbsolutePos(el);var w=el.offsetWidth;var x=ev.clientX;var dx;var decrease=true;if(x>pos.x+w){dx=x-pos.x-w;decrease=false;}else dx=pos.x-x;if(dx<0)dx=0;var range=el._range;var current=el._current;var count=Math.floor(dx/10)%range.length;for(var i=range.length;--i>=0;)if(range[i]==current)break;while(count-->0)if(decrease){if(--i<0)i=range.length-1;}else if(++i>=range.length)i=0;var newval=range[i];el.innerHTML=newval;cal.onUpdateTime();}var mon=Calendar.findMonth(target);if(mon){if(mon.month!=cal.date.getMonth()){if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}Calendar.addClass(mon,"hilite");cal.hilitedMonth=mon;}else if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}}else{if(cal.hilitedMonth){Calendar.removeClass(cal.hilitedMonth,"hilite");}var year=Calendar.findYear(target);if(year){if(year.year!=cal.date.getFullYear()){if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}Calendar.addClass(year,"hilite");cal.hilitedYear=year;}else if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}}else if(cal.hilitedYear){Calendar.removeClass(cal.hilitedYear,"hilite");}}return Calendar.stopEvent(ev);};Calendar.tableMouseDown=function(ev){if(Calendar.getTargetElement(ev)==Calendar.getElement(ev)){return Calendar.stopEvent(ev);}};Calendar.calDragIt=function(ev){var cal=Calendar._C;if(!(cal&&cal.dragging)){return false;}var posX;var posY;if(Calendar.is_ie){posY=window.event.clientY+document.body.scrollTop;posX=window.event.clientX+document.body.scrollLeft;}else{posX=ev.pageX;posY=ev.pageY;}cal.hideShowCovered();var st=cal.element.style;st.left=(posX-cal.xOffs)+"px";st.top=(posY-cal.yOffs)+"px";return Calendar.stopEvent(ev);};Calendar.calDragEnd=function(ev){var cal=Calendar._C;if(!cal){return false;}cal.dragging=false;with(Calendar){removeEvent(document,"mousemove",calDragIt);removeEvent(document,"mouseup",calDragEnd);tableMouseUp(ev);}cal.hideShowCovered();};Calendar.dayMouseDown=function(ev){var el=Calendar.getElement(ev);if(el.disabled){return false;}var cal=el.calendar;cal.activeDiv=el;Calendar._C=cal;if(el.navtype!=300)with(Calendar){if(el.navtype==50){el._current=el.innerHTML;addEvent(document,"mousemove",tableMouseOver);}else addEvent(document,Calendar.is_ie5?"mousemove":"mouseover",tableMouseOver);addClass(el,"hilite active");addEvent(document,"mouseup",tableMouseUp);}else if(cal.isPopup){cal._dragStart(ev);}if(el.navtype==-1||el.navtype==1){if(cal.timeout)clearTimeout(cal.timeout);cal.timeout=setTimeout("Calendar.showMonthsCombo()",250);}else if(el.navtype==-2||el.navtype==2){if(cal.timeout)clearTimeout(cal.timeout);cal.timeout=setTimeout((el.navtype>0)?"Calendar.showYearsCombo(true)":"Calendar.showYearsCombo(false)",250);}else{cal.timeout=null;}return Calendar.stopEvent(ev);};Calendar.dayMouseDblClick=function(ev){Calendar.cellClick(Calendar.getElement(ev),ev||window.event);if(Calendar.is_ie){document.selection.empty();}};Calendar.dayMouseOver=function(ev){var el=Calendar.getElement(ev);if(Calendar.isRelated(el,ev)||Calendar._C||el.disabled){return false;}if(el.ttip){if(el.ttip.substr(0,1)=="_"){el.ttip=el.caldate.print(el.calendar.ttDateFormat)+el.ttip.substr(1);}el.calendar.tooltips.innerHTML=el.ttip;}if(el.navtype!=300){Calendar.addClass(el,"hilite");if(el.caldate){Calendar.addClass(el.parentNode,"rowhilite");}}return Calendar.stopEvent(ev);};Calendar.dayMouseOut=function(ev){with(Calendar){var el=getElement(ev);if(isRelated(el,ev)||_C||el.disabled)return false;removeClass(el,"hilite");if(el.caldate)removeClass(el.parentNode,"rowhilite");if(el.calendar)el.calendar.tooltips.innerHTML=_TT["SEL_DATE"];return stopEvent(ev);}};Calendar.cellClick=function(el,ev){var cal=el.calendar;var closing=false;var newdate=false;var date=null;if(typeof el.navtype=="undefined"){if(cal.currentDateEl){Calendar.removeClass(cal.currentDateEl,"selected");Calendar.addClass(el,"selected");closing=(cal.currentDateEl==el);if(!closing){cal.currentDateEl=el;}}cal.date.setDateOnly(el.caldate);date=cal.date;var other_month=!(cal.dateClicked=!el.otherMonth);if(!other_month&&!cal.currentDateEl)cal._toggleMultipleDate(new Date(date));else newdate=!el.disabled;if(other_month)cal._init(cal.firstDayOfWeek,date);}else{if(el.navtype==200){Calendar.removeClass(el,"hilite");cal.callCloseHandler();return;}date=new Date(cal.date);if(el.navtype==0)date.setDateOnly(new Date());cal.dateClicked=false;var year=date.getFullYear();var mon=date.getMonth();function setMonth(m){var day=date.getDate();var max=date.getMonthDays(m);if(day>max){date.setDate(max);}date.setMonth(m);};switch(el.navtype){case 400:Calendar.removeClass(el,"hilite");var text=Calendar._TT["ABOUT"];if(typeof text!="undefined"){text+=cal.showsTime?Calendar._TT["ABOUT_TIME"]:"";}else{text="Help and about box text is not translated into this language.\n"+"If you know this language and you feel generous please update\n"+"the corresponding file in \"lang\" subdir to match calendar-en.js\n"+"and send it back to <mihai_bazon@yahoo.com> to get it into the distribution  ;-)\n\n"+"Thank you!\n"+"http://dynarch.com/mishoo/calendar.epl\n";}alert(text);return;case-2:if(year>cal.minYear){date.setFullYear(year-1);}break;case-1:if(mon>0){setMonth(mon-1);}else if(year-->cal.minYear){date.setFullYear(year);setMonth(11);}break;case 1:if(mon<11){setMonth(mon+1);}else if(year<cal.maxYear){date.setFullYear(year+1);setMonth(0);}break;case 2:if(year<cal.maxYear){date.setFullYear(year+1);}break;case 100:cal.setFirstDayOfWeek(el.fdow);return;case 50:var range=el._range;var current=el.innerHTML;for(var i=range.length;--i>=0;)if(range[i]==current)break;if(ev&&ev.shiftKey){if(--i<0)i=range.length-1;}else if(++i>=range.length)i=0;var newval=range[i];el.innerHTML=newval;cal.onUpdateTime();return;case 0:if((typeof cal.getDateStatus=="function")&&cal.getDateStatus(date,date.getFullYear(),date.getMonth(),date.getDate())){return false;}break;}if(!date.equalsTo(cal.date)){cal.setDate(date);newdate=true;}else if(el.navtype==0)newdate=closing=true;}if(newdate){ev&&cal.callHandler();}if(closing){Calendar.removeClass(el,"hilite");ev&&cal.callCloseHandler();}};Calendar.prototype.create=function(_par){var parent=null;if(!_par){parent=document.getElementsByTagName("body")[0];this.isPopup=true;}else{parent=_par;this.isPopup=false;}this.date=this.dateStr?new Date(this.dateStr):new Date();var table=Calendar.createElement("table");this.table=table;table.cellSpacing=0;table.cellPadding=0;table.calendar=this;Calendar.addEvent(table,"mousedown",Calendar.tableMouseDown);var div=Calendar.createElement("div");this.element=div;div.className="calendar";if(this.isPopup){div.style.position="absolute";div.style.display="none";}div.appendChild(table);var thead=Calendar.createElement("thead",table);var cell=null;var row=null;var cal=this;var hh=function(text,cs,navtype){cell=Calendar.createElement("td",row);cell.colSpan=cs;cell.className="button";if(navtype!=0&&Math.abs(navtype)<=2)cell.className+=" nav";Calendar._add_evs(cell);cell.calendar=cal;cell.navtype=navtype;cell.innerHTML="<div unselectable='on'>"+text+"</div>";return cell;};row=Calendar.createElement("tr",thead);var title_length=6;(this.isPopup)&&--title_length;(this.weekNumbers)&&++title_length;hh("?",1,400).ttip=Calendar._TT["INFO"];this.title=hh("",title_length,300);this.title.className="title";if(this.isPopup){this.title.ttip=Calendar._TT["DRAG_TO_MOVE"];this.title.style.cursor="move";hh("&#x00d7;",1,200).ttip=Calendar._TT["CLOSE"];}row=Calendar.createElement("tr",thead);row.className="headrow";this._nav_py=hh("&#x00ab;",1,-2);this._nav_py.ttip=Calendar._TT["PREV_YEAR"];this._nav_pm=hh("&#x2039;",1,-1);this._nav_pm.ttip=Calendar._TT["PREV_MONTH"];this._nav_now=hh(Calendar._TT["TODAY"],this.weekNumbers?4:3,0);this._nav_now.ttip=Calendar._TT["GO_TODAY"];this._nav_nm=hh("&#x203a;",1,1);this._nav_nm.ttip=Calendar._TT["NEXT_MONTH"];this._nav_ny=hh("&#x00bb;",1,2);this._nav_ny.ttip=Calendar._TT["NEXT_YEAR"];row=Calendar.createElement("tr",thead);row.className="daynames";if(this.weekNumbers){cell=Calendar.createElement("td",row);cell.className="name wn";cell.innerHTML=Calendar._TT["WK"];}for(var i=7;i>0;--i){cell=Calendar.createElement("td",row);if(!i){cell.navtype=100;cell.calendar=this;Calendar._add_evs(cell);}}this.firstdayname=(this.weekNumbers)?row.firstChild.nextSibling:row.firstChild;this._displayWeekdays();var tbody=Calendar.createElement("tbody",table);this.tbody=tbody;for(i=6;i>0;--i){row=Calendar.createElement("tr",tbody);if(this.weekNumbers){cell=Calendar.createElement("td",row);}for(var j=7;j>0;--j){cell=Calendar.createElement("td",row);cell.calendar=this;Calendar._add_evs(cell);}}if(this.showsTime){row=Calendar.createElement("tr",tbody);row.className="time";cell=Calendar.createElement("td",row);cell.className="time";cell.colSpan=2;cell.innerHTML=Calendar._TT["TIME"]||"&nbsp;";cell=Calendar.createElement("td",row);cell.className="time";cell.colSpan=this.weekNumbers?4:3;(function(){function makeTimePart(className,init,range_start,range_end){var part=Calendar.createElement("span",cell);part.className=className;part.innerHTML=init;part.calendar=cal;part.ttip=Calendar._TT["TIME_PART"];part.navtype=50;part._range=[];if(typeof range_start!="number")part._range=range_start;else{for(var i=range_start;i<=range_end;++i){var txt;if(i<10&&range_end>=10)txt='0'+i;else txt=''+i;part._range[part._range.length]=txt;}}Calendar._add_evs(part);return part;};var hrs=cal.date.getHours();var mins=cal.date.getMinutes();var t12=!cal.time24;var pm=(hrs>12);if(t12&&pm)hrs-=12;var H=makeTimePart("hour",hrs,t12?1:0,t12?12:23);var span=Calendar.createElement("span",cell);span.innerHTML=":";span.className="colon";var M=makeTimePart("minute",mins,0,59);var AP=null;cell=Calendar.createElement("td",row);cell.className="time";cell.colSpan=2;if(t12)AP=makeTimePart("ampm",pm?"pm":"am",["am","pm"]);else cell.innerHTML="&nbsp;";cal.onSetTime=function(){var pm,hrs=this.date.getHours(),mins=this.date.getMinutes();if(t12){pm=(hrs>=12);if(pm)hrs-=12;if(hrs==0)hrs=12;AP.innerHTML=pm?"pm":"am";}H.innerHTML=(hrs<10)?("0"+hrs):hrs;M.innerHTML=(mins<10)?("0"+mins):mins;};cal.onUpdateTime=function(){var date=this.date;var h=parseInt(H.innerHTML,10);if(t12){if(/pm/i.test(AP.innerHTML)&&h<12)h+=12;else if(/am/i.test(AP.innerHTML)&&h==12)h=0;}var d=date.getDate();var m=date.getMonth();var y=date.getFullYear();date.setHours(h);date.setMinutes(parseInt(M.innerHTML,10));date.setFullYear(y);date.setMonth(m);date.setDate(d);this.dateClicked=false;this.callHandler();};})();}else{this.onSetTime=this.onUpdateTime=function(){};}var tfoot=Calendar.createElement("tfoot",table);row=Calendar.createElement("tr",tfoot);row.className="footrow";cell=hh(Calendar._TT["SEL_DATE"],this.weekNumbers?8:7,300);cell.className="ttip";if(this.isPopup){cell.ttip=Calendar._TT["DRAG_TO_MOVE"];cell.style.cursor="move";}this.tooltips=cell;div=Calendar.createElement("div",this.element);this.monthsCombo=div;div.className="combo";for(i=0;i<Calendar._MN.length;++i){var mn=Calendar.createElement("div");mn.className=Calendar.is_ie?"label-IEfix":"label";mn.month=i;mn.innerHTML=Calendar._SMN[i];div.appendChild(mn);}div=Calendar.createElement("div",this.element);this.yearsCombo=div;div.className="combo";for(i=12;i>0;--i){var yr=Calendar.createElement("div");yr.className=Calendar.is_ie?"label-IEfix":"label";div.appendChild(yr);}this._init(this.firstDayOfWeek,this.date);parent.appendChild(this.element);};Calendar._keyEvent=function(ev){var cal=window._dynarch_popupCalendar;if(!cal||cal.multiple)return false;(Calendar.is_ie)&&(ev=window.event);var act=(Calendar.is_ie||ev.type=="keypress"),K=ev.keyCode;if(ev.ctrlKey){switch(K){case 37:act&&Calendar.cellClick(cal._nav_pm);break;case 38:act&&Calendar.cellClick(cal._nav_py);break;case 39:act&&Calendar.cellClick(cal._nav_nm);break;case 40:act&&Calendar.cellClick(cal._nav_ny);break;default:return false;}}else switch(K){case 32:Calendar.cellClick(cal._nav_now);break;case 27:act&&cal.callCloseHandler();break;case 37:case 38:case 39:case 40:if(act){var prev,x,y,ne,el,step;prev=K==37||K==38;step=(K==37||K==39)?1:7;function setVars(){el=cal.currentDateEl;var p=el.pos;x=p&15;y=p>>4;ne=cal.ar_days[y][x];};setVars();function prevMonth(){var date=new Date(cal.date);date.setDate(date.getDate()-step);cal.setDate(date);};function nextMonth(){var date=new Date(cal.date);date.setDate(date.getDate()+step);cal.setDate(date);};while(1){switch(K){case 37:if(--x>=0)ne=cal.ar_days[y][x];else{x=6;K=38;continue;}break;case 38:if(--y>=0)ne=cal.ar_days[y][x];else{prevMonth();setVars();}break;case 39:if(++x<7)ne=cal.ar_days[y][x];else{x=0;K=40;continue;}break;case 40:if(++y<cal.ar_days.length)ne=cal.ar_days[y][x];else{nextMonth();setVars();}break;}break;}if(ne){if(!ne.disabled)Calendar.cellClick(ne);else if(prev)prevMonth();else nextMonth();}}break;case 13:if(act)Calendar.cellClick(cal.currentDateEl,ev);break;default:return false;}return Calendar.stopEvent(ev);};Calendar.prototype._init=function(firstDayOfWeek,date){var today=new Date(),TY=today.getFullYear(),TM=today.getMonth(),TD=today.getDate();this.table.style.visibility="hidden";var year=date.getFullYear();if(year<this.minYear){year=this.minYear;date.setFullYear(year);}else if(year>this.maxYear){year=this.maxYear;date.setFullYear(year);}this.firstDayOfWeek=firstDayOfWeek;this.date=new Date(date);var month=date.getMonth();var mday=date.getDate();var no_days=date.getMonthDays();date.setDate(1);var day1=(date.getDay()-this.firstDayOfWeek)%7;if(day1<0)day1+=7;date.setDate(-day1);date.setDate(date.getDate()+1);var row=this.tbody.firstChild;var MN=Calendar._SMN[month];var ar_days=this.ar_days=new Array();var weekend=Calendar._TT["WEEKEND"];var dates=this.multiple?(this.datesCells={}):null;for(var i=0;i<6;++i,row=row.nextSibling){var cell=row.firstChild;if(this.weekNumbers){cell.className="day wn";cell.innerHTML=date.getWeekNumber();cell=cell.nextSibling;}row.className="daysrow";var hasdays=false,iday,dpos=ar_days[i]=[];for(var j=0;j<7;++j,cell=cell.nextSibling,date.setDate(iday+1)){iday=date.getDate();var wday=date.getDay();cell.className="day";cell.pos=i<<4|j;dpos[j]=cell;var current_month=(date.getMonth()==month);if(!current_month){if(this.showsOtherMonths){cell.className+=" othermonth";cell.otherMonth=true;}else{cell.className="emptycell";cell.innerHTML="&nbsp;";cell.disabled=true;continue;}}else{cell.otherMonth=false;hasdays=true;}cell.disabled=false;cell.innerHTML=this.getDateText?this.getDateText(date,iday):iday;if(dates)dates[date.print("%Y%m%d")]=cell;if(this.getDateStatus){var status=this.getDateStatus(date,year,month,iday);if(this.getDateToolTip){var toolTip=this.getDateToolTip(date,year,month,iday);if(toolTip)cell.title=toolTip;}if(status===true){cell.className+=" disabled";cell.disabled=true;}else{if(/disabled/i.test(status))cell.disabled=true;cell.className+=" "+status;}}if(!cell.disabled){cell.caldate=new Date(date);cell.ttip="_";if(!this.multiple&&current_month&&iday==mday&&this.hiliteToday){cell.className+=" selected";this.currentDateEl=cell;}if(date.getFullYear()==TY&&date.getMonth()==TM&&iday==TD){cell.className+=" today";cell.ttip+=Calendar._TT["PART_TODAY"];}if(weekend.indexOf(wday.toString())!=-1)cell.className+=cell.otherMonth?" oweekend":" weekend";}}if(!(hasdays||this.showsOtherMonths))row.className="emptyrow";}this.title.innerHTML=Calendar._MN[month]+", "+year;this.onSetTime();this.table.style.visibility="visible";this._initMultipleDates();};Calendar.prototype._initMultipleDates=function(){if(this.multiple){for(var i in this.multiple){var cell=this.datesCells[i];var d=this.multiple[i];if(!d)continue;if(cell)cell.className+=" selected";}}};Calendar.prototype._toggleMultipleDate=function(date){if(this.multiple){var ds=date.print("%Y%m%d");var cell=this.datesCells[ds];if(cell){var d=this.multiple[ds];if(!d){Calendar.addClass(cell,"selected");this.multiple[ds]=date;}else{Calendar.removeClass(cell,"selected");delete this.multiple[ds];}}}};Calendar.prototype.setDateToolTipHandler=function(unaryFunction){this.getDateToolTip=unaryFunction;};Calendar.prototype.setDate=function(date){if(!date.equalsTo(this.date)){this._init(this.firstDayOfWeek,date);}};Calendar.prototype.refresh=function(){this._init(this.firstDayOfWeek,this.date);};Calendar.prototype.setFirstDayOfWeek=function(firstDayOfWeek){this._init(firstDayOfWeek,this.date);this._displayWeekdays();};Calendar.prototype.setDateStatusHandler=Calendar.prototype.setDisabledHandler=function(unaryFunction){this.getDateStatus=unaryFunction;};Calendar.prototype.setRange=function(a,z){this.minYear=a;this.maxYear=z;};Calendar.prototype.callHandler=function(){if(this.onSelected){this.onSelected(this,this.date.print(this.dateFormat));}};Calendar.prototype.callCloseHandler=function(){if(this.onClose){this.onClose(this);}this.hideShowCovered();};Calendar.prototype.destroy=function(){var el=this.element.parentNode;el.removeChild(this.element);Calendar._C=null;window._dynarch_popupCalendar=null;};Calendar.prototype.reparent=function(new_parent){var el=this.element;el.parentNode.removeChild(el);new_parent.appendChild(el);};Calendar._checkCalendar=function(ev){var calendar=window._dynarch_popupCalendar;if(!calendar){return false;}var el=Calendar.is_ie?Calendar.getElement(ev):Calendar.getTargetElement(ev);for(;el!=null&&el!=calendar.element;el=el.parentNode);if(el==null){window._dynarch_popupCalendar.callCloseHandler();return Calendar.stopEvent(ev);}};Calendar.prototype.show=function(){var rows=this.table.getElementsByTagName("tr");for(var i=rows.length;i>0;){var row=rows[--i];Calendar.removeClass(row,"rowhilite");var cells=row.getElementsByTagName("td");for(var j=cells.length;j>0;){var cell=cells[--j];Calendar.removeClass(cell,"hilite");Calendar.removeClass(cell,"active");}}this.element.style.display="block";this.hidden=false;if(this.isPopup){window._dynarch_popupCalendar=this;Calendar.addEvent(document,"keydown",Calendar._keyEvent);Calendar.addEvent(document,"keypress",Calendar._keyEvent);Calendar.addEvent(document,"mousedown",Calendar._checkCalendar);}this.hideShowCovered();};Calendar.prototype.hide=function(){if(this.isPopup){Calendar.removeEvent(document,"keydown",Calendar._keyEvent);Calendar.removeEvent(document,"keypress",Calendar._keyEvent);Calendar.removeEvent(document,"mousedown",Calendar._checkCalendar);}this.element.style.display="none";this.hidden=true;this.hideShowCovered();};Calendar.prototype.showAt=function(x,y){var s=this.element.style;s.left=x+"px";s.top=y+"px";this.show();};Calendar.prototype.showAtElement=function(el,opts){var self=this;var p=Calendar.getAbsolutePos(el);if(!opts||typeof opts!="string"){this.showAt(p.x,p.y+el.offsetHeight);return true;}function fixPosition(box){if(box.x<0)box.x=0;if(box.y<0)box.y=0;var cp=document.createElement("div");var s=cp.style;s.position="absolute";s.right=s.bottom=s.width=s.height="0px";document.body.appendChild(cp);var br=Calendar.getAbsolutePos(cp);document.body.removeChild(cp);if(Calendar.is_ie){br.y+=document.body.scrollTop;br.x+=document.body.scrollLeft;}else{br.y+=window.scrollY;br.x+=window.scrollX;}var tmp=box.x+box.width-br.x;if(tmp>0)box.x-=tmp;tmp=box.y+box.height-br.y;if(tmp>0)box.y-=tmp;};this.element.style.display="block";Calendar.continuation_for_the_fucking_khtml_browser=function(){var w=self.element.offsetWidth;var h=self.element.offsetHeight;self.element.style.display="none";var valign=opts.substr(0,1);var halign="l";if(opts.length>1){halign=opts.substr(1,1);}switch(valign){case "T":p.y-=h;break;case "B":p.y+=el.offsetHeight;break;case "C":p.y+=(el.offsetHeight-h)/2;break;case "t":p.y+=el.offsetHeight-h;break;case "b":break;}switch(halign){case "L":p.x-=w;break;case "R":p.x+=el.offsetWidth;break;case "C":p.x+=(el.offsetWidth-w)/2;break;case "l":p.x+=el.offsetWidth-w;break;case "r":break;}p.width=w;p.height=h+40;self.monthsCombo.style.display="none";fixPosition(p);self.showAt(p.x,p.y);};if(Calendar.is_khtml)setTimeout("Calendar.continuation_for_the_fucking_khtml_browser()",10);else Calendar.continuation_for_the_fucking_khtml_browser();};Calendar.prototype.setDateFormat=function(str){this.dateFormat=str;};Calendar.prototype.setTtDateFormat=function(str){this.ttDateFormat=str;};Calendar.prototype.parseDate=function(str,fmt){if(!fmt)fmt=this.dateFormat;this.setDate(Date.parseDate(str,fmt));};Calendar.prototype.hideShowCovered=function(){if(!Calendar.is_ie&&!Calendar.is_opera)return;function getVisib(obj){var value=obj.style.visibility;if(!value){if(document.defaultView&&typeof(document.defaultView.getComputedStyle)=="function"){if(!Calendar.is_khtml)value=document.defaultView. getComputedStyle(obj,"").getPropertyValue("visibility");else value='';}else if(obj.currentStyle){value=obj.currentStyle.visibility;}else value='';}return value;};var tags=new Array("applet","iframe","select");var el=this.element;var p=Calendar.getAbsolutePos(el);var EX1=p.x;var EX2=el.offsetWidth+EX1;var EY1=p.y;var EY2=el.offsetHeight+EY1;for(var k=tags.length;k>0;){var ar=document.getElementsByTagName(tags[--k]);var cc=null;for(var i=ar.length;i>0;){cc=ar[--i];p=Calendar.getAbsolutePos(cc);var CX1=p.x;var CX2=cc.offsetWidth+CX1;var CY1=p.y;var CY2=cc.offsetHeight+CY1;if(this.hidden||(CX1>EX2)||(CX2<EX1)||(CY1>EY2)||(CY2<EY1)){if(!cc.__msh_save_visibility){cc.__msh_save_visibility=getVisib(cc);}cc.style.visibility=cc.__msh_save_visibility;}else{if(!cc.__msh_save_visibility){cc.__msh_save_visibility=getVisib(cc);}cc.style.visibility="hidden";}}}};Calendar.prototype._displayWeekdays=function(){var fdow=this.firstDayOfWeek;var cell=this.firstdayname;var weekend=Calendar._TT["WEEKEND"];for(var i=0;i<7;++i){cell.className="day name";var realday=(i+fdow)%7;if(i){cell.ttip=Calendar._TT["DAY_FIRST"].replace("%s",Calendar._DN[realday]);cell.navtype=100;cell.calendar=this;cell.fdow=realday;Calendar._add_evs(cell);}if(weekend.indexOf(realday.toString())!=-1){Calendar.addClass(cell,"weekend");}cell.innerHTML=Calendar._SDN[(i+fdow)%7];cell=cell.nextSibling;}};Calendar.prototype._hideCombos=function(){this.monthsCombo.style.display="none";this.yearsCombo.style.display="none";};Calendar.prototype._dragStart=function(ev){if(this.dragging){return;}this.dragging=true;var posX;var posY;if(Calendar.is_ie){posY=window.event.clientY+document.body.scrollTop;posX=window.event.clientX+document.body.scrollLeft;}else{posY=ev.clientY+window.scrollY;posX=ev.clientX+window.scrollX;}var st=this.element.style;this.xOffs=posX-parseInt(st.left);this.yOffs=posY-parseInt(st.top);with(Calendar){addEvent(document,"mousemove",calDragIt);addEvent(document,"mouseup",calDragEnd);}};Date._MD=new Array(31,28,31,30,31,30,31,31,30,31,30,31);Date.SECOND=1000;Date.MINUTE=60*Date.SECOND;Date.HOUR=60*Date.MINUTE;Date.DAY=24*Date.HOUR;Date.WEEK=7*Date.DAY;Date.parseDate=function(str,fmt){var today=new Date();var y=0;var m=-1;var d=0;var a=str.split(/\W+/);var b=fmt.match(/%./g);var i=0,j=0;var hr=0;var min=0;for(i=0;i<a.length;++i){if(!a[i])continue;switch(b[i]){case "%d":case "%e":d=parseInt(a[i],10);break;case "%m":m=parseInt(a[i],10)-1;break;case "%Y":case "%y":y=parseInt(a[i],10);(y<100)&&(y+=(y>29)?1900:2000);break;case "%b":case "%B":for(j=0;j<12;++j){if(Calendar._MN[j].substr(0,a[i].length).toLowerCase()==a[i].toLowerCase()){m=j;break;}}break;case "%H":case "%I":case "%k":case "%l":hr=parseInt(a[i],10);break;case "%P":case "%p":if(/pm/i.test(a[i])&&hr<12)hr+=12;else if(/am/i.test(a[i])&&hr>=12)hr-=12;break;case "%M":min=parseInt(a[i],10);break;}}if(isNaN(y))y=today.getFullYear();if(isNaN(m))m=today.getMonth();if(isNaN(d))d=today.getDate();if(isNaN(hr))hr=today.getHours();if(isNaN(min))min=today.getMinutes();if(y!=0&&m!=-1&&d!=0)return new Date(y,m,d,hr,min,0);y=0;m=-1;d=0;for(i=0;i<a.length;++i){if(a[i].search(/[a-zA-Z]+/)!=-1){var t=-1;for(j=0;j<12;++j){if(Calendar._MN[j].substr(0,a[i].length).toLowerCase()==a[i].toLowerCase()){t=j;break;}}if(t!=-1){if(m!=-1){d=m+1;}m=t;}}else if(parseInt(a[i],10)<=12&&m==-1){m=a[i]-1;}else if(parseInt(a[i],10)>31&&y==0){y=parseInt(a[i],10);(y<100)&&(y+=(y>29)?1900:2000);}else if(d==0){d=a[i];}}if(y==0)y=today.getFullYear();if(m!=-1&&d!=0)return new Date(y,m,d,hr,min,0);return today;};Date.prototype.getMonthDays=function(month){var year=this.getFullYear();if(typeof month=="undefined"){month=this.getMonth();}if(((0==(year%4))&&((0!=(year%100))||(0==(year%400))))&&month==1){return 29;}else{return Date._MD[month];}};Date.prototype.getDayOfYear=function(){var now=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var then=new Date(this.getFullYear(),0,0,0,0,0);var time=now-then;return Math.floor(time/Date.DAY);};Date.prototype.getWeekNumber=function(){var d=new Date(this.getFullYear(),this.getMonth(),this.getDate(),0,0,0);var DoW=d.getDay();d.setDate(d.getDate()-(DoW+6)%7+3);var ms=d.valueOf();d.setMonth(0);d.setDate(4);return Math.round((ms-d.valueOf())/(7*864e5))+1;};Date.prototype.equalsTo=function(date){return((this.getFullYear()==date.getFullYear())&&(this.getMonth()==date.getMonth())&&(this.getDate()==date.getDate())&&(this.getHours()==date.getHours())&&(this.getMinutes()==date.getMinutes()));};Date.prototype.setDateOnly=function(date){var tmp=new Date(date);this.setDate(1);this.setFullYear(tmp.getFullYear());this.setMonth(tmp.getMonth());this.setDate(tmp.getDate());};Date.prototype.print=function(str){var m=this.getMonth();var d=this.getDate();var y=this.getFullYear();var wn=this.getWeekNumber();var w=this.getDay();var s={};var hr=this.getHours();var pm=(hr>=12);var ir=(pm)?(hr-12):hr;var dy=this.getDayOfYear();if(ir==0)ir=12;var min=this.getMinutes();var sec=this.getSeconds();s["%a"]=Calendar._SDN[w];s["%A"]=Calendar._DN[w];s["%b"]=Calendar._SMN[m];s["%B"]=Calendar._MN[m];s["%C"]=1+Math.floor(y/100);s["%d"]=(d<10)?("0"+d):d;s["%e"]=d;s["%H"]=(hr<10)?("0"+hr):hr;s["%I"]=(ir<10)?("0"+ir):ir;s["%j"]=(dy<100)?((dy<10)?("00"+dy):("0"+dy)):dy;s["%k"]=hr;s["%l"]=ir;s["%m"]=(m<9)?("0"+(1+m)):(1+m);s["%M"]=(min<10)?("0"+min):min;s["%n"]="\n";s["%p"]=pm?"PM":"AM";s["%P"]=pm?"pm":"am";s["%s"]=Math.floor(this.getTime()/1000);s["%S"]=(sec<10)?("0"+sec):sec;s["%t"]="\t";s["%U"]=s["%W"]=s["%V"]=(wn<10)?("0"+wn):wn;s["%u"]=w+1;s["%w"]=w;s["%y"]=(''+y).substr(2,2);s["%Y"]=y;s["%%"]="%";var re=/%./g;if(!Calendar.is_ie5&&!Calendar.is_khtml)return str.replace(re,function(par){return s[par]||par;});var a=str.match(re);for(var i=0;i<a.length;i++){var tmp=s[a[i]];if(tmp){re=new RegExp(a[i],'g');str=str.replace(re,tmp);}}return str;};Date.prototype.__msh_oldSetFullYear=Date.prototype.setFullYear;Date.prototype.setFullYear=function(y){var d=new Date(this);d.__msh_oldSetFullYear(y);if(d.getMonth()!=this.getMonth())this.setDate(28);this.__msh_oldSetFullYear(y);};window._dynarch_popupCalendar=null;
Calendar._DN = new Array
("Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday",
"Sunday");
Calendar._SDN = new Array
("Sun",
"Mon",
"Tue",
"Wed",
"Thu",
"Fri",
"Sat",
"Sun");
Calendar._FD = 0;
Calendar._MN = new Array
("January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December");
Calendar._SMN = new Array
("Jan",
"Feb",
"Mar",
"Apr",
"May",
"Jun",
"Jul",
"Aug",
"Sep",
"Oct",
"Nov",
"Dec");
Calendar._TT = {};
Calendar._TT["INFO"] = "About the calendar";
Calendar._TT["ABOUT"] =
"DHTML Date/Time Selector\n" +
"(c) dynarch.com 2002-2005 / Author: Mihai Bazon\n" + // don't translate this this ;-)
"For latest version visit: http://www.dynarch.com/projects/calendar/\n" +
"Distributed under GNU LGPL.  See http://gnu.org/licenses/lgpl.html for details." +
"\n\n" +
"Date selection:\n" +
"- Use the \xab, \xbb buttons to select year\n" +
"- Use the " + String.fromCharCode(0x2039) + ", " + String.fromCharCode(0x203a) + " buttons to select month\n" +
"- Hold mouse button on any of the above buttons for faster selection.";
Calendar._TT["ABOUT_TIME"] = "\n\n" +
"Time selection:\n" +
"- Click on any of the time parts to increase it\n" +
"- or Shift-click to decrease it\n" +
"- or click and drag for faster selection.";
Calendar._TT["PREV_YEAR"] = "Prev. year (hold for menu)";
Calendar._TT["PREV_MONTH"] = "Prev. month (hold for menu)";
Calendar._TT["GO_TODAY"] = "Go Today";
Calendar._TT["NEXT_MONTH"] = "Next month (hold for menu)";
Calendar._TT["NEXT_YEAR"] = "Next year (hold for menu)";
Calendar._TT["SEL_DATE"] = "Select date";
Calendar._TT["DRAG_TO_MOVE"] = "Drag to move";
Calendar._TT["PART_TODAY"] = " (today)";
Calendar._TT["DAY_FIRST"] = "Display %s first";
Calendar._TT["WEEKEND"] = "0,6";
Calendar._TT["CLOSE"] = "Close";
Calendar._TT["TODAY"] = "Today";
Calendar._TT["TIME_PART"] = "(Shift-)Click or drag to change value";
Calendar._TT["DEF_DATE_FORMAT"] = "%Y-%m-%d";
Calendar._TT["TT_DATE_FORMAT"] = "%a, %b %e";
Calendar._TT["WK"] = "wk";
Calendar._TT["TIME"] = "Time:";
/*  Copyright Mihai Bazon, 2002, 2003  |  http://dynarch.com/mishoo/
* ---------------------------------------------------------------------------
*
* The DHTML Calendar
*
* Details and latest version at:
* http://dynarch.com/mishoo/calendar.epl
*
* This script is distributed under the GNU Lesser General Public License.
* Read the entire license text here: http://www.gnu.org/licenses/lgpl.html
*
* This file defines helper functions for setting up the calendar.  They are
* intended to help non-programmers get a working calendar on their site
* quickly.  This script should not be seen as part of the calendar.  It just
* shows you what one can do with the calendar, while in the same time
* providing a quick and simple method for setting it up.  If you need
* exhaustive customization of the calendar creation process feel free to
* modify this code to suit your needs (this is recommended and much better
* than modifying calendar.js itself).
*/
Calendar.setup=function(params){function param_default(pname,def){if(typeof params[pname]=="undefined"){params[pname]=def;}};param_default("inputField",null);param_default("displayArea",null);param_default("button",null);param_default("eventName","click");param_default("ifFormat","%Y/%m/%d");param_default("daFormat","%Y/%m/%d");param_default("singleClick",true);param_default("disableFunc",null);param_default("dateStatusFunc",params["disableFunc"]);param_default("dateText",null);param_default("firstDay",1);param_default("align","Br");param_default("range",[1900,2999]);param_default("weekNumbers",true);param_default("flat",null);param_default("flatCallback",null);param_default("onSelect",null);param_default("onClose",null);param_default("onUpdate",null);param_default("date",null);param_default("showsTime",false);param_default("timeFormat","24");param_default("electric",true);param_default("step",2);param_default("position",null);param_default("cache",false);param_default("showOthers",false);param_default("multiple",null);var tmp=["inputField","displayArea","button"];for(var i in tmp){if(typeof params[tmp[i]]=="string"){params[tmp[i]]=document.getElementById(params[tmp[i]]);}}if(!(params.flat||params.multiple||params.inputField||params.displayArea||params.button)){alert("Calendar.setup:\n  Nothing to setup (no fields found).  Please check your code");return false;}function onSelect(cal){var p=cal.params;var update=(cal.dateClicked||p.electric);if(update&&p.inputField){p.inputField.value=cal.date.print(p.ifFormat);if(typeof p.inputField.onchange=="function")p.inputField.onchange();}if(update&&p.displayArea)p.displayArea.innerHTML=cal.date.print(p.daFormat);if(update&&typeof p.onUpdate=="function")p.onUpdate(cal);if(update&&p.flat){if(typeof p.flatCallback=="function")p.flatCallback(cal);}if(update&&p.singleClick&&cal.dateClicked)cal.callCloseHandler();};if(params.flat!=null){if(typeof params.flat=="string")params.flat=document.getElementById(params.flat);if(!params.flat){alert("Calendar.setup:\n  Flat specified but can't find parent.");return false;}var cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect);cal.showsOtherMonths=params.showOthers;cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.params=params;cal.weekNumbers=params.weekNumbers;cal.setRange(params.range[0],params.range[1]);cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;if(params.ifFormat){cal.setDateFormat(params.ifFormat);}if(params.inputField&&typeof params.inputField.value=="string"){cal.parseDate(params.inputField.value);}cal.create(params.flat);cal.show();return false;}var triggerEl=params.button||params.displayArea||params.inputField;triggerEl["on"+params.eventName]=function(){var dateEl=params.inputField||params.displayArea;var dateFmt=params.inputField?params.ifFormat:params.daFormat;var mustCreate=false;var cal=window.calendar;if(dateEl)params.date=Date.parseDate(dateEl.value||dateEl.innerHTML,dateFmt);if(!(cal&&params.cache)){window.calendar=cal=new Calendar(params.firstDay,params.date,params.onSelect||onSelect,params.onClose||function(cal){cal.hide();});cal.showsTime=params.showsTime;cal.time24=(params.timeFormat=="24");cal.weekNumbers=params.weekNumbers;mustCreate=true;}else{if(params.date)cal.setDate(params.date);cal.hide();}if(params.multiple){cal.multiple={};for(var i=params.multiple.length;--i>=0;){var d=params.multiple[i];var ds=d.print("%Y%m%d");cal.multiple[ds]=d;}}cal.showsOtherMonths=params.showOthers;cal.yearStep=params.step;cal.setRange(params.range[0],params.range[1]);cal.params=params;cal.setDateStatusHandler(params.dateStatusFunc);cal.getDateText=params.dateText;cal.setDateFormat(dateFmt);if(mustCreate)cal.create();cal.refresh();if(!params.position)cal.showAtElement(params.button||params.displayArea||params.inputField,params.align);else cal.showAt(params.position[0],params.position[1]);return false;};return cal;};
var Window = Class.create();
Window.keepMultiModalWindow = false;
Window.hasEffectLib = (typeof Effect != 'undefined');
Window.resizeEffectDuration = 0.4;
Window.prototype = {
initialize: function() {
var id;
var optionIndex = 0;
if (arguments.length > 0) {
if (typeof arguments[0] == "string" ) {
id = arguments[0];
optionIndex = 1;
}
else
id = arguments[0] ? arguments[0].id : null;
}
if (!id)
id = "window_" + new Date().getTime();
if ($(id))
alert("Window " + id + " is already registered in the DOM! Make sure you use setDestroyOnClose() or destroyOnClose: true in the constructor");
this.options = Object.extend({
className:         "dialog",
blurClassName:     null,
minWidth:          100,
minHeight:         20,
resizable:         true,
closable:          true,
minimizable:       true,
maximizable:       true,
draggable:         true,
userData:          null,
showEffect:        (Window.hasEffectLib ? Effect.Appear : Element.show),
hideEffect:        (Window.hasEffectLib ? Effect.Fade : Element.hide),
showEffectOptions: {},
hideEffectOptions: {},
effectOptions:     null,
parent:            document.body,
title:             "&nbsp;",
url:               null,
onload:            Prototype.emptyFunction,
width:             200,
height:            300,
opacity:           1,
recenterAuto:      true,
wiredDrag:         false,
closeCallback:     null,
destroyOnClose:    false,
gridX:             1,
gridY:             1
}, arguments[optionIndex] || {});
if (this.options.blurClassName)
this.options.focusClassName = this.options.className;
if (typeof this.options.top == "undefined" &&  typeof this.options.bottom ==  "undefined")
this.options.top = this._round(Math.random()*500, this.options.gridY);
if (typeof this.options.left == "undefined" &&  typeof this.options.right ==  "undefined")
this.options.left = this._round(Math.random()*500, this.options.gridX);
if (this.options.effectOptions) {
Object.extend(this.options.hideEffectOptions, this.options.effectOptions);
Object.extend(this.options.showEffectOptions, this.options.effectOptions);
if (this.options.showEffect == Element.Appear)
this.options.showEffectOptions.to = this.options.opacity;
}
if (Window.hasEffectLib) {
if (this.options.showEffect == Effect.Appear)
this.options.showEffectOptions.to = this.options.opacity;
if (this.options.hideEffect == Effect.Fade)
this.options.hideEffectOptions.from = this.options.opacity;
}
if (this.options.hideEffect == Element.hide)
this.options.hideEffect = function(){ Element.hide(this.element); if (this.options.destroyOnClose) this.destroy(); }.bind(this)
if (this.options.parent != document.body)
this.options.parent = $(this.options.parent);
this.element = this._createWindow(id);
this.element.win = this;
this.eventMouseDown = this._initDrag.bindAsEventListener(this);
this.eventMouseUp   = this._endDrag.bindAsEventListener(this);
this.eventMouseMove = this._updateDrag.bindAsEventListener(this);
this.eventOnLoad    = this._getWindowBorderSize.bindAsEventListener(this);
this.eventMouseDownContent = this.toFront.bindAsEventListener(this);
this.eventResize = this._recenter.bindAsEventListener(this);
this.topbar = $(this.element.id + "_top");
this.bottombar = $(this.element.id + "_bottom");
this.content = $(this.element.id + "_content");
Event.observe(this.topbar, "mousedown", this.eventMouseDown);
Event.observe(this.bottombar, "mousedown", this.eventMouseDown);
Event.observe(this.content, "mousedown", this.eventMouseDownContent);
Event.observe(window, "load", this.eventOnLoad);
Event.observe(window, "resize", this.eventResize);
Event.observe(window, "scroll", this.eventResize);
Event.observe(this.options.parent, "scroll", this.eventResize);
if (this.options.draggable)  {
var that = this;
[this.topbar, this.topbar.up().previous(), this.topbar.up().next()].each(function(element) {
element.observe("mousedown", that.eventMouseDown);
element.addClassName("top_draggable");
});
[this.bottombar.up(), this.bottombar.up().previous(), this.bottombar.up().next()].each(function(element) {
element.observe("mousedown", that.eventMouseDown);
element.addClassName("bottom_draggable");
});
}
if (this.options.resizable) {
this.sizer = $(this.element.id + "_sizer");
Event.observe(this.sizer, "mousedown", this.eventMouseDown);
}
this.useLeft = null;
this.useTop = null;
if (typeof this.options.left != "undefined") {
this.element.setStyle({left: parseFloat(this.options.left) + 'px'});
this.useLeft = true;
}
else {
this.element.setStyle({right: parseFloat(this.options.right) + 'px'});
this.useLeft = false;
}
if (typeof this.options.top != "undefined") {
this.element.setStyle({top: parseFloat(this.options.top) + 'px'});
this.useTop = true;
}
else {
this.element.setStyle({bottom: parseFloat(this.options.bottom) + 'px'});
this.useTop = false;
}
this.storedLocation = null;
this.setOpacity(this.options.opacity);
if (this.options.zIndex)
this.setZIndex(this.options.zIndex)
if (this.options.destroyOnClose)
this.setDestroyOnClose(true);
this._getWindowBorderSize();
this.width = this.options.width;
this.height = this.options.height;
this.visible = false;
this.constraint = false;
this.constraintPad = {top: 0, left:0, bottom:0, right:0};
if (this.width && this.height)
this.setSize(this.options.width, this.options.height);
this.setTitle(this.options.title)
Windows.register(this);
},
destroy: function() {
this._notify("onDestroy");
Event.stopObserving(this.topbar, "mousedown", this.eventMouseDown);
Event.stopObserving(this.bottombar, "mousedown", this.eventMouseDown);
Event.stopObserving(this.content, "mousedown", this.eventMouseDownContent);
Event.stopObserving(window, "load", this.eventOnLoad);
Event.stopObserving(window, "resize", this.eventResize);
Event.stopObserving(window, "scroll", this.eventResize);
Event.stopObserving(this.content, "load", this.options.onload);
if (this._oldParent) {
var content = this.getContent();
var originalContent = null;
for(var i = 0; i < content.childNodes.length; i++) {
originalContent = content.childNodes[i];
if (originalContent.nodeType == 1)
break;
originalContent = null;
}
if (originalContent)
this._oldParent.appendChild(originalContent);
this._oldParent = null;
}
if (this.sizer)
Event.stopObserving(this.sizer, "mousedown", this.eventMouseDown);
if (this.options.url)
this.content.src = null
if(this.iefix)
Element.remove(this.iefix);
Element.remove(this.element);
Windows.unregister(this);
},
setCloseCallback: function(callback) {
this.options.closeCallback = callback;
},
getContent: function () {
return this.content;
},
setContent: function(id, autoresize, autoposition) {
var element = $(id);
if (null == element) throw "Unable to find element '" + id + "' in DOM";
this._oldParent = element.parentNode;
var d = null;
var p = null;
if (autoresize)
d = Element.getDimensions(element);
if (autoposition)
p = Position.cumulativeOffset(element);
var content = this.getContent();
this.setHTMLContent("");
content = this.getContent();
content.appendChild(element);
element.show();
if (autoresize)
this.setSize(d.width, d.height);
if (autoposition)
this.setLocation(p[1] - this.heightN, p[0] - this.widthW);
},
setHTMLContent: function(html) {
if (this.options.url) {
this.content.src = null;
this.options.url = null;
  var content ="<div id=\"" + this.getId() + "_content\" class=\"" + this.options.className + "_content\"> </div>";
$(this.getId() +"_table_content").innerHTML = content;
this.content = $(this.element.id + "_content");
}
this.getContent().innerHTML = html;
},
setAjaxContent: function(url, options, showCentered, showModal) {
this.showFunction = showCentered ? "showCenter" : "show";
this.showModal = showModal || false;
options = options || {};
this.setHTMLContent("");
this.onComplete = options.onComplete;
if (! this._onCompleteHandler)
this._onCompleteHandler = this._setAjaxContent.bind(this);
options.onComplete = this._onCompleteHandler;
new Ajax.Request(url, options);
options.onComplete = this.onComplete;
},
_setAjaxContent: function(originalRequest) {
Element.update(this.getContent(), originalRequest.responseText);
if (this.onComplete)
this.onComplete(originalRequest);
this.onComplete = null;
this[this.showFunction](this.showModal)
},
setURL: function(url) {
if (this.options.url)
this.content.src = null;
this.options.url = url;
var content= "<iframe frameborder='0' name='" + this.getId() + "_content'  id='" + this.getId() + "_content' src='" + url + "' width='" + this.width + "' height='" + this.height + "'> </iframe>";
$(this.getId() +"_table_content").innerHTML = content;
this.content = $(this.element.id + "_content");
},
getURL: function() {
return this.options.url ? this.options.url : null;
},
refresh: function() {
if (this.options.url)
    $(this.element.getAttribute('id') + '_content').src = this.options.url;
},
setCookie: function(name, expires, path, domain, secure) {
name = name || this.element.id;
this.cookie = [name, expires, path, domain, secure];
var value = WindowUtilities.getCookie(name)
if (value) {
var values = value.split(',');
var x = values[0].split(':');
var y = values[1].split(':');
var w = parseFloat(values[2]), h = parseFloat(values[3]);
var mini = values[4];
var maxi = values[5];
this.setSize(w, h);
if (mini == "true")
this.doMinimize = true; // Minimize will be done at onload window event
else if (maxi == "true")
this.doMaximize = true; // Maximize will be done at onload window event
this.useLeft = x[0] == "l";
this.useTop = y[0] == "t";
this.element.setStyle(this.useLeft ? {left: x[1]} : {right: x[1]});
this.element.setStyle(this.useTop ? {top: y[1]} : {bottom: y[1]});
}
},
getId: function() {
return this.element.id;
},
setDestroyOnClose: function() {
this.options.destroyOnClose = true;
},
setConstraint: function(bool, padding) {
this.constraint = bool;
this.constraintPad = Object.extend(this.constraintPad, padding || {});
if (this.useTop && this.useLeft)
this.setLocation(parseFloat(this.element.style.top), parseFloat(this.element.style.left));
},
_initDrag: function(event) {
if (Event.element(event) == this.sizer && this.isMinimized())
return;
if (Event.element(event) != this.sizer && this.isMaximized())
return;
if (Prototype.Browser.IE && this.heightN == 0)
this._getWindowBorderSize();
this.pointer = [this._round(Event.pointerX(event), this.options.gridX), this._round(Event.pointerY(event), this.options.gridY)];
if (this.options.wiredDrag)
this.currentDrag = this._createWiredElement();
else
this.currentDrag = this.element;
if (Event.element(event) == this.sizer) {
this.doResize = true;
this.widthOrg = this.width;
this.heightOrg = this.height;
this.bottomOrg = parseFloat(this.element.getStyle('bottom'));
this.rightOrg = parseFloat(this.element.getStyle('right'));
this._notify("onStartResize");
}
else {
this.doResize = false;
var closeButton = $(this.getId() + '_close');
if (closeButton && Position.within(closeButton, this.pointer[0], this.pointer[1])) {
this.currentDrag = null;
return;
}
this.toFront();
if (! this.options.draggable)
return;
this._notify("onStartMove");
}
Event.observe(document, "mouseup", this.eventMouseUp, false);
Event.observe(document, "mousemove", this.eventMouseMove, false);
WindowUtilities.disableScreen('__invisible__', '__invisible__', this.overlayOpacity);
document.body.ondrag = function () { return false; };
document.body.onselectstart = function () { return false; };
this.currentDrag.show();
Event.stop(event);
},
_round: function(val, round) {
return round == 1 ? val  : val = Math.floor(val / round) * round;
},
_updateDrag: function(event) {
var pointer =  [this._round(Event.pointerX(event), this.options.gridX), this._round(Event.pointerY(event), this.options.gridY)];
var dx = pointer[0] - this.pointer[0];
var dy = pointer[1] - this.pointer[1];
if (this.doResize) {
var w = this.widthOrg + dx;
var h = this.heightOrg + dy;
dx = this.width - this.widthOrg
dy = this.height - this.heightOrg
if (this.useLeft)
w = this._updateWidthConstraint(w)
else
this.currentDrag.setStyle({right: (this.rightOrg -dx) + 'px'});
if (this.useTop)
h = this._updateHeightConstraint(h)
else
this.currentDrag.setStyle({bottom: (this.bottomOrg -dy) + 'px'});
this.setSize(w , h);
this._notify("onResize");
}
else {
this.pointer = pointer;
if (this.useLeft) {
var left =  parseFloat(this.currentDrag.getStyle('left')) + dx;
var newLeft = this._updateLeftConstraint(left);
this.pointer[0] += newLeft-left;
this.currentDrag.setStyle({left: newLeft + 'px'});
}
else
this.currentDrag.setStyle({right: parseFloat(this.currentDrag.getStyle('right')) - dx + 'px'});
if (this.useTop) {
var top =  parseFloat(this.currentDrag.getStyle('top')) + dy;
var newTop = this._updateTopConstraint(top);
this.pointer[1] += newTop - top;
this.currentDrag.setStyle({top: newTop + 'px'});
}
else
this.currentDrag.setStyle({bottom: parseFloat(this.currentDrag.getStyle('bottom')) - dy + 'px'});
this._notify("onMove");
}
if (this.iefix)
this._fixIEOverlapping();
this._removeStoreLocation();
Event.stop(event);
},
_endDrag: function(event) {
WindowUtilities.enableScreen('__invisible__');
if (this.doResize)
this._notify("onEndResize");
else
this._notify("onEndMove");
Event.stopObserving(document, "mouseup", this.eventMouseUp,false);
Event.stopObserving(document, "mousemove", this.eventMouseMove, false);
Event.stop(event);
this._hideWiredElement();
this._saveCookie()
document.body.ondrag = null;
document.body.onselectstart = null;
},
_updateLeftConstraint: function(left) {
if (this.constraint && this.useLeft && this.useTop) {
var width = this.options.parent == document.body ? WindowUtilities.getPageSize().windowWidth : this.options.parent.getDimensions().width;
if (left < this.constraintPad.left)
left = this.constraintPad.left;
if (left + this.width + this.widthE + this.widthW > width - this.constraintPad.right)
left = width - this.constraintPad.right - this.width - this.widthE - this.widthW;
}
return left;
},
_updateTopConstraint: function(top) {
if (this.constraint && this.useLeft && this.useTop) {
var height = this.options.parent == document.body ? WindowUtilities.getPageSize().windowHeight : this.options.parent.getDimensions().height;
var h = this.height + this.heightN + this.heightS;
if (top < this.constraintPad.top)
top = this.constraintPad.top;
if (top + h > height - this.constraintPad.bottom)
top = height - this.constraintPad.bottom - h;
}
return top;
},
_updateWidthConstraint: function(w) {
if (this.constraint && this.useLeft && this.useTop) {
var width = this.options.parent == document.body ? WindowUtilities.getPageSize().windowWidth : this.options.parent.getDimensions().width;
var left =  parseFloat(this.element.getStyle("left"));
if (left + w + this.widthE + this.widthW > width - this.constraintPad.right)
w = width - this.constraintPad.right - left - this.widthE - this.widthW;
}
return w;
},
_updateHeightConstraint: function(h) {
if (this.constraint && this.useLeft && this.useTop) {
var height = this.options.parent == document.body ? WindowUtilities.getPageSize().windowHeight : this.options.parent.getDimensions().height;
var top =  parseFloat(this.element.getStyle("top"));
if (top + h + this.heightN + this.heightS > height - this.constraintPad.bottom)
h = height - this.constraintPad.bottom - top - this.heightN - this.heightS;
}
return h;
},
_createWindow: function(id) {
var className = this.options.className;
var win = document.createElement("div");
win.setAttribute('id', id);
win.className = "dialog";
var content;
if (this.options.url)
content= "<iframe frameborder=\"0\" name=\"" + id + "_content\"  id=\"" + id + "_content\" src=\"" + this.options.url + "\"> </iframe>";
else
content ="<div id=\"" + id + "_content\" class=\"" +className + "_content\"> </div>";
var closeDiv = this.options.closable ? "<div class='"+ className +"_close' id='"+ id +"_close' onclick='Windows.close(\""+ id +"\", event)'> </div>" : "";
var minDiv = this.options.minimizable ? "<div class='"+ className + "_minimize' id='"+ id +"_minimize' onclick='Windows.minimize(\""+ id +"\", event)'> </div>" : "";
var maxDiv = this.options.maximizable ? "<div class='"+ className + "_maximize' id='"+ id +"_maximize' onclick='Windows.maximize(\""+ id +"\", event)'> </div>" : "";
var seAttributes = this.options.resizable ? "class='" + className + "_sizer' id='" + id + "_sizer'" : "class='"  + className + "_se'";
var blank = "../themes/default/blank.gif";
win.innerHTML = closeDiv + minDiv + maxDiv + "\
<table id='"+ id +"_row1' class=\"top table_window\">\
<tr>\
<td class='"+ className +"_nw'></td>\
<td class='"+ className +"_n'><div id='"+ id +"_top' class='"+ className +"_title title_window'>"+ this.options.title +"</div></td>\
<td class='"+ className +"_ne'></td>\
</tr>\
</table>\
<table id='"+ id +"_row2' class=\"mid table_window\">\
<tr>\
<td class='"+ className +"_w'></td>\
<td id='"+ id +"_table_content' class='"+ className +"_content' valign='top'>" + content + "</td>\
<td class='"+ className +"_e'></td>\
</tr>\
</table>\
<table id='"+ id +"_row3' class=\"bot table_window\">\
<tr>\
<td class='"+ className +"_sw'></td>\
<td class='"+ className +"_s'><div id='"+ id +"_bottom' class='status_bar'><span style='float:left; width:1px; height:1px'></span></div></td>\
<td " + seAttributes + "></td>\
</tr>\
</table>\
";
Element.hide(win);
this.options.parent.insertBefore(win, this.options.parent.firstChild);
Event.observe($(id + "_content"), "load", this.options.onload);
return win;
},
changeClassName: function(newClassName) {
var className = this.options.className;
var id = this.getId();
$A(["_close", "_minimize", "_maximize", "_sizer", "_content"]).each(function(value) { this._toggleClassName($(id + value), className + value, newClassName + value) }.bind(this));
this._toggleClassName($(id + "_top"), className + "_title", newClassName + "_title");
$$("#" + id + " td").each(function(td) {td.className = td.className.sub(className,newClassName); });
this.options.className = newClassName;
},
_toggleClassName: function(element, oldClassName, newClassName) {
if (element) {
element.removeClassName(oldClassName);
element.addClassName(newClassName);
}
},
setLocation: function(top, left) {
top = this._updateTopConstraint(top);
left = this._updateLeftConstraint(left);
var e = this.currentDrag || this.element;
e.setStyle({top: top + 'px'});
e.setStyle({left: left + 'px'});
this.useLeft = true;
this.useTop = true;
},
getLocation: function() {
var location = {};
if (this.useTop)
location = Object.extend(location, {top: this.element.getStyle("top")});
else
location = Object.extend(location, {bottom: this.element.getStyle("bottom")});
if (this.useLeft)
location = Object.extend(location, {left: this.element.getStyle("left")});
else
location = Object.extend(location, {right: this.element.getStyle("right")});
return location;
},
getSize: function() {
return {width: this.width, height: this.height};
},
setSize: function(width, height, useEffect) {
width = parseFloat(width);
height = parseFloat(height);
if (!this.minimized && width < this.options.minWidth)
width = this.options.minWidth;
if (!this.minimized && height < this.options.minHeight)
height = this.options.minHeight;
if (this.options. maxHeight && height > this.options. maxHeight)
height = this.options. maxHeight;
if (this.options. maxWidth && width > this.options. maxWidth)
width = this.options. maxWidth;
if (this.useTop && this.useLeft && Window.hasEffectLib && Effect.ResizeWindow && useEffect) {
new Effect.ResizeWindow(this, null, null, width, height, {duration: Window.resizeEffectDuration});
} else {
this.width = width;
this.height = height;
var e = this.currentDrag ? this.currentDrag : this.element;
e.setStyle({width: width + this.widthW + this.widthE + "px"})
e.setStyle({height: height  + this.heightN + this.heightS + "px"})
if (!this.currentDrag || this.currentDrag == this.element) {
var content = $(this.element.id + '_content');
content.setStyle({height: height  + 'px'});
content.setStyle({width: width  + 'px'});
}
}
},
updateHeight: function() {
this.setSize(this.width, this.content.scrollHeight, true);
},
updateWidth: function() {
this.setSize(this.content.scrollWidth, this.height, true);
},
toFront: function() {
if (this.element.style.zIndex < Windows.maxZIndex)
this.setZIndex(Windows.maxZIndex + 1);
if (this.iefix)
this._fixIEOverlapping();
},
getBounds: function(insideOnly) {
if (! this.width || !this.height || !this.visible)
this.computeBounds();
var w = this.width;
var h = this.height;
if (!insideOnly) {
w += this.widthW + this.widthE;
h += this.heightN + this.heightS;
}
var bounds = Object.extend(this.getLocation(), {width: w + "px", height: h + "px"});
return bounds;
},
computeBounds: function() {
if (! this.width || !this.height) {
var size = WindowUtilities._computeSize(this.content.innerHTML, this.content.id, this.width, this.height, 0, this.options.className)
if (this.height)
this.width = size + 5
else
this.height = size + 5
}
this.setSize(this.width, this.height);
if (this.centered)
this._center(this.centerTop, this.centerLeft);
},
show: function(modal) {
this.visible = true;
if (modal) {
if (typeof this.overlayOpacity == "undefined") {
var that = this;
setTimeout(function() {that.show(modal)}, 10);
return;
}
Windows.addModalWindow(this);
this.modal = true;
this.setZIndex(Windows.maxZIndex + 1);
Windows.unsetOverflow(this);
}
else
if (!this.element.style.zIndex)
this.setZIndex(Windows.maxZIndex + 1);
if (this.oldStyle)
this.getContent().setStyle({overflow: this.oldStyle});
this.computeBounds();
this._notify("onBeforeShow");
if (this.options.showEffect != Element.show && this.options.showEffectOptions)
this.options.showEffect(this.element, this.options.showEffectOptions);
else
this.options.showEffect(this.element);
this._checkIEOverlapping();
WindowUtilities.focusedWindow = this
this._notify("onShow");
},
showCenter: function(modal, top, left) {
this.centered = true;
this.centerTop = top;
this.centerLeft = left;
this.show(modal);
},
isVisible: function() {
return this.visible;
},
_center: function(top, left) {
var windowScroll = WindowUtilities.getWindowScroll(this.options.parent);
var pageSize = WindowUtilities.getPageSize(this.options.parent);
if (typeof top == "undefined")
top = (pageSize.windowHeight - (this.height + this.heightN + this.heightS))/2;
top += windowScroll.top
if (typeof left == "undefined")
left = (pageSize.windowWidth - (this.width + this.widthW + this.widthE))/2;
left += windowScroll.left
this.setLocation(top, left);
this.toFront();
},
_recenter: function(event) {
if (this.centered) {
var pageSize = WindowUtilities.getPageSize(this.options.parent);
var windowScroll = WindowUtilities.getWindowScroll(this.options.parent);
if (this.pageSize && this.pageSize.windowWidth == pageSize.windowWidth && this.pageSize.windowHeight == pageSize.windowHeight &&
this.windowScroll.left == windowScroll.left && this.windowScroll.top == windowScroll.top)
return;
this.pageSize = pageSize;
this.windowScroll = windowScroll;
if ($('overlay_modal'))
$('overlay_modal').setStyle({height: (pageSize.pageHeight + 'px')});
if (this.options.recenterAuto)
this._center(this.centerTop, this.centerLeft);
}
},
hide: function() {
this.visible = false;
if (this.modal) {
Windows.removeModalWindow(this);
Windows.resetOverflow();
}
this.oldStyle = this.getContent().getStyle('overflow') || "auto"
this.getContent().setStyle({overflow: "hidden"});
this.options.hideEffect(this.element, this.options.hideEffectOptions);
if(this.iefix)
this.iefix.hide();
if (!this.doNotNotifyHide)
this._notify("onHide");
},
close: function() {
if (this.visible) {
if (this.options.closeCallback && ! this.options.closeCallback(this))
return;
if (this.options.destroyOnClose) {
var destroyFunc = this.destroy.bind(this);
if (this.options.hideEffectOptions.afterFinish) {
var func = this.options.hideEffectOptions.afterFinish;
this.options.hideEffectOptions.afterFinish = function() {func();destroyFunc() }
}
else
this.options.hideEffectOptions.afterFinish = function() {destroyFunc() }
}
Windows.updateFocusedWindow();
this.doNotNotifyHide = true;
this.hide();
this.doNotNotifyHide = false;
this._notify("onClose");
}
},
minimize: function() {
if (this.resizing)
return;
var r2 = $(this.getId() + "_row2");
if (!this.minimized) {
this.minimized = true;
var dh = r2.getDimensions().height;
this.r2Height = dh;
var h  = this.element.getHeight() - dh;
if (this.useLeft && this.useTop && Window.hasEffectLib && Effect.ResizeWindow) {
new Effect.ResizeWindow(this, null, null, null, this.height -dh, {duration: Window.resizeEffectDuration});
} else  {
this.height -= dh;
this.element.setStyle({height: h + "px"});
r2.hide();
}
if (! this.useTop) {
var bottom = parseFloat(this.element.getStyle('bottom'));
this.element.setStyle({bottom: (bottom + dh) + 'px'});
}
}
else {
this.minimized = false;
var dh = this.r2Height;
this.r2Height = null;
if (this.useLeft && this.useTop && Window.hasEffectLib && Effect.ResizeWindow) {
new Effect.ResizeWindow(this, null, null, null, this.height + dh, {duration: Window.resizeEffectDuration});
}
else {
var h  = this.element.getHeight() + dh;
this.height += dh;
this.element.setStyle({height: h + "px"})
r2.show();
}
if (! this.useTop) {
var bottom = parseFloat(this.element.getStyle('bottom'));
this.element.setStyle({bottom: (bottom - dh) + 'px'});
}
this.toFront();
}
this._notify("onMinimize");
this._saveCookie()
},
maximize: function() {
if (this.isMinimized() || this.resizing)
return;
if (Prototype.Browser.IE && this.heightN == 0)
this._getWindowBorderSize();
if (this.storedLocation != null) {
this._restoreLocation();
if(this.iefix)
this.iefix.hide();
}
else {
this._storeLocation();
Windows.unsetOverflow(this);
var windowScroll = WindowUtilities.getWindowScroll(this.options.parent);
var pageSize = WindowUtilities.getPageSize(this.options.parent);
var left = windowScroll.left;
var top = windowScroll.top;
if (this.options.parent != document.body) {
windowScroll =  {top:0, left:0, bottom:0, right:0};
var dim = this.options.parent.getDimensions();
pageSize.windowWidth = dim.width;
pageSize.windowHeight = dim.height;
top = 0;
left = 0;
}
if (this.constraint) {
pageSize.windowWidth -= Math.max(0, this.constraintPad.left) + Math.max(0, this.constraintPad.right);
pageSize.windowHeight -= Math.max(0, this.constraintPad.top) + Math.max(0, this.constraintPad.bottom);
left +=  Math.max(0, this.constraintPad.left);
top +=  Math.max(0, this.constraintPad.top);
}
var width = pageSize.windowWidth - this.widthW - this.widthE;
var height= pageSize.windowHeight - this.heightN - this.heightS;
if (this.useLeft && this.useTop && Window.hasEffectLib && Effect.ResizeWindow) {
new Effect.ResizeWindow(this, top, left, width, height, {duration: Window.resizeEffectDuration});
}
else {
this.setSize(width, height);
this.element.setStyle(this.useLeft ? {left: left} : {right: left});
this.element.setStyle(this.useTop ? {top: top} : {bottom: top});
}
this.toFront();
if (this.iefix)
this._fixIEOverlapping();
}
this._notify("onMaximize");
this._saveCookie()
},
isMinimized: function() {
return this.minimized;
},
isMaximized: function() {
return (this.storedLocation != null);
},
setOpacity: function(opacity) {
if (Element.setOpacity)
Element.setOpacity(this.element, opacity);
},
setZIndex: function(zindex) {
this.element.setStyle({zIndex: zindex});
Windows.updateZindex(zindex, this);
},
setTitle: function(newTitle) {
if (!newTitle || newTitle == "")
newTitle = "&nbsp;";
Element.update(this.element.id + '_top', newTitle);
},
getTitle: function() {
return $(this.element.id + '_top').innerHTML;
},
setStatusBar: function(element) {
var statusBar = $(this.getId() + "_bottom");
if (typeof(element) == "object") {
if (this.bottombar.firstChild)
this.bottombar.replaceChild(element, this.bottombar.firstChild);
else
this.bottombar.appendChild(element);
}
else
this.bottombar.innerHTML = element;
},
_checkIEOverlapping: function() {
if(!this.iefix && (navigator.appVersion.indexOf('MSIE')>0) && (navigator.userAgent.indexOf('Opera')<0) && (this.element.getStyle('position')=='absolute')) {
new Insertion.After(this.element.id, '<iframe id="' + this.element.id + '_iefix" '+ 'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" ' + 'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');
this.iefix = $(this.element.id+'_iefix');
}
if(this.iefix)
setTimeout(this._fixIEOverlapping.bind(this), 50);
},
_fixIEOverlapping: function() {
Position.clone(this.element, this.iefix);
this.iefix.style.zIndex = this.element.style.zIndex - 1;
this.iefix.show();
},
_getWindowBorderSize: function(event) {
var div = this._createHiddenDiv(this.options.className + "_n")
this.heightN = Element.getDimensions(div).height;
div.parentNode.removeChild(div)
var div = this._createHiddenDiv(this.options.className + "_s")
this.heightS = Element.getDimensions(div).height;
div.parentNode.removeChild(div)
var div = this._createHiddenDiv(this.options.className + "_e")
this.widthE = Element.getDimensions(div).width;
div.parentNode.removeChild(div)
var div = this._createHiddenDiv(this.options.className + "_w")
this.widthW = Element.getDimensions(div).width;
div.parentNode.removeChild(div);
var div = document.createElement("div");
div.className = "overlay_" + this.options.className ;
document.body.appendChild(div);
var that = this;
setTimeout(function() {that.overlayOpacity = ($(div).getStyle("opacity")); div.parentNode.removeChild(div);}, 10);
if (Prototype.Browser.IE) {
this.heightS = $(this.getId() +"_row3").getDimensions().height;
this.heightN = $(this.getId() +"_row1").getDimensions().height;
}
if (Prototype.Browser.WebKit && Prototype.Browser.WebKitVersion < 420)
this.setSize(this.width, this.height);
if (this.doMaximize)
this.maximize();
if (this.doMinimize)
this.minimize();
},
_createHiddenDiv: function(className) {
var objBody = document.body;
var win = document.createElement("div");
win.setAttribute('id', this.element.id+ "_tmp");
win.className = className;
win.style.display = 'none';
win.innerHTML = '';
objBody.insertBefore(win, objBody.firstChild);
return win;
},
_storeLocation: function() {
if (this.storedLocation == null) {
this.storedLocation = {useTop: this.useTop, useLeft: this.useLeft,
top: this.element.getStyle('top'), bottom: this.element.getStyle('bottom'),
left: this.element.getStyle('left'), right: this.element.getStyle('right'),
width: this.width, height: this.height };
}
},
_restoreLocation: function() {
if (this.storedLocation != null) {
this.useLeft = this.storedLocation.useLeft;
this.useTop = this.storedLocation.useTop;
if (this.useLeft && this.useTop && Window.hasEffectLib && Effect.ResizeWindow)
new Effect.ResizeWindow(this, this.storedLocation.top, this.storedLocation.left, this.storedLocation.width, this.storedLocation.height, {duration: Window.resizeEffectDuration});
else {
this.element.setStyle(this.useLeft ? {left: this.storedLocation.left} : {right: this.storedLocation.right});
this.element.setStyle(this.useTop ? {top: this.storedLocation.top} : {bottom: this.storedLocation.bottom});
this.setSize(this.storedLocation.width, this.storedLocation.height);
}
Windows.resetOverflow();
this._removeStoreLocation();
}
},
_removeStoreLocation: function() {
this.storedLocation = null;
},
_saveCookie: function() {
if (this.cookie) {
var value = "";
if (this.useLeft)
value += "l:" +  (this.storedLocation ? this.storedLocation.left : this.element.getStyle('left'))
else
value += "r:" + (this.storedLocation ? this.storedLocation.right : this.element.getStyle('right'))
if (this.useTop)
value += ",t:" + (this.storedLocation ? this.storedLocation.top : this.element.getStyle('top'))
else
value += ",b:" + (this.storedLocation ? this.storedLocation.bottom :this.element.getStyle('bottom'))
value += "," + (this.storedLocation ? this.storedLocation.width : this.width);
value += "," + (this.storedLocation ? this.storedLocation.height : this.height);
value += "," + this.isMinimized();
value += "," + this.isMaximized();
WindowUtilities.setCookie(value, this.cookie)
}
},
_createWiredElement: function() {
if (! this.wiredElement) {
if (Prototype.Browser.IE)
this._getWindowBorderSize();
var div = document.createElement("div");
div.className = "wired_frame " + this.options.className + "_wired_frame";
div.style.position = 'absolute';
this.options.parent.insertBefore(div, this.options.parent.firstChild);
this.wiredElement = $(div);
}
if (this.useLeft)
this.wiredElement.setStyle({left: this.element.getStyle('left')});
else
this.wiredElement.setStyle({right: this.element.getStyle('right')});
if (this.useTop)
this.wiredElement.setStyle({top: this.element.getStyle('top')});
else
this.wiredElement.setStyle({bottom: this.element.getStyle('bottom')});
var dim = this.element.getDimensions();
this.wiredElement.setStyle({width: dim.width + "px", height: dim.height +"px"});
this.wiredElement.setStyle({zIndex: Windows.maxZIndex+30});
return this.wiredElement;
},
_hideWiredElement: function() {
if (! this.wiredElement || ! this.currentDrag)
return;
if (this.currentDrag == this.element)
this.currentDrag = null;
else {
if (this.useLeft)
this.element.setStyle({left: this.currentDrag.getStyle('left')});
else
this.element.setStyle({right: this.currentDrag.getStyle('right')});
if (this.useTop)
this.element.setStyle({top: this.currentDrag.getStyle('top')});
else
this.element.setStyle({bottom: this.currentDrag.getStyle('bottom')});
this.currentDrag.hide();
this.currentDrag = null;
if (this.doResize)
this.setSize(this.width, this.height);
}
},
_notify: function(eventName) {
if (this.options[eventName])
this.options[eventName](this);
else
Windows.notify(eventName, this);
}
};
var Windows = {
windows: [],
modalWindows: [],
observers: [],
focusedWindow: null,
maxZIndex: 0,
overlayShowEffectOptions: {duration: 0.5},
overlayHideEffectOptions: {duration: 0.5},
addObserver: function(observer) {
this.removeObserver(observer);
this.observers.push(observer);
},
removeObserver: function(observer) {
this.observers = this.observers.reject( function(o) { return o==observer });
},
notify: function(eventName, win) {
this.observers.each( function(o) {if(o[eventName]) o[eventName](eventName, win);});
},
getWindow: function(id) {
return this.windows.detect(function(d) { return d.getId() ==id });
},
getFocusedWindow: function() {
return this.focusedWindow;
},
updateFocusedWindow: function() {
this.focusedWindow = this.windows.length >=2 ? this.windows[this.windows.length-2] : null;
},
register: function(win) {
this.windows.push(win);
},
addModalWindow: function(win) {
if (this.modalWindows.length == 0) {
WindowUtilities.disableScreen(win.options.className, 'overlay_modal', win.overlayOpacity, win.getId(), win.options.parent);
}
else {
if (Window.keepMultiModalWindow) {
$('overlay_modal').style.zIndex = Windows.maxZIndex + 1;
Windows.maxZIndex += 1;
WindowUtilities._hideSelect(this.modalWindows.last().getId());
}
else
this.modalWindows.last().element.hide();
WindowUtilities._showSelect(win.getId());
}
this.modalWindows.push(win);
},
removeModalWindow: function(win) {
this.modalWindows.pop();
if (this.modalWindows.length == 0)
WindowUtilities.enableScreen();
else {
if (Window.keepMultiModalWindow) {
this.modalWindows.last().toFront();
WindowUtilities._showSelect(this.modalWindows.last().getId());
}
else
this.modalWindows.last().element.show();
}
},
register: function(win) {
this.windows.push(win);
},
unregister: function(win) {
this.windows = this.windows.reject(function(d) { return d==win });
},
closeAll: function() {
this.windows.each( function(w) {Windows.close(w.getId())} );
},
closeAllModalWindows: function() {
WindowUtilities.enableScreen();
this.modalWindows.each( function(win) {if (win) win.close()});
},
minimize: function(id, event) {
var win = this.getWindow(id)
if (win && win.visible)
win.minimize();
Event.stop(event);
},
maximize: function(id, event) {
var win = this.getWindow(id)
if (win && win.visible)
win.maximize();
Event.stop(event);
},
close: function(id, event) {
var win = this.getWindow(id);
if (win)
win.close();
if (event)
Event.stop(event);
},
blur: function(id) {
var win = this.getWindow(id);
if (!win)
return;
if (win.options.blurClassName)
win.changeClassName(win.options.blurClassName);
if (this.focusedWindow == win)
this.focusedWindow = null;
win._notify("onBlur");
},
focus: function(id) {
var win = this.getWindow(id);
if (!win)
return;
if (this.focusedWindow)
this.blur(this.focusedWindow.getId())
if (win.options.focusClassName)
win.changeClassName(win.options.focusClassName);
this.focusedWindow = win;
win._notify("onFocus");
},
unsetOverflow: function(except) {
this.windows.each(function(d) { d.oldOverflow = d.getContent().getStyle("overflow") || "auto" ; d.getContent().setStyle({overflow: "hidden"}) });
if (except && except.oldOverflow)
except.getContent().setStyle({overflow: except.oldOverflow});
},
resetOverflow: function() {
this.windows.each(function(d) { if (d.oldOverflow) d.getContent().setStyle({overflow: d.oldOverflow}) });
},
updateZindex: function(zindex, win) {
if (zindex > this.maxZIndex) {
this.maxZIndex = zindex;
if (this.focusedWindow)
this.blur(this.focusedWindow.getId())
}
this.focusedWindow = win;
if (this.focusedWindow)
this.focus(this.focusedWindow.getId())
}
};
var Dialog = {
dialogId: null,
onCompleteFunc: null,
callFunc: null,
parameters: null,
confirm: function(content, parameters) {
if (content && typeof content != "string") {
Dialog._runAjaxRequest(content, parameters, Dialog.confirm);
return
}
content = content || "";
parameters = parameters || {};
var okLabel = parameters.okLabel ? parameters.okLabel : "Ok";
var cancelLabel = parameters.cancelLabel ? parameters.cancelLabel : "Cancel";
parameters = Object.extend(parameters, parameters.windowParameters || {});
parameters.windowParameters = parameters.windowParameters || {};
parameters.className = parameters.className || "alert";
var okButtonClass = "class ='" + (parameters.buttonClass ? parameters.buttonClass + " " : "") + " ok_button'"
var cancelButtonClass = "class ='" + (parameters.buttonClass ? parameters.buttonClass + " " : "") + " cancel_button'"
var content = "\
<div class='" + parameters.className + "_message'>" + content  + "</div>\
<div class='" + parameters.className + "_buttons'>\
<input type='button' value='" + okLabel + "' onclick='Dialog.okCallback()' " + okButtonClass + "/>\
<input type='button' value='" + cancelLabel + "' onclick='Dialog.cancelCallback()' " + cancelButtonClass + "/>\
</div>\
";
return this._openDialog(content, parameters)
},
alert: function(content, parameters) {
if (content && typeof content != "string") {
Dialog._runAjaxRequest(content, parameters, Dialog.alert);
return
}
content = content || "";
parameters = parameters || {};
var okLabel = parameters.okLabel ? parameters.okLabel : "Ok";
parameters = Object.extend(parameters, parameters.windowParameters || {});
parameters.windowParameters = parameters.windowParameters || {};
parameters.className = parameters.className || "alert";
var okButtonClass = "class ='" + (parameters.buttonClass ? parameters.buttonClass + " " : "") + " ok_button'"
var content = "\
<div class='" + parameters.className + "_message'>" + content  + "</div>\
<div class='" + parameters.className + "_buttons'>\
<input type='button' value='" + okLabel + "' onclick='Dialog.okCallback()' " + okButtonClass + "/>\
</div>";
return this._openDialog(content, parameters)
},
info: function(content, parameters) {
if (content && typeof content != "string") {
Dialog._runAjaxRequest(content, parameters, Dialog.info);
return
}
content = content || "";
parameters = parameters || {};
parameters = Object.extend(parameters, parameters.windowParameters || {});
parameters.windowParameters = parameters.windowParameters || {};
parameters.className = parameters.className || "alert";
var content = "<div id='modal_dialog_message' class='" + parameters.className + "_message'>" + content  + "</div>";
if (parameters.showProgress)
content += "<div id='modal_dialog_progress' class='" + parameters.className + "_progress'>  </div>";
parameters.ok = null;
parameters.cancel = null;
return this._openDialog(content, parameters)
},
setInfoMessage: function(message) {
$('modal_dialog_message').update(message);
},
closeInfo: function() {
Windows.close(this.dialogId);
},
_openDialog: function(content, parameters) {
var className = parameters.className;
if (! parameters.height && ! parameters.width) {
parameters.width = WindowUtilities.getPageSize(parameters.options.parent || document.body).pageWidth / 2;
}
if (parameters.id)
this.dialogId = parameters.id;
else {
var t = new Date();
this.dialogId = 'modal_dialog_' + t.getTime();
parameters.id = this.dialogId;
}
if (! parameters.height || ! parameters.width) {
var size = WindowUtilities._computeSize(content, this.dialogId, parameters.width, parameters.height, 5, className)
if (parameters.height)
parameters.width = size + 5
else
parameters.height = size + 5
}
parameters.effectOptions = parameters.effectOptions ;
parameters.resizable   = parameters.resizable || false;
parameters.minimizable = parameters.minimizable || false;
parameters.maximizable = parameters.maximizable ||  false;
parameters.draggable   = parameters.draggable || false;
parameters.closable    = parameters.closable || false;
var win = new Window(parameters);
win.getContent().innerHTML = content;
win.showCenter(true, parameters.top, parameters.left);
win.setDestroyOnClose();
win.cancelCallback = parameters.onCancel || parameters.cancel;
win.okCallback = parameters.onOk || parameters.ok;
return win;
},
_getAjaxContent: function(originalRequest)  {
Dialog.callFunc(originalRequest.responseText, Dialog.parameters)
},
_runAjaxRequest: function(message, parameters, callFunc) {
if (message.options == null)
message.options = {}
Dialog.onCompleteFunc = message.options.onComplete;
Dialog.parameters = parameters;
Dialog.callFunc = callFunc;
message.options.onComplete = Dialog._getAjaxContent;
new Ajax.Request(message.url, message.options);
},
okCallback: function() {
var win = Windows.focusedWindow;
if (!win.okCallback || win.okCallback(win)) {
$$("#" + win.getId()+" input").each(function(element) {element.onclick=null;})
win.close();
}
},
cancelCallback: function() {
var win = Windows.focusedWindow;
$$("#" + win.getId()+" input").each(function(element) {element.onclick=null})
win.close();
if (win.cancelCallback)
win.cancelCallback(win);
}
}
/*
Based on Lightbox JS: Fullsize Image Overlays
by Lokesh Dhakar - http://www.huddletogether.com
For more information on this script, visit:
http://huddletogether.com/projects/lightbox/
Licensed under the Creative Commons Attribution 2.5 License - http://creativecommons.org/licenses/by/2.5/
(basically, do anything you want, just leave my name and link)
*/
if (Prototype.Browser.WebKit) {
var array = navigator.userAgent.match(new RegExp(/AppleWebKit\/([\d\.\+]*)/));
Prototype.Browser.WebKitVersion = parseFloat(array[1]);
}
var WindowUtilities = {
getWindowScroll: function(parent) {
var T, L, W, H;
parent = parent || document.body;
if (parent != document.body) {
T = parent.scrollTop;
L = parent.scrollLeft;
W = parent.scrollWidth;
H = parent.scrollHeight;
}
else {
var w = window;
with (w.document) {
if (w.document.documentElement && documentElement.scrollTop) {
T = documentElement.scrollTop;
L = documentElement.scrollLeft;
} else if (w.document.body) {
T = body.scrollTop;
L = body.scrollLeft;
}
if (w.innerWidth) {
W = w.innerWidth;
H = w.innerHeight;
} else if (w.document.documentElement && documentElement.clientWidth) {
W = documentElement.clientWidth;
H = documentElement.clientHeight;
} else {
W = body.offsetWidth;
H = body.offsetHeight
}
}
}
return { top: T, left: L, width: W, height: H };
},
getPageSize: function(parent){
parent = parent || document.body;
var windowWidth, windowHeight;
var pageHeight, pageWidth;
if (parent != document.body) {
windowWidth = parent.getWidth();
windowHeight = parent.getHeight();
pageWidth = parent.scrollWidth;
pageHeight = parent.scrollHeight;
}
else {
var xScroll, yScroll;
if (window.innerHeight && window.scrollMaxY) {
xScroll = document.body.scrollWidth;
yScroll = window.innerHeight + window.scrollMaxY;
} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
xScroll = document.body.scrollWidth;
yScroll = document.body.scrollHeight;
} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
xScroll = document.body.offsetWidth;
yScroll = document.body.offsetHeight;
}
if (self.innerHeight) {  // all except Explorer
windowWidth = self.innerWidth;
windowHeight = self.innerHeight;
} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
windowWidth = document.documentElement.clientWidth;
windowHeight = document.documentElement.clientHeight;
} else if (document.body) { // other Explorers
windowWidth = document.body.clientWidth;
windowHeight = document.body.clientHeight;
}
if(yScroll < windowHeight){
pageHeight = windowHeight;
} else {
pageHeight = yScroll;
}
if(xScroll < windowWidth){
pageWidth = windowWidth;
} else {
pageWidth = xScroll;
}
}
return {pageWidth: pageWidth ,pageHeight: pageHeight , windowWidth: windowWidth, windowHeight: windowHeight};
},
disableScreen: function(className, overlayId, overlayOpacity, contentId, parent) {
WindowUtilities.initLightbox(overlayId, className, function() {this._disableScreen(className, overlayId, overlayOpacity, contentId)}.bind(this), parent || document.body);
},
_disableScreen: function(className, overlayId, overlayOpacity, contentId) {
var objOverlay = $(overlayId);
var pageSize = WindowUtilities.getPageSize(objOverlay.parentNode);
if (contentId && Prototype.Browser.IE) {
WindowUtilities._hideSelect();
WindowUtilities._showSelect(contentId);
}
objOverlay.style.height = (pageSize.pageHeight + 'px');
objOverlay.style.display = 'none';
if (overlayId == "overlay_modal" && Window.hasEffectLib && Windows.overlayShowEffectOptions) {
objOverlay.overlayOpacity = overlayOpacity;
new Effect.Appear(objOverlay, Object.extend({from: 0, to: overlayOpacity}, Windows.overlayShowEffectOptions));
}
else
objOverlay.style.display = "block";
},
enableScreen: function(id) {
id = id || 'overlay_modal';
var objOverlay =  $(id);
if (objOverlay) {
if (id == "overlay_modal" && Window.hasEffectLib && Windows.overlayHideEffectOptions)
new Effect.Fade(objOverlay, Object.extend({from: objOverlay.overlayOpacity, to:0}, Windows.overlayHideEffectOptions));
else {
objOverlay.style.display = 'none';
objOverlay.parentNode.removeChild(objOverlay);
}
if (id != "__invisible__")
WindowUtilities._showSelect();
}
},
_hideSelect: function(id) {
if (Prototype.Browser.IE) {
id = id ==  null ? "" : "#" + id + " ";
$$(id + 'select').each(function(element) {
if (! WindowUtilities.isDefined(element.oldVisibility)) {
element.oldVisibility = element.style.visibility ? element.style.visibility : "visible";
element.style.visibility = "hidden";
}
});
}
},
_showSelect: function(id) {
if (Prototype.Browser.IE) {
id = id ==  null ? "" : "#" + id + " ";
$$(id + 'select').each(function(element) {
if (WindowUtilities.isDefined(element.oldVisibility)) {
try {
element.style.visibility = element.oldVisibility;
} catch(e) {
element.style.visibility = "visible";
}
element.oldVisibility = null;
}
else {
if (element.style.visibility)
element.style.visibility = "visible";
}
});
}
},
isDefined: function(object) {
return typeof(object) != "undefined" && object != null;
},
initLightbox: function(id, className, doneHandler, parent) {
if ($(id)) {
Element.setStyle(id, {zIndex: Windows.maxZIndex + 1});
Windows.maxZIndex++;
doneHandler();
}
else {
var objOverlay = document.createElement("div");
objOverlay.setAttribute('id', id);
objOverlay.className = "overlay_" + className
objOverlay.style.display = 'none';
objOverlay.style.position = 'absolute';
objOverlay.style.top = '0';
objOverlay.style.left = '0';
objOverlay.style.zIndex = Windows.maxZIndex + 1;
Windows.maxZIndex++;
objOverlay.style.width = '100%';
parent.insertBefore(objOverlay, parent.firstChild);
if (Prototype.Browser.WebKit && id == "overlay_modal") {
setTimeout(function() {doneHandler()}, 10);
}
else
doneHandler();
}
},
setCookie: function(value, parameters) {
document.cookie= parameters[0] + "=" + escape(value) +
((parameters[1]) ? "; expires=" + parameters[1].toGMTString() : "") +
((parameters[2]) ? "; path=" + parameters[2] : "") +
((parameters[3]) ? "; domain=" + parameters[3] : "") +
((parameters[4]) ? "; secure" : "");
},
getCookie: function(name) {
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else {
begin += 2;
}
var end = document.cookie.indexOf(";", begin);
if (end == -1) {
end = dc.length;
}
return unescape(dc.substring(begin + prefix.length, end));
},
_computeSize: function(content, id, width, height, margin, className) {
var objBody = document.body;
var tmpObj = document.createElement("div");
tmpObj.setAttribute('id', id);
tmpObj.className = className + "_content";
if (height)
tmpObj.style.height = height + "px"
else
tmpObj.style.width = width + "px"
tmpObj.style.position = 'absolute';
tmpObj.style.top = '0';
tmpObj.style.left = '0';
tmpObj.style.display = 'none';
tmpObj.innerHTML = content;
objBody.insertBefore(tmpObj, objBody.firstChild);
var size;
if (height)
size = $(tmpObj).getDimensions().width + margin;
else
size = $(tmpObj).getDimensions().height + margin;
objBody.removeChild(tmpObj);
return size;
}
}
/*
TableSort revisited v3.7 by frequency-decoder.com
Released under a creative commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/)
Please credit frequency decoder in any derivative work - thanks
You are free:
* to copy, distribute, display, and perform the work
* to make derivative works
* to make commercial use of the work
Under the following conditions:
by Attribution.
--------------
You must attribute the work in the manner specified by the author or licensor.
sa
--
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
* For any reuse or distribution, you must make clear to others the license terms of this work.
* Any of these conditions can be waived if you get permission from the copyright holder.
*/
var fdTableSort = {
regExp_Currency:        /^[£$€¥¤]/,
regExp_Number:          /^(\-)?[0-9]+(\.[0-9]*)?$/,
pos:                    -1,
uniqueHash:             1,
thNode:                 null,
tableId:                null,
tableCache:             {},
tmpCache:               {},
/*@cc_on
/*@if (@_win32)
colspan:                "colSpan",
rowspan:                "rowSpan",
@else @*/
colspan:                "colspan",
rowspan:                "rowspan",
/*@end
@*/
addEvent: function(obj, type, fn, tmp) {
tmp || (tmp = true);
if( obj.attachEvent ) {
obj["e"+type+fn] = fn;
obj[type+fn] = function(){obj["e"+type+fn]( window.event );};
obj.attachEvent( "on"+type, obj[type+fn] );
} else {
obj.addEventListener( type, fn, true );
};
},
removeEvent: function(obj, type, fn, tmp) {
tmp || (tmp = true);
if( obj.detachEvent ) {
obj.detachEvent( "on"+type, obj[type+fn] );
obj[type+fn] = null;
} else {
obj.removeEventListener( type, fn, true );
};
},
stopEvent: function(e) {
e = e || window.event;
if(e.stopPropagation) {
e.stopPropagation();
e.preventDefault();
};
/*@cc_on@*/
/*@if(@_win32)
e.cancelBubble = true;
e.returnValue = false;
/*@end@*/
return false;
},
initEvt: function(e) {
fdTableSort.init(false);
},
init: function(tableId) {
if (!document.getElementsByTagName || !document.createElement || !document.getElementById) return;
var tables = tableId && document.getElementById(tableId) ? new Array(document.getElementById(tableId)) : document.getElementsByTagName("table");
var workArr, sortable, headers, thtext, aclone, a, span, columnNum, noArrow, colCnt, cel, allRowArr, rowArr, sortableTable, celCount, colspan, rowspan, rowLength;
var onLoadTables = [];
a               = document.createElement("a");
a.href          = "#";
a.onkeypress    = fdTableSort.keyWrapper;
span            = document.createElement("span");
for(var k = 0, tbl; tbl = tables[k]; k++) {
if(tbl.id) fdTableSort.removeTableCache(tbl.id);
if(tbl.id) fdTableSort.removeTmpCache(tbl.id);
allRowArr = tbl.getElementsByTagName('thead').length ? tbl.getElementsByTagName('thead')[0].getElementsByTagName('tr') : tbl.getElementsByTagName('tr');
rowArr = [];
sortableTable = false;
for(var i = 0, tr; tr = allRowArr[i]; i++) {
if(tr.getElementsByTagName('td').length || !tr.getElementsByTagName('th').length) continue;
rowArr[rowArr.length] = tr.getElementsByTagName('th');
for(var j = 0, th; th = rowArr[rowArr.length - 1][j]; j++) {
if(th.className.search(/sortable/) != -1) sortableTable = true;
};
};
if(!sortableTable) continue;
if(!tbl.id) tbl.id = "fd-table-" + fdTableSort.uniqueHash++;
sortable  = false;
columnNum = tbl.className.search(/sortable-onload-([0-9]+)/) != -1 ? parseInt(tbl.className.match(/sortable-onload-([0-9]+)/)[1]) - 1 : -1;
showArrow = tbl.className.search(/no-arrow/) == -1;
reverse   = tbl.className.search(/sortable-onload-([0-9]+)-reverse/) != -1;
rowLength = rowArr[0].length;
for(var c = 0;c < rowArr[0].length;c++){
if(rowArr[0][c].getAttribute(fdTableSort.colspan) && rowArr[0][c].getAttribute(fdTableSort.colspan) > 1){
rowLength = rowLength + (rowArr[0][c].getAttribute(fdTableSort.colspan) - 1);
};
};
workArr = new Array(rowArr.length);
for(var c = rowArr.length;c--;){
workArr[c]= new Array(rowLength);
};
for(var c = 0;c < workArr.length;c++){
celCount = 0;
for(var i = 0;i < rowLength;i++){
if(!workArr[c][i]){
cel = rowArr[c][celCount];
colspan = (cel.getAttribute(fdTableSort.colspan) > 1) ? cel.getAttribute(fdTableSort.colspan):1;
rowspan = (cel.getAttribute(fdTableSort.rowspan) > 1) ? cel.getAttribute(fdTableSort.rowspan):1;
for(var t = 0;((t < colspan)&&((i+t) < rowLength));t++){
for(var n = 0;((n < rowspan)&&((c+n) < workArr.length));n++) {
workArr[(c+n)][(i+t)] = cel;
};
};
if(++celCount == rowArr[c].length) break;
};
};
};
for(var c = 0;c < workArr.length;c++) {
for(var i = 0;i < workArr[c].length;i++){
if(workArr[c][i].className.search("fd-column-") == -1 && workArr[c][i].className.search("sortable") != -1) workArr[c][i].className = workArr[c][i].className + " fd-column-" + i;
if(workArr[c][i].className.match('sortable')) {
workArr[c][i].className = workArr[c][i].className.replace(/forwardSort|reverseSort/, "");
if(i == columnNum) sortable = workArr[c][i];
thtext = fdTableSort.getInnerText(workArr[c][i]);
if(workArr[c][i].getElementsByTagName && workArr[c][i].getElementsByTagName('a').length) {
workArr[c][i].getElementsByTagName('a')[0].onclick = workArr[c][i].getElementsByTagName('a')[0].onkeypress = null;
}
while(workArr[c][i].firstChild) workArr[c][i].removeChild(workArr[c][i].firstChild);
aclone = a.cloneNode(true);
aclone.appendChild(document.createTextNode(thtext));
aclone.title = "Sort on \u201c" + thtext + "\u201d";
aclone.onclick = workArr[c][i].onclick = fdTableSort.clickWrapper;
workArr[c][i].appendChild(aclone);
if(showArrow) workArr[c][i].appendChild(span.cloneNode(false));
workArr[c][i].className = workArr[c][i].className.replace(/fd-identical|fd-not-identical/, "");
fdTableSort.disableSelection(workArr[c][i]);
aclone = null;
};
};
};
fdTableSort.tmpCache[tbl.id] = {cols:rowLength, headers:workArr};
workArr = null;
if(sortable) {
onLoadTables[onLoadTables.length] = sortable;
if(reverse) { onLoadTables[onLoadTables.length] = sortable; };
};
};
for(var i = 0, thNode; thNode = onLoadTables[i]; i++) {
fdTableSort.thNode = thNode;
fdTableSort.initSort(false);
};
aclone = a.onkeypress = a = span = workArr = sortable = thNode = onLoadTables = tbl = allRowArr = rowArr = null;
},
disableSelection: function(element) {
element.onselectstart = function() {
return false;
};
element.unselectable = "on";
element.style.MozUserSelect = "none";
},
clickWrapper: function(e) {
e = e || window.event;
if(fdTableSort.thNode == null) {
var targ = this;
while(targ.tagName.toLowerCase() != "th") targ = targ.parentNode;
fdTableSort.thNode = targ;
fdTableSort.addSortActiveClass();
setTimeout(fdTableSort.initSort,5,false);
};
return fdTableSort.stopEvent(e);
},
keyWrapper: function(e) {
e = e || window.event;
var kc = e.keyCode != null ? e.keyCode : e.charCode;
if(kc == 13) {
var targ = this;
while(targ.tagName.toLowerCase() != "th") targ = targ.parentNode;
fdTableSort.thNode = targ;
fdTableSort.addSortActiveClass();
setTimeout(fdTableSort.initSort,5,false);
return fdTableSort.stopEvent(e);
};
return true;
},
jsWrapper: function(tableid, colNum) {
if(!fdTableSort.tmpCache[tableid] || fdTableSort.tmpCache[tableid].headers[0].length <= colNum || fdTableSort.tmpCache[tableid].headers[0][colNum].className.search(/fd-column/) == -1) return false;
fdTableSort.thNode = fdTableSort.tmpCache[tableid].headers[0][colNum];
fdTableSort.initSort(true);
},
addSortActiveClass: function() {
if(fdTableSort.thNode == null) return;
fdTableSort.addClass(fdTableSort.thNode, "sort-active");
fdTableSort.addClass(document.getElementsByTagName('body')[0], "sort-active");
var tableElem = fdTableSort.thNode;
while(tableElem.tagName.toLowerCase() != 'table' && tableElem.parentNode) {
tableElem = tableElem.parentNode;
};
if("sortInitiatedCallback-" + tableElem.id in window) {
window["sortInitiatedCallback-" + tableElem.id]();
} else if("sortInitiatedCallback" in window) {
sortInitiatedCallback(tableElem.id);
};
},
removeSortActiveClass: function() {
fdTableSort.removeClass(fdTableSort.thNode, "sort-active");
fdTableSort.removeClass(document.getElementsByTagName('body')[0], "sort-active");
var tableElem = fdTableSort.thNode;
while(tableElem.tagName.toLowerCase() != 'table' && tableElem.parentNode) {
tableElem = tableElem.parentNode;
};
if("sortCompleteCallback-" + tableElem.id in window) {
window["sortCompleteCallback-" + tableElem.id]();
} else if("sortCompleteCallback" in window) {
sortCompleteCallback(tableElem.id);
};
},
addClass: function(e,c) {
if(new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className)) return;
e.className += ( e.className ? " " : "" ) + c;
},
removeClass: function(e,c) {
e.className = !c ? "" : e.className.replace(new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
},
prepareTableData: function(table) {
var data = [];
var start = table.getElementsByTagName('tbody');
start = start.length ? start[0] : table;
var trs = start.getElementsByTagName('tr');
var ths = table.getElementsByTagName('th');
var numberOfRows = trs.length;
var numberOfCols = fdTableSort.tmpCache[table.id].cols;
var data = [];
var identical = new Array(numberOfCols);
var identVal  = new Array(numberOfCols);
for(var tmp = 0; tmp < numberOfCols; tmp++) identical[tmp] = true;
var tr, td, th, txt, tds, col, row;
var re = new RegExp(/fd-column-([0-9]+)/);
var rowCnt = 0;
var sortableColumnNumbers = [];
for(var tmp = 0, th; th = ths[tmp]; tmp++) {
if(th.className.search(re) == -1) continue;
sortableColumnNumbers[sortableColumnNumbers.length] = th;
};
for(row = 0; row < numberOfRows; row++) {
tr              = trs[row];
if(tr.parentNode != start || tr.getElementsByTagName("th").length || (tr.parentNode.tagName && tr.parentNode.tagName.toLowerCase() == "tfoot")) continue;
data[rowCnt]    = [];
tds             = tr.getElementsByTagName('td');
for(var tmp = 0, th; th = sortableColumnNumbers[tmp]; tmp++) {
col = th.className.match(re)[1];
td  = tds[col];
txt = fdTableSort.getInnerText(td) + " ";
txt = txt.replace(/^\s+/,'').replace(/\s+$/,'');
if(th.className.search(/sortable-date/) != -1) {
txt = fdTableSort.dateFormat(txt, th.className.search(/sortable-date-dmy/) != -1);
} else if(th.className.search(/sortable-numeric|sortable-currency/) != -1) {
txt = parseFloat(txt.replace(/[^0-9\.\-]/g,''));
if(isNaN(txt)) txt = "";
} else if(th.className.search(/sortable-text/) != -1) {
txt = txt.toLowerCase();
} else if (th.className.search(/sortable-keep/) != -1) {
txt = rowCnt;
} else if(th.className.search(/sortable-([a-zA-Z\_]+)/) != -1) {
if((th.className.match(/sortable-([a-zA-Z\_]+)/)[1] + "PrepareData") in window) {
txt = window[th.className.match(/sortable-([a-zA-Z\_]+)/)[1] + "PrepareData"](td, txt);
};
} else {
if(txt != "") {
fdTableSort.removeClass(th, "sortable");
if(fdTableSort.dateFormat(txt) != 0) {
fdTableSort.addClass(th, "sortable-date");
txt = fdTableSort.dateFormat(txt);
} else if(txt.search(fdTableSort.regExp_Number) != -1 || txt.search(fdTableSort.regExp_Currency) != -1) {
fdTableSort.addClass(th, "sortable-numeric");
txt = parseFloat(txt.replace(/[^0-9\.\-]/g,''));
if(isNaN(txt)) txt = "";
} else {
fdTableSort.addClass(th, "sortable-text");
txt = txt.toLowerCase();
};
};
};
if(rowCnt > 0 && identical[col] && identVal[col] != txt) {
identical[col] = false;
};
identVal[col]     = txt;
data[rowCnt][col] = txt;
};
data[rowCnt][numberOfCols] = tr;
rowCnt++;
}
var colStyle = table.className.search(/colstyle-([\S]+)/) != -1 ? table.className.match(/colstyle-([\S]+)/)[1] : false;
var rowStyle = table.className.search(/rowstyle-([\S]+)/) != -1 ? table.className.match(/rowstyle-([\S]+)/)[1] : false;
fdTableSort.tableCache[table.id] = { data:data, identical:identical, colStyle:colStyle, rowStyle:rowStyle, noArrow:table.className.search(/no-arrow/) != -1 };
sortableColumnNumbers = data = tr = td = th = trs = identical = identVal = null;
},
onUnload: function() {
for(tbl in fdTableSort.tableCache) {
fdTableSort.removeTableCache(tbl);
}
for(tbl in fdTableSort.tmpCache) {
fdTableSort.removeTmpCache(tbl);
}
fdTableSort.removeEvent(window, "load", fdTableSort.initEvt);
fdTableSort.removeEvent(window, "unload", fdTableSort.onUnload);
fdTableSort.tmpCache = fdTableSort.tableCache = null;
},
removeTableCache: function(tableId) {
if(!(tableId in fdTableSort.tableCache)) return;
var data = fdTableSort.tableCache[tableId].data;
for(var i = 0, row; row = data[i]; i++) {
row[row.length - 1] = null;
}
data = row = null;
fdTableSort.tableCache[tableId] = null;
delete fdTableSort.tableCache[tableId];
var tbl = document.getElementById(tableId);
if(!tbl) return;
var ths = tbl.getElementsByTagName("th");
var a;
for(var i = 0, th; th = ths[i]; i++) {
a = th.getElementsByTagName("a");
if(a.length) a[0].onkeypress = a[0].onclick = null;
th.onclick = th.onselectstart = th = a = null;
}
},
removeTmpCache: function(tableId) {
if(!(tableId in fdTableSort.tmpCache)) return;
var headers = fdTableSort.tmpCache[tableId].headers;
var a
for(var i = 0, row; row = headers[i]; i++) {
for(var j = 0, th; th = row[j]; j++) {
a = th.getElementsByTagName("a");
if(a.length) a[0].onkeypress = a[0].onclick = null;
th.onclick = th.onselectstart = th = a = null;
}
}
fdTableSort.tmpCache[tableId] = null;
delete fdTableSort.tmpCache[tableId];
},
initSort: function(noCallback) {
var span;
var thNode      = fdTableSort.thNode;
var tableElem   = fdTableSort.thNode;
while(tableElem.tagName.toLowerCase() != 'table' && tableElem.parentNode) {
tableElem = tableElem.parentNode;
};
if(!tableElem.id || !(tableElem.id in fdTableSort.tableCache)) {
fdTableSort.prepareTableData(tableElem);
};
fdTableSort.tableId = tableElem.id;
fdTableSort.pos = thNode.className.match(/fd-column-([0-9]+)/)[1];
var dataObj     = fdTableSort.tableCache[tableElem.id];
var lastPos     = dataObj.pos ? dataObj.pos.className.match(/fd-column-([0-9]+)/)[1] : -1;
var data        = dataObj.data;
var colStyle    = dataObj.colStyle;
var rowStyle    = dataObj.rowStyle;
var len1        = data.length;
var len2        = data.length > 0 ? data[0].length - 1 : 0;
var identical   = dataObj.identical[fdTableSort.pos];
var noArrow     = dataObj.noArrow;
if(lastPos != fdTableSort.pos && lastPos != -1) {
var th = dataObj.pos;
fdTableSort.removeClass(th, "(forwardSort|reverseSort)");
if(!noArrow) {
span = th.getElementsByTagName('span')[0];
while(span.firstChild) span.removeChild(span.firstChild);
};
};
var classToAdd = "forwardSort";
if((lastPos == fdTableSort.pos && !identical) || (thNode.className.search(/sortable-keep/) != -1 && lastPos == -1)) {
data.reverse();
classToAdd = thNode.className.search(/reverseSort/) != -1 ? "forwardSort" : "reverseSort";
if(thNode.className.search(/sortable-keep/) != -1 && lastPos == -1) fdTableSort.tableCache[tableElem.id].pos = thNode;
} else {
fdTableSort.tableCache[tableElem.id].pos = thNode;
if(!identical) {
if(thNode.className.match(/sortable-(numeric|currency|date|keep)/)) {
data.sort(fdTableSort.sortNumeric);
} else if(thNode.className.match('sortable-text')) {
data.sort(fdTableSort.sortText);
} else if(thNode.className.search(/sortable-([a-zA-Z\_]+)/) != -1 && thNode.className.match(/sortable-([a-zA-Z\_]+)/)[1] in window) {
data.sort(window[thNode.className.match(/sortable-([a-zA-Z\_]+)/)[1]]);
};
};
};
fdTableSort.removeClass(thNode, "(forwardSort|reverseSort)");
fdTableSort.addClass(thNode, classToAdd);
if(!noArrow) {
var arrow = thNode.className.search(/forwardSort/) != -1 ? " \u2193" : " \u2191";
span = thNode.getElementsByTagName('span')[0];
while(span.firstChild) span.removeChild(span.firstChild);
span.appendChild(document.createTextNode(arrow));
};
if(!rowStyle && !colStyle && identical) {
if(!noCallback) fdTableSort.removeSortActiveClass();
fdTableSort.thNode = null;
return;
}
var hook = tableElem.getElementsByTagName('tbody');
hook = hook.length ? hook[0] : tableElem;
var tr, tds;
var rowReg = rowStyle ? new RegExp("(^|\\s*\\b[^-])"+rowStyle+"($|\\b(?=[^-]))", "g") : false;
var colReg = colStyle ? new RegExp("(^|\\s*\\b[^-])"+colStyle+"($|\\b(?=[^-]))", "g") : false;
for(var i = 0; i < len1; i++) {
tr = data[i][len2];
if(colStyle) {
tds = tr.getElementsByTagName('td');
if(lastPos != -1) {
tds[lastPos].className = tds[lastPos].className.replace(colReg, "");
}
fdTableSort.addClass(tds[fdTableSort.pos], colStyle);
tds = null;
};
if(!identical) {
if(rowStyle) {
if(i % 2) fdTableSort.addClass(tr, rowStyle);
else tr.className = tr.className.replace(rowReg, "");
};
hook.removeChild(tr); // Netscape 8.1.2 requires the removeChild call
hook.appendChild(tr);
};
tr = null;
};
if(!noCallback) fdTableSort.removeSortActiveClass();
fdTableSort.thNode = hook = null;
},
getInnerText: function(el) {
if (typeof el == "string" || typeof el == "undefined") return el;
if(el.innerText) return el.innerText;
var txt = '', i;
for (i = el.firstChild; i; i = i.nextSibling) {
if (i.nodeType == 3)            txt += i.nodeValue;
else if (i.nodeType == 1)       txt += fdTableSort.getInnerText(i);
};
return txt;
},
dateFormat: function(dateIn, favourDMY) {
var dateTest = [
{ regExp:/^(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])([- \/.])((\d\d)?\d\d)$/, d:3, m:1, y:5 },  // mdy
{ regExp:/^(0?[1-9]|[12][0-9]|3[01])([- \/.])(0?[1-9]|1[012])([- \/.])((\d\d)?\d\d)$/, d:1, m:3, y:5 },  // dmy
{ regExp:/^(\d\d\d\d)([- \/.])(0?[1-9]|1[012])([- \/.])(0?[1-9]|[12][0-9]|3[01])$/, d:5, m:3, y:1 }   // ymd
];
var start;
var cnt = 0;
var numFormats = dateTest.length;
while(cnt < numFormats) {
start = (cnt + (favourDMY ? numFormats + 1 : numFormats)) % numFormats;
if(dateIn.match(dateTest[start].regExp)) {
res = dateIn.match(dateTest[start].regExp);
y = res[dateTest[start].y];
m = res[dateTest[start].m];
d = res[dateTest[start].d];
if(m.length == 1) m = "0" + String(m);
if(d.length == 1) d = "0" + String(d);
if(y.length != 4) y = (parseInt(y) < 50) ? "20" + String(y) : "19" + String(y);
return y+String(m)+d;
}
cnt++;
}
return 0;
},
sortDate: function(a,b) {
var aa = a[fdTableSort.pos];
var bb = b[fdTableSort.pos];
return aa - bb;
},
sortNumeric:function (a,b) {
var aa = a[fdTableSort.pos];
var bb = b[fdTableSort.pos];
if(aa == bb) return 0;
if(aa === "" && !isNaN(bb)) return -1;
if(bb === "" && !isNaN(aa)) return 1;
return aa - bb;
},
sortText:function (a,b) {
var aa = a[fdTableSort.pos];
var bb = b[fdTableSort.pos];
if(aa == bb) return 0;
if(aa < bb)  return -1;
return 1;
}
};
fdTableSort.addEvent(window, "load", fdTableSort.initEvt);
fdTableSort.addEvent(window, "unload", fdTableSort.onUnload);
/*
paginate table object v1.1 by frequency-decoder.com
Released under a creative commons Attribution-ShareAlike 2.5 license (http://creativecommons.org/licenses/by-sa/2.5/)
Please credit frequency decoder in any derivative work - thanks
You are free:
* to copy, distribute, display, and perform the work
* to make derivative works
* to make commercial use of the work
Under the following conditions:
by Attribution.
--------------
You must attribute the work in the manner specified by the author or licensor.
sa
--
Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one.
* For any reuse or distribution, you must make clear to others the license terms of this work.
* Any of these conditions can be waived if you get permission from the copyright holder.
*/
/* The sortCompleteCallback does nothing but call the pagination object below, passing in the table id */
function sortCompleteCallback(tableId) {
tablePaginater.showPage(tableId);
}
/* This is the JS object that paginates the table (N.B: Tables do not have to be sortable to use this object) */
var tablePaginater = {
tableInfo: {},
init: function() {
var tables = document.getElementsByTagName('table');
for(var t = 0, tbl; tbl = tables[t]; t++) {
if(!tbl.id || tbl.id == "" || tbl.className.search(/paginate-([0-9]+)/) == -1) continue;
tablePaginater.tableInfo[tbl.id] = {
rowsPerPage:tbl.className.match(/paginate-([0-9]+)/)[1],
currentPage:0
};
tablePaginater.showPage(tbl.id, 0);
tablePaginater.createPageinationList(tbl.id);
};
},
addClass: function(e,c) {
if(new RegExp("(^|\\s)" + c + "(\\s|$)").test(e.className)) return;
e.className += ( e.className ? " " : "" ) + c;
},
removeClass: function(e,c) {
e.className = !c ? "" : e.className.replace(new RegExp("(^|\\s*\\b[^-])"+c+"($|\\b(?=[^-]))", "g"), "");
},
/* I shall leave it as an excercise for the reader to create the next|prev links commonly
found within such pagination systems. I'm just creating a simple linked list(s).       */
createPageinationList: function(tableId) {
var tbl = document.getElementById(tableId);
var ul = document.createElement("ul");
ul.className = "tablePaginater";
ul.id = "paginateList-" + tableId;
var ulc = ul.cloneNode(true);
ulc.id =  "paginateList-" + tableId + "-clone";
if ($(ul.id)) $(ul.id).remove();
if ($(ulc.id)) $(ulc.id).remove();
var rows = tablePaginater.getTableRows(tableId);
var total = rows.length;
var rowsPerPage
var pages = Math.max(1, Math.ceil(total / tablePaginater.tableInfo[tableId].rowsPerPage));
if (total <= tablePaginater.tableInfo[tableId].rowsPerPage) return false;
var li = document.createElement("li");
var a  = document.createElement("a");
a.href = "#";
var lic, ac;
for(var i = 0; i < pages; i++) {
lic = li.cloneNode(false);
ac  = a.cloneNode(true);
ac.appendChild(document.createTextNode(i+1));
lic.onclick = a.onclick = tablePaginater.show;
lic.appendChild(ac);
if(i == 0) lic.className = "currentPage";
ul.appendChild(lic);
lic = lic.cloneNode(true);
lic.onclick = lic.getElementsByTagName("a")[0].onclick = tablePaginater.show;
ulc.appendChild(lic);
};
if(tbl.nextSibling) {
tbl.parentNode.insertBefore(ul, tbl.nextSibling);
} else {
tbl.parentNode.appendChild(ul);
};
tbl.parentNode.insertBefore(ulc, tbl);
},
getTableRows: function(tableId) {
var rows = [];
var tbl = document.getElementById(tableId);
var tbody = tbl.getElementsByTagName('tbody');
if(tbody && tbody.length) {
tbody = tbody[0];
rows = tbody.getElementsByTagName('tr');
} else {
var tmp = tbl.getElementsByTagName('tr');
for(var i = tmp.length; i--;) {
if(tmp[i].getElementsByTagName('th') || tmp[i].parentNode.tagName == "TFOOT") continue;
rows[rows.length] = tmp[i];
};
};
return rows;
},
showPage: function(tableId, page) {
if(!(tableId in tablePaginater.tableInfo)) return;
var tbl = document.getElementById(tableId);
var rowsPerPage = tablePaginater.tableInfo[tableId].rowsPerPage;
var rows = tablePaginater.getTableRows(tableId);
page = typeof page == "undefined" ? tablePaginater.tableInfo[tableId].currentPage : page;
var min = rowsPerPage * page;
var max = Number(min) + Number(rowsPerPage);
var rowStyle = tbl.className.search(/rowstyle-([\S]+)/) != -1 ? tbl.className.match(/rowstyle-([\S]+)/)[1] : false;
var cnt = 0;
var len = rows.length;
for(var i = 0; i < len; i++) {
rows[i].style.display = (i >= min && i < max) ? "" : "none";
if(rowsPerPage % 2 && rowStyle && i >= min && i < max) {
tablePaginater.removeClass(rows[i], rowStyle);
if(cnt++ % 2) tablePaginater.addClass(rows[i], rowStyle);
};
};
tablePaginater.tableInfo[tableId].currentPage = page;
},
/* Event handler for the li|a click event */
show: function(e) {
var li = (this.tagName && this.tagName == "A") ? this.parentNode : this;
var tableId = li.parentNode.id.replace("paginateList-", "").replace("-clone", "");
var cnt     = 0;
while(li.previousSibling) {
li = li.previousSibling;
if(li.tagName && li.tagName.toLowerCase() == "li") cnt++;
};
tablePaginater.showPage(tableId, cnt);
var ul  = document.getElementById("paginateList-" + tableId);
var ulc = document.getElementById("paginateList-" + tableId + "-clone");
var i   = 0;
while(ul.childNodes[i]) {
ul.childNodes[i].className = ulc.childNodes[i].className = i == cnt ? "currentPage" : "";
i++;
};
return false;
}
}
fdTableSort.addEvent(window, "load", tablePaginater.init);
function mouseCoordinates(ev)
{
ev = ev || window.event;
if(ev.pageX || ev.pageY) return {x:ev.pageX, y:ev.pageY};
return {x:ev.clientX + document.body.scrollLeft - document.body.clientLeft, y:ev.clientY + document.body.scrollTop  - document.body.clientTop};
}
function getPosition(obj)
{
var left = 0;
var top  = 0;
while (obj.offsetParent)
{
left += obj.offsetLeft;
top  += obj.offsetTop;
obj   = obj.offsetParent;
}
left += obj.offsetLeft;
top  += obj.offsetTop;
return {x:left, y:top};
}
function hex(c)
{
c=parseInt(c).toString(16);
return c.length<2?"0"+c:c
}
function getHorizGray(i, width)
{
var c=i%width; // column
if (c==0 || c==1) return hex(255)+hex(255)+hex(255);
if (c==52 || c==53) return hex(0)+hex(0)+hex(0);
var l=(255/(width-4))*(c-2); // color percentage
return hex(255-l)+hex(255-l)+hex(255-l);
}
function getHorizColor(i, width, height)
{
var sWidth = (width)/6;         // "section" width
var C=i%width;                  // column
var R=Math.floor(i/(sWidth*6)); // row
var c=i%sWidth;                 // column in current group
var r, g, b, h;
var l=(255/sWidth)*c;           // color percentage
h=255-l;
r=C<sWidth?255:C<sWidth*2?h:C<sWidth*4?0:C<sWidth*5?l:255;
g=C<sWidth?l:C<sWidth*3?255:C<sWidth*4?h:0;
b=C<sWidth*2?0:C<sWidth*3?l:C<sWidth*5?255:h;
if(R<(height/2))
{
var base = 255-(255*2/height)*R;
r=base+(r*R*2/height);
g=base+(g*R*2/height);
b=base+(b*R*2/height);
}
else if(R>(height/2))
{
var base = (height-R)/(height/2);
r=r*base;
g=g*base;
b=b*base;
}
return hex(r)+hex(g)+hex(b);
}
function hGrayPickerMouseMove(ev, previewObj)
{
ev            = ev || window.event;
var hCPImg    = ev.target || ev.srcElement;
var mousePos  = mouseCoordinates(ev);
var colorPos  = getPosition(hCPImg);
var x         = mousePos.x-colorPos.x;
var y         = mousePos.y-colorPos.y;
var width     = parseInt(hCPImg.offsetWidth);
var height    = parseInt(hCPImg.offsetHeight);
var color     = getHorizGray(y*width+x-1, width, height);
previewObj.style.backgroundColor = '#'+color;
}
function hGrayPickerMouseDown(ev, previewObj, inputObj)
{
ev            = ev || window.event;
var hCPImg    = ev.target || ev.srcElement;
var mousePos  = mouseCoordinates(ev);
var colorPos  = getPosition(hCPImg);
tt_HideInit();
var x         = mousePos.x-colorPos.x;
var y         = mousePos.y-colorPos.y;
var width     = parseInt(hCPImg.offsetWidth);
var height    = parseInt(hCPImg.offsetHeight);
var color     = getHorizGray(y*width+x-1, width, height);
previewObj.style.backgroundColor = '#'+color;
inputObj.value = ('#'+color).toUpperCase();
}
function hColorPickerMouseMove(ev, previewObj)
{
ev            = ev || window.event;
var hCPImg    = ev.target || ev.srcElement;
var mousePos  = mouseCoordinates(ev);
var colorPos  = getPosition(hCPImg);
var x         = mousePos.x-colorPos.x;
var y         = mousePos.y-colorPos.y;
var width     = parseInt(hCPImg.offsetWidth);
var height    = parseInt(hCPImg.offsetHeight);
var color     = getHorizColor(y*width+x-1, width, height);
previewObj.style.backgroundColor = '#'+color;
}
function hColorPickerMouseDown(ev, previewObj, inputObj)
{
ev            = ev || window.event;
var hCPImg    = ev.target || ev.srcElement;
var mousePos  = mouseCoordinates(ev);
var colorPos  = getPosition(hCPImg);
tt_HideInit();
var x         = mousePos.x-colorPos.x;
var y         = mousePos.y-colorPos.y;
var width     = parseInt(hCPImg.offsetWidth);
var height    = parseInt(hCPImg.offsetHeight);
var color     = getHorizColor(y*width+x-1, width, height);
previewObj.style.backgroundColor = '#'+color;
inputObj.value = ('#'+color).toUpperCase();
}
function responseDummy(Resp) {
};
function openFeedbackDialog() {
$('FeedbackFormPane').innerHTML = T("loading");
showModalDialog("FeedbackDialog", T("feedback.title"), 500, 450);
x_getEmptyFeedbackForm(showFeedbackDialog);
};
function showFeedbackDialog(resp) {
updateID('FeedbackFormPane', resp);
win.setContent('FeedbackDialog', true);
};
function hideFeedbackForm() {
hideModalDialog();
};
function myAlert(text) {
Dialog.alert(text, {width:300, height:100, okLabel: "OK"});
};
function getInnerText(el) {
if(typeof el.innerText != "undefined") {
return el.innerText;
} else {
return el.textContent;
}
};
function getRadioValue(formname, elname) {
var radiovalue;
try {
Form.getInputs(formname, 'radio').each(function(input) {
if(input.name==elname && input.checked) {
radiovalue=input.value
};
});
return radiovalue;
} catch(e) {
alert(e);
return false;
}
};
function getCheckValue(elname) {
if ($F(elname) == "on") {
return 1;
} else {
return 0;
}
};
function setToolTip(el, text) {
$(el).onmouseover = 'return escape("' + text + '");';
};
function strikeThrough(obj) {
obj.innerHTML = '<span style="text-decoration:line-through">' + obj.innerHTML + '</span>';
};
function addOnLoadEvent(func) {
var oldonload = window.onload;
if (typeof window.onload != 'function') {
window.onload = func;
} else {
window.onload = function() {
if (oldonload) {
oldonload();
}
func();
}
}
};
function addOnClickEvent(obj, func) {
var oldonclick = obj.onclick;
if (typeof obj.onclick != 'function') {
obj.onclick = func;
} else {
obj.onclick = function() {
if (oldonclick) {
oldonclick();
}
func();
}
}
};
function addOnChangeEvent(obj, func) {
var oldonchange = obj.onchange;
if (typeof obj.onchange != 'function') {
obj.onchange = func;
} else {
obj.onchange = function() {
if (oldonchange) {
oldonchange();
}
func();
}
}
};
function addOnKeyUpEvent(obj, func) {
var oldonkeyup = obj.onkeyup;
if (typeof obj.onkeyup != 'function') {
obj.onkeyup = func;
} else {
obj.onkeyup = function() {
if (oldonkeyup) {
oldonkeyup();
}
func();
}
}
};
function getCurHRefBase() {
var href = window.location.href;
var comp = href.split("/");
comp.pop();
return comp.join("/") + "/";
};
function JSDate2SQL(jsdate) {
return jsdate.getFullYear() + '-' + (jsdate.getMonth()+1) + '-' + jsdate.getDate() +
  ' ' + jsdate.getHours() + ':' + jsdate.getMinutes() + ':00';
};
function showModalDialog(name, caption, width, height, zindex) {
if (arguments.length<3) width = 350;
if (arguments.length<4) height = 220;
win = new Window({className: "alphacube", title:caption, zIndex: zindex, minWidth:width, minHeight:height, resizable:true, minimizable:false, maximizable:false, destroyOnClose:false, recenterAuto:true});
win.setContent(name, true);
win.showCenter(true);
resizeModalDialog();
};
function hideModalDialog(name) {
win.close();
};
function resizeModalDialog() {
win.updateWidth();
win.updateHeight();
};
function bindOnClick(elID, funcName, obj) {
if ($(elID)) addOnClickEvent($(elID), funcName.bind(obj));
};
function bindOnChange(elID, funcName, obj) {
if ($(elID)) addOnChangeEvent($(elID), funcName.bind(obj));
};
function bindOnKeyUp(elID, funcName, obj) {
if ($(elID)) addOnKeyUpEvent($(elID), funcName.bind(obj));
};
function bindOnReturn(elID, funcName, obj, evalcode) {
if (arguments.length < 4) evalcode = "";
if ($(elID)) $(elID).onkeypress = function(event) {
var code = (event.which) ? event.which : event.keyCode;
if (code == 13) {
if (evalcode != "") {
eval(evalcode);
} else {
funcName();
}
}
}.bindAsEventListener(obj);
};
function exchangeMainPage(name) {
$('Loading').show();
x_getMainPage(name, exchangeMainPage_Resp);
};
function registerDynScripts(obj) {
scripts = obj.getElementsByTagName('script');
for (i=0; i<scripts.length; i++) {
eval(scripts[i].innerHTML);
}
}
function exchangeMainPage_Resp(resp) {
$('MainContentPane').innerHTML =
'<img id="Loading" src="images/loading.gif" align="right" title="' + T('loading') + '..."/>' +
resp;
registerDynScripts($('MainContentPane'));
setTitleBar();
$('Loading').hide();
};
function updateID(id, resp) {
if ($(id)) {
$(id).innerHTML = unescape(resp);
registerDynScripts($(id));
}
};
function closeAllQuickEntry() {
var list = document.getElementsByClassName('NewQuickEntry');
for (i=0; i<list.length; i++) {
list[i].hide();
}
};
function MyTab(Caption, ID, Link, Pane, JSCode, ConObject) {
this.Caption = Caption;
this.ID = ID;
this.Link = Link;
this.Pane = Pane;
this.JSCode = JSCode;
this.ConObject = ConObject;
};
function MyTabs(VarName, Container) {
this.VarName = VarName;
this.Container = Container;
this.Class = "CommandArea";
this.MainMenuLink = false;
this.DisplayType = 0;
this.ActiveTab = 0;
this.Tabs = new Array();
};
MyTabs.prototype.setActiveTab = function(tabIdx) {
for (var i=0; i<this.Tabs.length; i++) {
if (this.Tabs[i].Pane != "" && $(this.Tabs[i].Pane)) {
$(this.Tabs[i].Pane).hide();
}
if (this.Tabs[i].ConObject != "" && $(this.Tabs[i].ConObject)) {
$(this.Tabs[i].ConObject).hide();
}
if (this.Tabs[i].ID != "" && this.Tabs[i].ID == tabIdx) tabIdx = i;
}
this.ActiveTab = tabIdx;
if (tabIdx >= 0) {
this.ActiveTabKey = this.Tabs[tabIdx].ID;
if ($(this.Tabs[tabIdx].Pane)) {
$(this.Tabs[tabIdx].Pane).show();
}
if ($(this.Tabs[tabIdx].ConObject)) {
$(this.Tabs[tabIdx].ConObject).show();
}
if (this.Tabs[tabIdx].JSCode != "") {
eval(this.Tabs[tabIdx].JSCode);
}
}
this.showTabs();
};
MyTabs.prototype.setNextTab = function() {
this.setActiveTab(this.ActiveTab+1);
};
MyTabs.prototype.hideIfOne = function() {
if (this.Tabs.length <= 1) {
$(this.Container).innerHTML = '<div class="CommandArea2">&nbsp;</div>';
if ($('MainMenuContent')) $('MainMenuContent').show();
}
};
MyTabs.prototype.showTabs = function() {
var ret = "";
var onClickStr = "";
if (this.DisplayType == 0) {
if ($(this.Container)) {
ret += '<div class="' + this.Class + ' tabstrip">';
if (this.MainMenuLink) {
if ($("MainMenuContent")) {
$("MainMenuContent").hide();
ret += '<div id="ShowMainMenuContent" style="float:left;vertical-align:middle">';
ret += '<a href="#" onclick="$(\'ShowMainMenuContent\').hide();$(\'MainMenuContent\').show();">';
ret += '<img src="images/up.gif" align="left" vspace="0" hspace="2"/> '+T('Mainmenu');
ret += '</a></div>';
}
}
ret += '<ul>&nbsp;';
for (var i=0; i<this.Tabs.length; i++) {
ret += '<li>';
if (this.ActiveTab == i && (this.Tabs.length > 1 || this.Tabs[i].Link == "")) {
ret += '<span class="selected">' + this.Tabs[i].Caption + "</span>";
} else {
onClickStr = '';
if (this.Tabs[i].Link == "") {
if (this.Tabs[i].Pane != "") {
onClickStr += 'onClick="' + this.VarName + '.setActiveTab(' + i + ');';
onClickStr += '"';
} else {
if (this.Tabs[i].JSCode != "") {
onClickStr += 'onClick="' + this.Tabs[i].JSCode + ';"';
}
}
ret += '<nobr><a href="#" id="' + this.Tabs[i].ID + '" ' + onClickStr + '>';
ret += this.Tabs[i].Caption;
ret += '</a></nobr>';
} else {
if (this.Tabs[i].JSCode != "") {
onClickStr += 'onClick="' + this.Tabs[i].JSCode + '"';
}
ret += '<nobr><a href="' + this.Tabs[i].Link + '" id="' + this.Tabs[i].ID + '" ' + onClickStr + '>';
ret += this.Tabs[i].Caption;
ret += '</a></nobr>';
}
}
ret += '</li>';
ret += '<li class="spacer"> </li>';
}
ret += '</ul>';
ret += '</div>';
$(this.Container).innerHTML = ret;
}
} else {
for (var i=0; i<this.Tabs.length; i++) {
onClickStr = "$('" + this.Tabs[i].Pane + "').toggle();$('" + this.Tabs[i].ID + "_closedimg').toggle();$('" + this.Tabs[i].ID + "_openimg').toggle();";
ret = '<div class="paragraph">';
ret += '<h2 class="link" onclick="' + onClickStr + '">';
if (this.ActiveTab == i) {
ret += '<img id="' + this.Tabs[i].ID + '_closedimg" src="/images/bullet.png" style="display:none"/>';
ret += '<img id="' + this.Tabs[i].ID + '_openimg" src="/images/bullet_down.png"/>';
} else {
ret += '<img id="' + this.Tabs[i].ID + '_closedimg" src="/images/bullet.png"/>';
ret += '<img id="' + this.Tabs[i].ID + '_openimg" src="/images/bullet_down.png" style="display:none"/>';
}
ret += this.Tabs[i].Caption;
ret += '</h2>';
ret += '<div/>';
if ($(this.Tabs[i].ID + '_menu')) $(this.Tabs[i].ID + '_menu').remove();
var menu = document.createElement('div');
menu.id = this.Tabs[i].ID + '_menu';
menu.innerHTML = ret;
$('EventEditPane').insertBefore(menu, $(this.Tabs[i].Pane));
}
}
};
MyTabs.prototype.addTab = function(Caption, ID, Link, Pane, JSCode, ConObject) {
ID = (arguments.length >= 2) ? ID : "";
Link = (arguments.length >= 3) ? Link : "";
Pane = (arguments.length >= 4) ? Pane : "";
JSCode = (arguments.length >= 5) ? JSCode : "";
ConObject = (arguments.length >= 6) ? ConObject : "";
this.Tabs[this.Tabs.length] = new MyTab(Caption, ID, Link, Pane, JSCode, ConObject);
};
function updateDynamics() {
fdTableSort.init();
tablePaginater.init();
};
function ieGallery(element, idx) {
this.allItems = element.getElementsByClassName('imageElement');
this.allItems.each(function(el) {
var img = el.getElementsByClassName("full")[0];
el.style.backgroundImage = "url('" + img.src + "')";
});
this.currentItem = 0;
this.selectItem(idx);
};
ieGallery.prototype.selectItem = function(idx) {
this.allItems[this.currentItem].style.display = "none";
this.allItems[idx].style.display = "block";
this.currentItem = idx;
};
ieGallery.prototype.prevItem = function() {
var idx = this.currentItem;
idx--;
if( idx < 0 ) idx = this.allItems.length - 1;
this.selectItem(idx);
};
ieGallery.prototype.nextItem = function() {
var idx = this.currentItem;
idx++;
if( idx >= this.allItems.length ) idx = 0;
this.selectItem(idx);
};
var FCKeditorLoaded = false;
function FCKeditor_OnComplete(editorInstance) {
FCKeditorLoaded = true;
}
function switchEditors(ID) {
if(!FCKeditorLoaded) {
setTimeout('switchEditors(\'' + ID + '\')', 500);
return;
}
DoSwitchEditors(document.getElementById(ID));
}
function DoSwitchEditors(oNode) {
var i;
for (i = 0; i < oNode.childNodes.length;i++) {
childNode = oNode.childNodes.item(i);
editor = FCKeditorAPI.GetInstance(childNode.name);
if (editor && editor.EditorDocument && editor.EditMode == FCK_EDITMODE_WYSIWYG) {
editor.SwitchEditMode();
editor.SwitchEditMode();
}
DoSwitchEditors(childNode);
}
}
function saveBookmark(text) {
if (Prototype.Browser.IE) {
window.external.addFavorite(location.href, text);
} else {
window.sidebar.addPanel(text, location.href, "");
}
}
function loadScript(link, id) {
if ($(id)) return false;
var d = document.createElement('div');
d.id = id;
var a = document.createElement('script');
a.setAttribute('type', 'text/javascript');
a.setAttribute('src', link);
d.appendChild(a);
document.getElementsByTagName('body')[0].appendChild(d);
/*registerDynScripts(d);*/
}
/** returns an Elements absolute screen position
*/
function getElementPosition(obj) {
if (!obj) return false;
var curleft = curtop = 0;
if (obj.offsetParent) {
curleft = obj.offsetLeft
curtop = obj.offsetTop
while (obj = obj.offsetParent) {
curleft += obj.offsetLeft
curtop += obj.offsetTop
}
}
return [curleft,curtop];
}
function getRadioValue2(radioGroup) {
var r = document.getElementsByName(radioGroup);
for (var i=0; i<r.length; i++) {
if (r[i].checked) return r[i].value;
}
return null;
}
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
}
function showEMTicketShop(EventKey) {
window.open("https://www.eventmotor.com/shopwidget.php?AccessKey=" + EventKey, 'EMShopWidget', 'width=600,height=400,scrollbars=yes,location=no,menubar=no,toolbar=no,status=no,resizable=yes,screenX=15,screenY=10');
return false;
};