var Prototype={Version:"1.7",Browser:(function(){var b=navigator.userAgent;var a=Object.prototype.toString.call(window.opera)=="[object Opera]";return{IE:!!window.attachEvent&&!a,Opera:a,WebKit:b.indexOf("AppleWebKit/")>-1,Gecko:b.indexOf("Gecko")>-1&&b.indexOf("KHTML")===-1,MobileSafari:/Apple.*Mobile/.test(b)}})(),BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:(function(){var a=window.Element||window.HTMLElement;return !!(a&&a.prototype)})(),SpecificElementExtensions:(function(){if(typeof window.HTMLDivElement!=="undefined"){return true}var c=document.createElement("div"),b=document.createElement("form"),a=false;if(c.__proto__&&(c.__proto__!==b.__proto__)){a=true}c=b=null;return a})()},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}var Abstract={};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(f){}}return c}};var Class=(function(){var d=(function(){for(var e in {toString:1}){if(e==="toString"){return false}}return true})();function a(){}function b(){var h=null,g=$A(arguments);if(Object.isFunction(g[0])){h=g.shift()}function e(){this.initialize.apply(this,arguments)}Object.extend(e,Class.Methods);e.superclass=h;e.subclasses=[];if(h){a.prototype=h.prototype;e.prototype=new a;h.subclasses.push(e)}for(var f=0,j=g.length;f<j;f++){e.addMethods(g[f])}if(!e.prototype.initialize){e.prototype.initialize=Prototype.emptyFunction}e.prototype.constructor=e;return e}function c(l){var g=this.superclass&&this.superclass.prototype,f=Object.keys(l);if(d){if(l.toString!=Object.prototype.toString){f.push("toString")}if(l.valueOf!=Object.prototype.valueOf){f.push("valueOf")}}for(var e=0,h=f.length;e<h;e++){var k=f[e],j=l[k];if(g&&Object.isFunction(j)&&j.argumentNames()[0]=="$super"){var m=j;j=(function(i){return function(){return g[i].apply(this,arguments)}})(k).wrap(m);j.valueOf=m.valueOf.bind(m);j.toString=m.toString.bind(m)}this.prototype[k]=j}return this}return{create:b,Methods:{addMethods:c}}})();(function(){var C=Object.prototype.toString,B="Null",o="Undefined",v="Boolean",f="Number",s="String",H="Object",t="[object Function]",y="[object Boolean]",g="[object Number]",l="[object String]",h="[object Array]",x="[object Date]",i=window.JSON&&typeof JSON.stringify==="function"&&JSON.stringify(0)==="0"&&typeof JSON.stringify(Prototype.K)==="undefined";function k(J){switch(J){case null:return B;case (void 0):return o}var I=typeof J;switch(I){case"boolean":return v;case"number":return f;case"string":return s}return H}function z(I,K){for(var J in K){I[J]=K[J]}return I}function G(I){try{if(c(I)){return"undefined"}if(I===null){return"null"}return I.inspect?I.inspect():String(I)}catch(J){if(J instanceof RangeError){return"..."}throw J}}function D(I){return F("",{"":I},[])}function F(R,O,P){var Q=O[R],N=typeof Q;if(k(Q)===H&&typeof Q.toJSON==="function"){Q=Q.toJSON(R)}var K=C.call(Q);switch(K){case g:case y:case l:Q=Q.valueOf()}switch(Q){case null:return"null";case true:return"true";case false:return"false"}N=typeof Q;switch(N){case"string":return Q.inspect(true);case"number":return isFinite(Q)?String(Q):"null";case"object":for(var J=0,I=P.length;J<I;J++){if(P[J]===Q){throw new TypeError()}}P.push(Q);var M=[];if(K===h){for(var J=0,I=Q.length;J<I;J++){var L=F(J,Q,P);M.push(typeof L==="undefined"?"null":L)}M="["+M.join(",")+"]"}else{var S=Object.keys(Q);for(var J=0,I=S.length;J<I;J++){var R=S[J],L=F(R,Q,P);if(typeof L!=="undefined"){M.push(R.inspect(true)+":"+L)}}M="{"+M.join(",")+"}"}P.pop();return M}}function w(I){return JSON.stringify(I)}function j(I){return $H(I).toQueryString()}function p(I){return I&&I.toHTML?I.toHTML():String.interpret(I)}function r(I){if(k(I)!==H){throw new TypeError()}var J=[];for(var K in I){if(I.hasOwnProperty(K)){J.push(K)}}return J}function d(I){var J=[];for(var K in I){J.push(I[K])}return J}function A(I){return z({},I)}function u(I){return !!(I&&I.nodeType==1)}function m(I){return C.call(I)===h}var b=(typeof Array.isArray=="function")&&Array.isArray([])&&!Array.isArray({});if(b){m=Array.isArray}function e(I){return I instanceof Hash}function a(I){return C.call(I)===t}function n(I){return C.call(I)===l}function q(I){return C.call(I)===g}function E(I){return C.call(I)===x}function c(I){return typeof I==="undefined"}z(Object,{extend:z,inspect:G,toJSON:i?w:D,toQueryString:j,toHTML:p,keys:Object.keys||r,values:d,clone:A,isElement:u,isArray:m,isHash:e,isFunction:a,isString:n,isNumber:q,isDate:E,isUndefined:c})})();Object.extend(Function.prototype,(function(){var k=Array.prototype.slice;function d(o,l){var n=o.length,m=l.length;while(m--){o[n+m]=l[m]}return o}function i(m,l){m=k.call(m,0);return d(m,l)}function g(){var l=this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1].replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g,"").replace(/\s+/g,"").split(",");return l.length==1&&!l[0]?[]:l}function h(n){if(arguments.length<2&&Object.isUndefined(arguments[0])){return this}var l=this,m=k.call(arguments,1);return function(){var o=i(m,arguments);return l.apply(n,o)}}function f(n){var l=this,m=k.call(arguments,1);return function(p){var o=d([p||window.event],m);return l.apply(n,o)}}function j(){if(!arguments.length){return this}var l=this,m=k.call(arguments,0);return function(){var n=i(m,arguments);return l.apply(this,n)}}function e(n){var l=this,m=k.call(arguments,1);n=n*1000;return window.setTimeout(function(){return l.apply(l,m)},n)}function a(){var l=d([0.01],arguments);return this.delay.apply(this,l)}function c(m){var l=this;return function(){var n=d([l.bind(this)],arguments);return m.apply(this,n)}}function b(){if(this._methodized){return this._methodized}var l=this;return this._methodized=function(){var m=d([this],arguments);return l.apply(null,m)}}return{argumentNames:g,bind:h,bindAsEventListener:f,curry:j,delay:e,defer:a,wrap:c,methodize:b}})());(function(c){function b(){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"}function a(){return this.toISOString()}if(!c.toISOString){c.toISOString=b}if(!c.toJSON){c.toJSON=a}})(Date.prototype);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();this.currentlyExecuting=false}catch(a){this.currentlyExecuting=false;throw a}}}});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,(function(){var NATIVE_JSON_PARSE_SUPPORT=window.JSON&&typeof JSON.parse==="function"&&JSON.parse('{"test": true}').test;function prepareReplacement(replacement){if(Object.isFunction(replacement)){return replacement}var template=new Template(replacement);return function(match){return template.evaluate(match)}}function gsub(pattern,replacement){var result="",source=this,match;replacement=prepareReplacement(replacement);if(Object.isString(pattern)){pattern=RegExp.escape(pattern)}if(!(pattern.length||pattern.source)){replacement=replacement("");return replacement+source.split("").join(replacement)+replacement}while(source.length>0){if(match=source.match(pattern)){result+=source.slice(0,match.index);result+=String.interpret(replacement(match));source=source.slice(match.index+match[0].length)}else{result+=source,source=""}}return result}function sub(pattern,replacement,count){replacement=prepareReplacement(replacement);count=Object.isUndefined(count)?1:count;return this.gsub(pattern,function(match){if(--count<0){return match[0]}return replacement(match)})}function scan(pattern,iterator){this.gsub(pattern,iterator);return String(this)}function truncate(length,truncation){length=length||30;truncation=Object.isUndefined(truncation)?"...":truncation;return this.length>length?this.slice(0,length-truncation.length)+truncation:String(this)}function strip(){return this.replace(/^\s+/,"").replace(/\s+$/,"")}function stripTags(){return this.replace(/<\w+(\s+("[^"]*"|'[^']*'|[^>])+)?>|<\/\w+>/gi,"")}function stripScripts(){return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"")}function extractScripts(){var matchAll=new RegExp(Prototype.ScriptFragment,"img"),matchOne=new RegExp(Prototype.ScriptFragment,"im");return(this.match(matchAll)||[]).map(function(scriptTag){return(scriptTag.match(matchOne)||["",""])[1]})}function evalScripts(){return this.extractScripts().map(function(script){return eval(script)})}function escapeHTML(){return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}function unescapeHTML(){return this.stripTags().replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&amp;/g,"&")}function toQueryParams(separator){var match=this.strip().match(/([^?#]*)(#.*)?$/);if(!match){return{}}return match[1].split(separator||"&").inject({},function(hash,pair){if((pair=pair.split("="))[0]){var key=decodeURIComponent(pair.shift()),value=pair.length>1?pair.join("="):pair[0];if(value!=undefined){value=decodeURIComponent(value)}if(key in hash){if(!Object.isArray(hash[key])){hash[key]=[hash[key]]}hash[key].push(value)}else{hash[key]=value}}return hash})}function toArray(){return this.split("")}function succ(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)}function times(count){return count<1?"":new Array(count+1).join(this)}function camelize(){return this.replace(/-+(.)?/g,function(match,chr){return chr?chr.toUpperCase():""})}function capitalize(){return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase()}function underscore(){return this.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/-/g,"_").toLowerCase()}function dasherize(){return this.replace(/_/g,"-")}function inspect(useDoubleQuotes){var escapedString=this.replace(/[\x00-\x1f\\]/g,function(character){if(character in String.specialChar){return String.specialChar[character]}return"\\u00"+character.charCodeAt().toPaddedString(2,16)});if(useDoubleQuotes){return'"'+escapedString.replace(/"/g,'\\"')+'"'}return"'"+escapedString.replace(/'/g,"\\'")+"'"}function unfilterJSON(filter){return this.replace(filter||Prototype.JSONFilter,"$1")}function isJSON(){var str=this;if(str.blank()){return false}str=str.replace(/\\(?:["\\\/bfnrt]|u[0-9a-fA-F]{4})/g,"@");str=str.replace(/"[^"\\\n\r]*"|true|false|null|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?/g,"]");str=str.replace(/(?:^|:|,)(?:\s*\[)+/g,"");return(/^[\],:{}\s]*$/).test(str)}function evalJSON(sanitize){var json=this.unfilterJSON(),cx=/[\u0000\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g;if(cx.test(json)){json=json.replace(cx,function(a){return"\\u"+("0000"+a.charCodeAt(0).toString(16)).slice(-4)})}try{if(!sanitize||json.isJSON()){return eval("("+json+")")}}catch(e){}throw new SyntaxError("Badly formed JSON string: "+this.inspect())}function parseJSON(){var json=this.unfilterJSON();return JSON.parse(json)}function include(pattern){return this.indexOf(pattern)>-1}function startsWith(pattern){return this.lastIndexOf(pattern,0)===0}function endsWith(pattern){var d=this.length-pattern.length;return d>=0&&this.indexOf(pattern,d)===d}function empty(){return this==""}function blank(){return/^\s*$/.test(this)}function interpolate(object,pattern){return new Template(this,pattern).evaluate(object)}return{gsub:gsub,sub:sub,scan:scan,truncate:truncate,strip:String.prototype.trim||strip,stripTags:stripTags,stripScripts:stripScripts,extractScripts:extractScripts,evalScripts:evalScripts,escapeHTML:escapeHTML,unescapeHTML:unescapeHTML,toQueryParams:toQueryParams,parseQuery:toQueryParams,toArray:toArray,succ:succ,times:times,camelize:camelize,capitalize:capitalize,underscore:underscore,dasherize:dasherize,inspect:inspect,unfilterJSON:unfilterJSON,isJSON:isJSON,evalJSON:NATIVE_JSON_PARSE_SUPPORT?parseJSON:evalJSON,include:include,startsWith:startsWith,endsWith:endsWith,empty:empty,blank:blank,interpolate:interpolate}})());var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(a){if(a&&Object.isFunction(a.toTemplateReplacements)){a=a.toTemplateReplacements()}return this.template.gsub(this.pattern,function(d){if(a==null){return(d[1]+"")}var f=d[1]||"";if(f=="\\"){return d[2]}var b=a,g=d[3],e=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;d=e.exec(g);if(d==null){return f}while(d!=null){var c=d[1].startsWith("[")?d[2].replace(/\\\\]/g,"]"):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)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable=(function(){function c(y,x){var w=0;try{this._each(function(A){y.call(x,A,w++)})}catch(z){if(z!=$break){throw z}}return this}function r(z,y,x){var w=-z,A=[],B=this.toArray();if(z<1){return B}while((w+=z)<B.length){A.push(B.slice(w,w+z))}return A.collect(y,x)}function b(y,x){y=y||Prototype.K;var w=true;this.each(function(A,z){w=w&&!!y.call(x,A,z);if(!w){throw $break}});return w}function i(y,x){y=y||Prototype.K;var w=false;this.each(function(A,z){if(w=!!y.call(x,A,z)){throw $break}});return w}function j(y,x){y=y||Prototype.K;var w=[];this.each(function(A,z){w.push(y.call(x,A,z))});return w}function t(y,x){var w;this.each(function(A,z){if(y.call(x,A,z)){w=A;throw $break}});return w}function h(y,x){var w=[];this.each(function(A,z){if(y.call(x,A,z)){w.push(A)}});return w}function g(z,y,x){y=y||Prototype.K;var w=[];if(Object.isString(z)){z=new RegExp(RegExp.escape(z))}this.each(function(B,A){if(z.match(B)){w.push(y.call(x,B,A))}});return w}function a(w){if(Object.isFunction(this.indexOf)){if(this.indexOf(w)!=-1){return true}}var x=false;this.each(function(y){if(y==w){x=true;throw $break}});return x}function q(x,w){w=Object.isUndefined(w)?null:w;return this.eachSlice(x,function(y){while(y.length<x){y.push(w)}return y})}function l(w,y,x){this.each(function(A,z){w=y.call(x,w,A,z)});return w}function v(x){var w=$A(arguments).slice(1);return this.map(function(y){return y[x].apply(y,w)})}function p(y,x){y=y||Prototype.K;var w;this.each(function(A,z){A=y.call(x,A,z);if(w==null||A>=w){w=A}});return w}function n(y,x){y=y||Prototype.K;var w;this.each(function(A,z){A=y.call(x,A,z);if(w==null||A<w){w=A}});return w}function e(z,x){z=z||Prototype.K;var y=[],w=[];this.each(function(B,A){(z.call(x,B,A)?y:w).push(B)});return[y,w]}function f(x){var w=[];this.each(function(y){w.push(y[x])});return w}function d(y,x){var w=[];this.each(function(A,z){if(!y.call(x,A,z)){w.push(A)}});return w}function m(x,w){return this.map(function(z,y){return{value:z,criteria:x.call(w,z,y)}}).sort(function(B,A){var z=B.criteria,y=A.criteria;return z<y?-1:z>y?1:0}).pluck("value")}function o(){return this.map()}function s(){var x=Prototype.K,w=$A(arguments);if(Object.isFunction(w.last())){x=w.pop()}var y=[this].concat(w).map($A);return this.map(function(A,z){return x(y.pluck(z))})}function k(){return this.toArray().length}function u(){return"#<Enumerable:"+this.toArray().inspect()+">"}return{each:c,eachSlice:r,all:b,every:b,any:i,some:i,collect:j,map:j,detect:t,findAll:h,select:h,filter:h,grep:g,include:a,member:a,inGroupsOf:q,inject:l,invoke:v,max:p,min:n,partition:e,pluck:f,reject:d,sortBy:m,toArray:o,entries:o,zip:s,size:k,inspect:u,find:t}})();function $A(c){if(!c){return[]}if("toArray" in Object(c)){return c.toArray()}var b=c.length||0,a=new Array(b);while(b--){a[b]=c[b]}return a}function $w(a){if(!Object.isString(a)){return[]}a=a.strip();return a?a.split(/\s+/):[]}Array.from=$A;(function(){var r=Array.prototype,m=r.slice,o=r.forEach;function b(w,v){for(var u=0,x=this.length>>>0;u<x;u++){if(u in this){w.call(v,this[u],u,this)}}}if(!o){o=b}function l(){this.length=0;return this}function d(){return this[0]}function g(){return this[this.length-1]}function i(){return this.select(function(u){return u!=null})}function t(){return this.inject([],function(v,u){if(Object.isArray(u)){return v.concat(u.flatten())}v.push(u);return v})}function h(){var u=m.call(arguments,0);return this.select(function(v){return !u.include(v)})}function f(u){return(u===false?this.toArray():this)._reverse()}function k(u){return this.inject([],function(x,w,v){if(0==v||(u?x.last()!=w:!x.include(w))){x.push(w)}return x})}function p(u){return this.uniq().findAll(function(v){return u.detect(function(w){return v===w})})}function q(){return m.call(this,0)}function j(){return this.length}function s(){return"["+this.map(Object.inspect).join(", ")+"]"}function a(w,u){u||(u=0);var v=this.length;if(u<0){u=v+u}for(;u<v;u++){if(this[u]===w){return u}}return -1}function n(v,u){u=isNaN(u)?this.length:(u<0?this.length+u:u)+1;var w=this.slice(0,u).reverse().indexOf(v);return(w<0)?w:u-w-1}function c(){var z=m.call(this,0),x;for(var v=0,w=arguments.length;v<w;v++){x=arguments[v];if(Object.isArray(x)&&!("callee" in x)){for(var u=0,y=x.length;u<y;u++){z.push(x[u])}}else{z.push(x)}}return z}Object.extend(r,Enumerable);if(!r._reverse){r._reverse=r.reverse}Object.extend(r,{_each:o,clear:l,first:d,last:g,compact:i,flatten:t,without:h,reverse:f,uniq:k,intersect:p,clone:q,toArray:q,size:j,inspect:s});var e=(function(){return[].concat(arguments)[0][0]!==1})(1,2);if(e){r.concat=c}if(!r.indexOf){r.indexOf=a}if(!r.lastIndexOf){r.lastIndexOf=n}})();function $H(a){return new Hash(a)}var Hash=Class.create(Enumerable,(function(){function e(p){this._object=Object.isHash(p)?p.toObject():Object.clone(p)}function f(q){for(var p in this._object){var r=this._object[p],s=[p,r];s.key=p;s.value=r;q(s)}}function j(p,q){return this._object[p]=q}function c(p){if(this._object[p]!==Object.prototype[p]){return this._object[p]}}function m(p){var q=this._object[p];delete this._object[p];return q}function o(){return Object.clone(this._object)}function n(){return this.pluck("key")}function l(){return this.pluck("value")}function g(q){var p=this.detect(function(r){return r.value===q});return p&&p.key}function i(p){return this.clone().update(p)}function d(p){return new Hash(p).inject(this,function(q,r){q.set(r.key,r.value);return q})}function b(p,q){if(Object.isUndefined(q)){return p}return p+"="+encodeURIComponent(String.interpret(q))}function a(){return this.inject([],function(t,w){var s=encodeURIComponent(w.key),q=w.value;if(q&&typeof q=="object"){if(Object.isArray(q)){var v=[];for(var r=0,p=q.length,u;r<p;r++){u=q[r];v.push(b(s,u))}return t.concat(v)}}else{t.push(b(s,q))}return t}).join("&")}function k(){return"#<Hash:{"+this.map(function(p){return p.map(Object.inspect).join(": ")}).join(", ")+"}>"}function h(){return new Hash(this)}return{initialize:e,_each:f,set:j,get:c,unset:m,toObject:o,toTemplateReplacements:o,keys:n,values:l,index:g,merge:i,update:d,toQueryString:a,inspect:k,toJSON:o,clone:h}})());Hash.from=$H;Object.extend(Number.prototype,(function(){function d(){return this.toPaddedString(2,16)}function b(){return this+1}function h(j,i){$R(0,this,true).each(j,i);return this}function g(k,j){var i=this.toString(j||10);return"0".times(k-i.length)+i}function a(){return Math.abs(this)}function c(){return Math.round(this)}function e(){return Math.ceil(this)}function f(){return Math.floor(this)}return{toColorPart:d,succ:b,times:h,toPaddedString:g,abs:a,round:c,ceil:e,floor:f}})());function $R(c,a,b){return new ObjectRange(c,a,b)}var ObjectRange=Class.create(Enumerable,(function(){function b(f,d,e){this.start=f;this.end=d;this.exclusive=e}function c(d){var e=this.start;while(this.include(e)){d(e);e=e.succ()}}function a(d){if(d<this.start){return false}if(this.exclusive){return d<this.end}return d<=this.end}return{initialize:b,_each:c,include:a}})());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(f){if(Object.isFunction(f[d])){try{f[d].apply(f,[b,c,a])}catch(g){}}})}};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.isHash(this.options.parameters)){this.options.parameters=this.options.parameters.toObject()}}});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.isString(this.options.parameters)?this.options.parameters:Object.toQueryString(this.options.parameters);if(!["get","post"].include(this.method)){d+=(d?"&":"")+"_method="+this.method;this.method="post"}if(d&&this.method==="get"){this.url+=(this.url.include("?")?"&":"?")+d}this.parameters=d.toQueryParams();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)||a==304},getStatus:function(){try{if(this.transport.status===1223){return 204}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 f=b.getHeader("Content-type");if(this.options.evalJS=="force"||(this.options.evalJS&&this.isSameOrigin()&&f&&f.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}},isSameOrigin:function(){var a=this.url.match(/^\s*https?:\/\/[^\/]*/);return !a||(a[0]=="#{protocol}//#{domain}#{port}".interpolate({protocol:location.protocol,domain:document.domain,port:location.port?":"+location.port:""}))},getHeader:function(a){try{return this.transport.getResponseHeader(a)||null}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=Object.isUndefined(b)?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||!this.request.isSameOrigin())}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"))||this.responseText.blank()){return null}try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}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=Object.clone(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)}}}});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(!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(c){function d(f,e){if(f==="select"){return false}if("type" in e){return false}return true}var b=(function(){try{var e=document.createElement('<input name="x">');return e.tagName.toLowerCase()==="input"&&e.name==="x"}catch(f){return false}})();var a=c.Element;c.Element=function(g,f){f=f||{};g=g.toLowerCase();var e=Element.cache;if(b&&f.name){g="<"+g+' name="'+f.name+'">';delete f.name;return Element.writeAttribute(document.createElement(g),f)}if(!e[g]){e[g]=Element.extend(document.createElement(g))}var h=d(g,f)?e[g].cloneNode(false):document.createElement(g);return Element.writeAttribute(h,f)};Object.extend(c.Element,a||{});if(a){c.Element.prototype=a.prototype}})(this);Element.idCounter=1;Element.cache={};Element._purgeElement=function(b){var a=b._prototypeUID;if(a){Element.stopObserving(b);b._prototypeUID=void 0;delete Element.Storage[a]}};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=$(a);a.style.display="none";return a},show:function(a){a=$(a);a.style.display="";return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:(function(){var d=(function(){var g=document.createElement("select"),h=true;g.innerHTML='<option value="test">test</option>';if(g.options&&g.options[0]){h=g.options[0].nodeName.toUpperCase()!=="OPTION"}g=null;return h})();var b=(function(){try{var g=document.createElement("table");if(g&&g.tBodies){g.innerHTML="<tbody><tr><td>test</td></tr></tbody>";var i=typeof g.tBodies[0]=="undefined";g=null;return i}}catch(h){return true}})();var a=(function(){try{var g=document.createElement("div");g.innerHTML="<link>";var i=(g.childNodes.length===0);g=null;return i}catch(h){return true}})();var c=d||b||a;var f=(function(){var g=document.createElement("script"),i=false;try{g.appendChild(document.createTextNode(""));i=!g.firstChild||g.firstChild&&g.firstChild.nodeType!==3}catch(h){i=true}g=null;return i})();function e(l,m){l=$(l);var g=Element._purgeElement;var n=l.getElementsByTagName("*"),k=n.length;while(k--){g(n[k])}if(m&&m.toElement){m=m.toElement()}if(Object.isElement(m)){return l.update().insert(m)}m=Object.toHTML(m);var j=l.tagName.toUpperCase();if(j==="SCRIPT"&&f){l.text=m;return l}if(c){if(j in Element._insertionTranslations.tags){while(l.firstChild){l.removeChild(l.firstChild)}Element._getContentFromAnonymousElement(j,m.stripScripts()).each(function(i){l.appendChild(i)})}else{if(a&&Object.isString(m)&&m.indexOf("<link")>-1){while(l.firstChild){l.removeChild(l.firstChild)}var h=Element._getContentFromAnonymousElement(j,m.stripScripts(),true);h.each(function(i){l.appendChild(i)})}else{l.innerHTML=m.stripScripts()}}}else{l.innerHTML=m.stripScripts()}m.evalScripts.bind(m).defer();return l}return e})(),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,f,b,g;for(var a in e){d=e[a];a=a.toLowerCase();f=Element._insertionTranslations[a];if(d&&d.toElement){d=d.toElement()}if(Object.isElement(d)){f(c,d);continue}d=Object.toHTML(d);b=((a=="before"||a=="after")?c.parentNode:c).tagName.toUpperCase();g=Element._getContentFromAnonymousElement(b,d.stripScripts());if(a=="top"||a=="after"){g.reverse()}g.each(f.curry(c));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(),d=(b[e]||"").toString();if(d){a+=" "+c+"="+d.inspect(true)}});return a+">"},recursivelyCollect:function(a,c,d){a=$(a);d=d||-1;var b=[];while(a=a[c]){if(a.nodeType==1){b.push(Element.extend(a))}if(b.length==d){break}}return b},ancestors:function(a){return Element.recursivelyCollect(a,"parentNode")},descendants:function(a){return Element.select(a,"*")},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1){a=a.nextSibling}return $(a)},immediateDescendants:function(b){var a=[],c=$(b).firstChild;while(c){if(c.nodeType===1){a.push(Element.extend(c))}c=c.nextSibling}return a},previousSiblings:function(a,b){return Element.recursivelyCollect(a,"previousSibling")},nextSiblings:function(a){return Element.recursivelyCollect(a,"nextSibling")},siblings:function(a){a=$(a);return Element.previousSiblings(a).reverse().concat(Element.nextSiblings(a))},match:function(b,a){b=$(b);if(Object.isString(a)){return Prototype.Selector.match(b,a)}return a.match(b)},up:function(b,d,a){b=$(b);if(arguments.length==1){return $(b.parentNode)}var c=Element.ancestors(b);return Object.isNumber(d)?c[d]:Prototype.Selector.find(c,d,a)},down:function(b,c,a){b=$(b);if(arguments.length==1){return Element.firstDescendant(b)}return Object.isNumber(c)?Element.descendants(b)[c]:Element.select(b,c)[a||0]},previous:function(b,c,a){b=$(b);if(Object.isNumber(c)){a=c,c=false}if(!Object.isNumber(a)){a=0}if(c){return Prototype.Selector.find(b.previousSiblings(),c,a)}else{return b.recursivelyCollect("previousSibling",a+1)[a]}},next:function(b,d,a){b=$(b);if(Object.isNumber(d)){a=d,d=false}if(!Object.isNumber(a)){a=0}if(d){return Prototype.Selector.find(b.nextSiblings(),d,a)}else{var c=Object.isNumber(a)?a+1:1;return b.recursivelyCollect("nextSibling",a+1)[a]}},select:function(a){a=$(a);var b=Array.prototype.slice.call(arguments,1).join(", ");return Prototype.Selector.select(b,a)},adjacent:function(a){a=$(a);var b=Array.prototype.slice.call(arguments,1).join(", ");return Prototype.Selector.select(b,a.parentNode).without(a)},identify:function(a){a=$(a);var b=Element.readAttribute(a,"id");if(b){return b}do{b="anonymous_element_"+Element.idCounter++}while($(b));Element.writeAttribute(a,"id",b);return b},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]=Object.isUndefined(f)?true:f}for(var a in b){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 Element.getDimensions(a).height},getWidth:function(a){return Element.getDimensions(a).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(!Element.hasClassName(a,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 Element[Element.hasClassName(a,b)?"removeClassName":"addClassName"](a,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(b,a){b=$(b),a=$(a);if(b.compareDocumentPosition){return(b.compareDocumentPosition(a)&8)===8}if(a.contains){return a.contains(b)&&a!==b}while(b=b.parentNode){if(b==a){return true}}return false},scrollTo:function(a){a=$(a);var b=Element.cumulativeOffset(a);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||d=="auto"){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")?(Object.isUndefined(e.styleFloat)?"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},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,"position");if(b=="static"||!b){a._madePositioned=true;a.style.position="relative";if(Prototype.Browser.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},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=Element.viewportOffset(d),f=[0,0],c=null;b=$(b);if(Element.getStyle(b,"position")=="absolute"){c=Element.getOffsetParent(b);f=Element.viewportOffset(c)}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}};Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:"class",htmlFor:"for"},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(d,b,c){switch(c){case"height":case"width":if(!Element.visible(b)){return null}var e=parseInt(d(b,c),10);if(e!==b["offset"+c.capitalize()]){return e+"px"}var a;if(c==="height"){a=["border-top-width","padding-top","padding-bottom","border-bottom-width"]}else{a=["border-left-width","padding-left","padding-right","border-right-width"]}return a.inject(e,function(f,g){var h=d(b,g);return h===null?f:f-parseInt(h,10)})+"px";default:return d(b,c)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(c,a,b){if(b==="title"){return a.title}return c(a,b)})}else{if(Prototype.Browser.IE){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=(function(){var b="className",a="for",c=document.createElement("div");c.setAttribute(b,"x");if(c.className!=="x"){c.setAttribute("class","x");if(c.className==="x"){b="class"}}c=null;c=document.createElement("label");c.setAttribute(a,"x");if(c.htmlFor!=="x"){c.setAttribute("htmlFor","x");if(c.htmlFor==="x"){a="htmlFor"}}c=null;return{read:{names:{"class":b,className:b,"for":a,htmlFor:a},values:{_getAttr:function(d,e){return d.getAttribute(e)},_getAttr2:function(d,e){return d.getAttribute(e,2)},_getAttrNode:function(d,f){var e=d.getAttributeNode(f);return e?e.value:""},_getEv:(function(){var d=document.createElement("div"),g;d.onclick=Prototype.emptyFunction;var e=d.getAttribute("onclick");if(String(e).indexOf("{")>-1){g=function(f,h){h=f.getAttribute(h);if(!h){return null}h=h.toString();h=h.split("{")[1];h=h.split("}")[0];return h.strip()}}else{if(e===""){g=function(f,h){h=f.getAttribute(h);if(!h){return null}return h.strip()}}}d=null;return g})(),_flag:function(d,e){return $(d).hasAttribute(e)?e:null},style:function(d){return d.style.cssText.toLowerCase()},title:function(d){return d.title}}}}})();Element._attributeTranslations.write={names:Object.extend({cellpadding:"cellPadding",cellspacing:"cellSpacing"},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 frameBorder").each(function(a){Element._attributeTranslations.write.names[a.toLowerCase()]=a;Element._attributeTranslations.has[a.toLowerCase()]=a});(function(a){Object.extend(a,{href:a._getAttr2,src:a._getAttr2,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);if(Prototype.BrowserFeatures.ElementExtensions){(function(){function a(e){var b=e.getElementsByTagName("*"),d=[];for(var c=0,f;f=b[c];c++){if(f.tagName!=="!"){d.push(f)}}return d}Element.Methods.down=function(c,d,b){c=$(c);if(arguments.length==1){return c.firstDescendant()}return Object.isNumber(d)?a(c)[d]:Element.select(c,d)[b||0]}})()}}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.toUpperCase()=="IMG"&&a.width){a.width++;a.width--}else{try{var d=document.createTextNode(" ");a.appendChild(d);a.removeChild(d)}catch(c){}}}return a}}}}}if("outerHTML" in document.documentElement){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(),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(e,d,f){var g=new Element("div"),c=Element._insertionTranslations.tags[e];var a=false;if(c){a=true}else{if(f){a=true;c=["","",0]}}if(a){g.innerHTML="&nbsp;"+c[0]+d+c[1];g.removeChild(g.firstChild);for(var b=c[2];b--;){g=g.firstChild}}else{g.innerHTML=d}return $A(g.childNodes)};Element._insertionTranslations={before:function(a,b){a.parentNode.insertBefore(b,a)},top:function(a,b){a.insertBefore(b,a.firstChild)},bottom:function(a,b){a.appendChild(b)},after:function(a,b){a.parentNode.insertBefore(b,a.nextSibling)},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(){var a=Element._insertionTranslations.tags;Object.extend(a,{THEAD:a.TBODY,TFOOT:a.TBODY,TH:a.TD})})();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);(function(a){if(!Prototype.BrowserFeatures.ElementExtensions&&a.__proto__){window.HTMLElement={};window.HTMLElement.prototype=a.__proto__;Prototype.BrowserFeatures.ElementExtensions=true}a=null})(document.createElement("div"));Element.extend=(function(){function c(g){if(typeof window.Element!="undefined"){var i=window.Element.prototype;if(i){var k="_"+(Math.random()+"").slice(2),h=document.createElement(g);i[k]="x";var j=(h[k]!=="x");delete i[k];h=null;return j}}return false}function b(h,g){for(var j in g){var i=g[j];if(Object.isFunction(i)&&!(j in h)){h[j]=i.methodize()}}}var d=c("object");if(Prototype.BrowserFeatures.SpecificElementExtensions){if(d){return function(h){if(h&&typeof h._extendedByPrototype=="undefined"){var g=h.tagName;if(g&&(/^(?:object|applet|embed)$/i.test(g))){b(h,Element.Methods);b(h,Element.Methods.Simulated);b(h,Element.Methods.ByTag[g.toUpperCase()])}}return h}}return Prototype.K}var a={},e=Element.Methods.ByTag;var f=Object.extend(function(i){if(!i||typeof i._extendedByPrototype!="undefined"||i.nodeType!=1||i==window){return i}var g=Object.clone(a),h=i.tagName.toUpperCase();if(e[h]){Object.extend(g,e[h])}b(i,g);i._extendedByPrototype=Prototype.emptyFunction;return i},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(a,Element.Methods);Object.extend(a,Element.Methods.Simulated)}}});f.refresh();return f})();if(document.documentElement.hasAttribute){Element.hasAttribute=function(a,b){return a.hasAttribute(b)}}else{Element.hasAttribute=Element.Methods.Simulated.hasAttribute}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),BUTTON: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(g)}else{g(b)}}function g(k){k=k.toUpperCase();if(!Element.Methods.ByTag[k]){Element.Methods.ByTag[k]={}}Object.extend(Element.Methods.ByTag[k],c)}function a(m,l,k){k=k||false;for(var o in m){var n=m[o];if(!Object.isFunction(n)){continue}if(!k||!(o in l)){l[o]=n.methodize()}}}function e(n){var k;var m={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(m[n]){k="HTML"+m[n]+"Element"}if(window[k]){return window[k]}k="HTML"+n+"Element";if(window[k]){return window[k]}k="HTML"+n.capitalize()+"Element";if(window[k]){return window[k]}var l=document.createElement(n),o=l.__proto__||l.constructor.prototype;l=null;return o}var h=window.HTMLElement?HTMLElement.prototype:Element.prototype;if(i.ElementExtensions){a(Element.Methods,h);a(Element.Methods.Simulated,h,true)}if(i.SpecificElementExtensions){for(var j in Element.Methods.ByTag){var f=e(j);if(Object.isUndefined(f)){continue}a(d[j],f.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh){Element.extend.refresh()}Element.cache={}};document.viewport={getDimensions:function(){return{width:this.getWidth(),height:this.getHeight()}},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};(function(b){var g=Prototype.Browser,e=document,c,d={};function a(){if(g.WebKit&&!e.evaluate){return document}if(g.Opera&&window.parseFloat(window.opera.version())<9.5){return document.body}return document.documentElement}function f(h){if(!c){c=a()}d[h]="client"+h;b["get"+h]=function(){return c[d[h]]};return b["get"+h]()}b.getWidth=f.curry("Width");b.getHeight=f.curry("Height")})(document.viewport);Element.Storage={UID:1};Element.addMethods({getStorage:function(b){if(!(b=$(b))){return}var a;if(b===window){a=0}else{if(typeof b._prototypeUID==="undefined"){b._prototypeUID=Element.Storage.UID++}a=b._prototypeUID}if(!Element.Storage[a]){Element.Storage[a]=$H()}return Element.Storage[a]},store:function(b,a,c){if(!(b=$(b))){return}if(arguments.length===2){Element.getStorage(b).update(a)}else{Element.getStorage(b).set(a,c)}return b},retrieve:function(c,b,a){if(!(c=$(c))){return}var e=Element.getStorage(c),d=e.get(b);if(Object.isUndefined(d)){e.set(b,a);d=a}return d},clone:function(c,a){if(!(c=$(c))){return}var e=c.cloneNode(a);e._prototypeUID=void 0;if(a){var d=Element.select(e,"*"),b=d.length;while(b--){d[b]._prototypeUID=void 0}}return Element.extend(e)},purge:function(c){if(!(c=$(c))){return}var a=Element._purgeElement;a(c);var d=c.getElementsByTagName("*"),b=d.length;while(b--){a(d[b])}return null}});(function(){function h(v){var u=v.match(/^(\d+)%?$/i);if(!u){return null}return(Number(u[1])/100)}function o(F,G,v){var y=null;if(Object.isElement(F)){y=F;F=y.getStyle(G)}if(F===null){return null}if((/^(?:-)?\d+(\.\d+)?(px)?$/i).test(F)){return window.parseFloat(F)}var A=F.include("%"),w=(v===document.viewport);if(/\d/.test(F)&&y&&y.runtimeStyle&&!(A&&w)){var u=y.style.left,E=y.runtimeStyle.left;y.runtimeStyle.left=y.currentStyle.left;y.style.left=F||0;F=y.style.pixelLeft;y.style.left=u;y.runtimeStyle.left=E;return F}if(y&&A){v=v||y.parentNode;var x=h(F);var B=null;var z=y.getStyle("position");var D=G.include("left")||G.include("right")||G.include("width");var C=G.include("top")||G.include("bottom")||G.include("height");if(v===document.viewport){if(D){B=document.viewport.getWidth()}else{if(C){B=document.viewport.getHeight()}}}else{if(D){B=$(v).measure("width")}else{if(C){B=$(v).measure("height")}}}return(B===null)?0:B*x}return 0}function g(u){if(Object.isString(u)&&u.endsWith("px")){return u}return u+"px"}function j(v){var u=v;while(v&&v.parentNode){var w=v.getStyle("display");if(w==="none"){return false}v=$(v.parentNode)}return true}var d=Prototype.K;if("currentStyle" in document.documentElement){d=function(u){if(!u.currentStyle.hasLayout){u.style.zoom=1}return u}}function f(u){if(u.include("border")){u=u+"-width"}return u.camelize()}Element.Layout=Class.create(Hash,{initialize:function($super,v,u){$super();this.element=$(v);Element.Layout.PROPERTIES.each(function(w){this._set(w,null)},this);if(u){this._preComputing=true;this._begin();Element.Layout.PROPERTIES.each(this._compute,this);this._end();this._preComputing=false}},_set:function(v,u){return Hash.prototype.set.call(this,v,u)},set:function(v,u){throw"Properties of Element.Layout are read-only."},get:function($super,v){var u=$super(v);return u===null?this._compute(v):u},_begin:function(){if(this._prepared){return}var y=this.element;if(j(y)){this._prepared=true;return}var A={position:y.style.position||"",width:y.style.width||"",visibility:y.style.visibility||"",display:y.style.display||""};y.store("prototype_original_styles",A);var B=y.getStyle("position"),u=y.getStyle("width");if(u==="0px"||u===null){y.style.display="block";u=y.getStyle("width")}var v=(B==="fixed")?document.viewport:y.parentNode;y.setStyle({position:"absolute",visibility:"hidden",display:"block"});var w=y.getStyle("width");var x;if(u&&(w===u)){x=o(y,"width",v)}else{if(B==="absolute"||B==="fixed"){x=o(y,"width",v)}else{var C=y.parentNode,z=$(C).getLayout();x=z.get("width")-this.get("margin-left")-this.get("border-left")-this.get("padding-left")-this.get("padding-right")-this.get("border-right")-this.get("margin-right")}}y.setStyle({width:x+"px"});this._prepared=true},_end:function(){var v=this.element;var u=v.retrieve("prototype_original_styles");v.store("prototype_original_styles",null);v.setStyle(u);this._prepared=false},_compute:function(v){var u=Element.Layout.COMPUTATIONS;if(!(v in u)){throw"Property not found."}return this._set(v,u[v].call(this,this.element))},toObject:function(){var u=$A(arguments);var v=(u.length===0)?Element.Layout.PROPERTIES:u.join(" ").split(" ");var w={};v.each(function(x){if(!Element.Layout.PROPERTIES.include(x)){return}var y=this.get(x);if(y!=null){w[x]=y}},this);return w},toHash:function(){var u=this.toObject.apply(this,arguments);return new Hash(u)},toCSS:function(){var u=$A(arguments);var w=(u.length===0)?Element.Layout.PROPERTIES:u.join(" ").split(" ");var v={};w.each(function(x){if(!Element.Layout.PROPERTIES.include(x)){return}if(Element.Layout.COMPOSITE_PROPERTIES.include(x)){return}var y=this.get(x);if(y!=null){v[f(x)]=y+"px"}},this);return v},inspect:function(){return"#<Element.Layout>"}});Object.extend(Element.Layout,{PROPERTIES:$w("height width top left right bottom border-left border-right border-top border-bottom padding-left padding-right padding-top padding-bottom margin-top margin-bottom margin-left margin-right padding-box-width padding-box-height border-box-width border-box-height margin-box-width margin-box-height"),COMPOSITE_PROPERTIES:$w("padding-box-width padding-box-height margin-box-width margin-box-height border-box-width border-box-height"),COMPUTATIONS:{height:function(w){if(!this._preComputing){this._begin()}var u=this.get("border-box-height");if(u<=0){if(!this._preComputing){this._end()}return 0}var x=this.get("border-top"),v=this.get("border-bottom");var z=this.get("padding-top"),y=this.get("padding-bottom");if(!this._preComputing){this._end()}return u-x-v-z-y},width:function(w){if(!this._preComputing){this._begin()}var v=this.get("border-box-width");if(v<=0){if(!this._preComputing){this._end()}return 0}var z=this.get("border-left"),u=this.get("border-right");var x=this.get("padding-left"),y=this.get("padding-right");if(!this._preComputing){this._end()}return v-z-u-x-y},"padding-box-height":function(v){var u=this.get("height"),x=this.get("padding-top"),w=this.get("padding-bottom");return u+x+w},"padding-box-width":function(u){var v=this.get("width"),w=this.get("padding-left"),x=this.get("padding-right");return v+w+x},"border-box-height":function(v){if(!this._preComputing){this._begin()}var u=v.offsetHeight;if(!this._preComputing){this._end()}return u},"border-box-width":function(u){if(!this._preComputing){this._begin()}var v=u.offsetWidth;if(!this._preComputing){this._end()}return v},"margin-box-height":function(v){var u=this.get("border-box-height"),w=this.get("margin-top"),x=this.get("margin-bottom");if(u<=0){return 0}return u+w+x},"margin-box-width":function(w){var v=this.get("border-box-width"),x=this.get("margin-left"),u=this.get("margin-right");if(v<=0){return 0}return v+x+u},top:function(u){var v=u.positionedOffset();return v.top},bottom:function(u){var x=u.positionedOffset(),v=u.getOffsetParent(),w=v.measure("height");var y=this.get("border-box-height");return w-y-x.top},left:function(u){var v=u.positionedOffset();return v.left},right:function(w){var y=w.positionedOffset(),x=w.getOffsetParent(),u=x.measure("width");var v=this.get("border-box-width");return u-v-y.left},"padding-top":function(u){return o(u,"paddingTop")},"padding-bottom":function(u){return o(u,"paddingBottom")},"padding-left":function(u){return o(u,"paddingLeft")},"padding-right":function(u){return o(u,"paddingRight")},"border-top":function(u){return o(u,"borderTopWidth")},"border-bottom":function(u){return o(u,"borderBottomWidth")},"border-left":function(u){return o(u,"borderLeftWidth")},"border-right":function(u){return o(u,"borderRightWidth")},"margin-top":function(u){return o(u,"marginTop")},"margin-bottom":function(u){return o(u,"marginBottom")},"margin-left":function(u){return o(u,"marginLeft")},"margin-right":function(u){return o(u,"marginRight")}}});if("getBoundingClientRect" in document.documentElement){Object.extend(Element.Layout.COMPUTATIONS,{right:function(v){var w=d(v.getOffsetParent());var x=v.getBoundingClientRect(),u=w.getBoundingClientRect();return(u.right-x.right).round()},bottom:function(v){var w=d(v.getOffsetParent());var x=v.getBoundingClientRect(),u=w.getBoundingClientRect();return(u.bottom-x.bottom).round()}})}Element.Offset=Class.create({initialize:function(v,u){this.left=v.round();this.top=u.round();this[0]=this.left;this[1]=this.top},relativeTo:function(u){return new Element.Offset(this.left-u.left,this.top-u.top)},inspect:function(){return"#<Element.Offset left: #{left} top: #{top}>".interpolate(this)},toString:function(){return"[#{left}, #{top}]".interpolate(this)},toArray:function(){return[this.left,this.top]}});function r(v,u){return new Element.Layout(v,u)}function b(u,v){return $(u).getLayout().get(v)}function n(v){v=$(v);var z=Element.getStyle(v,"display");if(z&&z!=="none"){return{width:v.offsetWidth,height:v.offsetHeight}}var w=v.style;var u={visibility:w.visibility,position:w.position,display:w.display};var y={visibility:"hidden",display:"block"};if(u.position!=="fixed"){y.position="absolute"}Element.setStyle(v,y);var x={width:v.offsetWidth,height:v.offsetHeight};Element.setStyle(v,u);return x}function l(u){u=$(u);if(e(u)||c(u)||m(u)||k(u)){return $(document.body)}var v=(Element.getStyle(u,"display")==="inline");if(!v&&u.offsetParent){return $(u.offsetParent)}while((u=u.parentNode)&&u!==document.body){if(Element.getStyle(u,"position")!=="static"){return k(u)?$(document.body):$(u)}}return $(document.body)}function t(v){v=$(v);var u=0,w=0;if(v.parentNode){do{u+=v.offsetTop||0;w+=v.offsetLeft||0;v=v.offsetParent}while(v)}return new Element.Offset(w,u)}function p(v){v=$(v);var w=v.getLayout();var u=0,y=0;do{u+=v.offsetTop||0;y+=v.offsetLeft||0;v=v.offsetParent;if(v){if(m(v)){break}var x=Element.getStyle(v,"position");if(x!=="static"){break}}}while(v);y-=w.get("margin-top");u-=w.get("margin-left");return new Element.Offset(y,u)}function a(v){var u=0,w=0;do{u+=v.scrollTop||0;w+=v.scrollLeft||0;v=v.parentNode}while(v);return new Element.Offset(w,u)}function s(y){v=$(v);var u=0,x=0,w=document.body;var v=y;do{u+=v.offsetTop||0;x+=v.offsetLeft||0;if(v.offsetParent==w&&Element.getStyle(v,"position")=="absolute"){break}}while(v=v.offsetParent);v=y;do{if(v!=w){u-=v.scrollTop||0;x-=v.scrollLeft||0}}while(v=v.parentNode);return new Element.Offset(x,u)}function q(u){u=$(u);if(Element.getStyle(u,"position")==="absolute"){return u}var y=l(u);var x=u.viewportOffset(),v=y.viewportOffset();var z=x.relativeTo(v);var w=u.getLayout();u.store("prototype_absolutize_original_styles",{left:u.getStyle("left"),top:u.getStyle("top"),width:u.getStyle("width"),height:u.getStyle("height")});u.setStyle({position:"absolute",top:z.top+"px",left:z.left+"px",width:w.get("width")+"px",height:w.get("height")+"px"});return u}function i(v){v=$(v);if(Element.getStyle(v,"position")==="relative"){return v}var u=v.retrieve("prototype_absolutize_original_styles");if(u){v.setStyle(u)}return v}if(Prototype.Browser.IE){l=l.wrap(function(w,v){v=$(v);if(e(v)||c(v)||m(v)||k(v)){return $(document.body)}var u=v.getStyle("position");if(u!=="static"){return w(v)}v.setStyle({position:"relative"});var x=w(v);v.setStyle({position:u});return x});p=p.wrap(function(x,v){v=$(v);if(!v.parentNode){return new Element.Offset(0,0)}var u=v.getStyle("position");if(u!=="static"){return x(v)}var w=v.getOffsetParent();if(w&&w.getStyle("position")==="fixed"){d(w)}v.setStyle({position:"relative"});var y=x(v);v.setStyle({position:u});return y})}else{if(Prototype.Browser.Webkit){t=function(v){v=$(v);var u=0,w=0;do{u+=v.offsetTop||0;w+=v.offsetLeft||0;if(v.offsetParent==document.body){if(Element.getStyle(v,"position")=="absolute"){break}}v=v.offsetParent}while(v);return new Element.Offset(w,u)}}}Element.addMethods({getLayout:r,measure:b,getDimensions:n,getOffsetParent:l,cumulativeOffset:t,positionedOffset:p,cumulativeScrollOffset:a,viewportOffset:s,absolutize:q,relativize:i});function m(u){return u.nodeName.toUpperCase()==="BODY"}function k(u){return u.nodeName.toUpperCase()==="HTML"}function e(u){return u.nodeType===Node.DOCUMENT_NODE}function c(u){return u!==document.body&&!Element.descendantOf(u,document.body)}if("getBoundingClientRect" in document.documentElement){Element.addMethods({viewportOffset:function(u){u=$(u);if(c(u)){return new Element.Offset(0,0)}var v=u.getBoundingClientRect(),w=document.documentElement;return new Element.Offset(v.left-w.clientLeft,v.top-w.clientTop)}})}})();window.$$=function(){var a=$A(arguments).join(", ");return Prototype.Selector.select(a,document)};Prototype.Selector=(function(){function a(){throw new Error('Method "Prototype.Selector.select" must be defined.')}function c(){throw new Error('Method "Prototype.Selector.match" must be defined.')}function d(l,m,h){h=h||0;var g=Prototype.Selector.match,k=l.length,f=0,j;for(j=0;j<k;j++){if(g(l[j],m)&&h==f++){return Element.extend(l[j])}}}function e(h){for(var f=0,g=h.length;f<g;f++){Element.extend(h[f])}return h}var b=Prototype.K;return{select:a,match:c,find:d,extendElements:(Element.extend===b)?b:e,extendElement:Element.extend}})();Prototype._original_property=window.Sizzle;
/*!
 * Sizzle CSS Selector Engine - v1.0
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){var q=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?((?:.|\r|\n)*)/g,j=0,d=Object.prototype.toString,o=false,i=true;[0,0].sort(function(){i=false;return 0});var b=function(E,u,B,w){B=B||[];var e=u=u||document;if(u.nodeType!==1&&u.nodeType!==9){return[]}if(!E||typeof E!=="string"){return B}var C=[],D,z,I,H,A,t,s=true,x=p(u),G=E;while((q.exec(""),D=q.exec(G))!==null){G=D[3];C.push(D[1]);if(D[2]){t=D[3];break}}if(C.length>1&&k.exec(E)){if(C.length===2&&f.relative[C[0]]){z=g(C[0]+C[1],u)}else{z=f.relative[C[0]]?[u]:b(C.shift(),u);while(C.length){E=C.shift();if(f.relative[E]){E+=C.shift()}z=g(E,z)}}}else{if(!w&&C.length>1&&u.nodeType===9&&!x&&f.match.ID.test(C[0])&&!f.match.ID.test(C[C.length-1])){var J=b.find(C.shift(),u,x);u=J.expr?b.filter(J.expr,J.set)[0]:J.set[0]}if(u){var J=w?{expr:C.pop(),set:a(w)}:b.find(C.pop(),C.length===1&&(C[0]==="~"||C[0]==="+")&&u.parentNode?u.parentNode:u,x);z=J.expr?b.filter(J.expr,J.set):J.set;if(C.length>0){I=a(z)}else{s=false}while(C.length){var v=C.pop(),y=v;if(!f.relative[v]){v=""}else{y=C.pop()}if(y==null){y=u}f.relative[v](I,y,x)}}else{I=C=[]}}if(!I){I=z}if(!I){throw"Syntax error, unrecognized expression: "+(v||E)}if(d.call(I)==="[object Array]"){if(!s){B.push.apply(B,I)}else{if(u&&u.nodeType===1){for(var F=0;I[F]!=null;F++){if(I[F]&&(I[F]===true||I[F].nodeType===1&&h(u,I[F]))){B.push(z[F])}}}else{for(var F=0;I[F]!=null;F++){if(I[F]&&I[F].nodeType===1){B.push(z[F])}}}}}else{a(I,B)}if(t){b(t,e,B,w);b.uniqueSort(B)}return B};b.uniqueSort=function(s){if(c){o=i;s.sort(c);if(o){for(var e=1;e<s.length;e++){if(s[e]===s[e-1]){s.splice(e--,1)}}}}return s};b.matches=function(e,s){return b(e,null,null,s)};b.find=function(y,e,z){var x,v;if(!y){return[]}for(var u=0,t=f.order.length;u<t;u++){var w=f.order[u],v;if((v=f.leftMatch[w].exec(y))){var s=v[1];v.splice(1,1);if(s.substr(s.length-1)!=="\\"){v[1]=(v[1]||"").replace(/\\/g,"");x=f.find[w](v,e,z);if(x!=null){y=y.replace(f.match[w],"");break}}}}if(!x){x=e.getElementsByTagName("*")}return{set:x,expr:y}};b.filter=function(B,A,E,u){var t=B,G=[],y=A,w,e,x=A&&A[0]&&p(A[0]);while(B&&A.length){for(var z in f.filter){if((w=f.match[z].exec(B))!=null){var s=f.filter[z],F,D;e=false;if(y==G){G=[]}if(f.preFilter[z]){w=f.preFilter[z](w,y,E,G,u,x);if(!w){e=F=true}else{if(w===true){continue}}}if(w){for(var v=0;(D=y[v])!=null;v++){if(D){F=s(D,w,v,y);var C=u^!!F;if(E&&F!=null){if(C){e=true}else{y[v]=false}}else{if(C){G.push(D);e=true}}}}}if(F!==undefined){if(!E){y=G}B=B.replace(f.match[z],"");if(!e){return[]}break}}}if(B==t){if(e==null){throw"Syntax error, unrecognized expression: "+B}else{break}}t=B}return y};var f=b.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},leftMatch:{},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")}},relative:{"+":function(y,e,x){var v=typeof e==="string",z=v&&!/\W/.test(e),w=v&&!z;if(z&&!x){e=e.toUpperCase()}for(var u=0,t=y.length,s;u<t;u++){if((s=y[u])){while((s=s.previousSibling)&&s.nodeType!==1){}y[u]=w||s&&s.nodeName===e?s||false:s===e}}if(w){b.filter(e,y,true)}},">":function(x,s,y){var v=typeof s==="string";if(v&&!/\W/.test(s)){s=y?s:s.toUpperCase();for(var t=0,e=x.length;t<e;t++){var w=x[t];if(w){var u=w.parentNode;x[t]=u.nodeName===s?u:false}}}else{for(var t=0,e=x.length;t<e;t++){var w=x[t];if(w){x[t]=v?w.parentNode:w.parentNode===s}}if(v){b.filter(s,x,true)}}},"":function(u,s,w){var t=j++,e=r;if(!/\W/.test(s)){var v=s=w?s:s.toUpperCase();e=n}e("parentNode",s,t,u,v,w)},"~":function(u,s,w){var t=j++,e=r;if(typeof s==="string"&&!/\W/.test(s)){var v=s=w?s:s.toUpperCase();e=n}e("previousSibling",s,t,u,v,w)}},find:{ID:function(s,t,u){if(typeof t.getElementById!=="undefined"&&!u){var e=t.getElementById(s[1]);return e?[e]:[]}},NAME:function(t,w,x){if(typeof w.getElementsByName!=="undefined"){var s=[],v=w.getElementsByName(t[1]);for(var u=0,e=v.length;u<e;u++){if(v[u].getAttribute("name")===t[1]){s.push(v[u])}}return s.length===0?null:s}},TAG:function(e,s){return s.getElementsByTagName(e[1])}},preFilter:{CLASS:function(u,s,t,e,x,y){u=" "+u[1].replace(/\\/g,"")+" ";if(y){return u}for(var v=0,w;(w=s[v])!=null;v++){if(w){if(x^(w.className&&(" "+w.className+" ").indexOf(u)>=0)){if(!t){e.push(w)}}else{if(t){s[v]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(s,e){for(var t=0;e[t]===false;t++){}return e[t]&&p(e[t])?s[1]:s[1].toUpperCase()},CHILD:function(e){if(e[1]=="nth"){var s=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]=="even"&&"2n"||e[2]=="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(s[1]+(s[2]||1))-0;e[3]=s[3]-0}e[0]=j++;return e},ATTR:function(v,s,t,e,w,x){var u=v[1].replace(/\\/g,"");if(!x&&f.attrMap[u]){v[1]=f.attrMap[u]}if(v[2]==="~="){v[4]=" "+v[4]+" "}return v},PSEUDO:function(v,s,t,e,w){if(v[1]==="not"){if((q.exec(v[3])||"").length>1||/^\w/.test(v[3])){v[3]=b(v[3],null,null,s)}else{var u=b.filter(v[3],s,t,true^w);if(!t){e.push.apply(e,u)}return false}}else{if(f.match.POS.test(v[0])||f.match.CHILD.test(v[0])){return true}}return v},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(t,s,e){return !!b(e[3],t).length},header:function(e){return/h\d/i.test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toUpperCase()==="BUTTON"},input:function(e){return/input|select|textarea|button/i.test(e.nodeName)}},setFilters:{first:function(s,e){return e===0},last:function(t,s,e,u){return s===u.length-1},even:function(s,e){return e%2===0},odd:function(s,e){return e%2===1},lt:function(t,s,e){return s<e[3]-0},gt:function(t,s,e){return s>e[3]-0},nth:function(t,s,e){return e[3]-0==s},eq:function(t,s,e){return e[3]-0==s}},filter:{PSEUDO:function(x,t,u,y){var s=t[1],v=f.filters[s];if(v){return v(x,u,t,y)}else{if(s==="contains"){return(x.textContent||x.innerText||"").indexOf(t[3])>=0}else{if(s==="not"){var w=t[3];for(var u=0,e=w.length;u<e;u++){if(w[u]===x){return false}}return true}}}},CHILD:function(e,u){var x=u[1],s=e;switch(x){case"only":case"first":while((s=s.previousSibling)){if(s.nodeType===1){return false}}if(x=="first"){return true}s=e;case"last":while((s=s.nextSibling)){if(s.nodeType===1){return false}}return true;case"nth":var t=u[2],A=u[3];if(t==1&&A==0){return true}var w=u[0],z=e.parentNode;if(z&&(z.sizcache!==w||!e.nodeIndex)){var v=0;for(s=z.firstChild;s;s=s.nextSibling){if(s.nodeType===1){s.nodeIndex=++v}}z.sizcache=w}var y=e.nodeIndex-A;if(t==0){return y==0}else{return(y%t==0&&y/t>=0)}}},ID:function(s,e){return s.nodeType===1&&s.getAttribute("id")===e},TAG:function(s,e){return(e==="*"&&s.nodeType===1)||s.nodeName===e},CLASS:function(s,e){return(" "+(s.className||s.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(w,u){var t=u[1],e=f.attrHandle[t]?f.attrHandle[t](w):w[t]!=null?w[t]:w.getAttribute(t),x=e+"",v=u[2],s=u[4];return e==null?v==="!=":v==="="?x===s:v==="*="?x.indexOf(s)>=0:v==="~="?(" "+x+" ").indexOf(s)>=0:!s?x&&e!==false:v==="!="?x!=s:v==="^="?x.indexOf(s)===0:v==="$="?x.substr(x.length-s.length)===s:v==="|="?x===s||x.substr(0,s.length+1)===s+"-":false},POS:function(v,s,t,w){var e=s[2],u=f.setFilters[e];if(u){return u(v,t,s,w)}}}};var k=f.match.POS;for(var m in f.match){f.match[m]=new RegExp(f.match[m].source+/(?![^\[]*\])(?![^\(]*\))/.source);f.leftMatch[m]=new RegExp(/(^(?:.|\r|\n)*?)/.source+f.match[m].source)}var a=function(s,e){s=Array.prototype.slice.call(s,0);if(e){e.push.apply(e,s);return e}return s};try{Array.prototype.slice.call(document.documentElement.childNodes,0)}catch(l){a=function(v,u){var s=u||[];if(d.call(v)==="[object Array]"){Array.prototype.push.apply(s,v)}else{if(typeof v.length==="number"){for(var t=0,e=v.length;t<e;t++){s.push(v[t])}}else{for(var t=0;v[t];t++){s.push(v[t])}}}return s}}var c;if(document.documentElement.compareDocumentPosition){c=function(s,e){if(!s.compareDocumentPosition||!e.compareDocumentPosition){if(s==e){o=true}return 0}var t=s.compareDocumentPosition(e)&4?-1:s===e?0:1;if(t===0){o=true}return t}}else{if("sourceIndex" in document.documentElement){c=function(s,e){if(!s.sourceIndex||!e.sourceIndex){if(s==e){o=true}return 0}var t=s.sourceIndex-e.sourceIndex;if(t===0){o=true}return t}}else{if(document.createRange){c=function(u,s){if(!u.ownerDocument||!s.ownerDocument){if(u==s){o=true}return 0}var t=u.ownerDocument.createRange(),e=s.ownerDocument.createRange();t.setStart(u,0);t.setEnd(u,0);e.setStart(s,0);e.setEnd(s,0);var v=t.compareBoundaryPoints(Range.START_TO_END,e);if(v===0){o=true}return v}}}}(function(){var s=document.createElement("div"),t="script"+(new Date).getTime();s.innerHTML="<a name='"+t+"'/>";var e=document.documentElement;e.insertBefore(s,e.firstChild);if(!!document.getElementById(t)){f.find.ID=function(v,w,x){if(typeof w.getElementById!=="undefined"&&!x){var u=w.getElementById(v[1]);return u?u.id===v[1]||typeof u.getAttributeNode!=="undefined"&&u.getAttributeNode("id").nodeValue===v[1]?[u]:undefined:[]}};f.filter.ID=function(w,u){var v=typeof w.getAttributeNode!=="undefined"&&w.getAttributeNode("id");return w.nodeType===1&&v&&v.nodeValue===u}}e.removeChild(s);e=s=null})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(s,w){var v=w.getElementsByTagName(s[1]);if(s[1]==="*"){var u=[];for(var t=0;v[t];t++){if(v[t].nodeType===1){u.push(v[t])}}v=u}return v}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(s){return s.getAttribute("href",2)}}e=null})();if(document.querySelectorAll){(function(){var e=b,t=document.createElement("div");t.innerHTML="<p class='TEST'></p>";if(t.querySelectorAll&&t.querySelectorAll(".TEST").length===0){return}b=function(x,w,u,v){w=w||document;if(!v&&w.nodeType===9&&!p(w)){try{return a(w.querySelectorAll(x),u)}catch(y){}}return e(x,w,u,v)};for(var s in e){b[s]=e[s]}t=null})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(s,t,u){if(typeof t.getElementsByClassName!=="undefined"&&!u){return t.getElementsByClassName(s[1])}};e=null})()}function n(s,x,w,B,y,A){var z=s=="previousSibling"&&!A;for(var u=0,t=B.length;u<t;u++){var e=B[u];if(e){if(z&&e.nodeType===1){e.sizcache=w;e.sizset=u}e=e[s];var v=false;while(e){if(e.sizcache===w){v=B[e.sizset];break}if(e.nodeType===1&&!A){e.sizcache=w;e.sizset=u}if(e.nodeName===x){v=e;break}e=e[s]}B[u]=v}}}function r(s,x,w,B,y,A){var z=s=="previousSibling"&&!A;for(var u=0,t=B.length;u<t;u++){var e=B[u];if(e){if(z&&e.nodeType===1){e.sizcache=w;e.sizset=u}e=e[s];var v=false;while(e){if(e.sizcache===w){v=B[e.sizset];break}if(e.nodeType===1){if(!A){e.sizcache=w;e.sizset=u}if(typeof x!=="string"){if(e===x){v=true;break}}else{if(b.filter(x,[e]).length>0){v=e;break}}}e=e[s]}B[u]=v}}}var h=document.compareDocumentPosition?function(s,e){return s.compareDocumentPosition(e)&16}:function(s,e){return s!==e&&(s.contains?s.contains(e):true)};var p=function(e){return e.nodeType===9&&e.documentElement.nodeName!=="HTML"||!!e.ownerDocument&&e.ownerDocument.documentElement.nodeName!=="HTML"};var g=function(e,y){var u=[],v="",w,t=y.nodeType?[y]:y;while((w=f.match.PSEUDO.exec(e))){v+=w[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var x=0,s=t.length;x<s;x++){b(e,t[x],u)}return b.filter(v,u)};window.Sizzle=b})();(function(c){var d=Prototype.Selector.extendElements;function a(e,f){return d(c(e,f||document))}function b(f,e){return c.matches(e,[f]).length==1}Prototype.Selector.engine=c;Prototype.Selector.select=a;Prototype.Selector.match=b})(Sizzle);window.Sizzle=Prototype._original_property;delete Prototype._original_property;var Form={reset:function(a){a=$(a);a.reset();return a},serializeElements:function(h,d){if(typeof d!="object"){d={hash:!!d}}else{if(Object.isUndefined(d.hash)){d.hash=true}}var e,g,a=false,f=d.submit,b,c;if(d.hash){c={};b=function(i,j,k){if(j in i){if(!Object.isArray(i[j])){i[j]=[i[j]]}i[j].push(k)}else{i[j]=k}return i}}else{c="";b=function(i,j,k){return i+(i?"&":"")+encodeURIComponent(j)+"="+encodeURIComponent(k)}}return h.inject(c,function(i,j){if(!j.disabled&&j.name){e=j.name;g=$(j).getValue();if(g!=null&&j.type!="file"&&(j.type!="submit"||(!a&&f!==false&&(!f||e==f)&&(a=true)))){i=b(i,e,g)}}return i})}};Form.Methods={serialize:function(b,a){return Form.serializeElements(Form.getElements(b),a)},getElements:function(e){var f=$(e).getElementsByTagName("*"),d,a=[],c=Form.Element.Serializers;for(var b=0;d=f[b];b++){a.push(d)}return a.inject([],function(g,h){if(c[h.tagName.toLowerCase()]){g.push(Element.extend(h))}return g})},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)$/i.test(d.tagName)})},focusFirstElement:function(b){b=$(b);var a=b.findFirstElement();if(a){a.activate()}return b},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)$/i.test(a.type)))){a.select()}}catch(b){}return a},disable:function(a){a=$(a);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=(function(){function b(h,i){switch(h.type.toLowerCase()){case"checkbox":case"radio":return f(h,i);default:return e(h,i)}}function f(h,i){if(Object.isUndefined(i)){return h.checked?h.value:null}else{h.checked=!!i}}function e(h,i){if(Object.isUndefined(i)){return h.value}else{h.value=i}}function a(k,n){if(Object.isUndefined(n)){return(k.type==="select-one"?c:d)(k)}var j,l,o=!Object.isArray(n);for(var h=0,m=k.length;h<m;h++){j=k.options[h];l=this.optionValue(j);if(o){if(l==n){j.selected=true;return}}else{j.selected=n.include(l)}}}function c(i){var h=i.selectedIndex;return h>=0?g(i.options[h]):null}function d(l){var h,m=l.length;if(!m){return null}for(var k=0,h=[];k<m;k++){var j=l.options[k];if(j.selected){h.push(g(j))}}return h}function g(h){return Element.hasAttribute(h,"value")?h.value:h.text}return{input:b,inputSelector:f,textarea:e,select:a,selectOne:c,selectMany:d,optionValue:g,button:e}})();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)}});(function(){var C={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:{}};var f=document.documentElement;var D="onmouseenter" in f&&"onmouseleave" in f;var a=function(E){return false};if(window.attachEvent){if(window.addEventListener){a=function(E){return !(E instanceof window.Event)}}else{a=function(E){return true}}}var r;function A(F,E){return F.which?(F.which===E+1):(F.button===E)}var o={0:1,1:4,2:2};function y(F,E){return F.button===o[E]}function B(F,E){switch(E){case 0:return F.which==1&&!F.metaKey;case 1:return F.which==2||(F.which==1&&F.metaKey);case 2:return F.which==3;default:return false}}if(window.attachEvent){if(!window.addEventListener){r=y}else{r=function(F,E){return a(F)?y(F,E):A(F,E)}}}else{if(Prototype.Browser.WebKit){r=B}else{r=A}}function v(E){return r(E,0)}function t(E){return r(E,1)}function n(E){return r(E,2)}function d(G){G=C.extend(G);var F=G.target,E=G.type,H=G.currentTarget;if(H&&H.tagName){if(E==="load"||E==="error"||(E==="click"&&H.tagName.toLowerCase()==="input"&&H.type==="radio")){F=H}}if(F.nodeType==Node.TEXT_NODE){F=F.parentNode}return Element.extend(F)}function p(F,G){var E=C.element(F);if(!G){return E}while(E){if(Object.isElement(E)&&Prototype.Selector.match(E,G)){return Element.extend(E)}E=E.parentNode}}function s(E){return{x:c(E),y:b(E)}}function c(G){var F=document.documentElement,E=document.body||{scrollLeft:0};return G.pageX||(G.clientX+(F.scrollLeft||E.scrollLeft)-(F.clientLeft||0))}function b(G){var F=document.documentElement,E=document.body||{scrollTop:0};return G.pageY||(G.clientY+(F.scrollTop||E.scrollTop)-(F.clientTop||0))}function q(E){C.extend(E);E.preventDefault();E.stopPropagation();E.stopped=true}C.Methods={isLeftClick:v,isMiddleClick:t,isRightClick:n,element:d,findElement:p,pointer:s,pointerX:c,pointerY:b,stop:q};var x=Object.keys(C.Methods).inject({},function(E,F){E[F]=C.Methods[F].methodize();return E});if(window.attachEvent){function i(F){var E;switch(F.type){case"mouseover":case"mouseenter":E=F.fromElement;break;case"mouseout":case"mouseleave":E=F.toElement;break;default:return null}return Element.extend(E)}var u={stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}};C.extend=function(F,E){if(!F){return false}if(!a(F)){return F}if(F._extendedByPrototype){return F}F._extendedByPrototype=Prototype.emptyFunction;var G=C.pointer(F);Object.extend(F,{target:F.srcElement||E,relatedTarget:i(F),pageX:G.x,pageY:G.y});Object.extend(F,x);Object.extend(F,u);return F}}else{C.extend=Prototype.K}if(window.addEventListener){C.prototype=window.Event.prototype||document.createEvent("HTMLEvents").__proto__;Object.extend(C.prototype,x)}function m(I,H,J){var G=Element.retrieve(I,"prototype_event_registry");if(Object.isUndefined(G)){e.push(I);G=Element.retrieve(I,"prototype_event_registry",$H())}var E=G.get(H);if(Object.isUndefined(E)){E=[];G.set(H,E)}if(E.pluck("handler").include(J)){return false}var F;if(H.include(":")){F=function(K){if(Object.isUndefined(K.eventName)){return false}if(K.eventName!==H){return false}C.extend(K,I);J.call(I,K)}}else{if(!D&&(H==="mouseenter"||H==="mouseleave")){if(H==="mouseenter"||H==="mouseleave"){F=function(L){C.extend(L,I);var K=L.relatedTarget;while(K&&K!==I){try{K=K.parentNode}catch(M){K=I}}if(K===I){return}J.call(I,L)}}}else{F=function(K){C.extend(K,I);J.call(I,K)}}}F.handler=J;E.push(F);return F}function h(){for(var E=0,F=e.length;E<F;E++){C.stopObserving(e[E]);e[E]=null}}var e=[];if(Prototype.Browser.IE){window.attachEvent("onunload",h)}if(Prototype.Browser.WebKit){window.addEventListener("unload",Prototype.emptyFunction,false)}var l=Prototype.K,g={mouseenter:"mouseover",mouseleave:"mouseout"};if(!D){l=function(E){return(g[E]||E)}}function w(H,G,I){H=$(H);var F=m(H,G,I);if(!F){return H}if(G.include(":")){if(H.addEventListener){H.addEventListener("dataavailable",F,false)}else{H.attachEvent("ondataavailable",F);H.attachEvent("onlosecapture",F)}}else{var E=l(G);if(H.addEventListener){H.addEventListener(E,F,false)}else{H.attachEvent("on"+E,F)}}return H}function k(K,H,L){K=$(K);var G=Element.retrieve(K,"prototype_event_registry");if(!G){return K}if(!H){G.each(function(N){var M=N.key;k(K,M)});return K}var I=G.get(H);if(!I){return K}if(!L){I.each(function(M){k(K,H,M.handler)});return K}var J=I.length,F;while(J--){if(I[J].handler===L){F=I[J];break}}if(!F){return K}if(H.include(":")){if(K.removeEventListener){K.removeEventListener("dataavailable",F,false)}else{K.detachEvent("ondataavailable",F);K.detachEvent("onlosecapture",F)}}else{var E=l(H);if(K.removeEventListener){K.removeEventListener(E,F,false)}else{K.detachEvent("on"+E,F)}}G.set(H,I.without(F));return K}function z(H,G,F,E){H=$(H);if(Object.isUndefined(E)){E=true}if(H==document&&document.createEvent&&!H.dispatchEvent){H=document.documentElement}var I;if(document.createEvent){I=document.createEvent("HTMLEvents");I.initEvent("dataavailable",E,true)}else{I=document.createEventObject();I.eventType=E?"ondataavailable":"onlosecapture"}I.eventName=G;I.memo=F||{};if(document.createEvent){H.dispatchEvent(I)}else{H.fireEvent(I.eventType,I)}return C.extend(I)}C.Handler=Class.create({initialize:function(G,F,E,H){this.element=$(G);this.eventName=F;this.selector=E;this.callback=H;this.handler=this.handleEvent.bind(this)},start:function(){C.observe(this.element,this.eventName,this.handler);return this},stop:function(){C.stopObserving(this.element,this.eventName,this.handler);return this},handleEvent:function(F){var E=C.findElement(F,this.selector);if(E){this.callback.call(this.element,F,E)}}});function j(G,F,E,H){G=$(G);if(Object.isFunction(E)&&Object.isUndefined(H)){H=E,E=null}return new C.Handler(G,F,E,H).start()}Object.extend(C,C.Methods);Object.extend(C,{fire:z,observe:w,stopObserving:k,on:j});Element.addMethods({fire:z,observe:w,stopObserving:k,on:j});Object.extend(document,{fire:z.methodize(),observe:w.methodize(),stopObserving:k.methodize(),on:j.methodize(),loaded:false});if(window.Event){Object.extend(window.Event,C)}else{window.Event=C}})();(function(){var d;function a(){if(document.loaded){return}if(d){window.clearTimeout(d)}document.loaded=true;document.fire("dom:loaded")}function c(){if(document.readyState==="complete"){document.stopObserving("readystatechange",c);a()}}function b(){try{document.documentElement.doScroll("left")}catch(f){d=b.defer();return}a()}if(document.addEventListener){document.addEventListener("DOMContentLoaded",a,false)}else{document.observe("readystatechange",c);if(window==top){d=b.defer()}}Event.observe(window,"load",a)})();Element.addMethods();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,k,j;k=c[d];d++){if(k.className&&(j=" "+k.className+" ")&&(j.include(f)||(h&&h.all(function(i){return !i.toString().blank()&&j.include(" "+i+" ")})))){g.push(Element.extend(k))}}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);(function(){window.Selector=Class.create({initialize:function(a){this.expression=a.strip()},findElements:function(a){return Prototype.Selector.select(this.expression,a)},match:function(a){return Prototype.Selector.match(a,this.expression)},toString:function(){return this.expression},inspect:function(){return"#<Selector: "+this.expression+">"}});Object.extend(Selector,{matchElements:function(f,g){var a=Prototype.Selector.match,d=[];for(var c=0,e=f.length;c<e;c++){var b=f[c];if(a(b,g)){d.push(Element.extend(b))}}return d},findElement:function(f,g,b){b=b||0;var a=0,d;for(var c=0,e=f.length;c<e;c++){d=f[c];if(Prototype.Selector.match(d,g)&&b===a++){return Element.extend(d)}}},findChildElements:function(b,c){var a=c.toArray().join(", ");return Prototype.Selector.select(a,b||document)}})})();
var EventSelectors={version:"1.0_pre",cache:[],start:function(a){this.rules=a||{};this.timer=new Array();this._extendRules();this.assign(this.rules)},assign:function(b){var a=null;this._unloadCache();b._each(function(d){var c=$A(d.key.split(","));c.each(function(e){var g=e.split(":");var f=g[1];$$(g[0]).each(function(h){if(g[1]==""||g.length==1){return d.value(h)}if(f.toLowerCase()=="loaded"){this.timer[g[0]]=setInterval(this._checkLoaded.bind(this,h,g[0],d),15)}else{a=function(j){var i=Event.element(j);if(i.nodeType==3){i=i.parentNode}d.value($(i),j)};this.cache.push([h,f,a]);Event.observe(h,f,a)}}.bind(this))}.bind(this))}.bind(this))},_unloadCache:function(){if(!this.cache){return}for(var a=0;a<this.cache.length;a++){Event.stopObserving.apply(this,this.cache[a]);this.cache[a][0]=null}this.cache=[]},_checkLoaded:function(a,d,c){var b=$(a);if(a.tagName!="undefined"){clearInterval(this.timer[d]);c.value(b)}},_extendRules:function(){Object.extend(this.rules,{_each:function(a){for(key in this){if(key=="_each"){continue}var b=this[key];var c=[key,b];c.key=key;c.value=b;a(c)}}})}};
var Scriptaculous={Version:"1.9.0",require:function(b){try{document.write('<script type="text/javascript" src="'+b+'"><\/script>')}catch(c){var a=document.createElement("script");a.type="text/javascript";a.src=b;document.getElementsByTagName("head")[0].appendChild(a)}},REQUIRED_PROTOTYPE:"1.6.0.3",load:function(){function a(c){var d=c.replace(/_.*|\./g,"");d=parseInt(d+"0".times(4-d.length));return c.indexOf("_")>-1?d-1:d}if((typeof Prototype=="undefined")||(typeof Element=="undefined")||(typeof Element.Methods=="undefined")||(a(Prototype.Version)<a(Scriptaculous.REQUIRED_PROTOTYPE))){throw ("script.aculo.us requires the Prototype JavaScript framework >= "+Scriptaculous.REQUIRED_PROTOTYPE)}var b=/scriptaculous\.js(\?.*)?$/;$$("script[src]").findAll(function(c){return c.src.match(b)}).each(function(d){var e=d.src.replace(b,""),c=d.src.match(/\?.*load=([a-z,]*)/);(c?c[1]:"builder,effects,dragdrop,controls,slider,sound").split(",").each(function(f){Scriptaculous.require(e+f+".js")})})}};Scriptaculous.load();String.prototype.parseColor=function(){var a="#";if(this.slice(0,4)=="rgb("){var c=this.slice(4,this.length-1).split(",");var b=0;do{a+=parseInt(c[b]).toColorPart()}while(++b<3)}else{if(this.slice(0,1)=="#"){if(this.length==4){for(var b=1;b<4;b++){a+=(this.charAt(b)+this.charAt(b)).toLowerCase()}}if(this.length==7){a=this.toLowerCase()}}}return(a.length==7?a:(arguments[0]||this))};Element.collectTextNodes=function(a){return $A($(a).childNodes).collect(function(b){return(b.nodeType==3?b.nodeValue:(b.hasChildNodes()?Element.collectTextNodes(b):""))}).flatten().join("")};Element.collectTextNodesIgnoreClass=function(a,b){return $A($(a).childNodes).collect(function(c){return(c.nodeType==3?c.nodeValue:((c.hasChildNodes()&&!Element.hasClassName(c,b))?Element.collectTextNodesIgnoreClass(c,b):""))}).flatten().join("")};Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:(b/100)+"em"});if(Prototype.Browser.WebKit){window.scrollBy(0,0)}return a};Element.getInlineOpacity=function(a){return $(a).style.opacity||""};Element.forceRerendering=function(a){try{a=$(a);var c=document.createTextNode(" ");a.appendChild(c);a.removeChild(c)}catch(b){}};var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},Transitions:{linear:Prototype.K,sinoidal:function(a){return(-Math.cos(a*Math.PI)/2)+0.5},reverse:function(a){return 1-a},flicker:function(a){var a=((-Math.cos(a*Math.PI)/4)+0.75)+Math.random()/4;return a>1?1:a},wobble:function(a){return(-Math.cos(a*Math.PI*(9*a))/2)+0.5},pulse:function(b,a){return(-Math.cos((b*((a||5)-0.5)*2)*Math.PI)/2)+0.5},spring:function(a){return 1-(Math.cos(a*4.5*Math.PI)*Math.exp(-a*6))},none:function(a){return 0},full:function(a){return 1}},DefaultOptions:{duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"},tagifyText:function(a){var b="position:relative";if(Prototype.Browser.IE){b+=";zoom:1"}a=$(a);$A(a.childNodes).each(function(c){if(c.nodeType==3){c.nodeValue.toArray().each(function(d){a.insertBefore(new Element("span",{style:b}).update(d==" "?String.fromCharCode(160):d),c)});Element.remove(c)}})},multiple:function(b,c){var e;if(((typeof b=="object")||Object.isFunction(b))&&(b.length)){e=b}else{e=$(b).childNodes}var a=Object.extend({speed:0.1,delay:0},arguments[2]||{});var d=a.delay;$A(e).each(function(g,f){new c(g,Object.extend(a,{delay:f*a.speed+d}))})},PAIRS:{slide:["SlideDown","SlideUp"],blind:["BlindDown","BlindUp"],appear:["Appear","Fade"]},toggle:function(b,c,a){b=$(b);c=(c||"appear").toLowerCase();return Effect[Effect.PAIRS[c][b.visible()?1:0]](b,Object.extend({queue:{position:"end",scope:(b.id||"global"),limit:1}},a||{}))}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];this.interval=null},_each:function(a){this.effects._each(a)},add:function(b){var c=new Date().getTime();var a=Object.isString(b.options.queue)?b.options.queue:b.options.queue.position;switch(a){case"front":this.effects.findAll(function(d){return d.state=="idle"}).each(function(d){d.startOn+=b.finishOn;d.finishOn+=b.finishOn});break;case"with-last":c=this.effects.pluck("startOn").max()||c;break;case"end":c=this.effects.pluck("finishOn").max()||c;break}b.startOn+=c;b.finishOn+=c;if(!b.options.queue.limit||(this.effects.length<b.options.queue.limit)){this.effects.push(b)}if(!this.interval){this.interval=setInterval(this.loop.bind(this),15)}},remove:function(a){this.effects=this.effects.reject(function(b){return b==a});if(this.effects.length==0){clearInterval(this.interval);this.interval=null}},loop:function(){var c=new Date().getTime();for(var b=0,a=this.effects.length;b<a;b++){this.effects[b]&&this.effects[b].loop(c)}}});Effect.Queues={instances:$H(),get:function(a){if(!Object.isString(a)){return a}return this.instances.get(a)||this.instances.set(a,new Effect.ScopedQueue())}};Effect.Queue=Effect.Queues.get("global");Effect.Base=Class.create({position:null,start:function(a){if(a&&a.transition===false){a.transition=Effect.Transitions.linear}this.options=Object.extend(Object.extend({},Effect.DefaultOptions),a||{});this.currentFrame=0;this.state="idle";this.startOn=this.options.delay*1000;this.finishOn=this.startOn+(this.options.duration*1000);this.fromToDelta=this.options.to-this.options.from;this.totalTime=this.finishOn-this.startOn;this.totalFrames=this.options.fps*this.options.duration;this.render=(function(){function b(d,c){if(d.options[c+"Internal"]){d.options[c+"Internal"](d)}if(d.options[c]){d.options[c](d)}}return function(c){if(this.state==="idle"){this.state="running";b(this,"beforeSetup");if(this.setup){this.setup()}b(this,"afterSetup")}if(this.state==="running"){c=(this.options.transition(c)*this.fromToDelta)+this.options.from;this.position=c;b(this,"beforeUpdate");if(this.update){this.update(c)}b(this,"afterUpdate")}}})();this.event("beforeStart");if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).add(this)}},loop:function(c){if(c>=this.startOn){if(c>=this.finishOn){this.render(1);this.cancel();this.event("beforeFinish");if(this.finish){this.finish()}this.event("afterFinish");return}var b=(c-this.startOn)/this.totalTime,a=(b*this.totalFrames).round();if(a>this.currentFrame){this.render(b);this.currentFrame=a}}},cancel:function(){if(!this.options.sync){Effect.Queues.get(Object.isString(this.options.queue)?"global":this.options.queue.scope).remove(this)}this.state="finished"},event:function(a){if(this.options[a+"Internal"]){this.options[a+"Internal"](this)}if(this.options[a]){this.options[a](this)}},inspect:function(){var a=$H();for(property in this){if(!Object.isFunction(this[property])){a.set(property,this[property])}}return"#<Effect:"+a.inspect()+",options:"+$H(this.options).inspect()+">"}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(a){this.effects=a||[];this.start(arguments[1])},update:function(a){this.effects.invoke("render",a)},finish:function(a){this.effects.each(function(b){b.render(1);b.cancel();b.event("beforeFinish");if(b.finish){b.finish(a)}b.event("afterFinish")})}});Effect.Tween=Class.create(Effect.Base,{initialize:function(c,f,e){c=Object.isString(c)?$(c):c;var b=$A(arguments),d=b.last(),a=b.length==5?b[3]:null;this.method=Object.isFunction(d)?d.bind(c):Object.isFunction(c[d])?c[d].bind(c):function(g){c[d]=g};this.start(Object.extend({from:f,to:e},a||{}))},update:function(a){this.method(a)}});Effect.Event=Class.create(Effect.Base,{initialize:function(){this.start(Object.extend({duration:0},arguments[0]||{}))},update:Prototype.emptyFunction});Effect.Opacity=Class.create(Effect.Base,{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}var a=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});this.start(a)},update:function(a){this.element.setOpacity(a)}});Effect.Move=Class.create(Effect.Base,{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});this.start(a)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle("left")||"0");this.originalTop=parseFloat(this.element.getStyle("top")||"0");if(this.options.mode=="absolute"){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(a){this.element.setStyle({left:(this.options.x*a+this.originalLeft).round()+"px",top:(this.options.y*a+this.originalTop).round()+"px"})}});Effect.MoveBy=function(b,a,c){return new Effect.Move(b,Object.extend({x:c,y:a},arguments[3]||{}))};Effect.Scale=Class.create(Effect.Base,{initialize:function(b,c){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:c},arguments[2]||{});this.start(a)},setup:function(){this.restoreAfterFinish=this.options.restoreAfterFinish||false;this.elementPositioning=this.element.getStyle("position");this.originalStyle={};["top","left","width","height","fontSize"].each(function(b){this.originalStyle[b]=this.element.style[b]}.bind(this));this.originalTop=this.element.offsetTop;this.originalLeft=this.element.offsetLeft;var a=this.element.getStyle("font-size")||"100%";["em","px","%","pt"].each(function(b){if(a.indexOf(b)>0){this.fontSize=parseFloat(a);this.fontSizeType=b}}.bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=="box"){this.dims=[this.element.offsetHeight,this.element.offsetWidth]}if(/^content/.test(this.options.scaleMode)){this.dims=[this.element.scrollHeight,this.element.scrollWidth]}if(!this.dims){this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]}},update:function(a){var b=(this.options.scaleFrom/100)+(this.factor*a);if(this.options.scaleContent&&this.fontSize){this.element.setStyle({fontSize:this.fontSize*b+this.fontSizeType})}this.setDimensions(this.dims[0]*b,this.dims[1]*b)},finish:function(a){if(this.restoreAfterFinish){this.element.setStyle(this.originalStyle)}},setDimensions:function(a,e){var f={};if(this.options.scaleX){f.width=e.round()+"px"}if(this.options.scaleY){f.height=a.round()+"px"}if(this.options.scaleFromCenter){var c=(a-this.dims[0])/2;var b=(e-this.dims[1])/2;if(this.elementPositioning=="absolute"){if(this.options.scaleY){f.top=this.originalTop-c+"px"}if(this.options.scaleX){f.left=this.originalLeft-b+"px"}}else{if(this.options.scaleY){f.top=-c+"px"}if(this.options.scaleX){f.left=-b+"px"}}}this.element.setStyle(f)}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(b){this.element=$(b);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({startcolor:"#ffff99"},arguments[1]||{});this.start(a)},setup:function(){if(this.element.getStyle("display")=="none"){this.cancel();return}this.oldStyle={};if(!this.options.keepBackgroundImage){this.oldStyle.backgroundImage=this.element.getStyle("background-image");this.element.setStyle({backgroundImage:"none"})}if(!this.options.endcolor){this.options.endcolor=this.element.getStyle("background-color").parseColor("#ffffff")}if(!this.options.restorecolor){this.options.restorecolor=this.element.getStyle("background-color")}this._base=$R(0,2).map(function(a){return parseInt(this.options.startcolor.slice(a*2+1,a*2+3),16)}.bind(this));this._delta=$R(0,2).map(function(a){return parseInt(this.options.endcolor.slice(a*2+1,a*2+3),16)-this._base[a]}.bind(this))},update:function(a){this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(b,c,d){return b+((this._base[d]+(this._delta[d]*a)).round().toColorPart())}.bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=function(c){var b=arguments[1]||{},a=document.viewport.getScrollOffsets(),d=$(c).cumulativeOffset();if(b.offset){d[1]+=b.offset}return new Effect.Tween(null,a.top,d[1],b,function(e){scrollTo(a.left,e.round())})};Effect.Fade=function(c){c=$(c);var a=c.getInlineOpacity();var b=Object.extend({from:c.getOpacity()||1,to:0,afterFinishInternal:function(d){if(d.options.to!=0){return}d.element.hide().setStyle({opacity:a})}},arguments[1]||{});return new Effect.Opacity(c,b)};Effect.Appear=function(b){b=$(b);var a=Object.extend({from:(b.getStyle("display")=="none"?0:b.getOpacity()||0),to:1,afterFinishInternal:function(c){c.element.forceRerendering()},beforeSetup:function(c){c.element.setOpacity(c.options.from).show()}},arguments[1]||{});return new Effect.Opacity(b,a)};Effect.Puff=function(b){b=$(b);var a={opacity:b.getInlineOpacity(),position:b.getStyle("position"),top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};return new Effect.Parallel([new Effect.Scale(b,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(b,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(c){Position.absolutize(c.effects[0].element)},afterFinishInternal:function(c){c.effects[0].element.hide().setStyle(a)}},arguments[1]||{}))};Effect.BlindUp=function(a){a=$(a);a.makeClipping();return new Effect.Scale(a,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(b){b.element.hide().undoClipping()}},arguments[1]||{}))};Effect.BlindDown=function(b){b=$(b);var a=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:a.height,originalWidth:a.width},restoreAfterFinish:true,afterSetup:function(c){c.element.makeClipping().setStyle({height:"0px"}).show()},afterFinishInternal:function(c){c.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(b){b=$(b);var a=b.getInlineOpacity();return new Effect.Appear(b,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(c){new Effect.Scale(c.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(d){d.element.makePositioned().makeClipping()},afterFinishInternal:function(d){d.element.hide().undoClipping().undoPositioned().setStyle({opacity:a})}})}},arguments[1]||{}))};Effect.DropOut=function(b){b=$(b);var a={top:b.getStyle("top"),left:b.getStyle("left"),opacity:b.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(b,{x:0,y:100,sync:true}),new Effect.Opacity(b,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(c){c.effects[0].element.makePositioned()},afterFinishInternal:function(c){c.effects[0].element.hide().undoPositioned().setStyle(a)}},arguments[1]||{}))};Effect.Shake=function(d){d=$(d);var b=Object.extend({distance:20,duration:0.5},arguments[1]||{});var e=parseFloat(b.distance);var c=parseFloat(b.duration)/10;var a={top:d.getStyle("top"),left:d.getStyle("left")};return new Effect.Move(d,{x:e,y:0,duration:c,afterFinishInternal:function(f){new Effect.Move(f.element,{x:-e*2,y:0,duration:c*2,afterFinishInternal:function(g){new Effect.Move(g.element,{x:e*2,y:0,duration:c*2,afterFinishInternal:function(h){new Effect.Move(h.element,{x:-e*2,y:0,duration:c*2,afterFinishInternal:function(i){new Effect.Move(i.element,{x:e*2,y:0,duration:c*2,afterFinishInternal:function(j){new Effect.Move(j.element,{x:-e,y:0,duration:c,afterFinishInternal:function(k){k.element.undoPositioned().setStyle(a)}})}})}})}})}})}})};Effect.SlideDown=function(c){c=$(c).cleanWhitespace();var a=c.down().getStyle("bottom");var b=c.getDimensions();return new Effect.Scale(c,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:b.height,originalWidth:b.width},restoreAfterFinish:true,afterSetup:function(d){d.element.makePositioned();d.element.down().makePositioned();if(window.opera){d.element.setStyle({top:""})}d.element.makeClipping().setStyle({height:"0px"}).show()},afterUpdateInternal:function(d){d.element.down().setStyle({bottom:(d.dims[0]-d.element.clientHeight)+"px"})},afterFinishInternal:function(d){d.element.undoClipping().undoPositioned();d.element.down().undoPositioned().setStyle({bottom:a})}},arguments[1]||{}))};Effect.SlideUp=function(c){c=$(c).cleanWhitespace();var a=c.down().getStyle("bottom");var b=c.getDimensions();return new Effect.Scale(c,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,scaleMode:{originalHeight:b.height,originalWidth:b.width},restoreAfterFinish:true,afterSetup:function(d){d.element.makePositioned();d.element.down().makePositioned();if(window.opera){d.element.setStyle({top:""})}d.element.makeClipping().show()},afterUpdateInternal:function(d){d.element.down().setStyle({bottom:(d.dims[0]-d.element.clientHeight)+"px"})},afterFinishInternal:function(d){d.element.hide().undoClipping().undoPositioned();d.element.down().undoPositioned().setStyle({bottom:a})}},arguments[1]||{}))};Effect.Squish=function(a){return new Effect.Scale(a,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(b){b.element.makeClipping()},afterFinishInternal:function(b){b.element.hide().undoClipping()}})};Effect.Grow=function(c){c=$(c);var b=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var a={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};var g=c.getDimensions();var h,f;var e,d;switch(b.direction){case"top-left":h=f=e=d=0;break;case"top-right":h=g.width;f=d=0;e=-g.width;break;case"bottom-left":h=e=0;f=g.height;d=-g.height;break;case"bottom-right":h=g.width;f=g.height;e=-g.width;d=-g.height;break;case"center":h=g.width/2;f=g.height/2;e=-g.width/2;d=-g.height/2;break}return new Effect.Move(c,{x:h,y:f,duration:0.01,beforeSetup:function(i){i.element.hide().makeClipping().makePositioned()},afterFinishInternal:function(i){new Effect.Parallel([new Effect.Opacity(i.element,{sync:true,to:1,from:0,transition:b.opacityTransition}),new Effect.Move(i.element,{x:e,y:d,sync:true,transition:b.moveTransition}),new Effect.Scale(i.element,100,{scaleMode:{originalHeight:g.height,originalWidth:g.width},sync:true,scaleFrom:window.opera?1:0,transition:b.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(j){j.effects[0].element.setStyle({height:"0px"}).show()},afterFinishInternal:function(j){j.effects[0].element.undoClipping().undoPositioned().setStyle(a)}},b))}})};Effect.Shrink=function(c){c=$(c);var b=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var a={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};var f=c.getDimensions();var e,d;switch(b.direction){case"top-left":e=d=0;break;case"top-right":e=f.width;d=0;break;case"bottom-left":e=0;d=f.height;break;case"bottom-right":e=f.width;d=f.height;break;case"center":e=f.width/2;d=f.height/2;break}return new Effect.Parallel([new Effect.Opacity(c,{sync:true,to:0,from:1,transition:b.opacityTransition}),new Effect.Scale(c,window.opera?1:0,{sync:true,transition:b.scaleTransition,restoreAfterFinish:true}),new Effect.Move(c,{x:e,y:d,sync:true,transition:b.moveTransition})],Object.extend({beforeStartInternal:function(g){g.effects[0].element.makePositioned().makeClipping()},afterFinishInternal:function(g){g.effects[0].element.hide().undoClipping().undoPositioned().setStyle(a)}},b))};Effect.Pulsate=function(c){c=$(c);var b=arguments[1]||{},a=c.getInlineOpacity(),e=b.transition||Effect.Transitions.linear,d=function(f){return 1-e((-Math.cos((f*(b.pulses||5)*2)*Math.PI)/2)+0.5)};return new Effect.Opacity(c,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(f){f.element.setStyle({opacity:a})}},b),{transition:d}))};Effect.Fold=function(b){b=$(b);var a={top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};b.makeClipping();return new Effect.Scale(b,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(c){new Effect.Scale(b,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(d){d.element.hide().undoClipping().setStyle(a)}})}},arguments[1]||{}))};Effect.Morph=Class.create(Effect.Base,{initialize:function(c){this.element=$(c);if(!this.element){throw (Effect._elementDoesNotExistError)}var a=Object.extend({style:{}},arguments[1]||{});if(!Object.isString(a.style)){this.style=$H(a.style)}else{if(a.style.include(":")){this.style=a.style.parseStyle()}else{this.element.addClassName(a.style);this.style=$H(this.element.getStyles());this.element.removeClassName(a.style);var b=this.element.getStyles();this.style=this.style.reject(function(d){return d.value==b[d.key]});a.afterFinishInternal=function(d){d.element.addClassName(d.options.style);d.transforms.each(function(e){d.element.style[e.style]=""})}}}this.start(a)},setup:function(){function a(b){if(!b||["rgba(0, 0, 0, 0)","transparent"].include(b)){b="#ffffff"}b=b.parseColor();return $R(0,2).map(function(c){return parseInt(b.slice(c*2+1,c*2+3),16)})}this.transforms=this.style.map(function(g){var f=g[0],e=g[1],d=null;if(e.parseColor("#zzzzzz")!="#zzzzzz"){e=e.parseColor();d="color"}else{if(f=="opacity"){e=parseFloat(e);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){this.element.setStyle({zoom:1})}}else{if(Element.CSS_LENGTH.test(e)){var c=e.match(/^([\+\-]?[0-9\.]+)(.*)$/);e=parseFloat(c[1]);d=(c.length==3)?c[2]:null}}}var b=this.element.getStyle(f);return{style:f.camelize(),originalValue:d=="color"?a(b):parseFloat(b||0),targetValue:d=="color"?a(e):e,unit:d}}.bind(this)).reject(function(b){return((b.originalValue==b.targetValue)||(b.unit!="color"&&(isNaN(b.originalValue)||isNaN(b.targetValue))))})},update:function(a){var d={},b,c=this.transforms.length;while(c--){d[(b=this.transforms[c]).style]=b.unit=="color"?"#"+(Math.round(b.originalValue[0]+(b.targetValue[0]-b.originalValue[0])*a)).toColorPart()+(Math.round(b.originalValue[1]+(b.targetValue[1]-b.originalValue[1])*a)).toColorPart()+(Math.round(b.originalValue[2]+(b.targetValue[2]-b.originalValue[2])*a)).toColorPart():(b.originalValue+(b.targetValue-b.originalValue)*a).toFixed(3)+(b.unit===null?"":b.unit)}this.element.setStyle(d,true)}});Effect.Transform=Class.create({initialize:function(a){this.tracks=[];this.options=arguments[1]||{};this.addTracks(a)},addTracks:function(a){a.each(function(b){b=$H(b);var c=b.values().first();this.tracks.push($H({ids:b.keys().first(),effect:Effect.Morph,options:{style:c}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){var d=a.get("ids"),c=a.get("effect"),b=a.get("options");var e=[$(d)||$$(d)].flatten();return e.map(function(f){return new c(f,Object.extend({sync:true},b))})}).flatten(),this.options)}});Element.CSS_PROPERTIES=$w("backgroundColor backgroundPosition borderBottomColor borderBottomStyle borderBottomWidth borderLeftColor borderLeftStyle borderLeftWidth borderRightColor borderRightStyle borderRightWidth borderSpacing borderTopColor borderTopStyle borderTopWidth bottom clip color fontSize fontWeight height left letterSpacing lineHeight marginBottom marginLeft marginRight marginTop markerOffset maxHeight maxWidth minHeight minWidth opacity outlineColor outlineOffset outlineWidth paddingBottom paddingLeft paddingRight paddingTop right textIndent top width wordSpacing zIndex");Element.CSS_LENGTH=/^(([\+\-]?[0-9\.]+)(em|ex|px|in|cm|mm|pt|pc|\%))|0$/;String.__parseStyleElement=document.createElement("div");String.prototype.parseStyle=function(){var b,a=$H();if(Prototype.Browser.WebKit){b=new Element("div",{style:this}).style}else{String.__parseStyleElement.innerHTML='<div style="'+this+'"></div>';b=String.__parseStyleElement.childNodes[0].style}Element.CSS_PROPERTIES.each(function(c){if(b[c]){a.set(c,b[c])}});if(Prototype.Browser.IE&&this.include("opacity")){a.set("opacity",this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1])}return a};if(document.defaultView&&document.defaultView.getComputedStyle){Element.getStyles=function(b){var a=document.defaultView.getComputedStyle($(b),null);return Element.CSS_PROPERTIES.inject({},function(c,d){c[d]=a[d];return c})}}else{Element.getStyles=function(b){b=$(b);var a=b.currentStyle,c;c=Element.CSS_PROPERTIES.inject({},function(d,e){d[e]=a[e];return d});if(!c.opacity){c.opacity=b.getOpacity()}return c}}Effect.Methods={morph:function(a,b){a=$(a);new Effect.Morph(a,Object.extend({style:b},arguments[2]||{}));return a},visualEffect:function(c,e,b){c=$(c);var d=e.dasherize().camelize(),a=d.charAt(0).toUpperCase()+d.substring(1);new Effect[a](c,b);return c},highlight:function(b,a){b=$(b);new Effect.Highlight(b,a);return b}};$w("fade appear grow shrink fold blindUp blindDown slideUp slideDown pulsate shake puff squish switchOff dropOut").each(function(a){Effect.Methods[a]=function(c,b){c=$(c);Effect[a.charAt(0).toUpperCase()+a.substring(1)](c,b);return c}});$w("getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles").each(function(a){Effect.Methods[a]=Element[a]});Element.addMethods(Effect.Methods);
var swfobject=function(){var b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
(function(){var ua=navigator.userAgent.toLowerCase(),S={version:"3.0rc1",adapter:null,cache:[],client:{isIE:ua.indexOf("msie")>-1,isIE6:ua.indexOf("msie 6")>-1,isIE7:ua.indexOf("msie 7")>-1,isGecko:ua.indexOf("gecko")>-1&&ua.indexOf("safari")==-1,isWebkit:ua.indexOf("applewebkit/")>-1,isWindows:ua.indexOf("windows")>-1||ua.indexOf("win32")>-1,isMac:ua.indexOf("macintosh")>-1||ua.indexOf("mac os x")>-1,isLinux:ua.indexOf("linux")>-1},content:null,current:-1,dimensions:null,gallery:[],expando:"shadowboxCacheKey",libraries:{Prototype:"prototype",jQuery:"jquery",MooTools:"mootools",YAHOO:"yui",dojo:"dojo",Ext:"ext"},options:{adapter:null,animate:true,animateFade:true,autoplayMovies:true,continuous:false,ease:function(x){return 1+Math.pow(x-1,3)},enableKeys:true,errors:{fla:{name:"Flash",url:"http://www.adobe.com/products/flashplayer/"},qt:{name:"QuickTime",url:"http://www.apple.com/quicktime/download/"},wmp:{name:"Windows Media Player",url:"http://www.microsoft.com/windows/windowsmedia/"},f4m:{name:"Flip4Mac",url:"http://www.flip4mac.com/wmv_download.htm"}},ext:{img:["png","jpg","jpeg","gif","bmp"],swf:["swf"],flv:["flv","m4v"],qt:["dv","mov","moov","movie","mp4"],wmp:["asf","wm","wmv"],qtwmp:["avi","mpg","mpeg"]},flashParams:{bgcolor:"#000000",allowfullscreen:true},flashVars:{},flashVersion:"9.0.115",handleOversize:"resize",handleUnsupported:"link",language:"en",onChange:null,onClose:null,onFinish:null,onOpen:null,players:["img"],showMovieControls:true,skipSetup:false,slideshowDelay:0,useSizzle:true,viewportPadding:20},path:"",plugins:null,ready:false,regex:{domain:/:\/\/(.*?)[:\/]/,inline:/#(.+)$/,rel:/^(light|shadow)box/i,gallery:/^(light|shadow)box\[(.*?)\]/i,unsupported:/^unsupported-(\w+)/,param:/\s*([a-z_]*?)\s*=\s*(.+)\s*/},applyOptions:function(opts){if(opts){default_options=apply({},S.options);apply(S.options,opts)}},revertOptions:function(){apply(S.options,default_options)},change:function(index){if(!S.gallery){return}if(!S.gallery[index]){if(!S.options.continuous){return}else{index=index<0?S.gallery.length-1:0}}S.current=index;if(typeof slide_timer=="number"){clearTimeout(slide_timer);slide_timer=null;slide_delay=slide_start=0}if(S.options.onChange){S.options.onChange()}loadContent()},close:function(){if(!active){return}active=false;listenKeys(false);if(S.content){S.content.remove();S.content=null}if(typeof slide_timer=="number"){clearTimeout(slide_timer)}slide_timer=null;slide_delay=0;if(S.options.onClose){S.options.onClose()}S.skin.onClose();S.revertOptions()},contentId:function(){return content_id},error:function(msg){if(!S.debug){return}if(typeof window.console!="undefined"&&typeof console.log=="function"){console.log(msg)}else{alert(msg)}},getCurrent:function(){return S.current>-1?S.gallery[S.current]:null},hasNext:function(){return S.gallery.length>1&&(S.current!=S.gallery.length-1||S.options.continuous)},init:function(opts){if(initialized){return}initialized=true;opts=opts||{};init_options=opts;if(opts){apply(S.options,opts)}for(var e in S.options.ext){S.regex[e]=new RegExp(".("+S.options.ext[e].join("|")+")s*$","i")}if(!S.path){var pathre=/(.+\/)shadowbox\.js/i,path;each(document.getElementsByTagName("script"),function(s){path=pathre.exec(s.src);if(path){S.path=path[1];return false}})}if(S.options.adapter){S.adapter=S.options.adapter.toLowerCase()}else{for(var lib in S.libraries){if(typeof window[lib]!="undefined"){S.adapter=S.libraries[lib];break}}if(!S.adapter){S.adapter="base"}}if(S.options.useSizzle&&!window.Sizzle){if(window.jQuery){window.Sizzle=jQuery.find}else{U.include(S.path+"libraries/sizzle/sizzle.js")}}if(!S.lang){U.include(S.path+"languages/shadowbox-"+S.options.language+".js")}each(S.options.players,function(p){if((p=="swf"||p=="flv")&&!window.swfobject){U.include(S.path+"libraries/swfobject/swfobject.js")}if(!S[p]){U.include(S.path+"players/shadowbox-"+p+".js")}});if(!S.lib){U.include(S.path+"adapters/shadowbox-"+S.adapter+".js")}waitDom(waitLibs)},isActive:function(){return active},isPaused:function(){return slide_timer=="paused"},load:function(){if(S.ready){return}S.ready=true;if(S.skin.options){apply(S.options,S.skin.options);apply(S.options,init_options)}S.skin.init();if(!S.options.skipSetup){S.setup()}},next:function(){S.change(S.current+1)},open:function(obj){if(U.isLink(obj)){if(S.inCache(obj)){obj=S.cache[obj[S.expando]]}else{obj=S.buildCacheObj(obj)}}if(obj.constructor==Array){S.gallery=obj;S.current=0}else{if(!obj.gallery){S.gallery=[obj];S.current=0}else{S.current=null;S.gallery=[];each(S.cache,function(c){if(c.gallery&&c.gallery==obj.gallery){if(S.current==null&&c.content==obj.content&&c.title==obj.title){S.current=S.gallery.length}S.gallery.push(c)}});if(S.current==null){S.gallery.unshift(obj);S.current=0}}}obj=S.getCurrent();if(obj.options){S.revertOptions();S.applyOptions(obj.options)}var item,remove,m,format,replace,oe=S.options.errors,msg,el;for(var i=0;i<S.gallery.length;++i){item=S.gallery[i]=apply({},S.gallery[i]);remove=false;if(m=S.regex.unsupported.exec(item.player)){if(S.options.handleUnsupported=="link"){item.player="html";switch(m[1]){case"qtwmp":format="either";replace=[oe.qt.url,oe.qt.name,oe.wmp.url,oe.wmp.name];break;case"qtf4m":format="shared";replace=[oe.qt.url,oe.qt.name,oe.f4m.url,oe.f4m.name];break;default:format="single";if(m[1]=="swf"||m[1]=="flv"){m[1]="fla"}replace=[oe[m[1]].url,oe[m[1]].name]}msg=S.lang.errors[format].replace(/\{(\d+)\}/g,function(m,n){return replace[n]});item.content='<div class="sb-message">'+msg+"</div>"}else{remove=true}}else{if(item.player=="inline"){m=S.regex.inline.exec(item.content);if(m){var el=U.get(m[1]);if(el){item.content=el.innerHTML}else{S.error("Cannot find element with id "+m[1])}}else{S.error("Cannot find element id for inline content")}}else{if(item.player=="swf"||item.player=="flv"){var version=(item.options&&item.options.flashVersion)||S.options.flashVersion;if(!swfobject.hasFlashPlayerVersion(version)){item.width=310;item.height=177}}}}if(remove){S.gallery.splice(i,1);if(i<S.current){--S.current}else{if(i==S.current){S.current=i>0?i-1:i}}--i}}if(S.gallery.length){if(!active){if(typeof S.options.onOpen=="function"&&S.options.onOpen(obj)===false){return}S.skin.onOpen(obj,loadContent)}else{loadContent()}active=true}},pause:function(){if(typeof slide_timer!="number"){return}var time=new Date().getTime();slide_delay=Math.max(0,slide_delay-(time-slide_start));if(slide_delay){clearTimeout(slide_timer);slide_timer="paused";if(S.skin.onPause){S.skin.onPause()}}},play:function(){if(!S.hasNext()){return}if(!slide_delay){slide_delay=S.options.slideshowDelay*1000}if(slide_delay){slide_start=new Date().getTime();slide_timer=setTimeout(function(){slide_delay=slide_start=0;S.next()},slide_delay);if(S.skin.onPlay){S.skin.onPlay()}}},previous:function(){S.change(S.current-1)},setDimensions:function(height,width,max_h,max_w,tb,lr,resizable){var h=height=parseInt(height),w=width=parseInt(width),pad=parseInt(S.options.viewportPadding)||0;var extra_h=2*pad+tb;if(h+extra_h>=max_h){h=max_h-extra_h}var extra_w=2*pad+lr;if(w+extra_w>=max_w){w=max_w-extra_w}var resize_h=height,resize_w=width,change_h=(height-h)/height,change_w=(width-w)/width,oversized=(change_h>0||change_w>0);if(resizable&&oversized&&S.options.handleOversize=="resize"){if(change_h>change_w){w=Math.round((width/height)*h)}else{if(change_w>change_h){h=Math.round((height/width)*w)}}resize_w=w;resize_h=h}S.dimensions={height:h+tb,width:w+lr,inner_h:h,inner_w:w,top:(max_h-(h+extra_h))/2+pad,left:(max_w-(w+extra_w))/2+pad,oversized:oversized,resize_h:resize_h,resize_w:resize_w}},setup:function(links,opts){each(S.findLinks(links),function(link){S.addCache(link,opts)})},teardown:function(links){each(S.findLinks(links),S.removeCache)},findLinks:function(links){if(!links){var links=[],rel;each(document.getElementsByTagName("a"),function(a){rel=a.getAttribute("rel");if(rel&&S.regex.rel.test(rel)){links.push(a)}})}else{var len=links.length;if(len){if(window.Sizzle){if(typeof links=="string"){links=Sizzle(links)}else{if(len==2&&links.push&&typeof links[0]=="string"&&links[1].nodeType){links=Sizzle(links[0],links[1])}}}}else{links=[links]}}return links},inCache:function(link){return typeof link[S.expando]=="number"&&S.cache[link[S.expando]]},addCache:function(link,opts){if(!S.inCache(link)){link[S.expando]=S.cache.length;S.lib.addEvent(link,"click",handleClick)}S.cache[link[S.expando]]=S.buildCacheObj(link,opts)},removeCache:function(link){S.lib.removeEvent(link,"click",handleClick);S.cache[link[S.expando]]=null;delete link[S.expando]},clearCache:function(){each(S.cache,function(obj){S.removeCache(obj.link)});S.cache=[]},buildCacheObj:function(link,opts){var obj={link:link,title:link.getAttribute("title"),options:apply({},opts||{}),content:link.href};if(opts){each(["player","title","height","width","gallery"],function(option){if(typeof obj.options[option]!="undefined"){obj[option]=obj.options[option];delete obj.options[option]}})}if(!obj.player){obj.player=S.getPlayer(obj.content)}var rel=link.getAttribute("rel");if(rel){var match=rel.match(S.regex.gallery);if(match){obj.gallery=escape(match[2])}each(rel.split(";"),function(parameter){match=parameter.match(S.regex.param);if(match){if(match[1]=="options"){eval("apply(obj.options,"+match[2]+")")}else{obj[match[1]]=match[2]}}})}return obj},getPlayer:function(content){var r=S.regex,p=S.plugins,m=content.match(r.domain),same_domain=m&&document.domain==m[1];if(content.indexOf("#")>-1&&same_domain){return"inline"}var q=content.indexOf("?");if(q>-1){content=content.substring(0,q)}if(r.img.test(content)){return"img"}if(r.swf.test(content)){return p.fla?"swf":"unsupported-swf"}if(r.flv.test(content)){return p.fla?"flv":"unsupported-flv"}if(r.qt.test(content)){return p.qt?"qt":"unsupported-qt"}if(r.wmp.test(content)){if(p.wmp){return"wmp"}if(p.f4m){return"qt"}if(S.client.isMac){return p.qt?"unsupported-f4m":"unsupported-qtf4m"}return"unsupported-wmp"}if(r.qtwmp.test(content)){if(p.qt){return"qt"}if(p.wmp){return"wmp"}return S.client.isMac?"unsupported-qt":"unsupported-qtwmp"}return"iframe"}},U=S.util={animate:function(el,p,to,d,cb){var from=parseFloat(S.lib.getStyle(el,p));if(isNaN(from)){from=0}var delta=to-from;if(delta==0){if(cb){cb()}return}var op=p=="opacity";function fn(ease){var to=from+ease*delta;if(op){U.setOpacity(el,to)}else{el.style[p]=to+"px"}}if(!d||(!op&&!S.options.animate)||(op&&!S.options.animateFade)){fn(1);if(cb){cb()}return}d*=1000;var begin=new Date().getTime(),ease=S.options.ease,end=begin+d,time,timer=setInterval(function(){time=new Date().getTime();if(time>=end){clearInterval(timer);fn(1);if(cb){cb()}}else{fn(ease((time-begin)/d))}},10)},apply:function(o,e){for(var p in e){o[p]=e[p]}return o},clearOpacity:function(el){var s=el.style;if(window.ActiveXObject){if(typeof s.filter=="string"&&(/alpha/i).test(s.filter)){s.filter=s.filter.replace(/[\w\.]*alpha\(.*?\);?/i,"")}}else{s.opacity=""}},each:function(obj,fn,scope){for(var i=0,len=obj.length;i<len;++i){if(fn.call(scope||obj[i],obj[i],i,obj)===false){return}}},get:function(id){return document.getElementById(id)},include:function(){var includes={};return function(file){if(includes[file]){return}includes[file]=true;var head=document.getElementsByTagName("head")[0],script=document.createElement("script");script.src=file;head.appendChild(script)}}(),isLink:function(obj){if(!obj||!obj.tagName){return false}var up=obj.tagName.toUpperCase();return up=="A"||up=="AREA"},removeChildren:function(el){while(el.firstChild){el.removeChild(el.firstChild)}},setOpacity:function(el,o){var s=el.style;if(window.ActiveXObject){s.zoom=1;s.filter=(s.filter||"").replace(/\s*alpha\([^\)]*\)/gi,"")+(o==1?"":" alpha(opacity="+(o*100)+")")}else{s.opacity=o}}},apply=U.apply,each=U.each,init_options,initialized=false,default_options={},content_id="sb-content",active=false,slide_timer,slide_start,slide_delay=0;if(navigator.plugins&&navigator.plugins.length){var names=[];each(navigator.plugins,function(p){names.push(p.name)});names=names.join();var f4m=names.indexOf("Flip4Mac")>-1;S.plugins={fla:names.indexOf("Shockwave Flash")>-1,qt:names.indexOf("QuickTime")>-1,wmp:!f4m&&names.indexOf("Windows Media")>-1,f4m:f4m}}else{function detectPlugin(n){try{var axo=new ActiveXObject(n)}catch(e){}return !!axo}S.plugins={fla:detectPlugin("ShockwaveFlash.ShockwaveFlash"),qt:detectPlugin("QuickTime.QuickTime"),wmp:detectPlugin("wmplayer.ocx"),f4m:false}}function waitDom(cb){if(document.addEventListener){document.addEventListener("DOMContentLoaded",function(){document.removeEventListener("DOMContentLoaded",arguments.callee,false);cb()},false)}else{if(document.attachEvent){document.attachEvent("onreadystatechange",function(){if(document.readyState==="complete"){document.detachEvent("onreadystatechange",arguments.callee);cb()}});if(document.documentElement.doScroll&&window==window.top){(function(){if(S.ready){return}try{document.documentElement.doScroll("left")}catch(error){setTimeout(arguments.callee,0);return}cb()})()}}}if(typeof window.onload=="function"){var oldonload=window.onload;window.onload=function(){oldonload();cb()}}else{window.onload=cb}}function waitLibs(){if(S.lib&&S.lang){S.load()}else{setTimeout(waitLibs,0)}}function handleClick(e){var link;if(U.isLink(this)){link=this}else{link=S.lib.getTarget(e);while(!U.isLink(link)&&link.parentNode){link=link.parentNode}}S.lib.preventDefault(e);if(link){S.open(link);if(S.gallery.length){S.lib.preventDefault(e)}}}function listenKeys(on){if(!S.options.enableKeys){return}S.lib[(on?"add":"remove")+"Event"](document,"keydown",handleKey)}function handleKey(e){var code=S.lib.keyCode(e),handler;switch(code){case 81:case 88:case 27:handler=S.close;break;case 37:handler=S.previous;break;case 39:handler=S.next;break;case 32:handler=typeof slide_timer=="number"?S.pause:S.play}if(handler){S.lib.preventDefault(e);handler()}}function loadContent(){var obj=S.getCurrent();if(!obj){return}var p=obj.player=="inline"?"html":obj.player;if(typeof S[p]!="function"){S.error("Unknown player: "+p)}var change=false;if(S.content){S.content.remove();change=true;S.revertOptions();if(obj.options){S.applyOptions(obj.options)}}U.removeChildren(S.skin.bodyEl());S.content=new S[p](obj);listenKeys(false);S.skin.onLoad(S.content,change,function(){if(!S.content){return}if(typeof S.content.ready!="undefined"){var id=setInterval(function(){if(S.content){if(S.content.ready){clearInterval(id);id=null;S.skin.onReady(contentReady)}}else{clearInterval(id);id=null}},100)}else{S.skin.onReady(contentReady)}});if(S.gallery.length>1){var next=S.gallery[S.current+1]||S.gallery[0];if(next.player=="img"){var a=new Image();a.src=next.content}var prev=S.gallery[S.current-1]||S.gallery[S.gallery.length-1];if(prev.player=="img"){var b=new Image();b.src=prev.content}}}function contentReady(){if(!S.content){return}S.content.append(S.skin.bodyEl(),content_id,S.dimensions);S.skin.onFinish(finishContent)}function finishContent(){if(!S.content){return}if(S.content.onLoad){S.content.onLoad()}if(S.options.onFinish){S.options.onFinish()}if(!S.isPaused()){S.play()}listenKeys(true)}window.Shadowbox=S})();(function(){var g=Shadowbox,f=g.util,q=false,b=[],m=["sb-nav-close","sb-nav-next","sb-nav-play","sb-nav-pause","sb-nav-previous"],o={markup:'<div id="sb-container"><div id="sb-overlay"></div><div id="sb-wrapper"><div id="sb-nav-top"><a id="sb-nav-close" class="close" title="{close}" onclick="Shadowbox.close()">{close}</a></div><div id="sb-title"><div id="sb-title-inner"></div></div><div id="sb-body"><div id="sb-body-inner"></div><div id="sb-loading"><a onclick="Shadowbox.close()">{cancel}</a></div></div><div id="sb-info"><div id="sb-info-inner"><div id="sb-counter"></div><div id="sb-nav"><a id="sb-nav-close" title="{close}" onclick="Shadowbox.close()"></a><a id="sb-nav-next" title="{next}" onclick="Shadowbox.next()"></a><a id="sb-nav-play" title="{play}" onclick="Shadowbox.play()"></a><a id="sb-nav-pause" title="{pause}" onclick="Shadowbox.pause()"></a><a id="sb-nav-previous" title="{previous}" onclick="Shadowbox.previous()"></a></div><div style="clear:both"></div></div></div></div></div>',options:{animSequence:"sync",autoDimensions:false,counterLimit:10,counterType:"default",displayCounter:true,displayNav:true,fadeDuration:0.35,initialHeight:160,initialWidth:320,modal:false,overlayColor:"#000",overlayOpacity:0.8,resizeDuration:0.35,showOverlay:true,troubleElements:["iframe","select","object","embed","canvas"]},init:function(){var s=o.markup.replace(/\{(\w+)\}/g,function(w,x){return g.lang[x]});g.lib.append(document.body,s);if(g.client.isIE6){f.get("sb-body").style.zoom=1;var u,r,t=/url\("(.*\.png)"\)/;f.each(m,function(w){u=f.get(w);if(u){r=g.lib.getStyle(u,"backgroundImage").match(t);if(r){u.style.backgroundImage="none";u.style.filter="progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src="+r[1]+",sizingMethod=scale);"}}})}var v;g.lib.addEvent(window,"resize",function(){if(v){clearTimeout(v);v=null}if(g.isActive()){v=setTimeout(function(){o.onWindowResize();var w=g.content;if(w&&w.onWindowResize){w.onWindowResize()}},50)}})},bodyEl:function(){return f.get("sb-body-inner")},onOpen:function(u,r){e(false);var t=g.options.autoDimensions&&"height" in u?u.height:g.options.initialHeight,s=g.options.autoDimensions&&"width" in u?u.width:g.options.initialWidth;f.get("sb-container").style.display="block";var v=p(t,s);d(v.inner_h,v.top,false);h(v.width,v.left,false);i(r)},onLoad:function(s,t,r){k(true);j(t,function(){if(!s){return}if(!t){f.get("sb-wrapper").style.display=""}r()})},onReady:function(r){var t=g.content;if(!t){return}var s=p(t.height,t.width,t.resizable);o.resizeContent(s.inner_h,s.width,s.top,s.left,true,function(){l(r)})},onFinish:function(r){k(false,r)},onClose:function(){i();e(true)},onPlay:function(){c("play",false);c("pause",true)},onPause:function(){c("pause",false);c("play",true)},onWindowResize:function(){var t=g.content;if(!t){return}var s=p(t.height,t.width,t.resizable);h(s.width,s.left,false);d(s.inner_h,s.top,false);var r=f.get(g.contentId());if(r){if(t.resizable&&g.options.handleOversize=="resize"){r.height=s.resize_h;r.width=s.resize_w}}},applyResize:function() {o.onWindowResize()},resizeContent:function(s,t,w,v,u,r){var y=g.content;if(!y){return}var x=p(y.height,y.width,y.resizable);switch(g.options.animSequence){case"hw":d(x.inner_h,x.top,u,function(){h(x.width,x.left,u,r)});break;case"wh":h(x.width,x.left,u,function(){d(x.inner_h,x.top,u,r)});break;default:h(x.width,x.left,u);d(x.inner_h,x.top,u,r)}}};function n(){f.get("sb-container").style.top=document.documentElement.scrollTop+"px"}function e(r){if(r){f.each(b,function(s){s[0].style.visibility=s[1]||""})}else{b=[];f.each(g.options.troubleElements,function(s){f.each(document.getElementsByTagName(s),function(t){b.push([t,t.style.visibility]);t.style.visibility="hidden"})})}}function i(r){var s=f.get("sb-overlay"),t=f.get("sb-container"),v=f.get("sb-wrapper");if(r){if(g.client.isIE6){n();g.lib.addEvent(window,"scroll",n)}if(g.options.showOverlay){q=true;s.style.backgroundColor=g.options.overlayColor;f.setOpacity(s,0);if(!g.options.modal){g.lib.addEvent(s,"click",g.close)}v.style.display="none"}t.style.visibility="visible";if(q){var u=parseFloat(g.options.overlayOpacity);f.animate(s,"opacity",u,g.options.fadeDuration,r)}else{r()}}else{if(g.client.isIE6){g.lib.removeEvent(window,"scroll",n)}g.lib.removeEvent(s,"click",g.close);if(q){v.style.display="none";f.animate(s,"opacity",0,g.options.fadeDuration,function(){t.style.display="";v.style.display="";f.clearOpacity(s)})}else{t.style.visibility="hidden"}}}function c(t,r){var s=f.get("sb-nav-"+t);if(s){s.style.display=r?"":"none"}}function k(s,r){var u=f.get("sb-loading"),w=g.getCurrent().player,v=(w=="img"||w=="html");if(s){function t(){f.clearOpacity(u);if(r){r()}}f.setOpacity(u,0);u.style.display="";if(v){f.animate(u,"opacity",1,g.options.fadeDuration,t)}else{t()}}else{function t(){u.style.display="none";f.clearOpacity(u);if(r){r()}}if(v){f.animate(u,"opacity",0,g.options.fadeDuration,t)}else{t()}}}function a(u){var z=g.getCurrent();f.get("sb-title-inner").innerHTML=z.title||"";var C,t,x,D,s;if(g.options.displayNav){C=true;var B=g.gallery.length;if(B>1){if(g.options.continuous){t=s=true}else{t=(B-1)>g.current;s=g.current>0}}if(g.options.slideshowDelay>0&&g.hasNext()){D=!g.isPaused();x=!D}}else{C=t=x=D=s=false}c("close",C);c("next",t);c("play",x);c("pause",D);c("previous",s);var r="";if(g.options.displayCounter&&g.gallery.length>1){var B=g.gallery.length;if(g.options.counterType=="skip"){var y=0,w=B,v=parseInt(g.options.counterLimit)||0;if(v<B&&v>2){var A=Math.floor(v/2);y=g.current-A;if(y<0){y+=B}w=g.current+(v-A);if(w>B){w-=B}}while(y!=w){if(y==B){y=0}r+='<a onclick="Shadowbox.change('+y+');"';if(y==g.current){r+=' class="sb-counter-current"'}r+=">"+(y++)+"</a>"}}else{var r=(g.current+1)+" "+g.lang.of+" "+B}}f.get("sb-counter").innerHTML=r;u()}function j(u,s){var y=f.get("sb-wrapper"),B=f.get("sb-title"),v=f.get("sb-info"),r=f.get("sb-title-inner"),z=f.get("sb-info-inner"),A=parseInt(g.lib.getStyle(r,"height"))||0,x=parseInt(g.lib.getStyle(z,"height"))||0;var w=function(){r.style.visibility=z.style.visibility="hidden";a(s)};if(u){f.animate(B,"height",0,0.35);f.animate(v,"height",0,0.35);f.animate(y,"paddingTop",A,0.35);f.animate(y,"paddingBottom",x,0.35,w)}else{B.style.height=v.style.height="0px";y.style.paddingTop=A+"px";y.style.paddingBottom=x+"px";w()}}function l(u){var s=f.get("sb-wrapper"),w=f.get("sb-title"),v=f.get("sb-info"),z=f.get("sb-title-inner"),y=f.get("sb-info-inner"),x=parseInt(g.lib.getStyle(z,"height"))||0,r=parseInt(g.lib.getStyle(y,"height"))||0;z.style.visibility=y.style.visibility="";if(z.innerHTML!=""){f.animate(w,"height",x,0.35);f.animate(s,"paddingTop",0,0.35)}f.animate(v,"height",r,0.35);f.animate(s,"paddingBottom",0,0.35,u)}function d(u,z,y,r){var A=f.get("sb-body"),x=f.get("sb-wrapper"),w=parseInt(u),v=parseInt(z);if(y){f.animate(A,"height",w,g.options.resizeDuration);f.animate(x,"top",v,g.options.resizeDuration,r)}else{A.style.height=w+"px";x.style.top=v+"px";if(r){r()}}}function h(x,z,y,r){var v=f.get("sb-wrapper"),u=parseInt(x),t=parseInt(z);if(y){f.animate(v,"width",u,g.options.resizeDuration);f.animate(v,"left",t,g.options.resizeDuration,r)}else{v.style.width=u+"px";v.style.left=t+"px";if(r){r()}}}function p(r,u,t){var s=f.get("sb-body-inner");sw=f.get("sb-wrapper"),so=f.get("sb-overlay"),tb=sw.offsetHeight-s.offsetHeight,lr=sw.offsetWidth-s.offsetWidth,max_h=so.offsetHeight,max_w=so.offsetWidth;g.setDimensions(r,u,max_h,max_w,tb,lr,t);return g.dimensions}g.skin=o})();
if(typeof Shadowbox=="undefined"){throw"Unable to load Shadowbox language file, Shadowbox not found."}Shadowbox.lang={code:"fr",of:"de",loading:"chargement",cancel:"Annuler",next:"Suivant",previous:"Pr&#233;c&#233;dent",play:"Lire",pause:"Pause",close:"Fermer",errors:{single:'Vous devez installer le plugin <a href="{0}">{1}</a> pour afficher ce contenu.',shared:'Vous devez installer les plugins <a href="{0}">{1}</a> et <a href="{2}">{3}</a> pour afficher ce contenu.',either:'Vous devez installer le plugin <a href="{0}">{1}</a> ou <a href="{2}">{3}</a> pour afficher ce contenu.'}};
(function(h){var e=h.util,i,k,j="sb-drag-layer",d;function b(){i={x:0,y:0,start_x:null,start_y:null}}function c(m,o,l){if(m){b();var n=["position:absolute","height:"+o+"px","width:"+l+"px","cursor:"+(h.client.isGecko?"-moz-grab":"move"),"background-color:"+(h.client.isIE?"#fff;filter:alpha(opacity=0)":"transparent")].join(";");h.lib.append(h.skin.bodyEl(),'<div id="'+j+'" style="'+n+'"></div>');h.lib.addEvent(e.get(j),"mousedown",g)}else{var p=e.get(j);if(p){h.lib.removeEvent(p,"mousedown",g);h.lib.remove(p)}k=null}}function g(m){h.lib.preventDefault(m);var l=h.lib.getPageXY(m);i.start_x=l[0];i.start_y=l[1];k=e.get(h.contentId());h.lib.addEvent(document,"mousemove",f);h.lib.addEvent(document,"mouseup",a);if(h.client.isGecko){e.get(j).style.cursor="-moz-grabbing"}}function a(){h.lib.removeEvent(document,"mousemove",f);h.lib.removeEvent(document,"mouseup",a);if(h.client.isGecko){e.get(j).style.cursor="-moz-grab"}}function f(o){var q=h.content,p=h.dimensions,n=h.lib.getPageXY(o);var m=n[0]-i.start_x;i.start_x+=m;i.x=Math.max(Math.min(0,i.x+m),p.inner_w-q.width);k.style.left=i.x+"px";var l=n[1]-i.start_y;i.start_y+=l;i.y=Math.max(Math.min(0,i.y+l),p.inner_h-q.height);k.style.top=i.y+"px"}h.img=function(m){this.obj=m;this.resizable=true;this.ready=false;var l=this;d=new Image();d.onload=function(){l.height=m.height?parseInt(m.height,10):d.height;l.width=m.width?parseInt(m.width,10):d.width;l.ready=true;d.onload="";d=null};d.src=m.content};h.img.prototype={append:function(l,o,n){this.id=o;var m=document.createElement("img");m.id=o;m.src=this.obj.content;m.style.position="absolute";m.setAttribute("height",n.resize_h);m.setAttribute("width",n.resize_w);l.appendChild(m)},remove:function(){var l=e.get(this.id);if(l){h.lib.remove(l)}c(false);if(d){d.onload="";d=null}},onLoad:function(){var l=h.dimensions;if(l.oversized&&h.options.handleOversize=="drag"){c(true,l.resize_h,l.resize_w)}},onWindowResize:function(){if(k){var p=h.content,o=h.dimensions,n=parseInt(h.lib.getStyle(k,"top")),m=parseInt(h.lib.getStyle(k,"left"));if(n+p.height<o.inner_h){k.style.top=o.inner_h-p.height+"px"}if(m+p.width<o.inner_w){k.style.left=o.inner_w-p.width+"px"}}}}})(Shadowbox);
(function(a){a.html=function(b){this.obj=b;this.height=b.height?parseInt(b.height,10):300;this.width=b.width?parseInt(b.width,10):500};a.html.prototype={append:function(b,e,c){this.id=e;var d=document.createElement("div");d.id=e;d.className="html";d.innerHTML=this.obj.content;b.appendChild(d)},remove:function(){var b=document.getElementById(this.id);if(b){a.lib.remove(b)}}}})(Shadowbox);
(function(a){a.iframe=function(c){this.obj=c;var b=document.getElementById("sb-overlay");this.height=c.height?parseInt(c.height,10):b.offsetHeight;this.width=c.width?parseInt(c.width,10):b.offsetWidth};a.iframe.prototype={append:function(b,e,d){this.id=e;var c='<iframe id="'+e+'" name="'+e+'" height="100%" width="100%" frameborder="0" marginwidth="0" marginheight="0" scrolling="auto"';if(a.client.isIE){c+=' allowtransparency="true"';if(a.client.isIE6){c+=" src=\"javascript:false;document.write('');\""}}c+="></iframe>";b.innerHTML=c},remove:function(){var b=document.getElementById(this.id);if(b){a.lib.remove(b);if(a.client.isGecko){delete window.frames[this.id]}}},onLoad:function(){var b=a.client.isIE?document.getElementById(this.id).contentWindow:window.frames[this.id];b.location.href=this.obj.content}}})(Shadowbox);
(function(a){var b=16;a.qt=function(c){this.obj=c;this.height=c.height?parseInt(c.height,10):300;if(a.options.showMovieControls==true){this.height+=b}this.width=c.width?parseInt(c.width,10):300};a.qt.prototype={append:function(l,e,n){this.id=e;var f=a.options,g=String(f.autoplayMovies),o=String(f.showMovieControls);var k="<object",i={id:e,name:e,height:this.height,width:this.width,kioskmode:"true"};if(a.client.isIE){i.classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";i.codebase="http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0"}else{i.type="video/quicktime";i.data=this.obj.content}for(var h in i){k+=" "+h+'="'+i[h]+'"'}k+=">";var j={src:this.obj.content,scale:"aspect",controller:o,autoplay:g};for(var c in j){k+='<param name="'+c+'" value="'+j[c]+'">'}k+="</object>";l.innerHTML=k},remove:function(){var f=this.id;try{document[f].Stop()}catch(d){}var c=document.getElementById(f);if(c){a.lib.remove(c)}}}})(Shadowbox);
(function(a){var b=(a.client.isIE?70:45);a.wmp=function(c){this.obj=c;this.height=c.height?parseInt(c.height,10):300;if(a.options.showMovieControls){this.height+=b}this.width=c.width?parseInt(c.width,10):300};a.wmp.prototype={append:function(c,j,i){this.id=j;var e=a.options,f=e.autoplayMovies?1:0;var d='<object id="'+j+'" name="'+j+'" height="'+this.height+'" width="'+this.width+'"',h={autostart:e.autoplayMovies?1:0};if(a.client.isIE){d+=' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"';h.url=this.obj.content;h.uimode=e.showMovieControls?"full":"none"}else{d+=' type="video/x-ms-wmv"';d+=' data="'+this.obj.content+'"';h.showcontrols=e.showMovieControls?1:0}d+=">";for(var g in h){d+='<param name="'+g+'" value="'+h[g]+'">'}d+="</object>";c.innerHTML=d},remove:function(){var f=this.id;if(a.client.isIE){try{window[f].controls.stop();window[f].URL="non-existent.wmv";window[f]=function(){}}catch(d){}}var c=document.getElementById(f);if(c){setTimeout(function(){a.lib.remove(c)},10)}}}})(Shadowbox);
(function(b){var a=b.util;b.swf=function(c){this.obj=c;this.resizable=true;this.height=c.height?parseInt(c.height,10):300;this.width=c.width?parseInt(c.width,10):300};b.swf.prototype={append:function(k,d,m){this.id=d;var i=document.createElement("div");i.id=d;k.appendChild(i);var j=m.resize_h,n=m.resize_w,e=this.obj.content,l=b.options.flashVersion,c=b.path+"libraries/swfobject/expressInstall.swf",f=b.options.flashVars,g=b.options.flashParams;swfobject.embedSWF(e,d,n,j,l,c,f,g)},remove:function(){swfobject.expressInstallCallback();swfobject.removeSWF(this.id)}}})(Shadowbox);
(function(b){var a=b.util,c=20;b.flv=function(d){this.obj=d;this.resizable=true;this.height=d.height?parseInt(d.height,10):300;if(b.options.showMovieControls==true){this.height+=c}this.width=d.width?parseInt(d.width,10):300};b.flv.prototype={append:function(l,e,n){this.id=e;var j=document.createElement("div");j.id=e;l.appendChild(j);var k=n.resize_h,o=n.resize_w,f=b.path+"libraries/mediaplayer/player.swf",m=b.options.flashVersion,d=b.path+"libraries/swfobject/expressInstall.swf",g=a.apply({file:this.obj.content,height:k,width:o,autostart:(b.options.autoplayMovies?"true":"false"),controlbar:(b.options.showMovieControls?"bottom":"none"),backcolor:"0x000000",frontcolor:"0xCCCCCC",lightcolor:"0x557722"},b.options.flashVars),i=b.options.flashParams;swfobject.embedSWF(f,e,o,k,m,d,g,i)},remove:function(){swfobject.expressInstallCallback();swfobject.removeSWF(this.id)}}})(Shadowbox);
if(typeof Prototype=="undefined"){throw"Unable to load Shadowbox adapter, Prototype not found"}if(typeof Shadowbox=="undefined"){throw"Unable to load Shadowbox adapter, Shadowbox not found"}Shadowbox.lib={getStyle:function(b,a){return Element.getStyle(b,a)},remove:function(a){Element.remove(a)},getTarget:function(a){return Event.element(a)},getPageXY:function(b){var a=Event.pointer(b);return[a.x,a.y]},preventDefault:function(a){Event.stop(a)},keyCode:function(a){return a.keyCode},addEvent:function(c,a,b){Event.observe(c,a,b)},removeEvent:function(c,a,b){Event.stopObserving(c,a,b)},append:function(b,a){Element.insert(b,a)}};document.observe("dom:loaded",Shadowbox.load);
/*
 * Sizzle CSS Selector Engine - v1.0
 *  Copyright 2009, The Dojo Foundation
 *  Released under the MIT, BSD, and GPL Licenses.
 *  More information: http://sizzlejs.com/
 */
(function(){var p=/((?:\((?:\([^()]+\)|[^()]+)+\)|\[(?:\[[^[\]]*\]|['"][^'"]*['"]|[^[\]'"]+)+\]|\\.|[^ >+~,(\[\\]+)+|[>+~])(\s*,\s*)?/g,i=0,d=Object.prototype.toString,n=false;var b=function(D,t,A,v){A=A||[];var e=t=t||document;if(t.nodeType!==1&&t.nodeType!==9){return[]}if(!D||typeof D!=="string"){return A}var B=[],C,y,G,F,z,s,r=true,w=o(t);p.lastIndex=0;while((C=p.exec(D))!==null){B.push(C[1]);if(C[2]){s=RegExp.rightContext;break}}if(B.length>1&&j.exec(D)){if(B.length===2&&f.relative[B[0]]){y=g(B[0]+B[1],t)}else{y=f.relative[B[0]]?[t]:b(B.shift(),t);while(B.length){D=B.shift();if(f.relative[D]){D+=B.shift()}y=g(D,y)}}}else{if(!v&&B.length>1&&t.nodeType===9&&!w&&f.match.ID.test(B[0])&&!f.match.ID.test(B[B.length-1])){var H=b.find(B.shift(),t,w);t=H.expr?b.filter(H.expr,H.set)[0]:H.set[0]}if(t){var H=v?{expr:B.pop(),set:a(v)}:b.find(B.pop(),B.length===1&&(B[0]==="~"||B[0]==="+")&&t.parentNode?t.parentNode:t,w);y=H.expr?b.filter(H.expr,H.set):H.set;if(B.length>0){G=a(y)}else{r=false}while(B.length){var u=B.pop(),x=u;if(!f.relative[u]){u=""}else{x=B.pop()}if(x==null){x=t}f.relative[u](G,x,w)}}else{G=B=[]}}if(!G){G=y}if(!G){throw"Syntax error, unrecognized expression: "+(u||D)}if(d.call(G)==="[object Array]"){if(!r){A.push.apply(A,G)}else{if(t&&t.nodeType===1){for(var E=0;G[E]!=null;E++){if(G[E]&&(G[E]===true||G[E].nodeType===1&&h(t,G[E]))){A.push(y[E])}}}else{for(var E=0;G[E]!=null;E++){if(G[E]&&G[E].nodeType===1){A.push(y[E])}}}}}else{a(G,A)}if(s){b(s,e,A,v);b.uniqueSort(A)}return A};b.uniqueSort=function(r){if(c){n=false;r.sort(c);if(n){for(var e=1;e<r.length;e++){if(r[e]===r[e-1]){r.splice(e--,1)}}}}};b.matches=function(e,r){return b(e,null,null,r)};b.find=function(x,e,y){var w,u;if(!x){return[]}for(var t=0,s=f.order.length;t<s;t++){var v=f.order[t],u;if((u=f.match[v].exec(x))){var r=RegExp.leftContext;if(r.substr(r.length-1)!=="\\"){u[1]=(u[1]||"").replace(/\\/g,"");w=f.find[v](u,e,y);if(w!=null){x=x.replace(f.match[v],"");break}}}}if(!w){w=e.getElementsByTagName("*")}return{set:w,expr:x}};b.filter=function(A,z,D,t){var s=A,F=[],x=z,v,e,w=z&&z[0]&&o(z[0]);while(A&&z.length){for(var y in f.filter){if((v=f.match[y].exec(A))!=null){var r=f.filter[y],E,C;e=false;if(x==F){F=[]}if(f.preFilter[y]){v=f.preFilter[y](v,x,D,F,t,w);if(!v){e=E=true}else{if(v===true){continue}}}if(v){for(var u=0;(C=x[u])!=null;u++){if(C){E=r(C,v,u,x);var B=t^!!E;if(D&&E!=null){if(B){e=true}else{x[u]=false}}else{if(B){F.push(C);e=true}}}}}if(E!==undefined){if(!D){x=F}A=A.replace(f.match[y],"");if(!e){return[]}break}}}if(A==s){if(e==null){throw"Syntax error, unrecognized expression: "+A}else{break}}s=A}return x};var f=b.selectors={order:["ID","NAME","TAG"],match:{ID:/#((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,CLASS:/\.((?:[\w\u00c0-\uFFFF_-]|\\.)+)/,NAME:/\[name=['"]*((?:[\w\u00c0-\uFFFF_-]|\\.)+)['"]*\]/,ATTR:/\[\s*((?:[\w\u00c0-\uFFFF_-]|\\.)+)\s*(?:(\S?=)\s*(['"]*)(.*?)\3|)\s*\]/,TAG:/^((?:[\w\u00c0-\uFFFF\*_-]|\\.)+)/,CHILD:/:(only|nth|last|first)-child(?:\((even|odd|[\dn+-]*)\))?/,POS:/:(nth|eq|gt|lt|first|last|even|odd)(?:\((\d*)\))?(?=[^-]|$)/,PSEUDO:/:((?:[\w\u00c0-\uFFFF_-]|\\.)+)(?:\((['"]*)((?:\([^\)]+\)|[^\2\(\)]*)+)\2\))?/},attrMap:{"class":"className","for":"htmlFor"},attrHandle:{href:function(e){return e.getAttribute("href")}},relative:{"+":function(x,e,w){var u=typeof e==="string",y=u&&!/\W/.test(e),v=u&&!y;if(y&&!w){e=e.toUpperCase()}for(var t=0,s=x.length,r;t<s;t++){if((r=x[t])){while((r=r.previousSibling)&&r.nodeType!==1){}x[t]=v||r&&r.nodeName===e?r||false:r===e}}if(v){b.filter(e,x,true)}},">":function(w,r,x){var u=typeof r==="string";if(u&&!/\W/.test(r)){r=x?r:r.toUpperCase();for(var s=0,e=w.length;s<e;s++){var v=w[s];if(v){var t=v.parentNode;w[s]=t.nodeName===r?t:false}}}else{for(var s=0,e=w.length;s<e;s++){var v=w[s];if(v){w[s]=u?v.parentNode:v.parentNode===r}}if(u){b.filter(r,w,true)}}},"":function(t,r,v){var s=i++,e=q;if(!r.match(/\W/)){var u=r=v?r:r.toUpperCase();e=m}e("parentNode",r,s,t,u,v)},"~":function(t,r,v){var s=i++,e=q;if(typeof r==="string"&&!r.match(/\W/)){var u=r=v?r:r.toUpperCase();e=m}e("previousSibling",r,s,t,u,v)}},find:{ID:function(r,s,t){if(typeof s.getElementById!=="undefined"&&!t){var e=s.getElementById(r[1]);return e?[e]:[]}},NAME:function(s,v,w){if(typeof v.getElementsByName!=="undefined"){var r=[],u=v.getElementsByName(s[1]);for(var t=0,e=u.length;t<e;t++){if(u[t].getAttribute("name")===s[1]){r.push(u[t])}}return r.length===0?null:r}},TAG:function(e,r){return r.getElementsByTagName(e[1])}},preFilter:{CLASS:function(t,r,s,e,w,x){t=" "+t[1].replace(/\\/g,"")+" ";if(x){return t}for(var u=0,v;(v=r[u])!=null;u++){if(v){if(w^(v.className&&(" "+v.className+" ").indexOf(t)>=0)){if(!s){e.push(v)}}else{if(s){r[u]=false}}}}return false},ID:function(e){return e[1].replace(/\\/g,"")},TAG:function(r,e){for(var s=0;e[s]===false;s++){}return e[s]&&o(e[s])?r[1]:r[1].toUpperCase()},CHILD:function(e){if(e[1]=="nth"){var r=/(-?)(\d*)n((?:\+|-)?\d*)/.exec(e[2]=="even"&&"2n"||e[2]=="odd"&&"2n+1"||!/\D/.test(e[2])&&"0n+"+e[2]||e[2]);e[2]=(r[1]+(r[2]||1))-0;e[3]=r[3]-0}e[0]=i++;return e},ATTR:function(u,r,s,e,v,w){var t=u[1].replace(/\\/g,"");if(!w&&f.attrMap[t]){u[1]=f.attrMap[t]}if(u[2]==="~="){u[4]=" "+u[4]+" "}return u},PSEUDO:function(u,r,s,e,v){if(u[1]==="not"){if(u[3].match(p).length>1||/^\w/.test(u[3])){u[3]=b(u[3],null,null,r)}else{var t=b.filter(u[3],r,s,true^v);if(!s){e.push.apply(e,t)}return false}}else{if(f.match.POS.test(u[0])||f.match.CHILD.test(u[0])){return true}}return u},POS:function(e){e.unshift(true);return e}},filters:{enabled:function(e){return e.disabled===false&&e.type!=="hidden"},disabled:function(e){return e.disabled===true},checked:function(e){return e.checked===true},selected:function(e){e.parentNode.selectedIndex;return e.selected===true},parent:function(e){return !!e.firstChild},empty:function(e){return !e.firstChild},has:function(s,r,e){return !!b(e[3],s).length},header:function(e){return/h\d/i.test(e.nodeName)},text:function(e){return"text"===e.type},radio:function(e){return"radio"===e.type},checkbox:function(e){return"checkbox"===e.type},file:function(e){return"file"===e.type},password:function(e){return"password"===e.type},submit:function(e){return"submit"===e.type},image:function(e){return"image"===e.type},reset:function(e){return"reset"===e.type},button:function(e){return"button"===e.type||e.nodeName.toUpperCase()==="BUTTON"},input:function(e){return/input|select|textarea|button/i.test(e.nodeName)}},setFilters:{first:function(r,e){return e===0},last:function(s,r,e,t){return r===t.length-1},even:function(r,e){return e%2===0},odd:function(r,e){return e%2===1},lt:function(s,r,e){return r<e[3]-0},gt:function(s,r,e){return r>e[3]-0},nth:function(s,r,e){return e[3]-0==r},eq:function(s,r,e){return e[3]-0==r}},filter:{PSEUDO:function(w,s,t,x){var r=s[1],u=f.filters[r];if(u){return u(w,t,s,x)}else{if(r==="contains"){return(w.textContent||w.innerText||"").indexOf(s[3])>=0}else{if(r==="not"){var v=s[3];for(var t=0,e=v.length;t<e;t++){if(v[t]===w){return false}}return true}}}},CHILD:function(e,t){var w=t[1],r=e;switch(w){case"only":case"first":while(r=r.previousSibling){if(r.nodeType===1){return false}}if(w=="first"){return true}r=e;case"last":while(r=r.nextSibling){if(r.nodeType===1){return false}}return true;case"nth":var s=t[2],z=t[3];if(s==1&&z==0){return true}var v=t[0],y=e.parentNode;if(y&&(y.sizcache!==v||!e.nodeIndex)){var u=0;for(r=y.firstChild;r;r=r.nextSibling){if(r.nodeType===1){r.nodeIndex=++u}}y.sizcache=v}var x=e.nodeIndex-z;if(s==0){return x==0}else{return(x%s==0&&x/s>=0)}}},ID:function(r,e){return r.nodeType===1&&r.getAttribute("id")===e},TAG:function(r,e){return(e==="*"&&r.nodeType===1)||r.nodeName===e},CLASS:function(r,e){return(" "+(r.className||r.getAttribute("class"))+" ").indexOf(e)>-1},ATTR:function(v,t){var s=t[1],e=f.attrHandle[s]?f.attrHandle[s](v):v[s]!=null?v[s]:v.getAttribute(s),w=e+"",u=t[2],r=t[4];return e==null?u==="!=":u==="="?w===r:u==="*="?w.indexOf(r)>=0:u==="~="?(" "+w+" ").indexOf(r)>=0:!r?w&&e!==false:u==="!="?w!=r:u==="^="?w.indexOf(r)===0:u==="$="?w.substr(w.length-r.length)===r:u==="|="?w===r||w.substr(0,r.length+1)===r+"-":false},POS:function(u,r,s,v){var e=r[2],t=f.setFilters[e];if(t){return t(u,s,r,v)}}}};var j=f.match.POS;for(var l in f.match){f.match[l]=new RegExp(f.match[l].source+/(?![^\[]*\])(?![^\(]*\))/.source)}var a=function(r,e){r=Array.prototype.slice.call(r);if(e){e.push.apply(e,r);return e}return r};try{Array.prototype.slice.call(document.documentElement.childNodes)}catch(k){a=function(u,t){var r=t||[];if(d.call(u)==="[object Array]"){Array.prototype.push.apply(r,u)}else{if(typeof u.length==="number"){for(var s=0,e=u.length;s<e;s++){r.push(u[s])}}else{for(var s=0;u[s];s++){r.push(u[s])}}}return r}}var c;if(document.documentElement.compareDocumentPosition){c=function(r,e){var s=r.compareDocumentPosition(e)&4?-1:r===e?0:1;if(s===0){n=true}return s}}else{if("sourceIndex" in document.documentElement){c=function(r,e){var s=r.sourceIndex-e.sourceIndex;if(s===0){n=true}return s}}else{if(document.createRange){c=function(t,r){var s=t.ownerDocument.createRange(),e=r.ownerDocument.createRange();s.selectNode(t);s.collapse(true);e.selectNode(r);e.collapse(true);var u=s.compareBoundaryPoints(Range.START_TO_END,e);if(u===0){n=true}return u}}}}(function(){var r=document.createElement("div"),s="script"+(new Date).getTime();r.innerHTML="<a name='"+s+"'/>";var e=document.documentElement;e.insertBefore(r,e.firstChild);if(!!document.getElementById(s)){f.find.ID=function(u,v,w){if(typeof v.getElementById!=="undefined"&&!w){var t=v.getElementById(u[1]);return t?t.id===u[1]||typeof t.getAttributeNode!=="undefined"&&t.getAttributeNode("id").nodeValue===u[1]?[t]:undefined:[]}};f.filter.ID=function(v,t){var u=typeof v.getAttributeNode!=="undefined"&&v.getAttributeNode("id");return v.nodeType===1&&u&&u.nodeValue===t}}e.removeChild(r)})();(function(){var e=document.createElement("div");e.appendChild(document.createComment(""));if(e.getElementsByTagName("*").length>0){f.find.TAG=function(r,v){var u=v.getElementsByTagName(r[1]);if(r[1]==="*"){var t=[];for(var s=0;u[s];s++){if(u[s].nodeType===1){t.push(u[s])}}u=t}return u}}e.innerHTML="<a href='#'></a>";if(e.firstChild&&typeof e.firstChild.getAttribute!=="undefined"&&e.firstChild.getAttribute("href")!=="#"){f.attrHandle.href=function(r){return r.getAttribute("href",2)}}})();if(document.querySelectorAll){(function(){var e=b,s=document.createElement("div");s.innerHTML="<p class='TEST'></p>";if(s.querySelectorAll&&s.querySelectorAll(".TEST").length===0){return}b=function(w,v,t,u){v=v||document;if(!u&&v.nodeType===9&&!o(v)){try{return a(v.querySelectorAll(w),t)}catch(x){}}return e(w,v,t,u)};for(var r in e){b[r]=e[r]}})()}if(document.getElementsByClassName&&document.documentElement.getElementsByClassName){(function(){var e=document.createElement("div");e.innerHTML="<div class='test e'></div><div class='test'></div>";if(e.getElementsByClassName("e").length===0){return}e.lastChild.className="e";if(e.getElementsByClassName("e").length===1){return}f.order.splice(1,0,"CLASS");f.find.CLASS=function(r,s,t){if(typeof s.getElementsByClassName!=="undefined"&&!t){return s.getElementsByClassName(r[1])}}})()}function m(r,w,v,A,x,z){var y=r=="previousSibling"&&!z;for(var t=0,s=A.length;t<s;t++){var e=A[t];if(e){if(y&&e.nodeType===1){e.sizcache=v;e.sizset=t}e=e[r];var u=false;while(e){if(e.sizcache===v){u=A[e.sizset];break}if(e.nodeType===1&&!z){e.sizcache=v;e.sizset=t}if(e.nodeName===w){u=e;break}e=e[r]}A[t]=u}}}function q(r,w,v,A,x,z){var y=r=="previousSibling"&&!z;for(var t=0,s=A.length;t<s;t++){var e=A[t];if(e){if(y&&e.nodeType===1){e.sizcache=v;e.sizset=t}e=e[r];var u=false;while(e){if(e.sizcache===v){u=A[e.sizset];break}if(e.nodeType===1){if(!z){e.sizcache=v;e.sizset=t}if(typeof w!=="string"){if(e===w){u=true;break}}else{if(b.filter(w,[e]).length>0){u=e;break}}}e=e[r]}A[t]=u}}}var h=document.compareDocumentPosition?function(r,e){return r.compareDocumentPosition(e)&16}:function(r,e){return r!==e&&(r.contains?r.contains(e):true)};var o=function(e){return e.nodeType===9&&e.documentElement.nodeName!=="HTML"||!!e.ownerDocument&&e.ownerDocument.documentElement.nodeName!=="HTML"};var g=function(e,x){var t=[],u="",v,s=x.nodeType?[x]:x;while((v=f.match.PSEUDO.exec(e))){u+=v[0];e=e.replace(f.match.PSEUDO,"")}e=f.relative[e]?e+"*":e;for(var w=0,r=s.length;w<r;w++){b(e,s[w],t)}return b.filter(u,t)};window.Sizzle=b})();
/* For the Imagegallery */
var iPicId = 0;
var iPageId = 1;

var oGSAsuggestionTimer;

var IS_HTTPS = false;
var SERVER_URL = 'http://www.swisspost.com';
var SECURE_SERVER_URL = 'https://www.swisspost.com';

if (document.location.href.indexOf("https://") > -1)
{
	IS_HTTPS = true;
	SERVER_URL = SECURE_SERVER_URL;
}

var CURRENT_LANGUAGE = '';
if('14' != '14') {
	CURRENT_LANGUAGE = 'fr';
}
var URL_MAGIC = '/france';
if (URL_MAGIC == "/") {
	URL_MAGIC = "";
}

var DEFAULTPAGE = 'fr-home';

var oDefaultValues = new Object();

var Browsers = {
  Browser: {
    IE:     !!(window.attachEvent &&
      navigator.userAgent.indexOf('Opera') === -1),
    Opera:  navigator.userAgent.indexOf('Opera') > -1,
    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,
    SelectorsAPI: !!document.querySelector,
    ElementExtensions: !!window.HTMLElement,
    SpecificElementExtensions: 
      document.createElement('div')['__proto__'] &&
      document.createElement('div')['__proto__'] !== 
        document.createElement('form')['__proto__']
  }
}

Browsers.Browser.IE6 = Browsers.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 6;
Browsers.Browser.IE7 = Browsers.Browser.IE && parseInt(navigator.userAgent.substring(navigator.userAgent.indexOf("MSIE")+5)) == 7;
Browsers.Browser.IE8 = Browsers.Browser.IE && !Browsers.Browser.IE6 && !Browsers.Browser.IE7;

var Utf8 = {
 
	encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";
 
		for (var n = 0; n < string.length; n++) {
 
			var c = string.charCodeAt(n);
 
			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}
 
		}
 
		return utftext;
	},
 
	decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;
 
		while ( i < utftext.length ) {
 
			c = utftext.charCodeAt(i);
 
			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}
 
		}
 
		return string;
	}
 
}

var Rules = { 
  	rules: "1.0",
	
	'a.popup:click': function(element, event) {
		var oProperties = getLinkProperties(element);		
		var sHref = oProperties.href;
		var sClasses = oProperties.cssClasses;
		var iHeight = 500;
		var iWidth = 680;
		var asParam;

		if (sClasses) {
			var oRegExp = RegExp(/dim@[0-9]*@[0-9]*@(?:yes|no)@(?:yes|no)@(?:yes|no)/i);
			var sParam = sClasses.match(oRegExp);
		
			if(sParam){
				asParam = sParam.toString().split("@");
				myLightWindow.activateWindow({
					href: sHref, 
					title: '',
					width: asParam[1],
					height: asParam[2],
					iframeEmbed : true
				});
				//window.open(sHref, '_blank', 'toolbar=no, location=yes, status=' + asParam[4] + ', menubar=no, personalbar=no, scrollbars=' + asParam[5] + ', width=' + asParam[1] + ', height=' + asParam[2] + ', resizable=yes, screenx=50, left=50, screenY=50, top=50');
				
			}
			else{
				//window.open(sHref, "_blank", 'height=' + iHeight + ',width=' + iWidth +', location=yes, toolbar=no, status=no, resizable=yes, scrollbars=yes');
			}
		}
		
		Event.stop(event);
	},
	
	'a.windowpopup:click': function(element, event) {
		var oProperties = getLinkProperties(element);		
		var sHref = oProperties.href;
		var sClasses = oProperties.cssClasses;
		var iHeight = 500;
		var iWidth = 680;
		var sParam;
		var asParam;
		var oRegExp;
		
		if(!sClasses){
			sClasses = element ? element.parentNode.className : "";
		}
				
		if (sClasses) {
			oRegExp = RegExp(/dim@[0-9]*@[0-9]*@(?:yes|no)@(?:yes|no)@(?:yes|no)/i);
			var sParam = sClasses.match(oRegExp);
			
			if (sParam)
			{
				asParam = sParam.toString().split("@");
				//alert("toolbar " + asParam[3]);
				//alert("statusbar " + asParam[4]);
				//alert("scrollbar " + asParam[5]);
				//alert("width " + asParam[1]);
				//alert("height " + asParam[2]);
				
				window.open(sHref, '_blank', 'toolbar=no, location=yes, status=' + asParam[4] + ', menubar=no, personalbar=no, scrollbars=' + asParam[5] + ', width=' + asParam[1] + ', height=' + asParam[2] + ', resizable=yes, screenx=50, left=50, screenY=50, top=50');			
			}
			else{
				window.open(sHref, "_blank", 'height=' + iHeight + ',width=' + iWidth +', location=yes, toolbar=no, status=no, resizable=yes, scrollbars=yes');	
			}
		}
		Event.stop(event);
	},
	
	
	'a.printpopup:click': function(element, event) {
		var sUrl = getHref(element);
		printPage(sUrl);
		Event.stop(event);
	},
	
	'body.printWindow:loaded':function(element, event) {
		window.print();
		Event.stop(event);
	},
	
	'a.back:click': function(element, event) {
		history.back();		
		Event.stop(event);
	},

	'a.delete:click': function(element, event) {
		if (!confirmDelete()) {
			Event.stop(event);
		}
	},
		
	'.hideonloaded:loaded' : function(element, event) {
		element.hide();
	},
	
	'a.showhidehreftarget:click' : function(element, event) {
		var oMyElement = element;

		if(element.tagName.toLowerCase() == 'img' && element.parentNode.tagName.toLowerCase() == 'a'){
			oMyElement = element.parentNode;
		}

		var href = oMyElement.getAttribute('href');
		var iContentId = href.match(/#(\w.+)/)[1];
		var oContentElement = $(iContentId);
		if(oContentElement.style.display == 'none') {
			oContentElement.style.display = 'block';
		} else {
			oContentElement.style.display = 'none';
		}
		Event.stop(event);
	},
	
	'input.replace-value:focus' : function(element, event) {

		if (!oDefaultValues[element.id]) {
		
			oDefaultValues[element.id] = element.value;
		}
		if (element.value == oDefaultValues[element.id]) {
		
			element.value = "";
		}
	},

	'input.replace-value:blur' : function(element, event) {

		if (element.value == "") {
		
			element.value = oDefaultValues[element.id];
		}
	},	

	'a.saveWebcodeAdmin:click' : function(element, event) {
		var iId = getLinkProperties(element).rel;
		var sWebcode = $('webcode-' + iId).value;
		var sPage = $('page-' + iId).value;
		var sCluster = $('cluster-' + iId).value;
		
		if (sWebcode != "" && /^[0-9]+(,[0-9]+)*$/i.test(sWebcode) == false) {
			alert(asciiToText("Bitte geben Sie ein oder mehrere Zahlen (Kommasepariert) ein."));
		}
		else {
			
			$('save-' + iId).src = 'ajax-loader.gif';
			
			var oAjax = new Ajax.Request(
				getAbsoluteUrl('teaser-ajax-manager'),
				{
					method:		'get', 
					parameters:	"method=saveWebcode&teaser=none&webcode=" + sWebcode + "&page=" + sPage + "&cluster=" + sCluster,
					onSuccess:	function(transport, json) {
						var sResponse = transport.responseText;
						
						if (sResponse != "" && sResponse != "ok") {
							alert(asciiToText("Ces Webcodes sont d&#233;j&#224; r&#233;serv&#233;:\n") + sResponse);
						}
						else if (sResponse == "ok") {
							$('webcode-' + iId).writeAttribute("value", sWebcode);
						}
						else if (sResponse == "nan") {
							alert(asciiToText("Bitte geben Sie ein oder mehrere Zahlen (Kommasepariert) ein."));
						}
						else {
							alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
						}
						
						webcodeChanged(iId);
						
					},
					onFailure:	function(transport, json) {
						alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
						$('save-' + iId).src = 'layout-icon-save.gif';
					}
				}
			);
		}
				
		Event.stop(event);
	},
	
	'a.scheduleShowDetails:click' : function(element, event) {
		new Effect.SlideDown($('schedule_detail'), {duration:0.5, scaleContent: false});
		$('scheduleDetailsLink').removeClassName('scheduleShowDetails');
		$('scheduleDetailsLink').addClassName('scheduleHideDetails');
		$('scheduleDetailsLink').update(asciiToText("Masquer les d&#233;tails"));
		EventSelectors.assign(Rules);
		
		Event.stop(event);
	},
	
	'a.scheduleHideDetails:click' : function(element, event) {
		new Effect.SlideUp($('schedule_detail'), {duration:0.5, scaleContent: false});
		$('scheduleDetailsLink').removeClassName('scheduleHideDetails');
		$('scheduleDetailsLink').addClassName('scheduleShowDetails');
		$('scheduleDetailsLink').update(asciiToText("Afficher les d&#233;tails"));
		EventSelectors.assign(Rules);
		
		Event.stop(event);
	},
		
	'a.linksboxTeaserTitle:click' : function(element, event) {
		var titleDiv = $('teaserLinksBoxTitle_' + element.rel);
		var contentDiv = $('teaserLinksBoxContent_' + element.rel);
				
		if (titleDiv.hasClassName('linksBoxTitleOpened')) {
			titleDiv.removeClassName('linksBoxTitleOpened');
			titleDiv.addClassName('linksBoxTitleClosed');			
			
			new Effect.SlideUp(contentDiv, {duration:0.5});
		}
		else {
			titleDiv.removeClassName('linksBoxTitleClosed');
			titleDiv.addClassName('linksBoxTitleOpened');
									
			new Effect.SlideDown(contentDiv, {duration:0.5});
		}
	
		Event.stop(event);
	},
	
	'a.choose_continent:click' : function(element, event) {
		var oTitle = $(element.id);
		var oList = $("ccdiv" + element.id.substring(3, element.id.length));
					
		if (oTitle.hasClassName('ccListOpened')) {
			oTitle.removeClassName('ccListOpened');
			oTitle.addClassName('ccListClosed');			
			
			new Effect.SlideUp(oList, {duration:0.5});
		}
		else {
			var aOpenLists = $$('a.ccListOpened');
			var oOpenList, oContentDiv;
			
			if (aOpenLists) {
				for (var iCounter=0; iCounter<aOpenLists.length; ++iCounter) {
					oOpenList = aOpenLists[iCounter];
					oOpenList.removeClassName('ccListOpened');
					oOpenList.addClassName('ccListClosed');
					
					oContentDiv = $("ccdiv" + oOpenList.id.substring(3, oOpenList.id.length));
					new Effect.SlideUp(oContentDiv, {duration:0.5});
				}
			}
			
			oTitle.removeClassName('ccListClosed');
			oTitle.addClassName('ccListOpened');
									
			new Effect.SlideDown(oList, {duration:0.5});
		}
	
		Event.stop(event);
	},
	
	'a.galleryPaging:click' : function(element, event) {       
		var tmp = element.rel.split('_');
		var iColsPerPage = tmp[4];
		
		// Set the new page var
		if (tmp[3] == "next") {
			iPageId++;
		}
		else if (tmp[3] == "previous") {
			iPageId--;
		}
		else {
			iPageId = parseInt(tmp[3]);
		}
		
		// Show the loading picture, show every div and set the borders correctly
		
		var aPictures = $$('div.imagegallery_thumbnail');
		
		for (var e=1; e<=aPictures.length; e++) {
			$('pic_' + e).addClassName('thumbnail_loading');
			$('pic_' + e).src = 'imagegallery_load_130_86.gif';
			
			$('div_' + e).removeClassName('border_right');
			$('div_' + e).removeClassName('border_bottom');
			if (e % iColsPerPage == 0 || e == aPictures.length) {
				$('div_' + e).addClassName('border_right');
			}
			
			if ((aPictures.length - iColsPerPage) < e) {
				$('div_' + e).addClassName('border_bottom');
			}
			
			$('div_' + e).show();
		}
		
		var oAjax = new Ajax.Request(
			getAbsoluteUrl('imagegalleryajaxcontroller'),
			{
				method:		'get', 
				parameters:	"methodName=getPictures&gal=" + tmp[1] + "&page=" + iPageId + "&instanceLang=" + CURRENT_LANGUAGE,
				onSuccess:	function(transport, json) {
					if (transport.responseText != "error" && transport.responseText.length > 0) {
						var json  = eval("(" + transport.responseText + ")");
						
						// Update the paging string				
						$('imagegallery_paging').update(json.paging);
									
						var oPic;
						var qDec;
						for (var q=1; q<=json.length; q++) {
							// Set the new picture
							qDec = q-1;
							oPic = $('pic_' + q);
							oPic.src = eval("json.p" + qDec + ".src");
							oPic.title = eval("json.p" + qDec + ".desc");
							
							// Set the borders of the div correctly
							$('div_' + q).removeClassName('border_right');
							$('div_' + q).removeClassName('border_bottom');
							
							if (q % iColsPerPage == 0 || q == json.length) {
								$('div_' + q).addClassName('border_right');
							}
							
							if ((json.length - iColsPerPage) < q) {
								$('div_' + q).addClassName('border_bottom');
							}
							
							// Handle the dimension of the new picture
							var sDim = eval("json.p" + qDec + ".dim");
							$('pic_' + q).removeClassName('thumbnail_loading');
							$('pic_' + q).removeClassName('image_height');
							$('pic_' + q).removeClassName('image_width');
							$('pic_' + q).addClassName(sDim);
						}
						
						// Hide divs if we do not have to fill the whole page
						for (q; q<=aPictures.length; q++) {
							$('div_' + q).hide();
						}
					}
					else {
						imgGalleryShowError();
					}
				},
				onFailure:	function(transport, json) {
					imgGalleryShowError();
				}
			}
		);
		
		Event.stop(event);
	},
	
	'a.galleryOpenPicture:click' : function(element, event) { 
		var tmp = getLinkProperties(element); 		    	
		tmp = tmp.rel.split('_');		
		iPicId = ((iPageId-1) * parseInt(tmp[1])) + parseInt(tmp[2])-1;	
		imgGalleryLoadNewPicture(tmp[0], iPicId);					
		Event.stop(event);
	},
	
	'a.galleryClosePicture:click' : function(element, event) {  
		$('imagegallery_detailpage').setStyle({visibility: 'visible', height: 'auto', position: 'static'});     
		$('imagegalleryPicture').hide();
		Event.stop(event);
	},
	
	'a.imagegallery_previousPicture:click' : function(element, event) {       
		iPicId--;
		imgGalleryLoadNewPicture(element.parentNode.rel, iPicId);
		Event.stop(event);
	},
	
	'a.imagegallery_nextPicture:click' : function(element, event) {       
		iPicId++;
		imgGalleryLoadNewPicture(element.parentNode.rel, iPicId);
		Event.stop(event);
	},
	
	'a.remove_seminar:click' : function(element, event) {
		if (confirm("Etes-vous s&#251;r(e) de vouloir supprimer ce s&#233;minaire?"))
		{
			// check if event element is the link element itself or its inner image
			var bIsInnerClicked = element.nodeName.toLowerCase() != 'a';
			var sLinkUrl = bIsInnerClicked
				? element.parentNode.getAttribute('href')
				: element.getAttribute('href');
			var sToRemove = sLinkUrl.replace(/^[^#]*#/, '');;
			var sOldValue = ',' + $('seminars').value + ',';
			var sNewValue = sOldValue.replace(
				new RegExp("," + sToRemove + ','), ','
			);
			
			//alert(sToRemove + "\n" + $('seminars').value + "\n" + sNewValue);
			
			// remove trailing ,
			sNewValue = sNewValue.replace(/(^,)|(,$)/g, '');
			
			// set new value
			$('seminars').value = sNewValue;
			
			var oTrNode = element.parentNode.parentNode;
			if (bIsInnerClicked){
				oTrNode = oTrNode.parentNode;
			}
			var oTBodyNode = oTrNode.parentNode;
			
			// remove row
			oTrNode.remove();
			
			// no rows left
			if (oTBodyNode.immediateDescendants().length == 0){
				$('no-seminar-advice').show();
				// disable the remove buttons th column
				$$('#selected-seminars-list th.remove-seminar-enabled').each(function(el){
			 		el.removeClassName('remove-seminar-enabled');
			 		el.addClassName('remove-seminar-disabled');
				});
			}
		}
		
		Event.stop(event);
	},
	
	'select#clusterchoice:change' : function(element, event) {
		var asUrls = ["", "", "http://www.poste.ch", "http://www.swisspost.com/germany", "http://www.swisspost.com/austria/en", "http://www.swisspost.com/belgium/fr", "http://www.swisspost.com/denmark/en", "http://www.swisspost.com/spain/en", "http://www.swisspost.us", "http://www.swisspost.com/france", "http://www.swisspost.com/unitedkingdom", "http://www.swisspost.com/hongkong", "http://www.swisspost.com/india", "http://www.swisspost.com/italy", "http://www.swisspost.com/netherlands", "http://www.swisspost.com/singapore", "http://www.swisspost.com/sweden/en"];
		var sUrl = asUrls[parseInt(element.value, 10)]; 
		if (sUrl) {
			window.open(sUrl, "_blank");
		}
	},
	
	'li.ckb_pickpost:click': function(element, event) {
		var oSmsNumberMessage = $('advice-required-smsnumber');
		var oEmailMessage = $('advice-required-email');
		var oCheckBoxMessage = $('advice-validate-one-required-mail');
		var oSmsNumber = $('smsnumber');
		var oEmail = $('email');
		var oSms = $('sms');
		var oMail = $('mail');
		if(element == oSms) {
			if(oSms.checked) {
				if (oCheckBoxMessage && oCheckBoxMessage.visible()) {
					new Effect.Fade(oCheckBoxMessage, {Duration : 1});
				}
				if (!oSmsNumber.hasClassName("required")) {
					oSmsNumber.addClassName("required");
					Validation.validate(oSmsNumber);
					if(oSmsNumber.hasClassName("validation-failed") && oSmsNumberMessage && !oSmsNumberMessage.visible()) {
					 new Effect.Appear(oSmsNumberMessage, { Duration : 1 });
					}
				} 
				if (!oMail.checked && oMail.hasClassName("validate-one-required")) {
					oMail.removeClassName("validate-one-required");
				}
			} else {
				if (oSmsNumber.hasClassName("required")) {
					oSmsNumber.removeClassName("required");
				}
				if (oSmsNumberMessage) {
					new Effect.Fade(oSmsNumberMessage, {Duration : 1});
				}
				
				if (!oMail.checked) {
				
					if (!oMail.hasClassName("validate-one-required")) {
						oMail.addClassName("validate-one-required");
					}
					if (oCheckBoxMessage && !oCheckBoxMessage.visible()) {
						new Effect.Appear(oCheckBoxMessage, {Duration : 1});
					}
					Validation.validate(oMail);
				}
			}
		} else if (element == oMail) {
			if(oMail.checked) {
				if (oCheckBoxMessage && oCheckBoxMessage.visible()) {
					new Effect.Fade(oCheckBoxMessage, {Duration : 1});
				}
				if (!oEmail.hasClassName("required")) {
					oEmail.addClassName("required");
					Validation.validate(oEmail);
					if(oEmail.hasClassName("validation-failed") && oEmailMessage && !oEmailMessage.visible()) {
					 new Effect.Appear(oEmailMessage, { Duration : 1 });
					}
				} 	
				if (oMail.hasClassName("validate-one-required")) {
					oMail.removeClassName("validate-one-required");
				}
			} else {
				if (oEmail.hasClassName("required")) {
					oEmail.removeClassName("required");
				}
				if (oEmailMessage && oEmailMessage.visible()) {
					new Effect.Fade(oEmailMessage, {Duration : 1});
				}
				if (!oSms.checked) {
					if (!oMail.hasClassName("validate-one-required")) {
						oMail.addClassName("validate-one-required");
					}
					Validation.validate(oMail);
					if (oCheckBoxMessage && !oCheckBoxMessage.visible()) {
						new Effect.Appear(oCheckBoxMessage, {Duration : 1});
					}
				}
			}
		}
	},
	
	'a.sitemapTitle span.arrowlink:click' : function(element, event) {
		var contentDiv = element.next('div');
		var titleElement = element;
		if (!contentDiv) {
			contentDiv = element.up().next('div');
			titleElement = element.up();
		}
		if (contentDiv.hasClassName('sitemapOpened')) {
			contentDiv.removeClassName('sitemapOpened');
			titleElement.removeClassName('expanded');
			new Effect.SlideUp(contentDiv, {duration:0.5});
		}
		else {
			titleElement.addClassName('expanded');
			contentDiv.removeClassName('hide');
			contentDiv.addClassName('sitemapOpened'); 
			new Effect.SlideDown(contentDiv, {duration:0.5});
		}
		Event.stop(event);
	},
	
	'select.textOtherCountry:change': function(element, event) {
		var oForm = document.getElementById("spi_transportauftrag");
		var var_testo_finale = "Veuillez joindre le bordereau de d&#233;p&#244;t bien visiblement &#224; vos envois.<br>Merci beaucoup et salutations distingu&#233;es.";		
		var_testo_finale = asciiToText(var_testo_finale.replace(/<br>/g, "\n"));
		oForm.otherBemerkungen.value = var_testo_finale;
		Event.stop(event);
	},
	
	'a.newstab:click' : function(element, event) {       
		var oCurrent = $$('ul.tab-navigation li.current');
		if (oCurrent.length > 0) {
			oCurrent[0].removeClassName('current');
		}
		
		var oParent = element.parentNode;
		if (oParent) {
			$(oParent.id).addClassName('current');
		}
		
		$('news-loading').removeClassName('hidden');
		$('news-entries').addClassName('hidden');
		
		var tmp = element.rel.split('$$');
		var iYear = tmp[0];
		var iConfig = tmp[1];
		var iClusterConfig = tmp[2];
		var sDebug = ($('news-entries').hasClassName('edit'))? '&debug=210': '';
		var sChecksum = tmp[3];
		var sUrl = ($(element.parentNode.parentNode.id).hasClassName('podcasts'))? 'podcasts-ajax-changeyear' : 'news-ajax-changeyear';

		var oAjax = new Ajax.Request(
			getAbsoluteUrl(sUrl),
			{
				method:		'get', 
				parameters:	"year=" + iYear + "&config=" + iConfig + "&cluster=" + iClusterConfig + "&checksum=" + sChecksum + sDebug,
				onSuccess:	function(transport, json) {
					var sResponse = transport.responseText;
					if (sResponse != "error") {
						$('news-archive').update(sResponse);
					}
					else {
						$('news-loading').addClassName('hidden');
						$('news-entries').removeClassName('hidden');
						alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
					}
				},
				onFailure:	function(transport, json) {
					$('news-loading').addClassName('hidden');
					$('news-entries').removeClassName('hidden');
					alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
				}
			}
		);	
		
		Event.stop(event);
	},
	
	'a#newstab-next:click' : function(element, event) {
		var aNext = $('newstab-next').rel.split('$$');
		var aPrevious = $('newstab-previous').rel.split('$$');
		
		var iCurrentYear = parseInt(aNext[0]);
		var iLastYear = parseInt(aNext[1]);
				
		if (iCurrentYear != iLastYear) {
			aNext[0] = iCurrentYear - 1;
			aPrevious[0] = iCurrentYear - 1;
			$('newstab-next').rel = aNext.join('$$');
			$('newstab-previous').rel = aPrevious.join('$$');
			
			new Effect.Move($('news-tab-navigation'), {x:-($('newstab-2009').getWidth()),y:0,duration:0.7, queue: 'end'});
		}
		
		Event.stop(event);
	},
	
	'a#newstab-previous:click' : function(element, event) {
		var aNext = $('newstab-next').rel.split('$$');
		var aPrevious = $('newstab-previous').rel.split('$$');
		
		var iCurrentYear = parseInt(aNext[0]);
		var iFirstYear = parseInt(aPrevious[1]);
				
		if (iCurrentYear != iFirstYear) {
			aNext[0] = iCurrentYear + 1;
			aPrevious[0] = iCurrentYear + 1;
			$('newstab-next').rel = aNext.join('$$');
			$('newstab-previous').rel = aPrevious.join('$$');
		
			new Effect.Move($('news-tab-navigation'), {x:($('newstab-2009').getWidth()),y:0,duration:0.7, queue: 'end'});
		}
		
		Event.stop(event);
	},
	
	'textarea#absenderadresse_gls_bestellung:focus' : function(element, event) {
		if (element.value != "") {
			element.value = "";
		}
	},
	
	'input#formattedParcelCodes:focus' : function(element, event) {       
		if(element.value == asciiToText("Num&#233;ro d'envoi")) {
			element.value = "";
		}
	},
	
	'input#formattedParcelCodes:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Num&#233;ro d'envoi");
		}
	},
	
	'input#formattedParcelCodes2:focus' : function(element, event) {       
		if(element.value == asciiToText("Num&#233;ro d'envoi")) {
			element.value = "";
		}
	},
	
	'input#formattedParcelCodes2:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Num&#233;ro d'envoi");
		}
	},
	
	'form#form_tt_pk:submit' : function(element, event) {       
		if (Validation.validate($('formattedParcelCodes')) && $('formattedParcelCodes').value != '' && $('formattedParcelCodes').value != asciiToText("Num&#233;ro d'envoi")) {
			var sUrl = "http://www.post.ch/EasyTrack/submitParcelData.do?p_language=fr";

			var sParam = '&VTI-GROUP=' + $('VTI-GROUP').value;
			sParam += '&directSearch=' + $('directSearch').value;
			sParam += '&formattedParcelCodes=' + $('formattedParcelCodes').value;

			openShadowbox(sUrl + sParam, 'iframe', "Suivi des envois", 830, 450, true, getTrackingPath() + '/teaser-form_tt_pk');
		}
		
		Event.stop(event);
	},

	'form#form_tt_gk:submit' : function(element, event) {       
		if (Validation.validate($('formattedParcelCodes2')) && $('formattedParcelCodes2').value != '' && $('formattedParcelCodes2').value != asciiToText("Num&#233;ro d'envoi")) {
			var sUrl = "http://www.post.ch/EasyTrack/submitParcelData.do?p_language=fr";

			var sParam = '&VTI-GROUP=' + $('VTI-GROUP2').value;
			sParam += '&directSearch=' + $('directSearch2').value;
			sParam += '&formattedParcelCodes=' + $('formattedParcelCodes2').value;

			openShadowbox(sUrl + sParam, 'iframe', "Suivi des envois", 830, 450, true, getTrackingPath() + '/teaser-form_tt_gk');
		}
		
		Event.stop(event);
	},
	
	'form#form_schnellzugriff_vsc:submit' : function(element, event) {
		if ($("form_schnellzugriff_vsc").action) {
			var sURL = "/teaser-form_schnellzugriff_vsc";
			/* 
			if (sURL.indexOf("?") == -1) {
				sURL += "?";
			}
			else {
				sURL += "&";
			}
			sURL += "country=" + $("vsc_country_hidden").value
				+ "&format=" + $("vsc_format_hidden").value
				+ "&weight=" + $("vsc_weight_hidden").value;
			*/
			// alert(getTrackingPath() + sURL);
			dcsMultiTrack('DCS.dcsuri', getTrackingPath() + sURL);
		}
	},
	
	'form#form_haltestellenfahrplaene:submit' : function(element, event)
	{
		if ($("form_haltestellenfahrplaene").action)
		{
			var sURL = "/teaser-form_haltestellenfahrplaene";
			dcsMultiTrack('DCS.dcsuri', getTrackingPath() + sURL);
		}
	},
	
	'input#plzsuche:focus' : function(element, event) {       
		if(element.value == asciiToText("Lieu")) {
			element.value = "";
		}
	},
	
	'input#plzsuche:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Lieu");
		}
	},
	
	'form#form_tt_plz:submit' : function(element, event) {       
		if (Validation.validate($('plzsuche')) && $('plzsuche').value != '' && $('plzsuche').value != asciiToText("Lieu"))
		{
			var sUrl = "http://www.post.ch/db/owa/pv_plz_pack/pr_check_data?p_language=fr&p_nap=&p_localita=&p_cantone=&p_tipo=luogo";
			
			if (!isNaN($('plzsuche').value))
			{
				sUrl = sUrl.replace(/p_nap=/gi, "p_nap=" + $('plzsuche').value);
			}
			else
			{
				sUrl = sUrl.replace(/p_localita=/gi, "p_localita=" + escape($('plzsuche').value));
			}
			
			openShadowbox(sUrl, 'iframe', "NPA", 520, 450, true, getTrackingPath() + '/teaser-form_tt_plz');
		}
		
		Event.stop(event);
	},
	
	'div#search input#query:focus' : function(element, event) {       
		if(element.value == asciiToText("Crit&#232;re(s) de recherche")) {
			element.value = "";
		}
	},
	
	'div#search input#query:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Crit&#232;re(s) de recherche");
		}
	},
	
	'input#poststellensuche:focus' : function(element, event) {       
		if(element.value == asciiToText("Localit&#233; ou NPA")) {
			element.value = "";
		}
	},
	
	'input#poststellensuche:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Localit&#233; ou NPA");
		}
	},
	
	'form#form_tt_poststellensuche:submit' : function(element, event)
	{
		var sUrl = "http://standorte.post.ch/Suche/index/fr";
		
		var sValue = "";
		
		if (Validation.validate($('poststellensuche')) && $('poststellensuche').value != '' && $('poststellensuche').value != asciiToText("Localit&#233; ou NPA"))
		{					
			sValue = Utf8.encode($('poststellensuche').value);			
		}
		var sParam = "?location=" + escape(sValue)
			
		if ($('summary') && $('summary').value) {
			sValue = Utf8.encode($('summary').value);
			sParam += "&summary=" + escape(sValue);
		}
		
		if ($('homeurl') && $('homeurl').value) {
			sValue = Utf8.encode($('homeurl').value);
			sParam += "&homeurl=" + escape(sValue);
		}
								
		if ($('querytt') && $('querytt').value) {
			sParam += "&query=" + escape($('querytt').value);
		}
		
		openShadowbox(sUrl + sParam, 'iframe', "Sites et heures d'ouverture", 820, 600, true, getTrackingPath() + '/teaser-form_tt_poststellensuche');
		
		Event.stop(event);
	},
	
	'input#form_NameFirma:focus' : function(element, event) {       
		if(element.value == asciiToText("Nom ou nom d'entreprise")) {
			element.value = "";
		}
	},
	
	'input#form_NameFirma:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Nom ou nom d'entreprise");
		}
	},
	
	'input#form_RepAuftragsNr:focus' : function(element, event) {       
		if(element.value == asciiToText("Num&#233;ro d'ordre de r&#233;paration")) {
			element.value = "";
		}
	},
	
	'input#form_RepAuftragsNr:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Num&#233;ro d'ordre de r&#233;paration");
		}
	},
	
	'input#form_NameFirma:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Nom ou nom d'entreprise");
		}
	},
	
	'input#form_sendungsnr:focus' : function(element, event) {       
		if(element.value == asciiToText("Num&#233;ro d'envoi")) {
			element.value = "";
		}
	},
	
	'input#form_sendungsnr:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Num&#233;ro d'envoi");
		}
	},
	
	'form#TaT_innight:submit' : function(element, event) {       
		if (Validation.validate($('form_sendungsnr')) && $('form_sendungsnr').value != '' && $('form_sendungsnr').value != asciiToText("Num&#233;ro d'envoi")) {
			var sUrl = "http://www.eoscop.com/spntrackandtrace/default.aspx";
			
			if ($('searchfor').value == 'barcode') {
				sUrl += "?barcode=" + $('form_sendungsnr').value;
			}
			else {
				sUrl += "?reference=" + $('form_sendungsnr').value;
			}
			
			window.open(sUrl);
		}
		
		Event.stop(event);
	},
	
	'input.webcodefield:focus' : function(element, event) {       
		if(element.value == asciiToText("Web code")) {
			element.value = "";
		}
	},
	
	'input.webcodefield:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Web code");
		}
	},
	
	'form#form_webcode:submit' : function(element, event) { 
		if ($('DCSext.webcode').hasClassName('validation-passed')) {
			$('webcode_searching').removeClassName('hidden');
			
			var oAjax = new Ajax.Request(
				getAbsoluteUrl('teaser-ajax-webcode'),
				{
					method:		'get', 
					parameters:	"webcode=" + $('DCSext.webcode').value,
					onSuccess:	function(transport, json) {
						var sResponse = transport.responseText;
						if (sResponse != "error") {
							document.location = getAbsoluteUrl(sResponse);
							$('webcode_searching').addClassName('hidden');
						}
						else {
							$('webcode_searching').addClassName('hidden');
							alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
						}
					},
					onFailure:	function(transport, json) {
						$('webcode_searching').addClassName('hidden');
						alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
					}
				}
			);	
		}
		
		Event.stop(event);
	},
	
	'input#fpsearch:focus' : function(element, event) {       
		if(element.value == asciiToText("localit&#233;")) {
			element.value = "";
		}
	},
	
	'input#fpsearch:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("localit&#233;");
		}
	},
	
	'input#orquery:focus' : function(element, event) {       
		if(element.value == asciiToText("Mots-cl&#233;s")) {
			element.value = "";
		}
	},
	
 	'input#orquery:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("Mots-cl&#233;s");
		}
	},
	
	/* 'select#orregion:blur' : function(element, event) {       
		if(element.value == "") {
			$('orquery').value = asciiToText("Mots-cl&#233;s");
		}
		else {
			$('orquery').value = "";
		}
	}, */
	
	'form#form_fahrplanfelder:submit' : function(element, event) {       
		if (!Validation.validate($('fpsearch')) || $('fpsearch').value == asciiToText("localit&#233;")) {
			Event.stop(event);
		}
	},
	
	'div.hasOverlay:mouseover' : function(element, event) {
		try {
			
		} catch(e) {
			
		}
	},
	
	'div.hasOverlay:mouseout' : function(element, event) {
		try {
			
		} catch(e) {
			
		}
	},
	
	'input#REQ0JourneyStopsSG:focus' : function(element, event) {       
		if(element.value == asciiToText("de")) {
			element.value = "";
		}
	},
	
	'input#REQ0JourneyStopsSG:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("de");
		}
	},
	
	'input#REQ0JourneyStopsZG:focus' : function(element, event) {       
		if(element.value == asciiToText("&#224;")) {
			element.value = "";
		}
	},
	
	'input#REQ0JourneyStopsZG:blur' : function(element, event) {       
		if(element.value == "") {
			element.value = asciiToText("&#224;");
		}
	},		
	
	'li.ckb_competence:click': function(element, event) {
		if ($('spi_competence_form')) {
			var oContinue = true;
			var oMail = $('email');
			var oMailAdvice = $('advice-required-email');
			if ($('newsletter').checked) {
				if (!oMail.hasClassName("required")) {
					oMail.addClassName("required");
					Validation.validate(oMail);
					if (oMail.hasClassName("validation-failed") && !oMailAdvice.visible()) {
					 new Effect.Appear(oMailAdvice, { Duration : 1 });
					}
				}
				oContinue = false;   	
			} else {
				if (oMail.hasClassName("required")) {
					oMail.removeClassName("required");
				}
				if (oMailAdvice) {
					new Effect.Fade(oMailAdvice, {Duration : 1});
				}
			}
		}
	},
	
	'a.boardQuote:click' : function(element, event) {
		var sAjaxUrl = getAbsoluteUrl('board-ajax-getquote');
		var tmp = element.rel.split('_');
		var oAjax = new Ajax.Request(
			sAjaxUrl,
			{
				method:		'get', 
				parameters:	'boardId=' + tmp[0] + '&catId=' + tmp[1] + '&postId=' + tmp[2],
				onSuccess:	function(transport, json) {
					var sResponse = transport.responseText;
					if (sResponse != "error") {
						$('message').value = sResponse;
					}
				},
				onFailure:	function(transport, json) {
					
				}
			}
		);
	    
		location.href += '#postanchor';
		Event.stop(event);
	},
	
	'a.board_rating:click' : function(element, event) {
		var sHref = getHref(element);
		var iStart = sHref.toString().indexOf("rating=") + 7;
		var iStar = sHref.substring(iStart,iStart+1);
		
		var iStartId = sHref.toString().indexOf("threadId=") + 9;
		var iThreadId = sHref.substring(iStartId, sHref.length);
		iThreadId = iThreadId.substring(0, iThreadId.indexOf("&"));
		
		var sAjaxUrl = getAbsoluteUrl('board-ajax-insert-rating');
		
		if (sHref.indexOf("https://") == 0)
		{
			sAjaxUrl = getRelativeUrl('board-ajax-insert-rating', true);
		}
		
		var oAjax = new Ajax.Request(
			sAjaxUrl,
			{
				method:		'get', 
				parameters:	'postId=' + iThreadId + '&rating=' + iStar,
				onSuccess:	function(transport, json) {
					var sResponse = transport.responseText;
					if (sResponse != "error") {
						var iStarCount = 1;
						var imgStar = $('rating_star_'+iStarCount);
						
						while(imgStar) {
							var linkStar = $('link_rating_star_'+iStarCount);
							linkStar.href = 'javascript:void(0);';
							linkStar.onmouseover = null;
							linkStar.onmouseout = null;
							linkStar.removeClassName('board_rating');
							linkStar.setStyle({cursor: 'default'});
							
							var sImgUrl = "";
							var iAvgRating = parseFloat(sResponse);
							if (iStarCount <= iAvgRating) {
								sImgUrl = "board-icon-rating-fullstar.gif";
							}
							else {
								if ((iStarCount - iAvgRating) <= 0.5) {
									sImgUrl = "board-icon-rating-halfstar.gif";
								}
								else {
									sImgUrl = "board-icon-rating-nostar.gif";
								}
							}
							
							imgStar.src = sImgUrl;
							
							iStarCount++;
							imgStar = $('rating_star_'+iStarCount);
						}
					}
				},
				onFailure:	function(transport, json) {
						
				}
			}
		);
	
		Event.stop(event);
	},
	
	'#tarifrechner #line:change' : function(element, event) {
	
		var sOptions = "";
		var oStation = null;
		var value = element.value;
		var eDDStationsFrom = $('stationfrom');
		var eDDStationsTo = $('stationto');
		var eDIVtariff = $('tarifrechner-tariff');
		var eDIVinfo = $('tarifrechner-lineinfo');
			
		if (eDIVtariff) {
			eDIVtariff.remove();
		}
		
		if (eDIVinfo) {
			eDIVinfo.remove();
		}
		
		if (value > 0 && eDDStationsFrom && eDDStationsTo) {
			// lock and empty dropdowns
			eDDStationsFrom.writeAttribute('disabled','disabled');
			eDDStationsTo.writeAttribute('disabled','disabled');
			eDDStationsFrom.update();
			eDDStationsTo.update();
			
			var oAjax = new Ajax.Request(
				getAbsoluteUrl('tarifrechnerajaxcontroller'),
				{
					method:		'get', 
					parameters:	"methodName=getStationsForLine&line=" + value,
					onSuccess:	function(transport, json) {
						var sResponse = transport.responseText;
						var oResponse = eval("(" + transport.responseText + ")");
						if (oResponse && oResponse.length > 0) {
							for (var i = 0; i < oResponse.length; i++) {
								oStation = eval('oResponse.s' + i);
								sOptions += '<option value="' + oStation.id + '">' + oStation.name + '</option>';
							}
						}
						
						// fill and unlock dropdowns
						eDDStationsFrom.update(sOptions);
						eDDStationsTo.update(sOptions);
						eDDStationsFrom.writeAttribute('disabled',false);
						eDDStationsTo.writeAttribute('disabled',false);
						
						// update stationto
						setTimeout(trUpdateStationTo('last'), 10);						
						
						if (sResponse == "error") {
							alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
						}				
					},
					onFailure:	function(transport, json) {
						eDDStationsFrom.writeAttribute('disabled',false);
						eDDStationsTo.writeAttribute('disabled',false);
						alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
					}
				}
			);	
		}
	},
	
	'#tarifrechner #returnfare:click' : function(element, event) {
	
		var value = element.checked;
		var eSPANSingleFare = $$('.tarifrechner-tariff.singlefare')[0];
		var eSPANReturnFare = $$('.tarifrechner-tariff.returnfare')[0];
		
		if (eSPANSingleFare && eSPANReturnFare)
		{
			if (value)
			{
				eSPANSingleFare.removeClassName('active');
				eSPANReturnFare.addClassName('active');
			}
			else
			{
				eSPANReturnFare.removeClassName('active');
				eSPANSingleFare.addClassName('active');				
			}
		}
	},
	
	'input.userdisabled:click' : function(element, event) { 
		
		// don't do anything
		return false;     
		
		// stop event propagation
		Event.stop(event);
		
	}, 
	
	'form.submitting:submit' : function(element, event) { 
		
		// don't do anything
		return false;     
		
		// stop event propagation
		Event.stop(event);
		
	}, 
	
	'form input.skipsubmit:click' : function(element, event) { 
		
		// add class="skipping" to parent form
		var eForm = $(element).up('form', 0);
		if (eForm) {
			eForm.addClassName('skipping');
		}
	}, 
	
	'form input.backsubmit:click' : function(element, event) { 
		
		// add class="skipping" to parent form
		var eForm = $(element).up('form', 0);
		if (eForm) {
			eForm.addClassName('skipping');
		}
	}, 
	
	'form input.mainsubmit:click' : function(element, event) { 
		
		// add class="skipping" to parent form
		var eForm = $(element).up('form', 0);
		if (eForm) {
			eForm.removeClassName('skipping');
		}
	}, 	
	
	'.news-entries.unrefreshed:loaded' : function(element, event) {

		/* ensure reload is tried once only */	
		element.removeClassName('unrefreshed');
				
		/* generate request url and param */
		var oCurrent = $$('ul.tab-navigation li.current a')[0];
		if (oCurrent) {
		
			/* try getting the page title */
			var eNewsTitle = $$('#col3_content .subcolumns h1')[0];
			if (eNewsTitle) {
				eNewsTitle.addClassName('loading');
			}		
		
			/* generate request url and param */
			var tmp = oCurrent.rel.split('$$');
			var iYear = tmp[0];
			var iConfig = tmp[1];
			var iClusterConfig = tmp[2];
			var sChecksum = tmp[3];
			var sUrl = ($(oCurrent.parentNode.parentNode.id).hasClassName('podcasts'))? 'podcasts-ajax-changeyear' : 'news-ajax-changeyear';
			
			/* try loading from url */
			var oAjax = new Ajax.Request(
				getAbsoluteUrl(sUrl),
				{
					method:		'get', 
					parameters:	"year=" + iYear + "&config=" + iConfig + "&cluster=" + iClusterConfig + "&checksum=" + sChecksum,
					onSuccess:	function(transport, json) {
						var sResponse = transport.responseText;
						if (sResponse != "error") {
							if (sResponse != "") {
								$('news-archive').update(sResponse);
							}							
						}
						else {
							//alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
						}
						eNewsTitle.removeClassName('loading');
					},
					onFailure:	function(transport, json) {
						eNewsTitle.removeClassName('loading');
						//alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
					}
				}
			);
		}	
	}, 

	'.news-overview.unrefreshed:loaded' : function(element, event) {

		 $$('.news-overview.unrefreshed').each(function(element) { 	
		
			/* ensure reload is tried once only */
			element.removeClassName('unrefreshed');
		
			/* try getting news title */
			var eNewsTitle = element.down('h2');
			if (eNewsTitle) {
				eNewsTitle.addClassName('loading');
			}
				
			/* generate request url and param */	
			var tmp = element.readAttribute('class');
				tmp = tmp.substr(tmp.lastIndexOf('conf_')+5);
				tmp = tmp.split('$$');
		
			var iConfig = tmp[0];
			var iClusterConfig = tmp[1];
			var sChecksum = tmp[2];
			var sUrl = 'news-ajax-overview';
			/* try loading from url */
			var oAjax = new Ajax.Request(
				sUrl,
				{
					method:		'get', 
					parameters:	"config=" + iConfig + "&cluster=" + iClusterConfig + "&checksum=" + sChecksum,
					onSuccess:	function(transport, json) {
						var sResponse = transport.responseText;
						if (sResponse != "error") {
							if (sResponse != "") {
								element.update(sResponse);
							}
						}
						else {
							//alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
						}
						eNewsTitle.removeClassName('loading');
					},
					onFailure:	function(transport, json) {
						eNewsTitle.removeClassName('loading');
						//alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
					}
				}
			);
		});	
	},
	
	'div#search-paging a:click' : function(element, event) {
		var oLink = getLinkProperties(element); 
		var oLayer = $('search-layer');
		oLayer.show();
		var tmp = oLink.rel.split("$$");
		var href = oLink.href;
		var aUrl = null;
		var aTempUrl = href.split("?");
		var sParams = "";
		if (aTempUrl && aTempUrl[1]) {
			var aParams = aTempUrl[1].split("&");
			for (var iCount = 0; iCount < aParams.length; ++iCount) {
				if (aParams[iCount].indexOf("method") == -1 && aParams[iCount].indexOf("checksum") == -1) {
					sParams += "&" + aParams[iCount];
				}
			}
		}

		getSearchResults(sParams);
		$('top').scrollTo();
		Event.stop(event);
	},
	
	'div#search-container form#search-form:submit' : function(element, event) {
		var sParams = $('search-form').serialize();
		var oLayer = $('search-layer');
		if (oLayer) {
			oLayer.show();
		}
		
		var oLayerDiv = $('search-suggest');
		var oContainer = $('suggestions');
		if (oLayerDiv) {
			oLayerDiv.hide();
			oContainer.update("");
			$('q').blur();
		}
		getSearchResults("&" + sParams);
		
		Event.stop(event);
	},
	
	'div#search-suggest a#close:click' : function(element, event) {
		var oLayerDiv = $('search-suggest');
		var oContainer = $('suggestions');
		if (oLayerDiv) {
			oLayerDiv.hide();
			oContainer.update("");
		}
		Event.stop(event);
	},
	
	'div#search-suggest-top a.close:click' : function(element, event) {
		var oLayerDiv = $('search-suggest-top');
		var oContainer = $('suggestions-top');
		if (oLayerDiv) {
			oLayerDiv.hide();
			oContainer.update("");
		}
		Event.stop(event);
	},
	
	'div#search-container ul.ss-gac li:click' : function(element, event) {
		var sParams = $('search-form').serialize();
		var oLayer = $('search-layer');
		if (oLayer) {
			oLayer.show();
		}
		
		getSearchResults("&" + sParams);
	},
	
	'div#search-suggest-top ul.ss-gac li:click' : function(element, event) {
		var oForm = element.up('form');
		if (oForm) {
			oForm.submit();
		}
	},
	
	'div#search-suggest ul.ss-gac li:mouseover' : function(element, event) {
		$$('ul.ss-gac li').each(function(e) {
			e.removeClassName('active');
		});
		element.toggleClassName('active');
		$('q').value = element.innerHTML.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
	},
	
	'div#search-suggest-top ul.ss-gac li:mouseover' : function(element, event) {
		$$('ul.ss-gac li').each(function(e) {
			e.removeClassName('active');
		});
		element.toggleClassName('active');
		$('query').value = element.innerHTML.replace(/&gt;/g, ">").replace(/&lt;/g, "<").replace(/&amp;/g, "&");
	},
	
	'ul.ss-gac li:mouseout' : function(element, event) {
		$$('ul.ss-gac li').each(function(e) {
			e.removeClassName('active');
		});
		element.toggleClassName('active');
	},
	
	'div#search-container span.dropdown:click' : function(element, event) {
		
		var sDropdown = element.id.substring(16);

		if (sDropdown) {
			
			var oContainer = $('search-filter-' + sDropdown);
			
			if (oContainer) {
				if (oContainer.hasClassName('open')) {
					new Effect.SlideUp(oContainer, {duration:0.5, scaleContent: false});
				}
				else {
					if ($$('div#search-container .hide')) {
						$$('div#search-container .hide').each(function(item) {
							if (item.hasClassName('open')) {
								if ($(item.id)) {
									$(item.id).setStyle('z-index:1');
									new Effect.SlideUp($(item.id), {duration:0.5, scaleContent: false});
								}
							}
							item.removeClassName('open');
						});
					}
					oContainer.setStyle('z-index:1000');
					new Effect.SlideDown(oContainer, {duration:0.5, scaleContent: false});
					
				}
				oContainer.toggleClassName('open');
				Event.stop(event);
				$(document.body).observe('click', function(event) {
					var clickedElement = Event.element(event);
					var oContainer = $$('div#search-container .open');
					if (oContainer) {
						oContainer.each(function(item) {
							if (clickedElement.descendantOf(item) !== true && !clickedElement.hasClassName('dropdown')) {
								$(document.body).stopObserving('click');
								new Effect.SlideUp(item, {duration : 0.5, scaleContent : false});
								item.toggleClassName('open');
							}
						});
					}
				
				});
			}
		}
	},
	
	'div#search-container ul.filterControls li:click' : function(element, event) {
		var oLabel, oDropdown, oInput, oChoice;
		if (element.tagName == "LI") {
			oLabel = element.down('label');
			oDropdown = element.up('div.hide').previous('span.dropdown');
			oChoice = element.up('div.hide').previous('input.choice');
			oInput = element.down('input');
			if (oInput.type != "text") {
				(oInput.checked) ? oInput.checked = false : oInput.checked = true;
			}
		}
		else {
			oLabel = element.next('label');
			oInput = element;
			oDropdown = element.up('div.hide').previous('span.dropdown');
			oChoice = element.up('div.hide').previous('input.choice');
		}
		
		handleDropdownClick(oDropdown, oLabel, oChoice, oInput.type, oInput.value);
	},
	
	'div#search-container a#search-reset:click' : function(element, event) {
		var oAjax = new Ajax.Request(
		getAbsoluteUrl('gsa-ajax-manager'),
		{
			method:		'get', 
			parameters:	"method=resetFilter",
			onSuccess:	function(transport, json) {
				if (transport.responseText != "error") {
					var oContainer = $('search-filter');
					var oLayer = $('search-layer');
					if (oContainer && oLayer) {
						oLayer.show();
						oContainer.update(transport.responseText);
						getSearchResults("&q=" + $('q').value);
					}
				}
				else {
					//alert("Well, this is embarassing... Something went wrong, please try again!");
				}
			},
			onFailure:	function(transport, json) {
				//alert("Well, this is embarassing... Something went wrong, please try again!");
			}
		});
		Event.stop(event);
	},
	
	'div#search-container input#tbs_submit:click' : function(element, event) {
		var sParams = $('search-form').serialize();
		var oLayer = $('search-layer');
		if (oLayer) {
			oLayer.show();
		}
		
		getSearchResults("&" + sParams);
		Event.stop(event);
	},
	
	'a.search-filter-toggle:click' : function(element, event) {
		if (element.tagName.toLowerCase() != "a") {
			element = $(element).up("a");
		}
		var iFilterId = element.rel;
		var sToggleElementName = "search-filter-invisible-list-" + iFilterId;
		Effect.toggle(sToggleElementName, 'slide', {duration:0.2});
		Effect.toggle("search-filter-toggle-more-" + iFilterId, 'blind', {duration:0.2});
		Effect.toggle("search-filter-toggle-less-" + iFilterId, 'blind', {duration:0.2});
		
		if ($('search-filter-toggle-icon-' + iFilterId).hasClassName("search-filter-toggle-more-icon")) {
			$('search-filter-toggle-icon-' + iFilterId).removeClassName("search-filter-toggle-more-icon");
			$('search-filter-toggle-icon-' + iFilterId).addClassName("search-filter-toggle-less-icon");
		}
		else {
			$('search-filter-toggle-icon-' + iFilterId).removeClassName("search-filter-toggle-less-icon");
			$('search-filter-toggle-icon-' + iFilterId).addClassName("search-filter-toggle-more-icon");
		}

		Event.stop(event);
	},
	
	'a.search-filter-link:click' : function(element, event) {
		
		if (element.tagName.toLowerCase() != "a") {
			element = $(element).up("a");
		}
		
		var sCollection = element.rel;
		
		$('collectionfilter').value = sCollection;
		
		var sParams = $('search-form').serialize();
		var oLayer = $('search-layer');
		if (oLayer) {
			oLayer.show();
		}

		getSearchResults("&" + sParams);
		
		$$('a.search-filter-link').each(function(link) { $(link).removeClassName("active"); });
		element.addClassName("active");
		
		Event.stop(event);
	},
	
	'a.search-filter-document-link:click' : function(element, event) {
		if (element.tagName.toLowerCase() != "a") {
			element = $(element).up("a");
		}
		
		var sDocumentType = element.rel;
		
		$('as_filetype').value = sDocumentType;
		
		var sParams = $('search-form').serialize();
		var oLayer = $('search-layer');
		if (oLayer) {
			oLayer.show();
		}

		getSearchResults("&" + sParams);
		
		$$('a.search-filter-document-link').each(function(link) { $(link).removeClassName("active"); });
		element.addClassName("active");
		
		Event.stop(event);
	},
	
	'select#vsc_country:change' : function(element,event) {
		var sCountry = "";
		var sFormat = "";
		var sWeight = "";
		
		sCountry = element.options[element.selectedIndex].value;
		if($('vsc_format')) {
			sFormat = $('vsc_format').options[$('vsc_format').selectedIndex].value;
		}
		if($('vsc_weight')) {
			sWeight = $('vsc_weight').options[$('vsc_weight').selectedIndex].value;
		}
		
		var oAjax = new Ajax.Request(
		getAbsoluteUrl('schnellzugriff-vsc-ajax-manager'),
		{
			method:		'get', 
			parameters:	"method=getFormats&vsc_country=" + sCountry + "&vsc_format=" + sFormat + "&vsc_weight=" + sWeight,
			onSuccess:	function(transport, json) {
				if (transport.responseText != "error") {
					var oContainer = $('schnellzugriff_vsc_format');
					if (oContainer) {
						oContainer.update(transport.responseText);
						
						// perhaps timeout needed later
						sFormat = $('vsc_format').options[$('vsc_format').selectedIndex].value;

						var oAjax2 = new Ajax.Request(
						getAbsoluteUrl('schnellzugriff-vsc-ajax-manager'),
						{
							method:		'get', 
							parameters:	"method=getWeights&vsc_country=" + sCountry + "&vsc_format=" + sFormat + "&vsc_weight=" + sWeight,
							onSuccess:	function(transport, json) {
								if (transport.responseText != "error") {
									var oContainer = $('schnellzugriff_vsc_weight');
									if (oContainer) {
										oContainer.update(transport.responseText);
										
										// perhaps timeout needed later
										$('vsc_country_hidden').value = element.options[element.selectedIndex].value;
										$('vsc_format_hidden').value = $('vsc_format').options[$('vsc_format').selectedIndex].value;
										$('vsc_weight_hidden').value = $('vsc_weight').options[$('vsc_weight').selectedIndex].value;
									}
								}
								else {
									//alert("Well, this is embarassing... Something went wrong, please try again!");
								}
							},
							onFailure:	function(transport, json) {
								//alert("Well, this is embarassing... Something went wrong, please try again!");
							}
						});
					}
				}
				else {
					//alert("Well, this is embarassing... Something went wrong, please try again!");
				}
			},
			onFailure:	function(transport, json) {
				//alert("Well, this is embarassing... Something went wrong, please try again!");
			}
		});
	},
	
	'select#vsc_format:change' : function(element,event) {
		var sCountry = "";
		var sFormat = "";
		var sWeight = "";
		
		if($('vsc_country')) {
			sCountry = $('vsc_country').options[$('vsc_country').selectedIndex].value;
		}
		sFormat = element.options[element.selectedIndex].value;
		if($('vsc_weight')) {
			sWeight = $('vsc_weight').options[$('vsc_weight').selectedIndex].value;
		}
		
		var oAjax = new Ajax.Request(
		getAbsoluteUrl('schnellzugriff-vsc-ajax-manager'),
		{
			method:		'get', 
			parameters:	"method=getWeights&vsc_country=" + sCountry + "&vsc_format=" + sFormat + "&vsc_weight=" + sWeight,
			onSuccess:	function(transport, json) {
				if (transport.responseText != "error") {
					var oContainer = $('schnellzugriff_vsc_weight');
					if (oContainer) {
						oContainer.update(transport.responseText);
						
						// perhaps timeout needed later
						$('vsc_format_hidden').value = element.options[element.selectedIndex].value;
						$('vsc_weight_hidden').value = $('vsc_weight').options[$('vsc_weight').selectedIndex].value;
					}
				}
				else {
					//alert("Well, this is embarassing... Something went wrong, please try again!");
				}
			},
			onFailure:	function(transport, json) {
				//alert("Well, this is embarassing... Something went wrong, please try again!");
			}
		});
	},
	
	'select#vsc_weight:change' : function(element,event) {

		$('vsc_weight_hidden').value = element.options[element.selectedIndex].value;
	}
};

function handleDropdownClick(oDropdown, oLabel, oChoice, sType, sValue) {
		
	//if (sValue == "cdr" || sType == "text") {
	//	$('customDateRange').show();
	//	$('search-filter-date').scrollTop = $('search-filter-date').getHeight();
	//}
	//else {
	//	$('customDateRange').hide();
	//}
	
	if (oDropdown && oLabel && oChoice && sType != "text") {
		var sLabel = oLabel.innerHTML;
		var sChoice = oChoice.value;
		var sUpdate = "";
		if (sChoice != "") {							
			var tmp = sChoice.split(", ");
			if (sChoice.indexOf(sLabel) > -1) {								
				if (sType != "radio") {
					sUpdate = tmp.without(sLabel).join(", ");
					if (sUpdate == "") {
						sUpdate = "";
					}
				}
				else {
					sUpdate = sLabel;
				}
			}
			else {
				if (sType != "radio") {
					sUpdate = sChoice + ", " + sLabel;
				}
				else {
					sUpdate = sLabel;
				}
			}
		}
		else {
			sUpdate = sLabel;
		}
		oChoice.value = sUpdate;
		if (sUpdate == "") {
			sUpdate = asciiToText("Choisissez s.v.p.");
		}
		if (sUpdate.length > 28) {
			sUpdate = sUpdate.substring(0, 28) + '...';
		}
		oDropdown.update(sUpdate);
		
		// submit form
		if (sValue != "cdr") {
			var sParams = $('search-form').serialize();
			var oLayer = $('search-layer');
			if (oLayer) {
				oLayer.show();
			}
			
			if (sType == "radio") {
				$(document.body).stopObserving('click');
				var oList = oDropdown.next('div.open');
				new Effect.SlideUp(oList, {duration : 0.5, scaleContent : false});
				oList.toggleClassName('open');
			}
			
			getSearchResults("&" + sParams);
		}
	}
}

function getSearchResults(sParams) {
	
	// Post Webcode-Check:
	var iWebcode = $('q').value;
	if (iWebcode && !isNaN(iWebcode)) {
		var oAjax = new Ajax.Request(
			getAbsoluteUrl('teaser-ajax-webcode'),
			{
				method:		'get', 
				parameters:	"webcode=" + iWebcode,
				onSuccess:	function(transport, json) {
					var sResponse = transport.responseText;
					if (sResponse != "error" && sResponse.indexOf("undefined") == -1 && sResponse.indexOf("notfound") == -1) {
						document.location = sResponse;
					}
				},
				onFailure:	function(transport, json) {
					alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
				}
			}
		);
	}
	
	if (sParams) {
		var oAjax = new Ajax.Request(
		getAbsoluteUrl('gsa-ajax-manager'),
		{
			method:		'get', 
			parameters:	"method=getResults" + sParams,
			onSuccess:	function(transport, json) {
				if (transport.responseText != "error") {
					var oContainer = $('search-results');
					if (oContainer) {
						oContainer.update(transport.responseText);
						Shadowbox.setup();
						$('q').focus();
					}
				}
				else {
					alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
				}
			},
			onComplete: function() {
				var oLayerDiv = $('search-suggest');
				var oContainer = $('suggestions');
				if (oLayerDiv) {
					oLayerDiv.hide();
					oContainer.update("");
				}
			},
			onFailure:	function(transport, json) {
				alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
			}
		});
	}
}	

function getSuggestions(element, e) {
	
	element = $(element.id);
	var iKeyCode = e.keyCode ? e.keyCode : e.charCode;
	var sValue = "";
	var oLayerDiv = element.next('div.suggestions');
	var oContainer = oLayerDiv.down('div');
	switch (iKeyCode) {
		case 38: //up arrow
			var oSelected = $$('ul.ss-gac li.active');
			if (oSelected && oSelected[0] && oSelected[0].previous('li')) {
				oSelected[0].removeClassName('active');
				oSelected[0].previous('li').addClassName('active');
				sValue = oSelected[0].previous('li').innerHTML;
			}
			else {
				var oEntries = $$('ul.ss-gac li');
				if (!oSelected[0]) {
					if (oEntries && oEntries[oEntries.length - 1]) {
						oEntries[oEntries.length - 1].addClassName('active');
						sValue = oEntries[oEntries.length - 1].innerHTML;
					}
				}
				else {
					oSelected[0].removeClassName('active');
					oEntries[oEntries.length-1].addClassName('active');
					sValue = oEntries[oEntries.length-1].innerHTML;
				}
			}
			element.value = sValue;
			break;
		case 40: //down arrow
			var oSelected = $$('ul.ss-gac li.active');
			if (oSelected && oSelected[0] && oSelected[0].next('li')) {
				oSelected[0].removeClassName('active');
				oSelected[0].next('li').addClassName('active');
				sValue = oSelected[0].next('li').innerHTML;
			}
			else {
				var oEntries = $$('ul.ss-gac li');
				if (!oSelected[0]) {
					if (oEntries && oEntries[0]) {
						oEntries[0].addClassName('active');
						sValue = oEntries[0].innerHTML;
					}
				}
				else {
					oSelected[0].removeClassName('active');
					oEntries[0].addClassName('active');
					sValue = oEntries[0].innerHTML;
				}
			}
			element.value = sValue;
			break;
		case 13: //enter
			oLayerDiv.hide();
			oContainer.update("");
			break;
		default:
			if (oGSAsuggestionTimer) {
				window.clearTimeout(oGSAsuggestionTimer);
			}
			oGSAsuggestionTimer = window.setTimeout(function() {
				doSearchSuggestionAJAX(element, oLayerDiv, oContainer); }, 500);
			break;
		
	}
}

function doSearchSuggestionAJAX(element, oLayerDiv, oContainer) {
	var sToken = element.value;
	if (sToken && sToken.length > 0 && oLayerDiv && oContainer) {
		var oAjax = new Ajax.Request(
			getAbsoluteUrl('gsa-ajax-manager'),
			{
				method:		'get', 
				parameters:	"method=getQuerySuggestions&token=" + sToken,
				onSuccess:	function(transport, json) {
					var sResponse = transport.responseText;
					var aSuggestions = eval(sResponse);
					if (aSuggestions.length > 0) {
						var sHtmlString = "<ul class=\"ss-gac\">";
						for (var iCount = 0; iCount < aSuggestions.length; ++iCount) {
							sHtmlString += "<li>" + aSuggestions[iCount] + "</li>";
						}
						sHtmlString += "</ul>";
						oContainer.update(sHtmlString);
						oLayerDiv.show();
					}
					else {
						oLayerDiv.hide();
						oContainer.update("");
					}
				},
				onFailure:	function(transport, json) {
					alert(asciiToText("Une erreur s'est produite. Veuillez r&#233;p&#233;ter l'op&#233;ration ult&#233;rieurement."));
					oLayerDiv.hide();
					oContainer.update("");
				}
			}
		);
	}
	else {
		oLayerDiv.hide();
		oContainer.update("");
	}
}

function imgGalleryLoadNewPicture(galId, picId) {
	// Display "loading"
	$('imagegallery_detailpage').setStyle({visibility: 'hidden', height: '0', position: 'absolute'});
	$('imagegalleryPicture_load').show();
	$('imagegalleryPicture').hide();
	$('imagegallery_picture').src = 'imagegallery_load_596_395.gif';
		
	var oAjax = new Ajax.Request(
		getAbsoluteUrl('imagegalleryajaxcontroller'),
		{
			method:		'get', 
			parameters:	"methodName=picDetails&gal=" + galId + "&pic=" + picId + "&instanceLang=" + CURRENT_LANGUAGE,
			onSuccess:	function(transport, json) {
				if (transport.responseText != "error" && transport.responseText.length > 0) {
					var json  = eval("(" + transport.responseText + ")");
					
					var sPrintUrl = 'imagegallerypicturepopup.htm';
					var sDownloadUrl = 'imagegallery-download';
					
					sPrintUrl = getAbsoluteUrl(DEFAULTPAGE + sPrintUrl.substring(sPrintUrl.lastIndexOf('/')));
					
					if (sPrintUrl.indexOf('debugstate') > -1) {
						sPrintUrl += '&';
					}
					else {
						sPrintUrl += '?';
					}
					
					if (sDownloadUrl.indexOf('debugstate') > -1) {
						sDownloadUrl += '&';
					}
					else {
						sDownloadUrl += '?';
					}
					
					// Change the footer, the download- and the printlink
					$('imagegallery_popup_print').href = sPrintUrl + 'galId=' + galId + '&picId=' + picId + '&checksum=' + json.checksum + '&browser=print';					
					$('imagegallery_popup_download').href = sDownloadUrl + 'galId=' + galId + '&picId=' + picId + '&checksum=' + json.checksum;
					$('imagegallery_footer').update('<p>' + json.description + '</p>');
					
					// Handle the paging
					if (json.number == "isFirst" || json.number == "isOnePicture") {
						$('imagegallery_paging_left').hide();
					}
					else {
						$('imagegallery_paging_left').show();
					}
					
					if (json.number == "isLast" || json.number == "isOnePicture") {
						$('imagegallery_paging_right').hide();
					}
					else {
						$('imagegallery_paging_right').show();
					}
					
					// Handle the dimension of the new picture
					var sDim = eval("json.dim");
					$('imagegallery_picture').src = json.url;				
					$('imagegallery_picture').removeClassName('image_height');
					$('imagegallery_picture').removeClassName('image_width');
					$('imagegallery_picture').addClassName(sDim);
					$('imagegallery_picture').show();
					
					$('imagegalleryPicture_load').hide();
					$('imagegalleryPicture').show();
				}
				else {
					imgGalleryShowError();
				}
			},
			onFailure:	function(transport, json) {
				imgGalleryShowError();
			}
		}
	);
}

function imgGalleryShowError() {
	$('imagegallery_detailpage').setStyle({visibility: 'hidden', height: '0', position: 'absolute'});
	$('imagegalleryPicture').hide();
	$('imagegalleryPicture_load').hide();
	$('imagegallery_errorpage').show();
}

function windowOpen(sUrl, iWidth, iHeight) {
	if (iWidth && iWidth != "" && iHeight && iHeight != "") {
		window.open(sUrl, "_blank", "toolbar=no, location=no, status=no, menubar=no, personalbar=no, scrollbars=yes, width=" + iWidth + ", height=" + iHeight + ", resizable=yes, screenx=50, left=50, screenY=50, top=50");
	}
	else {
		window.open(sUrl, "_blank", "toolbar=no, location=no, status=no, menubar=no, personalbar=no, scrollbars=yes, width=775, height=500, resizable=yes, screenx=50, left=50, screenY=50, top=50");
	}
}


// Fallback / Debug
if(!dcsMultiTrack) {
	var dcsMultiTrack = function(v1, href, v2, title) {
		//alert("dcsMultiTrack(): " + href + ", " + title);
	}
}

// Get the href of the element (recursive)
function getHref(element) {
    var sHref="";      
	while (element) {
	    if (element.tagName.toLowerCase() == 'a' && element.href) {
			sHref = element.href;
			break;
	    }
	    else {
	    	element = element.parentNode;
	    }
	}
    return sHref;
}

// Get the link Properties of the element (recursive)
function getLinkProperties(element) {
    var oLinkProperties = new Object();      
	while (element) {
	    if (element.tagName.toLowerCase() == 'a' && element.href) {
			oLinkProperties.href = element.href;
			oLinkProperties.cssClasses = element.className;
			oLinkProperties.rel = element.rel;
			break;
	    }
	    else {
	    	element = element.parentNode;
	    }
	}
    return oLinkProperties;
}

function confirmDelete() {
	if (!confirm("Veuillez saisir un chiffre valide.")) {
		return false;
	} else {
		return true;
	}
}

function focusFirstFormField() {

	var oForm = $("col3").getElementsByTagName("FORM")[0];
	if (oForm) {
	
		for (var iElementCount = 0; iElementCount < oForm.elements.length; ++iElementCount) {

			var oCurrentElem = oForm.elements[iElementCount];
			if (((((oCurrentElem.nodeName == "INPUT") && ((oCurrentElem.type == "text") || (oCurrentElem.type == "password") || (oCurrentElem.type == "radio") || (oCurrentElem.type == "checkbox"))) || (oCurrentElem.nodeName == "TEXTAREA")) && 
				(oCurrentElem.value == "")) || oCurrentElem.nodeName == "SELECT") {
				
				oCurrentElem.focus();
				break;
			}
		}
	}
}

function printPage(sUrl) {
	window.open(sUrl, "printWindow", "toolbar=no, location=no, status=no, menubar=yes, personalbar=no, scrollbars=yes, width=615, height=500, resizable=yes, screenx=50, left=50, screenY=50, top=50");
}

function getTrackingPath() {
	var sPath = window.location.href;
	sPath = sPath.substring(sPath.indexOf("://") + 3);
	sPath = sPath.substring(sPath.indexOf("/"));
	if (sPath.indexOf("?") > -1) {
		sPath = sPath.substring(0, sPath.indexOf("?"));
	}
	if (sPath.indexOf("&") > -1) {
		sPath = sPath.substring(0, sPath.indexOf("&"));
	}
	if (sPath.indexOf(".") > -1) {
		sPath = sPath.substring(0, sPath.lastIndexOf("."));
	}
	while (sPath.charAt(sPath.length-1) == "/") {
	
		sPath = sPath.substring(0, sPath.length-2);
	}
	while (sPath.charAt(1) == "/") {
	
		sPath = sPath.substring(1);
	}
	return sPath;
}

function openShadowbox(sConent, sPlayer, sTitle, iWidth, iHeight, bTrack, sTrackingURL) {
	if (sConent != "" && bTrack == true) {
		if (sTrackingURL) {	
			// alert(sTrackingURL);
			dcsMultiTrack('DCS.dcsuri', sTrackingURL);
		}
		else {
			dcsMultiTrack('DCS.dcsuri', sConent);
		}
	}
	Shadowbox.open({
		content:    sConent,
        player:     sPlayer,
        title:      sTitle,
		width:		iWidth,
		height:		iHeight
	});
}

function asciiToText(sInput) {
	return sInput.replace(/&#(\d+);/g, function (m, n) { return String.fromCharCode(n); });
}

/* List Application */

function containsDOM (container, containee) {
  var isParent = false;
  do {
    if ((isParent = container == containee))
      break;
    containee = containee.parentNode;
  }
  while (containee != null);
  return isParent;
}

function checkMouseLeave (element, evt) {
  if (element.contains && evt.toElement) {
    return !element.contains(evt.toElement);
  }
  else if (evt.relatedTarget) {
    return !containsDOM(element, evt.relatedTarget);
  }
}

function boardRatingmouseOverStar(oObject) {
	var sHref = oObject.href;
	var iStart = sHref.indexOf("rating=");
	iStart = iStart + 7;
	var iStar = sHref.substring(iStart, iStart+1);
	
	var iStarCount = 1;
	var imgStar = $('rating_star_'+iStarCount);
	
	while(imgStar) {
		if (iStarCount <= iStar) {
			imgStar.src = "board-icon-rating-fullstar.gif";
		}
		else {
			imgStar.src = "board-icon-rating-nostar.gif";
		}
		
		iStarCount++;
		imgStar = $('rating_star_'+iStarCount);
	}	
}

function boardRatingmouseOutStar(oObject) {
	var sHref = oObject.href;
	var iStart = sHref.indexOf("rating=");
	iStart = iStart + 7;
	var iStar = sHref.substring(iStart, iStart+1);
	
	var iStarCount = 1;
	var imgStar = $('rating_star_'+iStarCount);
	
	while(imgStar) {
		var linkStar = $('link_rating_star_'+iStarCount);
		imgStar.src = linkStar.rel;
		
		iStarCount++;
		imgStar = $('rating_star_'+iStarCount);
	}	
}


// Remove/Comment this if you do not wish to reapply Rules automatically
// on Ajax request.
Ajax.Responders.register({
  onComplete: function() { EventSelectors.assign(Rules);}
});

function VPSTrackEvent(sTitle, sCrowdLabel, sUrl, sTrackingUrl)
{
	//Call method for storing information for Crowdsourcing
	
	//Call method for tracking in WebTrends
	dcsMultiTrack('DCS.dcsuri', sTrackingUrl, 'WT.ti', sTitle);
}
	
function ee(d){var b=(function(){var e=[37,39,80,79,83,84];ee.requireEnterKey&&e.push(13);return e})(),a=function(){a.codes=a.codes||Array.apply({},b);a.reset=function(){a.codes=null};return a.codes},c=function(f){if(a()[0]==(f||window.event).keyCode){a().shift();if(!a().length){a.reset();d()}}else{a.reset()}};window.addEventListener?window.addEventListener("keydown",c,false):document.attachEvent("onkeydown",c)}ee.requireEnterKey=true;ee(function(){openShadowbox(SERVER_URL+URL_MAGIC+"/"+CURRENT_LANGUAGE+"/--ee--?showtheeaseregg=true","iframe","Osterei :-)",800,600)});

function webcodeChanged(iId) {
	if ($('webcode-' + iId).value == $('webcode-' + iId).readAttribute("value")) {
		$('save-' + iId).src = 'layout-icon-save.gif';
	} else {
		$('save-' + iId).src = 'layout-icon-not-saved.gif';
	}
}

function openTextWizard(iObjectId) {
	if ('webengine' == 'cmengine') {
		if (iObjectId != "" && iObjectId != "null") {
			window.open("cmo-WizardStarter?lang=1&appl=texwiz&id=" + iObjectId + "&objlang=1&objbrowser=1&objrevision=0&ocmid=2." + iObjectId+ ".1.1.0.0.0.0.0","WizardStarter","width=203,height=104");			
		}
		else {
			alert("Aucune donn&#233;e trouv&#233;e");
		}
	}
}

function trUpdateStationTo(value) {
	
	var eDDStationsTo = $('stationto');
	var bSelected = false;
	
	if (eDDStationsTo && !value) {
		eDDStationsTo.selectedIndex = 1;
	}
	
	if (value == 'last') {
		var aOptions = $$('select#stationto option');
		eDDStationsTo.selectedIndex = aOptions.length-1;
	}	
	else if (eDDStationsTo && value > 0) {
		
		var aOptions = $$('select#stationto option');

		for (var i = 0; i < aOptions.length; i++) {
		
			// select station that immediately follows the starting station
			if (aOptions[i-1] && value == aOptions[i-1].readAttribute('value')) {			
				eDDStationsTo.selectedIndex = i;
				bSelected = true;
			}
			// select last element if none is selected
			else if (!bSelected && i == aOptions.length-1) {
				eDDStationsTo.selectedIndex = i;
			}
		}
	}	
}

function globalFormValidationCallback(bValidated, eForm) {

	//alert('Classname: ' + eForm.className);
	if (eForm.hasClassName('skipping')){
			
		// allow submission
		return true;		
	}
	
	if (bValidated) {
	
		if (eForm.hasClassName('submitting')) {
			
			// abort submission
			return false;		
		}
		else {
		
			//disable forms
			eForm.addClassName('submitting');
			
			// disable all input buttons that submit the final form (main button) and
			// all buttons that are only clickable once
			aInputButtons = $$('#' + eForm.readAttribute('id') + ' input.mainsubmit, #' + eForm.readAttribute('id') + ' input.clickableonce');
			for (var i = 0; i < aInputButtons.length; i++) {
				disableButton(aInputButtons[i], true);
			}
			
			// disable all resetbuttons
			aResetButtons = $$('#' + eForm.readAttribute('id') + ' input[type=reset]');
			for (var i = 0; i < aResetButtons.length; i++) {
				disableButton(aResetButtons[i]);
			}
		}
	}
	
	// continue as planned
	return bValidated;
}

function disableButton(eButton, bChangeValue, sNewValue) {

	// disable visually
	eButton.addClassName('userdisabled');
	
	// change button value
	var	sMessage = sNewValue || asciiToText("Veuillez patienter&#8230;");
	if (bChangeValue) {
		eButton.writeAttribute("value", sMessage);
	}
	
	// disable anything but submit buttons as this would change how a form behaves
	if (eButton.readAttribute('type') != 'submit') {
		eButton.writeAttribute('disabled', 'disabled');
	}
}

function getAbsoluteUrl(sUrl, bUseHttps)
{
	var sReturn = sUrl;
	
	if (sUrl.indexOf("http://") != 0 && sUrl.indexOf("https://") != 0)
	{
		if (bUseHttps)
		{
			sReturn = SECURE_SERVER_URL + URL_MAGIC;
		}
		else
		{
			sReturn = SERVER_URL + URL_MAGIC;
		}
		
		if (CURRENT_LANGUAGE && CURRENT_LANGUAGE != '')
		{
			sReturn += '/' + CURRENT_LANGUAGE;
		}
		
		sReturn += '/' + sUrl;
	}

	if ((IS_HTTPS || bUseHttps) && sReturn.indexOf("http://") == 0)
	{
		sReturn = sReturn.replace("http://", "https://");
	}
	
	return sReturn;
}

function joinObjects(obj1, obj2) 
{
	for (var elem in obj2) {
	
		obj1[elem] = obj2[elem];
	}
}

/*
* Really easy field validation with Prototype
* http://tetlaw.id.au/view/javascript/really-easy-field-validation
* Andrew Tetlaw
* (Version 1.5.4.1 (2007-01-05) - original version)
* Version 1.5.4.1unic3
* 
* Copyright (c) 2007 Andrew Tetlaw
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use, copy,
* modify, merge, publish, distribute, sublicense, and/or sell copies
* of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
* 
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
* 
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
* BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
* ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
* 
*/

/*
 * @changelog 1.5.4.1unic1/AlR	Added support for error messages in label element.
 * @changelog 1.5.4.1unic2/AlR	Bugfix: Error messages in label are now properly removed if validated.
 * @changelog 1.5.4.1unic3/NEA	Bugfix: onFormVAlidate & onElementValidate callbacks properly pass on return value (groups dot google dot com thread b8b139e340ea6fb/e0b4964d39f35cdd)
 */
var Validator = Class.create();

Validator.prototype = {
	initialize : function(className, error, test, options) {
		if(typeof test == 'function'){
			this.options = $H(options);
			this._test = test;
		} else {
			this.options = $H(test);
			this._test = function(){return true};
		}
		this.error = error || 'Validation failed.';
		this.className = className;
	},
	test : function(v, elm) {
		return (this._test(v,elm) && this.options.all(function(p){
			return Validator.methods[p.key] ? Validator.methods[p.key](v,elm,p.value) : true;
		}));
	}
}
Validator.methods = {
	pattern : function(v,elm,opt) {return Validation.get('IsEmpty').test(v) || opt.test(v)},
	minLength : function(v,elm,opt) {return v.length >= opt},
	maxLength : function(v,elm,opt) {return v.length <= opt},
	min : function(v,elm,opt) {return v >= parseFloat(opt)}, 
	max : function(v,elm,opt) {return v <= parseFloat(opt)},
	notOneOf : function(v,elm,opt) {return $A(opt).all(function(value) {
		return v != value;
	})},
	oneOf : function(v,elm,opt) {return $A(opt).any(function(value) {
		return v == value;
	})},
	is : function(v,elm,opt) {return v == opt},
	isNot : function(v,elm,opt) {return v != opt},
	equalToField : function(v,elm,opt) {return v == $F(opt)},
	notEqualToField : function(v,elm,opt) {return v != $F(opt)},
	include : function(v,elm,opt) {return $A(opt).all(function(value) {
		return Validation.get(value).test(v,elm);
	})}
}

var Validation = Class.create();

Validation.prototype = {
	initialize : function(form, options){
		this.options = Object.extend({
			onSubmit : true,
			stopOnFirst : false,
			immediate : false,
			focusOnError : true,
			useTitles : false,
			onFormValidate : function(result, form) { return result; },
			onElementValidate : function(result, elm) { return result; }
		}, options || {});
		this.form = $(form);
		if(this.options.onSubmit) Event.observe(this.form,'submit',this.onSubmit.bind(this),false);
		if(this.options.immediate) {
			var useTitles = this.options.useTitles;
			var callback = this.options.onElementValidate;
			Form.getElements(this.form).each(function(input) { // Thanks Mike!
				Event.observe(input, 'blur', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
				if (input.type == "checkbox" || input.type == "radio") {
					Event.observe(input, 'click', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
				}
				else if (input.type.indexOf("select") > -1) {
					Event.observe(input, 'change', function(ev) { Validation.validate(Event.element(ev),{useTitle : useTitles, onElementValidate : callback}); });
				}
			});
		}
	},
	onSubmit :  function(ev){
		if(!this.validate()) Event.stop(ev);
	},
	validate : function() {
		var result = false;
		var useTitles = this.options.useTitles;
		var callback = this.options.onElementValidate;
		if(this.options.stopOnFirst) {
			result = Form.getElements(this.form).all(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); });
		} else {
			result = Form.getElements(this.form).collect(function(elm) { return Validation.validate(elm,{useTitle : useTitles, onElementValidate : callback}); }).all();
		}
		if(!result && this.options.focusOnError) {
			try{
				Form.getElements(this.form).findAll(function(elm){return $(elm).hasClassName('validation-failed')}).first().focus()
			}catch(e){}
		}
		result = this.options.onFormValidate(result, this.form);
		return result;
	},
	reset : function() {
		Form.getElements(this.form).each(Validation.reset);
	}
}

Object.extend(Validation, {
	validate : function(elm, options){
		options = Object.extend({
			useTitle : false,
			onElementValidate : function(result, elm) {}
		}, options || {});
		elm = $(elm);
		var cn = elm.classNames();
		return result = cn.all(function(value) {
			var test = Validation.test(value,elm,options.useTitle);
			options.onElementValidate(test, elm);
			return test;
		});
	},
	test : function(name, elm, useTitle) {
		var v = Validation.get(name);
		var prop = '__advice'+name.camelize();
		try {
		if(Validation.isVisible(elm) && !v.test($F(elm), elm)) {
			if(!elm[prop]) {
				var advice = Validation.getAdvice(name, elm);
				if(advice == null) {
					var errorMsg = useTitle ? ((elm && elm.title) ? elm.title : v.error) : v.error;
					advice = '<div class="validation-advice" id="advice-' + name + '-' + Validation.getElmID(elm) +'" style="display:none">' + errorMsg + '</div>'
					var p = elm.parentNode;
					if(p) {
						new Insertion.Bottom(p, advice);
					} else {
						new Insertion.After(elm, advice);
					}
					advice = Validation.getAdvice(name, elm);
					
					/* validation advice into label*/
					var labels = document.getElementsByTagName('label');
					var idOrName = (elm? elm.getAttribute('id') : name);
					
					for (var i = 0; i < labels.length; ++i){
						var currentNode = labels[i];
						if (currentNode.getAttributeNode('for').nodeValue == idOrName){
							var errorMessageLabel = '<span class="validation-advice-hidden">' + errorMsg + '</span>';
							currentNode.innerHTML += errorMessageLabel;
							break;
						}
					}
					
					
				}
				if(typeof Effect == 'undefined') {
					advice.style.display = 'block';
				} else {
					new Effect.Appear(advice, {duration : 1 });
				}
			}
			elm[prop] = true;
			elm.removeClassName('validation-passed');
			elm.addClassName('validation-failed');
			
			return false;
		} else {
			var advice = Validation.getAdvice(name, elm);
			if(advice != null) advice.hide();
			
			/* remove validation advice from label */
			var labels = document.getElementsByTagName('label');
			var idOrName = (elm? elm.getAttribute('id') : name);
			
			for (var i = 0; i < labels.length; ++i){
				var currentNode = labels[i];
				if (currentNode.getAttributeNode('for').nodeValue == idOrName){
					var childNodes = currentNode.childNodes;
					if (childNodes){
						for (var j = 0; j < childNodes.length; ++j){
							//alert(childNodes[j].nodeName);
							if (childNodes[j].nodeName.toLowerCase() == 'span'){
								currentNode.removeChild(childNodes[j]);
								break;
							}
						}
					}
					//alert(currentNode.innerHTML);
					break;
				}
			}
			
			elm[prop] = '';
			elm.removeClassName('validation-failed');
			elm.addClassName('validation-passed');
			return true;
		}
		} catch(e) {
			throw(e)
		}
	},
	isVisible : function(elm) {
		while(elm.tagName != 'BODY') {
			if(!$(elm).visible()) return false;
			elm = elm.parentNode;
		}
		return true;
	},
	getAdvice : function(name, elm) {
		return $('advice-' + name + '-' + Validation.getElmID(elm)) || $('advice-' + Validation.getElmID(elm));
	},
	getElmID : function(elm) {
		return elm.id ? elm.id : elm.name;
	},
	reset : function(elm) {
		elm = $(elm);
		var cn = elm.classNames();
		cn.each(function(value) {
			var prop = '__advice'+value.camelize();
			if(elm[prop]) {
				var advice = Validation.getAdvice(value, elm);
				advice.hide();
				elm[prop] = '';
			}
			elm.removeClassName('validation-failed');
			elm.removeClassName('validation-passed');
		});
	},
	add : function(className, error, test, options) {
		var nv = {};
		nv[className] = new Validator(className, error, test, options);
		Object.extend(Validation.methods, nv);
	},
	addAllThese : function(validators) {
		var nv = {};
		$A(validators).each(function(value) {
				nv[value[0]] = new Validator(value[0], value[1], value[2], (value.length > 3 ? value[3] : {}));
			});
		Object.extend(Validation.methods, nv);
	},
	get : function(name) {
		return  Validation.methods[name] ? Validation.methods[name] : Validation.methods['_LikeNoIDIEverSaw_'];
	},
	methods : {
		'_LikeNoIDIEverSaw_' : new Validator('_LikeNoIDIEverSaw_','',{})
	}
});



var sRequired = "Veuillez remplir ce champ obligatoire.";
var sValidateNumber = "Veuillez saisir un chiffre valide.";
var sValidateNumbers = "Veuillez saisir des chiffre valides.";
var sValidateDigits = "Veuillez saisir des chiffres valides sans espaces virgules ni points.";
var sValidateAlpha = "Ce champ doit comporter des lettres (a-z) uniquement.";
var sValidateAlphanum = "Ce champ doit comporter des lettres (a-z) ou des chiffres (0-9) uniquement.";
var sValidateDate = "Veuillez saisir une date valide (format: jj.mm.aaaa).";
var sValidateDatePast = "Veuillez entrer une date se situant dans le pass&#233; (format jj.mm.aaaa).";
var sValidateDateAfter = "Veuillez entrer une date se situant dans le future (format jj.mm.aaaa).";
var sValidateTime = "Please enter a valid time.";
var sValidatePhone = "Veuillez entrer un num&#233;ro de t&#233;l&#233;phone valide. Exemple: +41 45 121 12 12";
var sValidateFax = "Veuillez entrer un num&#233;ro de fax valide. Exemple: +41 45 121 12 12";
var sValidateMobile = "Veuillez entrer un num&#233;ro de t&#233;l&#233;phone mobile valide. Exemple: +41 45 121 12 12";
var sValidateEmail = "Veuillez entrer une adresse e-mail valide. Exemple: fred@domain.com";
var sValidateUrl = "Veuillez entrer une adresse URL valide.";
var sValidateDateAu = "Veuillez utiliser le format suivant: jj/mm/aaaa. Exemple: 17/03/2006 pour le 17 mars 2006.";
var sValidateCurrencyDollar = "Veuillez saisir un montant valide en $. Exemple: $ 100.00.";
var sValidateSelection = "Veuillez s&#233;lectionner un &#233;l&#233;ment.";
var sValidateOneRequired = "Veuillez s&#233;lectionner l'une des options ci-dessus.";
var sValidateKUDINachforschungAuslandSender = "Une demande de recherche peut &#234;tre lanc&#233;e uniquement par l&#8217;exp&#233;diteur. En tant que destinataire veuillez svp prendre contact avec l&#8217;exp&#233;diteur afin que celui-ci puisse lancer une recherche aupr&#232;s de la Poste &#233;trang&#232;re.";
var sValidateKUDILaufzeit = "Lancer une recherche uniquement si le d&#233;lai d&#8217;acheminement est d&#233;pass&#233;. La dur&#233;e de transport est la dur&#233;e moyenne que n&#233;cessite votre envoi pour parvenir &#224; son destinataire. Les d&#233;lais d&#8217;acheminement publi&#233;s sont indiqu&#233;s en jours ouvrables (lundi - vendredi) le jour du d&#233;p&#244;t n&#8217;&#233;tant pas compris.";
var sValidateKUDIAttachment = "Ce format n'est pas valable. Veuillez utiliser l&#8217;un des types de fichier ci-apr&#232;s: bmp doc docx eml htm html jpeg jpg pdf tif tiff txt.";
var sValidateCardDate = "Pour la date veuillez appliquer le format suivant: mm/yyyy. Exemple 03/2006";
var sValidateMaxLength6 = "Veuillez saisir 6 caract&#232;res au maximum.";
var sValidateMaxLength8 = "Veuillez saisir 8 caract&#232;res au maximum.";
var sValidateMaxLength10 = "Veuillez saisir 10 caract&#232;res au maximum.";
var sValidateMaxLength40 = "Veuillez saisir 40 caract&#232;res au maximum.";
var sValidateMaxLength255 = "Veuillez saisir 255 caract&#232;res au maximum.";
var sValidateMaxLength2000 = "Veuillez saisir 2000 caract&#232;res au maximum.";
var sValidateLength4 = "Veuillez saisir 4 caract&#232;res.";
var sValidateLength6 = "Veuillez saisir 6 caract&#232;res.";
var sValidateLength7 = "Veuillez saisir 7 caract&#232;res.";
var sValidateLength8 = "Veuillez saisir 8 caract&#232;res.";
var sValidateLength9 = "Veuillez saisir 9 caract&#232;res.";
var sValidateLength10 = "Veuillez saisir 10 caract&#232;res.";
var sValidateMinValue100 = "La valeur saisie doit &#234;tre &#233;quivalente ou sup&#233;rieure &#224; 100.";
var sValidateMinValue1000 = "La valeur saisie doit &#234;tre &#233;quivalente ou sup&#233;rieure &#224; 1000.";
var sValidateMaxValue3 = "La valeur saisie doit &#234;tre max. 3.";
var sValidateMaxValue200 = "La valeur saisie doit &#234;tre max. 200.";
var sValidateRRN = "Veuillez donner un num&#233;ro de r&#233;f&#233;rence de facture valable (format : 512345678).";
var sValidateZAZ = "Veuillez donner un num&#233;ro de compte PCD valable (format : 1234-5).";
var sValidateVAT = "Veuillez donner un num&#233;ro de compte TVA valable (format : 1234-5).";
var sValidateImageFlash = "Please upload an image or flash file.";
var sValidateImage = "Please upload an image.";
var sValidateFileCSV = "Pri&#232;re de t&#233;l&#233;charger un fichier Microsoft Excel (CSV).";
var sValidateWebcodesPAG = "Some of these WebCodes were already used.";
var sValidateUrlCharacters = "Please only insert alpha-numeric characters points dashes or underscores.";
var sValidateUrlPAG = "URL-Tag bereits vorhanden oder beginnt mit &quot;pag-&quot;.";
var sValidateNamePAG = "Dieser Name ist bereits vorhanden.";
var sValidateTillPAG = "Enddatum ist vor Startdatum.";
var sValidatePointsPAG = "Bitte definieren Sie mindestens einen Haupt-POI.";
var sValidateFile5MB = "La taille du fichier ne peut pas exc&#233;der 5MB.";
var sValidateTrackTraceValidNumber = "Veuillez indiquer un num&#233;ro d'envoi valable.";
var sValidateTrackTraceInternational = "Cet envoi a &#233;t&#233; d&#233;pos&#233; &#224; l'&#233;tranger. Veuillez vous adresser &#224; l'office de d&#233;p&#244;t pour proc&#233;der &#224; la recherche de cet envoi.";
var sValidateTrackTraceInland = "Le num&#233;ro d'envoi entr&#233; n'est pas un num&#233;ro d'un envoi du service int&#233;rieur.";
var sValidateTrackTraceAusland = "Le num&#233;ro d'envoi entr&#233; n'est pas un num&#233;ro d'un envoi du service international.";
var sValidateAttributesPAG = "Bitte w&#228;hlen Sie von jeder Kategorie mind. ein Attribut.";
var sValidateGeneralTerms = "Veuillez accepter les conditions d'utilisation.";
var sValidateUseradminUsername = "Der Benutzername existiert bereits fuer das ausgewaehlte Projekt.";
var sValidateEventCodeAdmin = "Entrez un code qui n'est pas encore utilis&#233; pour cette manifestation ou laissez ce champ vide pour g&#233;n&#233;rer un nouveau code.";
var sValidateEventCode = "Veuillez entrer un code valable.";
var sValidateEventTerm = "Le d&#233;lai d'inscription doit se situer avant la date de la manifestation.";
var sValidateGlobalPoi = "Un Poi ne peut pas posseder d'offre attache";

/*
 * Really easy field validation with Prototype
 * http://tetlaw.id.au/view/javascript/really-easy-field-validation
 * Andrew Tetlaw
 * (Original Version 1.5.4.2 (2008-05-15))
 * @version 1.5.4.4unic1
 * 
 * @changelog 1.5.4.1unic1/AlR:		validate--required: added check for serverside functioning.
 *									and clientside validation by name instead of by parent element.<br/>
 *									validate-selection: added check for serverside functioning.
 * @changelog 1.5.4.2unic1/KeB		add the validator "checklast"
 * @changelog 1.5.4.3unic1/PhR		replaced the validator "validate-email" 
 * @changelog 1.5.4.4unic1/PhR		added several new validators for the reiseapplikation
 *
 * Copyright (c) 2007 Andrew Tetlaw
 * Permission is hereby granted, free of charge, to any person
 * obtaining a copy of this software and associated documentation
 * files (the "Software"), to deal in the Software without
 * restriction, including without limitation the rights to use, copy,
 * modify, merge, publish, distribute, sublicense, and/or sell copies
 * of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 * 
 * The above copyright notice and this permission notice shall be
 * included in all copies or substantial portions of the Software.
 * 
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 * 
 */

Validation.add('IsEmpty', '', function(v) {
				return  ((v == null) || (v.length == 0)); // || /^\s+$/.test(v));
			});

Validation.addAllThese([
	['required', sRequired, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-number', sValidateNumber, function(v) {
				return Validation.get('IsEmpty').test(v) || (!isNaN(v) && !/^\s+$/.test(v));
			}],
	['validate-digits', sValidateDigits, function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/[^\d]/.test(v);
			}],
	['validate-alpha', sValidateAlpha, function (v) {
				return Validation.get('IsEmpty').test(v) ||  /^[a-zA-Z]+$/.test(v)
			}],
	['validate-alphanum', sValidateAlphanum, function(v) {
				return Validation.get('IsEmpty').test(v) ||  !/\W/.test(v)
			}],
	['validate-date', sValidateDate, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_slash = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				var regex_dot = /^(\d{2})\.(\d{2})\.(\d{4})$/;
				var regex_dash = /^(\d{2})\-(\d{2})\-(\d{4})$/;
				if(!regex_slash.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf("/") > -1) {
					
					d = new Date(v.replace(regex_slash, '$2/$1/$3'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '$2/$1/$3'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '$2/$1/$3'));
				}
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-date-past', sValidateDatePast, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_slash = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				var regex_dot = /^(\d{2})\.(\d{2})\.(\d{4})$/;
				var regex_dash = /^(\d{2})\-(\d{2})\-(\d{4})$/;
				if(!regex_slash.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf("/") > -1) {
					
					d = new Date(v.replace(regex_slash, '$2/$1/$3'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '$2/$1/$3'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '$2/$1/$3'));
				}
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
						( parseInt(RegExp.$1, 10) == d.getDate() ) && 
						( parseInt(RegExp.$3, 10) == d.getFullYear() ) &&
						( d.getTime() < (new Date()).getTime() );
			}],
	['validate-date-after', sValidateDateAfter, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_slash = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				var regex_dot = /^(\d{2})\.(\d{2})\.(\d{4})$/;
				var regex_dash = /^(\d{2})\-(\d{2})\-(\d{4})$/;
				if(!regex_slash.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf("/") > -1) {
					
					d = new Date(v.replace(regex_slash, '$2/$1/$3'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '$2/$1/$3'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '$2/$1/$3'));
				}
				var dToday = new Date();
				var dDay = dToday.getDate();
				var dMonth = dToday.getMonth();
				var dYear = dToday.getFullYear();
				dToday = new Date(dYear, dMonth, dDay);
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
						( parseInt(RegExp.$1, 10) == d.getDate() ) && 
						( parseInt(RegExp.$3, 10) == d.getFullYear() ) &&
						( d.getTime() >= dToday.getTime() );
			}],
	['validate-date-time', sValidateDate, function(v) {
				return Validation.get('IsEmpty').test(v) || /\d{1,2}\.\d{1,2}\.\d{4}/.test(v)
			}],
	['validate-url-characters', sValidateUrlCharacters, function(v) {
				return Validation.get('IsEmpty').test(v) || /^([A-Z0-9\._-]*)$/i.test(v);
			}],
	['validate-general-terms', sValidateGeneralTerms, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
	['validate-ra-url', sValidateUrlPAG, function(v, elm) {
				
				var sAddCondition = "";
				var bReturn = false;
				if (elm) {
					if (elm.value.indexOf("pag-") != 0) {
						bReturn = true;
					}
				}
				else {
					try {
						if (v) {
							if (v.indexOf("pag-") != 0) {							
								if (request.id) { 
									sAddCondition = " AND offr_id <> " + request.id;
								}
								var oDAO = new DAOLayerDb();
								var sSql = "!nocache: SELECT count(*) FROM tbl_ra_offer WHERE offr_shorturl = " + SecurityUtil.sqlEscape(v) + sAddCondition;
								var iCount = oDAO.read(sSql);
								
								if (iCount == 0) {
									bReturn = true;	
								}
							}
						}
						else {
							bReturn = true;	
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-url :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],
			
	['validate-ra-webcodes', sValidateWebcodesPAG, function (v,elm) {
				var bReturn = true;
				if (!elm) {
					var bValidCode = true;
					var sCode, sNumber;
					var asItems = v.replace(/\r/gi, "").split("\n");
					var iItemCount;
					if(asItems.length > 0){
						var sCluster = Properties.getProperty("ReiseApplikation.CLUSTER");
						for (iItemCount = 0; iItemCount < asItems.length; ++iItemCount) {
							sCode = asItems[iItemCount];
							if (sCode != "") {
								bValidCode = Util.ValidWebcode(sCluster + "-" + sCode, null, request.id);
								if ((isNaN(sCode) || /^\s+$/.test(sCode)) || !bValidCode) {
									bReturn = false;
									break;
								}
							}
						}
					}
				}
				return bReturn;
			}],
			
	['validate-ra-pois', sValidatePointsPAG, function (v,elm) {
				if(Validation.get('IsEmpty').test(v)) return false;
				if (v) {
					var aPOIs = v.split(",");
					for (var iCount = 0; iCount < aPOIs.length; ++iCount) {
						if (aPOIs[iCount].split("$")[1] == "1") {
							return true;
						}
					}
				}
				return false;
			}],
			
	['validate-ra-attributes', sValidateAttributesPAG, function (v,elm) {
				if (!elm) {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							oDAO.openConnection();
							var sSql = "!nocache: SELECT COUNT(DISTINCT cat_id) FROM tbl_ra_attribute WHERE attr_id IN (" + v + ")";
							var iCount = oDAO.read(sSql);
							var iTotal = oDAO.read("!nocache: SELECT COUNT(cat_id) FROM tbl_ra_category WHERE cat_filter = 1");
							if (parseInt(iCount) != parseInt(iTotal)) {
								return false;
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-attributes :: " + oException.message);	
					}
					finally {
						if (oDAO) {
							oDAO.closeConnection();
						}
					}
				}
				return true;
			}],
			
	['validate-ra-thumbnail', sRequired, function (v,elm) {
				if (elm) {
					var oInput = $(elm.id + "_id");
					if (oInput && oInput.value != "" && oInput.value != "null") {
						return true;
					}
					else {
						if(Validation.get('IsEmpty').test(v)) return false;
					}
				}
				return true;
			}],
						
	['validate-ra-offer-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT offr_id FROM tbl_ra_offer WHERE offr_title = " + SecurityUtil.sqlEscape(v);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-offer-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
			
	['validate-ra-poi-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT poi_id FROM tbl_ra_poi WHERE poi_title = " + SecurityUtil.sqlEscape(v);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-poi-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
			
	['validate-ra-route-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT route_id FROM tbl_ra_route WHERE route_title = " + SecurityUtil.sqlEscape(v);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-route-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
		
	['validate-ra-movie-name', sValidateNamePAG, function (v,elm) {
			var bReturn = false;
			if (elm) {
				bReturn = true;
			}
			else {
				try {
					if (v) {						
						var oDAO = new DAOLayerDb();
						var sSql = "!nocache: SELECT mov_id FROM tbl_ra_movie WHERE mov_title = " + SecurityUtil.sqlEscape(v);
						var aReturn = oDAO.read(sSql);
						
						if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
							bReturn = true;	
						}
					}
				}
				catch (oException) {
					Log4O.error("forms-add validators :: validate-ra-movie-name :: " + oException.message);	
				}
			}
			return bReturn;
		}],	
			
	['validate-ra-till', sValidateTillPAG, function (v,elm) {
				if (elm) {			
					var oFrom = $('valid_from');
					if (oFrom && oFrom.value != "") {
						if(Validation.get('IsEmpty').test(v)) return true;
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var f = new Date(oFrom.value.replace(regex, '$2/$1/$3'));
						var t = new Date(v.replace(regex, '$2/$1/$3'));
						if (t>=f) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				else {
					if (!v || (v == "")) {
						return true;
					}
					if (request.valid_from && request.valid_from != "") {
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var dFrom = new Date(request.valid_from.replace(regex, '$2/$1/$3'));
						var dTill = new Date(v.replace(regex, '$2/$1/$3'));
						if (dTill>=dFrom ) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				return false;
			}],
			
	['validate-ra-url-poi', sValidateUrlPAG, function(v, elm) {
				
				var sAddCondition = "";
				var bReturn = false;
				if (elm) {
					if (elm.value.indexOf("pag-") != 0) {
						bReturn = true;
					}
				}
				else {
					try {
						if (v) {
							if (v.indexOf("pag-") != 0) {							
								if (request.id) { 
									sAddCondition = " AND poi_id <> " + request.id;
								}
								var oDAO = new DAOLayerDb();
								var sSql = "!nocache: SELECT count(*) FROM tbl_ra_poi WHERE poi_shorturl = " + SecurityUtil.sqlEscape(v) + sAddCondition;
								var iCount = oDAO.read(sSql);
								
								if (iCount == 0) {
									bReturn = true;	
								}
							}
						}
						else {
							bReturn = true;	
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-ra-url-poi :: " + oException.message);	
					}
				}
				
				return bReturn;
			}],
	['validate-shortcut-name', sValidateNamePAG, function (v,elm) {
				var bReturn = false;
				if (elm) {
					bReturn = true;
				}
				else {
					try {
						if (v) {						
							var oDAO = new DAOLayerDb();
							var sSql = "!nocache: SELECT sc_id FROM tbl_shortcut WHERE sc_name = " + SecurityUtil.sqlEscape(v) + " AND sc_clusterconfig_id = " + SecurityUtil.sqlEscape(request.clusters);
							var aReturn = oDAO.read(sSql);
							
							if (!aReturn || aReturn.length == 0 || aReturn == request.id) {
								bReturn = true;	
							}
						}
					}
					catch (oException) {
						Log4O.error("forms-add validators :: validate-shortcut-name :: " + oException.message);	
					}
				}
				return bReturn;
			}],
	['validate-time', sValidateTime, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex_double = /^(\d{2})\:(\d{2})$/;
				var regex_dot = /^(\d{2})\.(\d{2})$/;
				var regex_dash = /^(\d{2})\-(\d{2})$/;
				if(!regex_double.test(v) && !regex_dot.test(v) && !regex_dash.test(v)) return false;
				var d;
				if(v.indexOf(":") > -1) {
					
					d = new Date(v.replace(regex_double, '01/01/1970 $1:$2'));
				}
				else if(v.indexOf(".") > -1) {
					
					d = new Date(v.replace(regex_dot, '01/01/1970 $1:$2'));
				}
				else if(v.indexOf("-") > -1) {
					
					d = new Date(v.replace(regex_dash, '01/01/1970 $1:$2'));
				}
				return ( ( parseInt(RegExp.$2, 10) == (d.getMinutes()) ) && 
							(parseInt(RegExp.$1, 10) == d.getHours()) );
			}],
	['validate-phone', sValidatePhone, function (v) {
				return Validation.get('IsEmpty').test(v) || /[0|\+]{1}[0-9|\ ]{6,}$/.test(v)
			}],
	['validate-fax', sValidateFax, function (v) {
				return Validation.get('IsEmpty').test(v) || /[0|\+]{1}[0-9|\ ]{6,}$/.test(v)
			}],
	['validate-mobile', sValidateMobile, function (v) {
				return Validation.get('IsEmpty').test(v) || /[0|\+]{1}[0-9|\ ]{6,}$/.test(v)
			}],
	['validate-email', sValidateEmail, function (v) {
				return Validation.get('IsEmpty').test(v) || /^([a-zA-Z0-9_.-])+@([a-zA-Z0-9_.-])+\.([a-zA-Z0-9_.-])+([a-zA-Z0-9_.-])+/.test(v);
			}],
	['validate-url', sValidateUrl, function (v) {
				return Validation.get('IsEmpty').test(v) || /^((http|https|ftp):\/\/)?(([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-shortcut-url', sValidateUrl, function (v) {
				return Validation.get('IsEmpty').test(v) || /^((http|https|ftp):\/\/)?((&[^\s]*;)?([\<\!WEM\s]*)?([A-Z0-9][A-Z0-9_-]*)(\.[A-Z0-9][A-Z0-9_-]*)+)(:(\d+))?\/?/i.test(v)
			}],
	['validate-date-au', sValidateDateAu, function(v) {
				if(Validation.get('IsEmpty').test(v)) return true;
				var regex = /^(\d{2})\/(\d{2})\/(\d{4})$/;
				if(!regex.test(v)) return false;
				var d = new Date(v.replace(regex, '$2/$1/$3'));
				return ( parseInt(RegExp.$2, 10) == (1+d.getMonth()) ) && 
							(parseInt(RegExp.$1, 10) == d.getDate()) && 
							(parseInt(RegExp.$3, 10) == d.getFullYear() );
			}],
	['validate-card-date', sValidateCardDate, function(v) {
				return Validation.get('IsEmpty').test(v) || /^(\d{2})\/(\d{4})$/.test(v);
			}],
	['validate-currency-dollar', sValidateCurrencyDollar, function(v) {
				// [$]1[##][,###]+[.##]
				// [$]1###+[.##]
				// [$]0.##
				// [$].##
				return Validation.get('IsEmpty').test(v) ||  /^\$?\-?([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v)
			}],
			
	/* dropdownlists */
	['validate-selection', sValidateSelection, function(v,elm){
				/* clientside javascript */
				if (elm){
					return elm.options ? elm.selectedIndex > 0 : !Validation.get('IsEmpty').test(v);
				}
				/* serverside ll script */
				else{
					return !Validation.get('IsEmpty').test(v);
				}
			}],
	
	/* checkboxes, radiobuttons */
	['validate-one-required', sValidateOneRequired, function (v,elm) {
				/* clientside javascript */
				if(elm){
					var sName = elm.getAttribute('name');
					var options = document.getElementsByName(sName);
					return $A(options).any(function(elm) {
						return $F(elm);
					});
				}
				/* serverside ll script */
				else{
					return !Validation.get('IsEmpty').test(v);
				}
			}],
			
	['validate-kudi-nachforschung-ausland-sender', sValidateKUDINachforschungAuslandSender, function (v,elm) {
				/* clientside javascript */
				if(elm){
					var sName = elm.getAttribute('name');
					var options = document.getElementsByName(sName);
					return $A(options).any(function(elm) {
						return $F(elm);
					});
				}
				/* serverside ll script */
				else{
					return !Validation.get('IsEmpty').test(v);
				}
			}],
			
	['validate-kudi-laufzeit', sValidateKUDILaufzeit, function(v) {
				return !Validation.get('IsEmpty').test(v);
			}],
			
	['validate-kudi-attachment', sValidateKUDIAttachment, function(v,elm) {
				
				var sFileName = "";
				
				if (elm)
				{
					/* clienside javascript */
					sFileName = v;
				}
				else
				{
					/* serverside javascript */
					sFileName = v.name;
				}
				
				var bIsEmpty = Validation.get('IsEmpty').test(sFileName);

				if (bIsEmpty)
				{
					return true;
				}
				else
				{
					var sFileExtension = sFileName.substr(sFileName.lastIndexOf(".") + 1).toLowerCase();

					if (sFileExtension == "bmp" ||
						sFileExtension == "doc" ||
						sFileExtension == "docx" ||
						sFileExtension == "eml" ||
						sFileExtension == "htm" ||
						sFileExtension == "html" ||
						sFileExtension == "jpeg" ||
						sFileExtension == "jpg" ||
						sFileExtension == "pdf" ||
						sFileExtension == "tif" ||
						sFileExtension == "tiff" ||
						sFileExtension == "txt")
					{
						return true;
					}
					else
					{
						return false;
					}
				}
			}],
			
	['validate-number-list', sValidateNumbers, function (v,elm) {
				var asItems = v.replace(/\r/gi, "").split("\n");
				var bReturn = true;
				var iItemCount;
				if(asItems.length > 0){
					for (iItemCount = 0; iItemCount < asItems.length; ++iItemCount) {
						if (isNaN(asItems[iItemCount]) || /^\s+$/.test(asItems[iItemCount])) {
							bReturn = false;	
						}
					}
				}
				return bReturn;
			}],
			
	['validate-image-flash', sValidateImageFlash, function (v,elm) {
				/* clientside javascript */
				var bValid = false;
				var iTypeCount, oMimeType;
				var asPossibleTypes = new Array(".jpg", ".gif", ".png", ".jpeg", ".swf");
				var aiPossibleMimeTypes = new Array(1, 2, 3, 4, 29, 101, 130);
				if(elm){
					return true;
				}
				/* serverside ll script */
				else{
					if (v && v.Mimetype && v.Mimetype != "application/octet-stream") {
						for (iTypeCount = 0; iTypeCount < aiPossibleMimeTypes.length; ++iTypeCount) {
							oMimeType = mimeTypes.fromId(aiPossibleMimeTypes[iTypeCount]);
							if (v.Mimetype == oMimeType.mimeType) {
								bValid = true;
								break;
							}	
						}						
					}
					else {
						bValid = true;	
					}
				}
				return bValid;
			}],
			
	['validate-image', sValidateImage, function (v,elm) {
				/* clientside javascript */
				var bValid = false;
				var iTypeCount, oMimeType;
				var asPossibleTypes = new Array(".jpg", ".gif", ".png", ".jpeg");
				var aiPossibleMimeTypes = new Array(1, 2, 3, 4, 101, 130);
				if(elm){
					return true;
				}
				/* serverside ll script */
				else{
					if (v && v.Mimetype && v.Mimetype != "application/octet-stream") {
						for (iTypeCount = 0; iTypeCount < aiPossibleMimeTypes.length; ++iTypeCount) {
							oMimeType = mimeTypes.fromId(aiPossibleMimeTypes[iTypeCount]);
							if (v.Mimetype == oMimeType.mimeType) {
								bValid = true;
								break;
							}	
						}						
					}
					else {
						bValid = true;	
					}
				}
				return bValid;
			}],
			
	['validate-file-csv', sValidateFileCSV, function (v,elm) {
				/* clientside javascript */
				var bValid = false;
				var iTypeCount, oMimeType, sExtension;
				var aiPossibleMimeTypes = new Array();
				aiPossibleMimeTypes.push(129);
				if(elm){
					return true;
				}
				/* serverside ll script */
				else{
					if (v && v.Mimetype && v.name) {
						sExtension = v.name.substr(v.name.lastIndexOf(".") + 1);
						for (iTypeCount = 0; iTypeCount < aiPossibleMimeTypes.length; ++iTypeCount) {
							oMimeType = mimeTypes.fromId(aiPossibleMimeTypes[iTypeCount]);
							if (v.Mimetype == oMimeType.mimeType && Util.inArray(sExtension, oMimeType.fileExt.split(","))) {
								bValid = true;
								break;
							}
						}
					}
					else {
						bValid = true;	
					}
				}
				return bValid;
			}],
			
	['validate-one-required-seminar', sValidateSelection, function (v,elm) {
				return Validation.get('validate-one-required').test(v, elm);
			}],			
	
	/* captcha */
	['information_4', ' ', function(v) {
				return Validation.get('IsEmpty').test(v);
			}],
	['information_5', ' ', function(v) {
				return v=='Die Post';
			}],

	/* validate for a max length */
	['validate-maxlength-6', sValidateMaxLength6, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 6;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 6;
				}
			}],
	['validate-maxlength-8', sValidateMaxLength8, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 8;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 8;
				}
			}],
	['validate-maxlength-10', sValidateMaxLength10, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 10;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 10;
				}
			}],
	['validate-maxlength-40', sValidateMaxLength40, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 40;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 40;
				}
			}],
	['validate-maxlength-255', sValidateMaxLength255, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 255;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 255;
				}
			}],
	['validate-maxlength-2000', sValidateMaxLength2000, function (v,elm) {
	
				if (elm)
				{
					return Validation.get('IsEmpty').test(v) || v.length <= 2000;
				}
				else
				{
					return Validation.get('IsEmpty').test(v) || FormatUtil.HTML2LATIN1(v).length <= 2000;
				}
			}],
			
	/* validate for a specific length */
	['validate-length-4', sValidateLength4, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==4;
			}],
	['validate-length-6', sValidateLength6, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==6;
			}],	
	['validate-length-7', sValidateLength7, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==7;
			}],	
	['validate-length-8', sValidateLength8, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==8;
			}],	
	['validate-length-9', sValidateLength9, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==9;
			}],
	['validate-length-10', sValidateLength10, function (v) {
				return Validation.get('IsEmpty').test(v) || v.length==10;
			}],		
	
	/* validate for a min value */
	
	['validate-maxvalue-3', sValidateMaxValue3, function(v) {
				return Validation.get('IsEmpty').test(v) || v<4;
			}],
	['validate-maxvalue-200', sValidateMaxValue200, function(v) {
				return Validation.get('IsEmpty').test(v) || v<201;
			}],
	['validate-minvalue-100', sValidateMinValue100, function(v) {
				return Validation.get('IsEmpty').test(v) || v>99;
			}],
	['validate-minvalue-1000', sValidateMinValue100, function(v) {
				return Validation.get('IsEmpty').test(v) || v>999;
			}],	
						
	/* custom */
	['checkLast', '', function(v, elm) {
				if (elm) {
					var groupElements = document.getElementsByName(elm.name);
					var lastId = '';
					
					if (groupElements.length > 0) {
						lastId = groupElements[groupElements.length-1].id;
					}
					
					if (lastId.length > 0) {
						Validation.validate($(lastId));
					}
				}
				
				return true;
			}],
			
	/* specific */
	['validate-rrn', sValidateRRN, function(v) {
	
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				sValue = sValue.replace(/ /g, "");
				
				if (sValue.length == 9)
				{
					var sRRN = sValue.substring(0, sValue.length - 1);
					var sCheck = sValue.substring(sValue.length - 1, sValue.length);
			
					var Num = new String(sRRN);
					var ModTab = new Array(0,9,4,6,8,2,7,1,3,5);
					var Uebertrag = 0;
			
					for (var i = 0; i < Num.length; i++)
					{
						Uebertrag = ModTab[(Uebertrag + parseInt(Num.charAt(i))) % 10];
					}
			
					var sModulo10 = (10 - Uebertrag) % 10;
					
					if (sCheck == sModulo10)
					{
						bResult = true;
					}
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],
		
	['validate-zaz', sValidateZAZ, function(v) {
	
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				var oRegEx = /[0-9]{4}-[0-9]{1}/;
				var oResult = oRegEx.exec(sValue);
				
				if (sValue.length == 6 &&
					oResult &&
					oResult.index == 0)
				{
					bResult = true;
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],
		
	['validate-vat', sValidateVAT, function(v) {
	
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				var oRegEx = /[0-9]{4}-[0-9]{1}/;
				var oResult = oRegEx.exec(sValue);
				
				if (sValue.length == 6 &&
					oResult &&
					oResult.index == 0)
				{
					bResult = true;
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-file-5mb', sValidateFile5MB, function(v,elm){
				/* clientside javascript */
				if (elm){
					return true;
				}
				/* serverside ll script */
				else{
					var bReturn = true;
					if (v) {
						var oObject = new WebObject(WebObject.PICTURE);
						oObject.rawData = v;
						if (oObject.rawSize > 5242880) {
							bReturn = false;
						}
						oObject = null;
					}
					return bReturn;
				}
		}],

	['validate-tracktrace-international', sValidateTrackTraceInternational, function(v,elm){
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				var oRegEx = /^(.*)([A-Za-z]{2})$/;
				bResult = oRegEx.test(sValue);
				
				if (bResult) {
					oRegEx = /^[^(ui)](.*)ch$/;
					bResult = oRegEx.test(sValue.toLowerCase());
				} else {
					bResult = true;
				}
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-tracktrace-inland', sValidateTrackTraceInland, function(v,elm){
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				
				var oRegEx = /^(.*)([A-Za-z]{2})$/;
				bResult = !oRegEx.test(sValue);
				
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-tracktrace-ausland', sValidateTrackTraceAusland, function(v,elm){
			var bResult = false;
			var sValue = v;
			
			if (sValue && sValue != "")
			{
				
				var oRegEx = /^(.*)([A-Za-z]{2})$/;
				bResult = oRegEx.test(sValue);
				
			}
			
			return bResult || Validation.get('IsEmpty').test(v);
		}],

	['validate-tracktrace-validnumber', sValidateTrackTraceValidNumber, function(v,elm){
				/* clientside javascript */
				if (elm){
					return true;
				}
				/* serverside ll script */
				else{
					var bReturn = true;
					if (v && v != "") {
						var oClient = new TrackAndTraceWsClient(false);
						var sContent = oClient.ShipmentsSearch(language.current.virtualpath, v);
						if (sContent === false) {
							bReturn = false;
						} else {
							sContent.parse();
							if (!sContent || !sContent.Envelope) {
								bReturn = false;
							} else if (sContent.Envelope.Body && sContent.Envelope.Body.Fault) {
								bReturn = false;
							}
						}
					}
					return bReturn;
				}
		}],
	
	['validate-useradmin-password-required', sRequired, function (v,elm) { 
			if(elm){ 
				return (aPasswordProcessProjects[$('user_project').value] 
						|| !Validation.get('IsEmpty').test(v) 
						|| !Validation.get('IsEmpty').test($('user_password').value));
			} else { 
				return (ExternalUserUtil.projectUsesPasswordProcess(request.user_project) 
						|| !Validation.get('IsEmpty').test(v) 
						|| !Validation.get('IsEmpty').test(request.user_password)); 
			} 
		}],
	
	['validate-useradmin-username', sValidateUseradminUsername, function (v,elm) { 
			if(elm){ 
				return true;
			} else { 
				return ExternalUserUtil.checkUsername(request.id, v, request.user_project); 
			} 
		}],

	['validate-eventcode-admin', sValidateEventCodeAdmin, function(v,elm){
			/* clientside javascript */
			if (elm){
				return true;
			}
			/* serverside ll script */
			else{
				var bReturn = true;
				if (v && v != "") {
					var iGuestId = request.id;
					if (Check.ValidId(iGuestId)) {
						bReturn = !EventUtil.codeExists(v, request.evt_id, iGuestId);
					} else {
						bReturn = !EventUtil.codeExists(v, request.evt_id);
					}
				}
				return bReturn;
			}
		}],
		
	['validate-eventcode', sValidateEventCode, function(v,elm){
			/* clientside javascript */
			if (elm){
				return true;
			}
			/* serverside ll script */
			else{
				var bReturn = true;
				if (v && v != "") {
					bReturn = EventUtil.codeExists(v, request.evt_id);
				}
				return bReturn;
			}
		}],
		
	['validate-globalpoi-offer', sValidateGlobalPoi, function(v,elm){
			/* clientside javascript */
			if (elm){
				var bGlobalC = $('poi_global').checked;
				var sAngeboteC = $('angebote').value;
				if (bGlobalC && sAngeboteC && sAngeboteC.length > 0) {
					return false;
				}
				return true;
			}
			/* serverside ll script */
			else{
				var bGlobal = oForm.getValue('poi_global');
				var sAngebote = oForm.getValue('angebote');
				
				if (bGlobal && sAngebote && sAngebote.length > 0) {
					return false;
				}
				return true;
			}
		}],
	
	['validate-required-image', sRequired, function (v,elm) {
				if (elm) {
					var oInput = $(elm.id + "_id");
					if (oInput && oInput.value != "" && oInput.value != "null") {
						return true;
					}
					else {
						if(Validation.get('IsEmpty').test(v)) return false;
					}
				}
				return true;
			}],
	
		
	['validate-event-term', sValidateEventTerm, function (v,elm) {
				if (elm) {			
					var oDate = $('evt_date');
					if (oDate && oDate.value != "") {
						if(Validation.get('IsEmpty').test(v)) return true;
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var d = new Date(oDate.value.replace(regex, '$2/$1/$3'));
						var t = new Date(v.replace(regex, '$2/$1/$3'));
						if (d>t) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				else {
					if (!v || (v == "")) {
						return true;
					}
					if (request.evt_date && request.evt_date != "") {
						var regex = /^(\d{2})\.(\d{2})\.(\d{4})$/;
						var dDate = new Date(request.evt_date.replace(regex, '$2/$1/$3'));
						var dTerm = new Date(v.replace(regex, '$2/$1/$3'));
						if (dDate>=dTerm ) {
							return true;
						}
					}
					else {
						return true;
					}
				}
				return false;
			}]
])
var fdLocale = {
        fullMonths:[
                "Janvier",
                "F\u00E9vrier",
                "Mars",
                "Avril",
                "Mai",
                "Juin",
                "Juillet",
                "Ao\u00FBt",
                "Septembre",
                "Octobre",
                "Novembre",
                "D\u00E9cembre"
                ],
        fullDays:[
                "Lundi",
                "Mardi",
                "Mercredi",
                "Jeudi",
                "Vendredi",
                "Samedi",
                "Dimanche"
                ],
        dayAbbrs:[
                "Lu",
                "Ma",
                "Me",
                "Je",
                "Ve",
                "Sa",
                "Di"
                ],
        monthAbbrs:[
                "Jan",
                "F\u00E9v",
                "Mar",
                "Avr",
                "Mai",
                "Jui",
                "Juil",
                "Ao\u00FB",
                "Sep",
                "Oct",
                "Nov",
                "D\u00E9c"
                ],
        /* Only stipulate the firstDayOfWeek should the first day not be Monday           
        firstDayOfWeek:1,        
         */         
        titles:[
                "Mois pr\u00E9cedent",
                "Mois suivant",
                "Ann\u00E9e pr\u00E9cedente",
                "Ann\u00E9e suivante",
                "Aujourd\u2019hui",
                "Ouvrir Calendrier",
                "sm",
                "Semaine [[%0%]]/[[%1%]]",
                "Semaine",
                "Choissisez une date",
                "Cliquez et d\u00E9placez",
                "Montre \u201C[[%0%]]\u201D en premier",
                "Aujourd\u2019hui",
                "Date d&#195;&#169;sactiv&#195;&#169; : "
                ]
};
try { datePickerController.loadLanguage(); } catch(err) {}
 

/*! DatePicker v6a MIT/GPL2 @freqdec
	http://www.frequency-decoder.com/2011/10/11/unobtrusive-accessible-datepicker-widgit-v6
*/
var datePickerController = (function datePickerController() {

        var debug               = false,
            isOpera             = Object.prototype.toString.call(window.opera) === "[object Opera]",
            describedBy         = "",
            languageInfo        = parseUILanguage(),
            nbsp                = String.fromCharCode(160),
            datePickers         = {},
            weeksInYearCache    = {},
            bespokeTitles       = {},
            uniqueId            = 0,
            finalOpacity        = 100,
            buttonTabIndex      = true,
            mouseWheel          = true,
            deriveLocale        = false,
            localeImport        = false,
            nodrag              = false,            
            returnLocaleDate    = false,              
            kbEvent             = false,
            cellFormat          = "%d %F %Y",
            titleFormat         = "%F %d, %Y",
            statusFormat        = "",
            formatParts         = isOpera ? ["%j"] : ["%j", " %F %Y"],
            dPartsRegExp        = /%([d|j])/,
            mPartsRegExp        = /%([M|F|m|n])/,
            yPartsRegExp        = /%[y|Y]/,                                    
            noSelectionRegExp   = /date-picker-unused|out-of-range|day-disabled|not-selectable/,
            formatTestRegExp    = /%([d|j|M|F|m|n|Y|y])/,
            formatSplitRegExp   = /%([d|D|l|j|N|w|S|W|M|F|m|n|t|Y|y])/,
            rangeRegExp         = /^((\d\d\d\d)(0[1-9]|1[012])(0[1-9]|[12][0-9]|3[01]))$/,
            wcDateRegExp        = /^(((\d\d\d\d)|(\*\*\*\*))((0[1-9]|1[012])|(\*\*))(0[1-9]|[12][0-9]|3[01]))$/,            
            wsCharClass         = "\u0009\u000A\u000B\u000C\u000D\u0020\u00A0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029";                                      
                
        (function() {                 
                var scriptFiles = document.getElementsByTagName('script'),
                    json        = parseJSON(String(scriptFiles[scriptFiles.length - 1].innerHTML).replace(/[\n\r\s\t]+/g, " ").replace(/^\s+/, "").replace(/\s+$/, ""));                
               
                if(typeof json === "object" && !("err" in json)) {                          
                        affectJSON(json);
                };
       
                if(deriveLocale && typeof(fdLocale) != "object") {
                        var head   = document.getElementsByTagName("head")[0] || document.documentElement,
                            loc    = scriptFiles[scriptFiles.length - 1].src.substr(0, scriptFiles[scriptFiles.length - 1].src.lastIndexOf("/")) + "/lang/",
                            script,
                            i;
                        
                        for(i = 0; i < languageInfo.length; i++) {                                 
                                script          = document.createElement('script');                                               
                                script.type     = "text/javascript";                         
                                script.src      = loc + languageInfo[i] + ".js"; 
                                script.charSet  = "utf-8";
                                
                                /*@cc_on
                                /*@if(@_win32)
                                var bases = document.getElementsByTagName('base');
                                if (bases.length && bases[0].childNodes.length) {
                                        bases[0].appendChild(script);
                                } else {
                                        document.getElementsByTagName('head')[0].appendChild(script);
                                };
                                bases = null;
                                @else @*/
                                head.appendChild(script);
                                /*@end
                                @*/    
                        };
                        script = null;                      
                } else {
                        returnLocaleDate = true;
                };                              
        })();
        
        // Simple add/remove class methods - they are slow but used rarely
        function addClass(e, c) {
                if(new RegExp("(^|[" + wsCharClass + "])" + c + "([" + wsCharClass + "]|$)").test(e.className)) { 
                        return; 
                };
                e.className += ( e.className ? " " : "" ) + c;
        };
        
        function removeClass(e, c) {
                e.className = !c ? "" : e.className.replace(new RegExp("(^|[" + wsCharClass + "])" + c + "([" + wsCharClass + "]|$)"), " ").replace(new RegExp("/^[" + wsCharClass + "][" + wsCharClass + "]*/"), '').replace(new RegExp("/[" + wsCharClass + "][" + wsCharClass + "]*$/"), '');
        };
        
        // Attempts to parse the current language from the HTML element. Defaults to "en" if none given.
        function parseUILanguage() {                                 
                var languageTag = document.getElementsByTagName('html')[0].getAttribute('lang') || document.getElementsByTagName('html')[0].getAttribute('xml:lang');                
                languageTag = !languageTag ? "en" : languageTag.toLowerCase();                                                            
                return languageTag.search(/^([a-z]{2,3})-([a-z]{2})$/) != -1 ? [languageTag.match(/^([a-z]{2,3})-([a-z]{2})$/)[1], languageTag] : [languageTag];                       
        };
        
        // Cross browser split from http://blog.stevenlevithan.com/archives/cross-browser-split 
        cbSplit = function(str, separator, limit) {
                // if `separator` is not a regex, use the native `split`
                if(Object.prototype.toString.call(separator) !== "[object RegExp]") {
                        return cbSplit._nativeSplit.call(str, separator, limit);
                };

                var output = [],
                    lastLastIndex = 0,
                    flags         = "",
                    separator     = RegExp(separator.source, "g"), 
                    separator2, match, lastIndex, lastLength;

                str = str + "";
                
                if(!cbSplit._compliantExecNpcg) {
                        separator2 = RegExp("^" + separator.source + "$(?!\\s)", flags);
                };

                /* behavior for `limit`: if it's...
                - `undefined`: no limit.
                - `NaN` or zero: return an empty array.
                - a positive number: use `Math.floor(limit)`.
                - a negative number: no limit.
                - other: type-convert, then use the above rules. */
                if(limit === undefined || +limit < 0) {
                        limit = Infinity;
                } else {
                        limit = Math.floor(+limit);
                        if(!limit) {
                                return [];
                        };
                };

                while(match = separator.exec(str)) {
                        lastIndex = match.index + match[0].length; // `separator.lastIndex` is not reliable cross-browser
                        
                        if (lastIndex > lastLastIndex) {
                                output.push(str.slice(lastLastIndex, match.index));
                                
                                // fix browsers whose `exec` methods don't consistently return `undefined` for nonparticipating capturing groups
                                if(!cbSplit._compliantExecNpcg && match.length > 1) {
                                        match[0].replace(separator2, function () {
                                                for (var i = 1; i < arguments.length - 2; i++) {
                                                        if(arguments[i] === undefined) {
                                                                match[i] = undefined;
                                                        };
                                                };
                                        });
                                };
                                
                                if(match.length > 1 && match.index < str.length) {
                                        Array.prototype.push.apply(output, match.slice(1));
                                };
                                
                                lastLength = match[0].length;
                                lastLastIndex = lastIndex;
                                
                                if(output.length >= limit) {
                                        break;
                                };
                        };
                        
                        if(separator.lastIndex === match.index) {
                                // avoid an infinite loop
                                separator.lastIndex++; 
                        };
                };
                
                if(lastLastIndex === str.length) {
                        if (lastLength || !separator.test("")) {
                                output.push("");
                        };
                } else {
                        output.push(str.slice(lastLastIndex));
                };
                
                return output.length > limit ? output.slice(0, limit) : output;
        };
        // NPCG: nonparticipating capturing group
        cbSplit._compliantExecNpcg = /()??/.exec("")[1] === undefined; 
        cbSplit._nativeSplit = String.prototype.split;

        // Affects the JSON passed to the script
        function affectJSON(json) {
                if(!(typeof json === "object")) { 
                        return; 
                };
                
                var key,
                    switchObj = {
                        "debug":function(value) {
                                debug = !!value;
                                return true;
                        },
                        "lang":function(value) {
                                if(typeof value === "string" && value.search(/^[a-z]{2,3}(-([a-z]{2}))?$/i) != -1) {                                                
                                        languageInfo = [value.toLowerCase()];                                                   
                                        returnLocaleDate = true;
                                };
                                return true;
                        },
                        "nodrag":function(value) {
                                nodrag = !!value;
                                return true;
                        },
                        "buttontabindex":function(value) {
                                buttonTabIndex = !!value;
                                return true;        
                        },
                        "derivelocale":function(value) {
                                deriveLocale = !!value;
                                return true;        
                        },
                        "mousewheel":function(value) {
                                mouseWheel = !!value;
                                return true;        
                        },
                        "cellformat":function(value) {
                                if(typeof value === "string") {
                                        parseCellFormat(value);
                                };
                                return true;
                        },
                        "titleformat":function(value) {
                                if(typeof value === "string") {
                                        titleFormat = value;
                                };
                                return true;
                        },
                        "statusformat":function(value) {
                                if(typeof value === "string") {
                                        statusFormat = value;
                                };
                                return true;
                        },
                        "describedby":function(value) {
                                if(typeof value === "string") {
                                        describedBy = value;
                                };
                                return true;
                        },
                        "finalopacity":function(value) {
                                if(typeof value === 'number' && (+value > 20 && +value <= 100)) {
                                        finalOpacity = parseInt(value, 10);
                                };
                                return true; 
                        },
                        "bespoketitles":function(value) {                               
                                if(typeof value === "object") {
                                        bespokeTitles = {};
                                        for(var dt in value) {
                                                if(value.hasOwnProperty(dt) && String(dt).match(wcDateRegExp) != -1) {
                                                        bespokeTitles[dt] = String(value[dt]);
                                                };
                                        };
                                };
                                return true;    
                        },
                        "_default":function() {
                                if(debug) {
                                        throw "Unknown key located within JSON data: " + key;
                                };
                                return true;
                        }
                };
                
                for(key in json) {
                        if(!json.hasOwnProperty(key)) {
                                continue;
                        };                                             
                        (switchObj.hasOwnProperty(String(key).toLowerCase()) && switchObj[key] || switchObj._default)(json[key]);
                };        
        };                  
        
        // Parses the cell format to use whenever the datepicker has keyboard focus
        function parseCellFormat(value) {                  
                if(isOpera) { 
                        // Don't use hidden text for opera due to the default 
                        // browser focus outline stretching outside of the viewport              
                        formatParts = ["%j"];
                        cellFormat  = "%j %F %Y";  
                        return;
                };   
                
                // If no day part stipulated then use presets
                if(value.match(/%([d|j])/) == -1) {
                        return;
                };
                
                // Basic split on the %j or %d modifiers
                formatParts = cbSplit(value, /%([d|j])/);
                cellFormat  = value;               
        };
        
        // Pads a number to "length" 
        function pad(value, length) { 
                length = Math.min(4, length || 2); 
                return "0000".substr(0,length - Math.min(String(value).length, length)) + value; 
        };
        
        // Basic event functions
        function addEvent(obj, type, fn) { 
                try {                 
                        if(obj.attachEvent) {
                                obj.attachEvent("on"+type, fn);
                        } else {
                                obj.addEventListener(type, fn, true);
                        };
                } catch(err) {};
        };
        
        function removeEvent(obj, type, fn) {
                try {
                        if(obj.detachEvent) {
                                obj.detachEvent("on"+type, fn);
                        } else {
                                obj.removeEventListener(type, fn, true);
                        };
                } catch(err) {};
        };   

        function stopEvent(e) {
                e = e || document.parentWindow.event;
                if(e.stopPropagation) {
                        e.stopPropagation();
                        e.preventDefault();
                };
                /*@cc_on
                @if(@_win32)
                e.cancelBubble = true;
                e.returnValue = false;
                @end
                @*/
                return false;
        };
        
        // Parses the JSON passed between the script tags or by using the setGlobalOptions method
        function parseJSON(str) {
                // Check we have a String
                if(!(typeof str === 'string') || str == "") { 
                        return {}; 
                };                 
                try {
                        // Does a JSON (native or not) Object exist                              
                        if(typeof JSON === "object" && JSON.parse) {                                              
                                return window.JSON.parse(str);  
                        // Genious code taken from: http://kentbrewster.com/badges/                                                      
                        } else if(/lang|buttontabindex|mousewheel|cellformat|titleformat|nodrag|describedby/.test(str.toLowerCase())) {                                               
                                var f = Function(['var document,top,self,window,parent,Number,Date,Object,Function,',
                                        'Array,String,Math,RegExp,Image,ActiveXObject;',
                                        'return (' , str.replace(/<\!--.+-->/gim,'').replace(/\bfunction\b/g,'function-') , ');'].join(''));
                                return f();                          
                        };
                } catch (e) { };
                
                if(debug) {
                        throw "Could not parse the JSON object";
                };
                
                return {"err":"Could not parse the JSON object"};                                            
        };        

        // Sets an ARIA role on an element
        function setARIARole(element, role) {
                if(element && element.tagName) {
                        element.setAttribute("role", role);
                };
        };
        
        // Sets an ARIA property on an element        
        function setARIAProperty(element, property, value) {
		if(element && element.tagName) {
                        element.setAttribute("aria-" + property, value);
                };	
	};

        // Sets a tabindex attribute on an element, bends over for IE.
        function setTabIndex(e, i) {
                e.setAttribute(!/*@cc_on!@*/false ? "tabIndex" : "tabindex", i);
                e.tabIndex = i;                        
        };
        
        function dateToYYYYMMDD(dt) {                
                return typeof dt == "date" && !isNaN(dt) ? dt.getFullYear() + pad(dt.getMonth() + 1) + "" + pad(dt.getDate()) : dt;                
        };
        
        // The datePicker object itself 
        function datePicker(options) {                                      
                this.dateSet             = null;                 
                this.timerSet            = false;
                this.visible             = false;
                this.fadeTimer           = null;
                this.timer               = null;
                this.yearInc             = 0;
                this.monthInc            = 0;
                this.dayInc              = 0;
                this.mx                  = 0;
                this.my                  = 0;
                this.x                   = 0;
                this.y                   = 0; 
                this.created             = false;
                this.disabled            = false;
                this.opacity             = 0; 
                this.opacityTo           = 99;
                this.inUpdate            = false;                              
                this.kbEventsAdded       = false;
                this.fullCreate          = false;
                this.selectedTD          = null;
                this.cursorTD            = null;
                this.cursorDate          = options.cursorDate ? options.cursorDate : "",       
                this.date                = options.cursorDate ? new Date(+options.cursorDate.substr(0,4), +options.cursorDate.substr(4,2) - 1, +options.cursorDate.substr(6,2)) : new Date();
                this.defaults            = {};
                this.dynDisabledDates    = {};
                this.dateList            = [];
                this.firstDayOfWeek      = localeImport.firstDayOfWeek; 
                this.interval            = new Date();
                this.clickActivated      = false;
                this.noFocus             = true;
                this.kbEvent             = false; 
                this.delayedUpdate       = false;  
                this.bespokeTitles       = {};             
                
                for(var thing in options) {
                        if(options.hasOwnProperty(thing) && String(thing).search(/callbacks|formElements|enabledDates|disabledDates/) != -1) { 
                                continue; 
                        };
                        this[thing] = options[thing];                 
                };                
                
                /*@cc_on
                @if(@_win32)                   
                this.iePopUp             = null;
                this.isIE7               = false;                 
                @end
                @*/
                
                /*@cc_on
                @if(@_jscript_version <= 5.7)
                this.isIE7               = document.documentElement && typeof document.documentElement.style.maxHeight != "undefined";
                @end
                @*/
                
                for(var i = 0, prop; prop = ["callbacks", "formElements"][i]; i++) { 
                        this[prop] = {};
                        if(options.hasOwnProperty(prop)) {                        
                                for(thing in options[prop]) {                                
                                        if(options[prop].hasOwnProperty(thing)) {
                                                this[prop][thing] = options[prop][thing];
                                        };                 
                                };
                        };
                };
                
                // Adjust time to stop daylight savings madness on windows
                this.date.setHours(5);

                // Called from an associated form elements onchange event
                this.changeHandler = function() {
                        if(o.disabled) {
                                return;
                        };                        
                        o.setDateFromInput();  
                        o.callback("dateset", o.createCbArgObj());                                                                                 
                };
                
                // Creates the object passed to the callback functions
                this.createCbArgObj = function() {                        
                        return this.dateSet ? {"id":this.id,"date":this.dateSet,"dd":pad(this.date.getDate()),"mm":pad(this.date.getMonth() + 1),"yyyy":this.date.getFullYear()} : {"id":this.id,"date":null,"dd":null,"mm":null,"yyyy":null};                         
                };
                
                // Attempts to grab the window scroll offsets
                this.getScrollOffsets = function() {                         
                        if(typeof(window.pageYOffset) == 'number') {
                                //Netscape compliant
                                return [window.pageXOffset, window.pageYOffset];                                
                        } else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
                                //DOM compliant
                                return [document.body.scrollLeft, document.body.scrollTop];                                
                        } else if(document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop)) {
                                //IE6 standards compliant mode
                                return [document.documentElement.scrollLeft, document.documentElement.scrollTop];
                        };
                        return [0,0];
                };
                
                // Calculates the current list of disabled & enabled dates for a specific year/month
                this.getDateExceptions = function(y, m) {
                
                        m = pad(m);                 
                        
                        var obj     = {},            
                            lower   = o.firstDateShown,
                            upper   = o.lastDateShown,
                            rLength = o.dateList.length,                            
                            rNumber, workingDt, workingY, workingM, dtLower, dtUpper, i, dt, dt1, dt2, rngLower, rngUpper, cDate;  
                        
                        if(!upper || !lower) {
                                lower = o.firstDateShown = y + pad(m) + "01";
                                upper = o.lastDateShown  = y + pad(m) + pad(daysInMonth(m, y));                        
                        };
                        
                        dtLower = Number(lower.substr(0,6));
                        dtUpper = Number(upper.substr(0,6));
                                        
                        workingDt = String(dtLower);
                        
                        while(+workingDt <= dtUpper) {
                                workingY = workingDt.substr(0,4);
                                workingM = workingDt.substr(4,2);
                                
                                for(rNumber = 0; rNumber < rLength; rNumber++) {                         
                                        dt1 = String(o.dateList[rNumber].rLow).replace(/^(\*\*\*\*)/, workingY).replace(/^(\d\d\d\d)(\*\*)/, "$1"+workingM);
                                        dt2 = String(o.dateList[rNumber].rHigh).replace(/^(\*\*\*\*)/, workingY).replace(/^(\d\d\d\d)(\*\*)/, "$1"+workingM);
                                        
                                        // Single date
                                        if(dt2 == 1) { 
                                                if(+dt1 >= +o.firstDateShown && +dt1 <= +o.lastDateShown) {                                               
                                                        obj[dt1] = o.dateList[rNumber].type;                                                              
                                                };
                                                continue; 
                                        };                       
                                        
                                        // Range
                                        if(+dt1 <= +dt2
                                           &&
                                           +workingDt >= dt1.substr(0,6)
                                           &&
                                           +workingDt <= dt2.substr(0,6)
                                           ) {
                                                rngLower = Math.max(dt1,Math.max(String(workingDt) + "01", this.firstDateShown));
                                                rngUpper = Math.min(dt2,Math.min(String(workingDt) + "31", this.lastDateShown));
                                                for(var i = rngLower; i <= rngUpper; i++) {
                                                        obj[i] = o.dateList[rNumber].type;                                                                                                
                                                };
                                        };
                                };
                                
                                workingDt = new Date(workingY, +workingM, 02);
                                workingDt = workingDt.getFullYear()+""+pad(workingDt.getMonth()+1);
                        };        
                        
                        return obj;
                };

                // Repositions the datepicker beside the button
                this.reposition = function() {
                        if(!o.created || o.staticPos) { return; };

                        o.div.style.visibility = "hidden";
                        o.div.style.left = o.div.style.top = "0px";                           
                        o.div.style.display = "block";

                        var osh         = o.div.offsetHeight,
                            osw         = o.div.offsetWidth,
                            elem        = document.getElementById('fd-but-' + o.id),
                            pos         = o.truePosition(elem),
                            trueBody    = (document.compatMode && document.compatMode!="BackCompat") ? document.documentElement : document.body,
                            sOffsets    = o.getScrollOffsets(),
                            scrollTop   = sOffsets[1], 
                            scrollLeft  = sOffsets[0],
                            fitsBottom  = parseInt(trueBody.clientHeight+scrollTop) > parseInt(osh+pos[1]+elem.offsetHeight+2),
                            fitsTop     = parseInt(pos[1]-(osh+elem.offsetHeight+2)) > parseInt(scrollTop); 
                        
                        o.div.style.visibility = "visible";

                        o.div.style.left = Number(parseInt(trueBody.clientWidth+scrollLeft) < parseInt(osw+pos[0]) ? Math.abs(parseInt((trueBody.clientWidth+scrollLeft) - osw)) : pos[0]) + "px";
                        o.div.style.top  = (fitsBottom || !fitsTop) ? Math.abs(parseInt(pos[1] + elem.offsetHeight + 2)) + "px" : Math.abs(parseInt(pos[1] - (osh + 2))) + "px";
                        /*@cc_on
                        @if(@_jscript_version <= 5.7)
                        if(o.isIE7) return;
                        o.iePopUp.style.top    = o.div.style.top;
                        o.iePopUp.style.left   = o.div.style.left;
                        o.iePopUp.style.width  = osw + "px";
                        o.iePopUp.style.height = (osh - 2) + "px";
                        @end
                        @*/
                };
                
                // Resets the tabindex of the previously focused cell
                this.removeOldFocus = function() {
                        var td = document.getElementById(o.id + "-date-picker-hover");
                        if(td) {                                        
                                try {                                        
                                        setTabIndex(td, -1);                                          
                                        removeClass(td, "date-picker-hover");
                                        td.id = ""; 
                                        td.onblur  = null; 
                                        td.onfocus = null;                                                                             
                                } catch(err) {};
                        };
                };
                
                // Sets the tabindex & focus on the currently highlighted cell
                this.setNewFocus = function() {                                                                                             
                        var td = document.getElementById(o.id + "-date-picker-hover");
                        if(td) {
                                try {                                             
                                        setTabIndex(td, 0);                                                                                                                   
                                        addClass(td, "date-picker-hover");
                                        // If opened with the keyboard then add focus & blur events to the cell
                                        if(!this.clickActivated) {                                                
                                                td.onblur    = o.onblur;  
                                                td.onfocus   = o.onfocus;                                   
                                        };
                                        
                                        // If opened with the keyboard (and not in opera) then add a screen-reader friendly date format                                                                                                                                                                                         
                                        if(!isOpera && !this.clickActivated) {  
                                                o.addAccessibleDate();
                                        };
                                        
                                        // Try to programmatically set focus on the cell
                                        if(!this.noFocus && !this.clickActivated) {                                                                                                                                                   
                                                setTimeout(function() { try { td.focus(); } catch(err) {}; }, 0);
                                        };                                         
                                } catch(err) { };
                        };
                };
                
                // Adds a screen-reader friendly date to the current cell whenever 
                // the datepicker has been opened with the keyboard 
                this.addAccessibleDate = function() {
                        var td   = document.getElementById(o.id + "-date-picker-hover");                            
                                
                        if(td && !(td.getElementsByTagName("span").length)) {                                                          
                                var ymd = td.className.match(/cd-([\d]{4})([\d]{2})([\d]{2})/),
                                    noS = td.className.search(noSelectionRegExp) != -1,
                                    spn = document.createElement('span'),
                                    spnC;                                        
                        
                                spn.className       = "fd-screen-reader";
                                
                                while(td.firstChild) {
                                        td.removeChild(td.firstChild);
                                };
                                
                                if(noS) {
                                        spnC = spn.cloneNode(false);
                                        spnC.appendChild(document.createTextNode(getTitleTranslation(13)));
                                        td.appendChild(spnC);
                                };
                                
                                for(var pt = 0, part; part = formatParts[pt]; pt++) {
                                        
                                        if(part == "%j" || part == "%d") {
                                                td.appendChild(document.createTextNode(printFormattedDate(new Date(ymd[1], +ymd[2]-1, ymd[3]), part, true)));
                                        } else {
                                                spnC = spn.cloneNode(false);
                                                spnC.appendChild(document.createTextNode(printFormattedDate(new Date(ymd[1], +ymd[2]-1, ymd[3]), part, true)));
                                                td.appendChild(spnC);
                                        };                                                
                                };
                        };
                };
                
                // Sets the current cursor to a specific date
                this.setCursorDate = function(yyyymmdd) {                        
                        if(String(yyyymmdd).search(/^([0-9]{8})$/) != -1) {
                                this.date = new Date(+yyyymmdd.substr(0,4), +yyyymmdd.substr(4,2) - 1, +yyyymmdd.substr(6,2));
                                this.cursorDate = yyyymmdd;
                                
                                if(this.staticPos) {                                         
                                        this.updateTable();
                                };                                                                                                  
                        };
                };
                
                // Updates the table used to display the datepicker                  
                this.updateTable = function(noCallback) {  
                        if(!o || o.inUpdate || !o.created) {
                                return;
                        };
                        
                        // We are currently updating (used to stop public methods from firing)
                        o.inUpdate = true;
                        
                        // Remove the focus from the currently highlighted cell                                         
                        o.removeOldFocus();
                        
                        // If the update timer initiated
                        if(o.timerSet && !o.delayedUpdate) {
                                // Are we incrementing/decrementing the month
                                if(o.monthInc) {
                                        var n = o.date.getDate(),
                                            d = new Date(o.date);                         
                       
                                        d.setDate(2);                                               
                                        d.setMonth(d.getMonth() + o.monthInc * 1);
                                        // Don't go over the days in the month
                                        d.setDate(Math.min(n, daysInMonth(d.getMonth(),d.getFullYear())));
                                        
                                        o.date = new Date(d);
                                } else {                                 
                                        o.date.setDate(Math.min(o.date.getDate()+o.dayInc, daysInMonth(o.date.getMonth()+o.monthInc,o.date.getFullYear()+o.yearInc)));
                                        o.date.setMonth(o.date.getMonth() + o.monthInc);                                        
                                        o.date.setFullYear(o.date.getFullYear() + o.yearInc);
                                };                                       
                        }; 
        
                        // Make sure the internal date is within range
                        o.outOfRange();
                        
                        // Disable/enable the today button
                        if(!o.noToday) { 
                                o.disableTodayButton(); 
                        };
                        
                        // Disable/enable the month & year buttons
                        o.showHideButtons(o.date);
                
                        var cd = o.date.getDate(),
                            cm = o.date.getMonth(),
                            cy = o.date.getFullYear(),
                            cursorDate = (String(cy) + pad(cm+1) + pad(cd)),
                            tmpDate    = new Date(cy, cm, 1);                      
                        
                        tmpDate.setHours(5);
                        
                        var dt, cName, td, i, currentDate, cellAdded, col, currentStub, abbr, bespokeRenderClass, spnC, dateSetD,
                            // Weekday of the fist of the month
                            weekDayC            = (tmpDate.getDay() + 6) % 7,
                            // The column index this weekday will occupy                
                            firstColIndex       = (((weekDayC - o.firstDayOfWeek) + 7 ) % 7) - 1,
                            // The number of days in the current month
                            dpm                 = daysInMonth(cm, cy),
                            // Today as a Date Object
                            today               = new Date(),
                            // Today as a YYYYMMDD String
                            today               = today.getFullYear() + pad(today.getMonth()+1) + pad(today.getDate()),
                            // A Sring date stub in a YYYYMM format for the current date                        
                            stub                = String(tmpDate.getFullYear()) + pad(tmpDate.getMonth()+1),
                            //
                            cellAdded           = [4,4,4,4,4,4],
                            // The first day of the previous month as a Date Object                                                                    
                            lm                  = new Date(cy, cm-1, 1),
                            // The first day of the next month as a Date Object
                            nm                  = new Date(cy, cm+1, 1),
                            // The number of days in the previous month                          
                            daySub              = daysInMonth(lm.getMonth(), lm.getFullYear()),
                            // YYYYMM String date stub for the next month                
                            stubN               = String(nm.getFullYear()) + pad(nm.getMonth()+1),
                            // YYYYMM String date stub for the previous month
                            stubP               = String(lm.getFullYear()) + pad(lm.getMonth()+1),                
                            weekDayN            = (nm.getDay() + 6) % 7,
                            weekDayP            = (lm.getDay() + 6) % 7,
                            // A SPAN node to clone when adding dates to individual cells                                       
                            spn                 = document.createElement('span');                        
                        
                        // Give the "fd-screen-reader" class to the span in order to hide them in the UI
                        // but keep them accessible to screen-readers
                        spn.className       = "fd-screen-reader";
                        
                        // The first & last dates shown on the datepicker UI - could be a date from the previous & next month respectively
                        o.firstDateShown    = !o.constrainSelection && o.fillGrid && (0 - firstColIndex < 1) ? String(stubP) + (daySub + (0 - firstColIndex)) : stub + "01";            
                        o.lastDateShown     = !o.constrainSelection && o.fillGrid ? stubN + pad(41 - firstColIndex - dpm) : stub + String(dpm);
                        
                        // Store a reference to the current YYYYMM String representation of the current month
                        o.currentYYYYMM     = stub;                    
                
                        bespokeRenderClass  = o.callback("redraw", {id:o.id, dd:pad(cd), mm:pad(cm+1), yyyy:cy, firstDateDisplayed:o.firstDateShown, lastDateDisplayed:o.lastDateShown}) || {};                                            
                        
                        // An Object of dates that have been explicitly disabled (1) or enabled (0)
                        dts                 = o.getDateExceptions(cy, cm+1);                               
                
                        // Double check current date within limits etc
                        o.checkSelectedDate();
                        
                        // 
                        dateSetD            = (o.dateSet != null) ? o.dateSet.getFullYear() + pad(o.dateSet.getMonth()+1) + pad(o.dateSet.getDate()) : false;
                        
                        // If we have selected a date then set its ARIA selected property
                        // to false. We then set the ARIA selected property to true on the 
                        // newly selected cell after redrawing the table
                        if(this.selectedTD != null) {
                                setARIAProperty(this.selectedTD, "selected", false);
                                this.selectedTD = null;
                        };
                        
                        // Redraw all of the table cells representing the date parts of the UI
                        for(var curr = 0; curr < 42; curr++) {
                                // Current row
                                row  = Math.floor(curr / 7);
                                // Current TD node                         
                                td   = o.tds[curr];
                                // Clone our SPAN node
                                spnC = spn.cloneNode(false); 
                                // Remove any previous contents from the cell
                                while(td.firstChild) {
                                        td.removeChild(td.firstChild);
                                };
                                // If the current cell contains a date       
                                if((curr > firstColIndex && curr <= (firstColIndex + dpm)) || o.fillGrid) {
                                        currentStub     = stub;
                                        weekDay         = weekDayC;                                
                                        dt              = curr - firstColIndex;
                                        cName           = [];                                         
                                        selectable      = true;                                     
                                        
                                        // Are we drawing last month
                                        if(dt < 1) {
                                                dt              = daySub + dt;
                                                currentStub     = stubP;
                                                weekDay         = weekDayP;                                        
                                                selectable      = !o.constrainSelection;
                                                cName.push("month-out");
                                        // Are we drawing next month                                                  
                                        } else if(dt > dpm) {
                                                dt -= dpm;
                                                currentStub     = stubN;
                                                weekDay         = weekDayN;                                        
                                                selectable      = !o.constrainSelection; 
                                                cName.push("month-out");                                                                                           
                                        }; 
                                        
                                        // Calcuate this cells weekday
                                        weekDay = (weekDay + dt + 6) % 7;
                                        
                                        // Push a classname representing the weekday e.g. "day-3"
                                        cName.push("day-" + weekDay + " cell-" + curr);
                                        
                                        // A YYYYMMDD String representation of this cells date
                                        currentDate = currentStub + String(dt < 10 ? "0" : "") + dt;                            
                                        
                                        // If this cells date is out of range
                                        if(o.rangeLow && +currentDate < +o.rangeLow || o.rangeHigh && +currentDate > +o.rangeHigh) {                                          
                                                // Add a classname to style the cell and stop selection
                                                td.className = "out-of-range";
                                                // Reset this TD nodes title attribute  
                                                td.title = "";
                                                // Append the cells date as a text node to the TD 
                                                td.appendChild(document.createTextNode(dt));
                                                // Jaysus, what the feck does this line do again...                                             
                                                if(o.showWeeks) { 
                                                        cellAdded[row] = Math.min(cellAdded[row], 2); 
                                                };                                                                                                                                               
                                        // This cells date is within the lower & upper ranges (or no ranges have been defined)
                                        } else {
                                                // If it's a date from last or next month and the "constrainSelection" option
                                                // is false then give the cell a CD-YYYYMMDD class  
                                                if(selectable) {                                                                                                        
                                                        td.title = titleFormat ? printFormattedDate(new Date(+String(currentStub).substr(0,4), +String(currentStub).substr(4, 2) - 1, +dt), titleFormat, true) : "";                                                                                                      
                                                        cName.push("cd-" + currentDate + " yyyymm-" + currentStub + " mmdd-" + currentStub.substr(4,2) + pad(dt));
                                                // Otherwise give a "not-selectable" class (which shouldn't be styled in any way, it's for internal use)
                                                } else {  
                                                        td.title = titleFormat ? getTitleTranslation(13) + " " + printFormattedDate(new Date(+String(currentStub).substr(0,4), +String(currentStub).substr(4, 2) - 1, +dt), titleFormat, true) : "";                                                                       
                                                        cName.push("yyyymm-" + currentStub + " mmdd-" + currentStub.substr(4,2) + pad(dt) + " not-selectable");
                                                };                                                                                                                                             
                                                
                                                // Add a classname if the current cells date is today
                                                if(currentDate == today) { 
                                                        cName.push("date-picker-today"); 
                                                };

                                                // If this cell represents the currently selected date 
                                                if(dateSetD == currentDate) {
                                                        // Add a classname (for styling purposes) 
                                                        cName.push("date-picker-selected-date");
                                                        // Set the ARIA selected property to true 
                                                        setARIAProperty(td, "selected", "true");
                                                        // And cache a reference to the current cell
                                                        this.selectedTD = td;
                                                };

                                                // If the current cell has been explicitly disabled
                                                if(((currentDate in dts) && dts[currentDate] == 1)
                                                   // or
                                                   ||
                                                   // ... the current weekday has been disabled
                                                   (o.disabledDays[weekDay]
                                                    &&
                                                   // ... and the current date has not been explicitly enabled
                                                   !((currentDate in dts) && dts[currentDate] == 0) 
                                                   )
                                                  ) {
                                                        // Add a classname to style the cell and stop selection
                                                        cName.push("day-disabled");
                                                        // Update the current cells title to say "Disabled date: ..." (or whatever the translation says) 
                                                        if(titleFormat && selectable) { td.title = getTitleTranslation(13) + " " + td.title; }; 
                                                };
                                                
                                                // Has the redraw callback given us a bespoke classname to add to this cell
                                                if(currentDate in bespokeRenderClass) { 
                                                        cName.push(bespokeRenderClass[currentDate]); 
                                                }
                                        
                                                // Do we need to highlight this cells weekday representation
                                                if(o.highlightDays[weekDay]) { 
                                                        cName.push("date-picker-highlight"); 
                                                };

                                                // Is the current onscreen cursor set to this cells date
                                                if(cursorDate == currentDate) { 
                                                        td.id = o.id + "-date-picker-hover";                                                                                                                                                                 
                                                };      
                                                
                                                // Add the date to the TD cell as a text node. Note: If the datepicker has been given keyboard
                                                // events, this textnode is replaced by a more screen-reader friendly date during the focus event                                  
                                                td.appendChild(document.createTextNode(dt));
                                                
                                                // Add the classnames to the TD node
                                                td.className = cName.join(" ");
                                               
                                                // If the UI displays week numbers then update the celladded 
                                                if(o.showWeeks) {                                                         
                                                        cellAdded[row] = Math.min(cName[0] == "month-out" ? 3 : 1, cellAdded[row]);                                                          
                                                }; 
                                        };
                                // The current TD node is empty i.e. represents no date in the UI                       
                                } else {
                                        // Add a classname to style the cell
                                        td.className = "date-picker-unused";
                                        // Add a non-breaking space to unused TD node (for IEs benefit mostly)                                                                                                                    
                                        td.appendChild(document.createTextNode(nbsp));
                                        // Reset the TD nodes title attribute
                                        td.title = "";                                                                              
                                };                                                  
                                
                                // Do we update the week number for this row
                                if(o.showWeeks && curr - (row * 7) == 6) { 
                                        while(o.wkThs[row].firstChild) {
                                                o.wkThs[row].removeChild(o.wkThs[row].firstChild);
                                        };                                         
                                        o.wkThs[row].appendChild(document.createTextNode(cellAdded[row] == 4 && !o.fillGrid ? nbsp : getWeekNumber(cy, cm, curr - firstColIndex - 6)));
                                        o.wkThs[row].className = "date-picker-week-header" + (["",""," out-of-range"," month-out",""][cellAdded[row]]);                                          
                                };                                
                        };            
                        
                        // Update the UI title bar displaying the year & month
                        var span = o.titleBar.getElementsByTagName("span");
                        while(span[0].firstChild) {
                                span[0].removeChild(span[0].firstChild);
                        };
                        while(span[1].firstChild) {
                                span[1].removeChild(span[1].firstChild);
                        };
                        span[0].appendChild(document.createTextNode(getMonthTranslation(cm, false) + nbsp));
                        span[1].appendChild(document.createTextNode(cy));
                        
                        // If we are in an animation 
                        if(o.timerSet) {
                                // Speed the timer up a little bit to make the pause between updates quicker
                                o.timerInc = 50 + Math.round(((o.timerInc - 50) / 1.8));
                                // Recall this function in a timeout
                                o.timer = window.setTimeout(o.updateTable, o.timerInc);
                        };
                        
                        // We are not currently updating the UI
                        o.inUpdate = o.delayedUpdate = false; 
                        // Focus on the correct TD node
                        o.setNewFocus();                         
                };
                
                // Removes all scaffold from the DOM & events from memory
                this.destroy = function() {
                        
                        // Remove the button if it exists
                        if(document.getElementById("fd-but-" + this.id)) {
                                document.getElementById("fd-but-" + this.id).parentNode.removeChild(document.getElementById("fd-but-" + this.id));        
                        };
                        
                        if(!this.created) { 
                                return; 
                        };
                        
                        // Event cleanup for Internet Explorers benefit
                        removeEvent(this.table, "mousedown", o.onmousedown);  
                        removeEvent(this.table, "mouseover", o.onmouseover);
                        removeEvent(this.table, "mouseout", o.onmouseout);
                        removeEvent(document, "mousedown", o.onmousedown);
                        removeEvent(document, "mouseup",   o.clearTimer);
                        
                        if (window.addEventListener && !window.devicePixelRatio) {
                                try {
                                        window.removeEventListener('DOMMouseScroll', this.onmousewheel, false);
                                } catch(err) {};                                 
                        } else {
                                removeEvent(document, "mousewheel", this.onmousewheel);
                                removeEvent(window,   "mousewheel", this.onmousewheel);
                        }; 
                        o.removeOnFocusEvents();
                        clearTimeout(o.fadeTimer);
                        clearTimeout(o.timer);

                        /*@cc_on
                        @if(@_jscript_version <= 5.7)                         
                        if(!o.staticPos && !o.isIE7) {
                                try {
                                        o.iePopUp.parentNode.removeChild(o.iePopUp);
                                        o.iePopUp = null;
                                } catch(err) {};
                        };
                        @end
                        @*/                         

                        if(this.div && this.div.parentNode) {
                                this.div.parentNode.removeChild(this.div);
                        };
                                                 
                        o = null;
                };
                this.resizeInlineDiv = function()  {                        
                        o.div.style.width = o.table.offsetWidth + "px";
                        o.div.style.height = o.table.offsetHeight + "px";
                };
                
                this.reset = function() {
                        var elemID, elem;
                        for(elemID in o.formElements) {
                                elem = document.getElementById(elemID); 
                                if(elem) {
                                        if(elem.tagName.toLowerCase() == "select") {
                                                elem.selectedIndex = o.formElements[elemID.defaultVal];
                                        } else {
                                                elem.value = o.formElements[elemID.defaultVal];
                                        };
                                };                                
                        };
                        o.changeHandler();                                             
                };
                
                // Creates the DOM scaffold
                this.create = function() {
                        
                        if(document.getElementById("fd-" + this.id)) {
                                return;
                        };
                        
                        this.noFocus = true; 
                        
                        function createTH(details) {
                                var th = document.createElement('th');
                                if(details.thClassName) {
                                        th.className = details.thClassName;
                                };
                                if(details.colspan) {
                                        th.setAttribute('colSpan',details.colspan);
                                };
                                /*@cc_on
                                /*@if (@_win32)
                                th.unselectable = "on";
                                /*@end@*/
                                return th;
                        };
                        function createThAndButton(tr, obj) {
                                for(var i = 0, details; details = obj[i]; i++) {
                                        var th = createTH(details);
                                        tr.appendChild(th);
                                        var but = document.createElement('span');
                                        but.className = details.className;
                                        but.id = o.id + details.id;
                                        but.appendChild(document.createTextNode(details.text || o.nbsp));
                                        but.title = details.title || "";                                          
                                        /*@cc_on
                                        /*@if(@_win32)
                                        th.unselectable = but.unselectable = "on";
                                        /*@end@*/
                                        th.appendChild(but);
                                };
                        };  
                        
                        this.div                     = document.createElement('div');
                        this.div.id                  = "fd-" + this.id;
                        this.div.className           = "date-picker";  
                        
                        // Attempt to hide the div from screen readers during content creation
                        this.div.style.visibility = "hidden";
                        this.div.style.display = "none";
                                                               
                        // Set the ARIA describedby property if the required block available
                        if(this.describedBy && document.getElementById(this.describedBy)) {
                                setARIAProperty(this.div, "describedby", this.describedBy);
                        };
                        
                        // Set the ARIA labelled property if the required label available
                        if(this.labelledBy) {
                                setARIAProperty(this.div, "labelledby", this.labelledBy.id);
                        };
                              
                        var tr, row, col, tableHead, tableBody, tableFoot;

                        this.table             = document.createElement('table');
                        this.table.className   = "date-picker-table";                         
                        this.table.onmouseover = this.onmouseover;
                        this.table.onmouseout  = this.onmouseout;
                        this.table.onclick     = this.onclick;
                        
                        if(this.staticPos) {
                                this.table.onmousedown  = this.onmousedown;
                        };

                        this.div.appendChild(this.table);   
                        
                        var dragEnabledCN = !this.dragDisabled ? " drag-enabled" : "";
                                
                        if(!this.staticPos) {
                                this.div.style.visibility = "hidden";
                                this.div.className += dragEnabledCN;
                                document.getElementsByTagName('body')[0].appendChild(this.div);
                                                              
                                /*@cc_on
                                @if(@_jscript_version <= 5.7) 
                                
                                if(!this.isIE7) {                                         
                                        this.iePopUp = document.createElement('iframe');
                                        this.iePopUp.src = "javascript:'<html></html>';";
                                        this.iePopUp.setAttribute('className','iehack');
                                        // Remove iFrame from tabIndex                                        
			                this.iePopUp.setAttribute("tabIndex", -1);  			                
                                        // Hide it from ARIA aware technologies
			                setARIARole(this.iePopUp, "presentation");
                                        setARIAProperty(this.iePopUp, "hidden", "true"); 			                
                                        this.iePopUp.scrolling = "no";
                                        this.iePopUp.frameBorder = "0";
                                        this.iePopUp.name = this.iePopUp.id = this.id + "-iePopUpHack";
                                        document.body.appendChild(this.iePopUp);                                        
                                };
                                
                                @end
                                @*/
                                
                                // Aria "hidden" property for non active popup datepickers
                                setARIAProperty(this.div, "hidden", "true");
                        } else {
                                elem = document.getElementById(this.positioned ? this.positioned : this.id);
                                if(!elem) {
                                        this.div = null;
                                        if(debug) {
                                                throw this.positioned ? "Could not locate a datePickers associated parent element with an id:" + this.positioned : "Could not locate a datePickers associated input with an id:" + this.id;
                                        };
                                        return;
                                };

                                this.div.className += " static-datepicker";                          

                                if(this.positioned) {
                                        elem.appendChild(this.div);
                                } else {
                                        elem.parentNode.insertBefore(this.div, elem.nextSibling);
                                };
                                
                                if(this.hideInput) {
                                        for(var elemID in this.formElements) {
                                                elem = document.getElementById(elemID);
                                                if(elem) {
                                                        elem.className += " fd-hidden-input";
                                                };        
                                        };                                        
                                };                                                                  
                                                                          
                                setTimeout(this.resizeInlineDiv, 300);                               
                        };                          
                        
                        // ARIA Application role
                        setARIARole(this.div, "application");
                        setARIARole(this.table, "grid");
                       
                        if(this.statusFormat) {
                                tableFoot = document.createElement('tfoot');
                                this.table.appendChild(tableFoot);
                                tr = document.createElement('tr');
                                tr.className = "date-picker-tfoot";
                                tableFoot.appendChild(tr);                                
                                this.statusBar = createTH({thClassName:"date-picker-statusbar" + dragEnabledCN, colspan:this.showWeeks ? 8 : 7});
                                tr.appendChild(this.statusBar); 
                                this.updateStatus(); 
                        };

                        tableHead = document.createElement('thead');
                        tableHead.className = "date-picker-thead";
                        this.table.appendChild(tableHead);

                        tr  = document.createElement('tr');
                        setARIARole(tr, "presentation");
                        
                        tableHead.appendChild(tr);

                        // Title Bar
                        this.titleBar = createTH({thClassName:"date-picker-title" + dragEnabledCN, colspan:this.showWeeks ? 8 : 7});
                        
                        tr.appendChild(this.titleBar);
                        tr = null;

                        var span = document.createElement('span');
                        span.appendChild(document.createTextNode(nbsp));
                        span.className = "month-display" + dragEnabledCN; 
                        this.titleBar.appendChild(span);

                        span = document.createElement('span');
                        span.appendChild(document.createTextNode(nbsp));
                        span.className = "year-display" + dragEnabledCN; 
                        this.titleBar.appendChild(span);

                        span = null;

                        tr  = document.createElement('tr');
                        setARIARole(tr, "presentation");
                        tableHead.appendChild(tr);

                        createThAndButton(tr, [
                        {className:"prev-but prev-year",  id:"-prev-year-but", text:" ", title:getTitleTranslation(2) },
                        {className:"prev-but prev-month", id:"-prev-month-but", text:" ", title:getTitleTranslation(0) },
                        {colspan:this.showWeeks ? 4 : 3, className:"today-but", id:"-today-but", text:getTitleTranslation(4)},
                        {className:"next-but next-month", id:"-next-month-but", text:" ", title:getTitleTranslation(1)},
                        {className:"next-but next-year",  id:"-next-year-but", text:" ", title:getTitleTranslation(3) }
                        ]);

                        tableBody = document.createElement('tbody');
                        this.table.appendChild(tableBody);

                        var colspanTotal = this.showWeeks ? 8 : 7,
                            colOffset    = this.showWeeks ? 0 : -1,
                            but, abbr, formElemId, formElem;   
                
                        for(var rows = 0; rows < 7; rows++) {
                                row = document.createElement('tr');

                                if(rows != 0) {
                                        // ARIA Grid role
                                        setARIARole(row, "row");
                                        tableBody.appendChild(row);   
                                } else {
                                        tableHead.appendChild(row);
                                };

                                for(var cols = 0; cols < colspanTotal; cols++) {                                                                                
                                        if(rows === 0 || (this.showWeeks && cols === 0)) {
                                                col = document.createElement('th');                                                                                              
                                        } else {
                                                col = document.createElement('td');                                                                                           
                                                setARIAProperty(col, "describedby", this.id + "-col-" + cols + (this.showWeeks ? " " + this.id + "-row-" + rows : ""));
                                                setARIAProperty(col, "selected", "false");                                                 
                                        };
                                        
                                        /*@cc_on@*/
                                        /*@if(@_win32)
                                        col.unselectable = "on";
                                        /*@end@*/  
                                        
                                        row.appendChild(col);
                                        if((this.showWeeks && cols > 0 && rows > 0) || (!this.showWeeks && rows > 0)) {                                                
                                                setARIARole(col, "gridcell"); 
                                        } else {
                                                if(rows === 0 && cols > colOffset) {
                                                        col.className = "date-picker-day-header";
                                                        col.scope = "col";
                                                        setARIARole(col, "columnheader"); 
                                                        col.id = this.id + "-col-" + cols;                                          
                                                } else {
                                                        col.className = "date-picker-week-header";
                                                        col.scope = "row";
                                                        setARIARole(col, "rowheader");
                                                        col.id = this.id + "-row-" + rows;
                                                };
                                        };
                                };
                        };

                        col = row = null; 
                
                        this.ths = this.table.getElementsByTagName('thead')[0].getElementsByTagName('tr')[2].getElementsByTagName('th');
                        for (var y = 0; y < colspanTotal; y++) {
                                if(y == 0 && this.showWeeks) {
                                        this.ths[y].appendChild(document.createTextNode(getTitleTranslation(6)));
                                        this.ths[y].title = getTitleTranslation(8);
                                        continue;
                                };

                                if(y > (this.showWeeks ? 0 : -1)) {
                                        but = document.createElement("span");
                                        but.className = "fd-day-header";                                        
                                        /*@cc_on@*/
                                        /*@if(@_win32)
                                        but.unselectable = "on";
                                        /*@end@*/
                                        this.ths[y].appendChild(but);
                                };
                        };
                
                        but = null; 
                                        
                        this.trs             = this.table.getElementsByTagName('tbody')[0].getElementsByTagName('tr');
                        this.tds             = this.table.getElementsByTagName('tbody')[0].getElementsByTagName('td');
                        this.butPrevYear     = document.getElementById(this.id + "-prev-year-but");
                        this.butPrevMonth    = document.getElementById(this.id + "-prev-month-but");
                        this.butToday        = document.getElementById(this.id + "-today-but");
                        this.butNextYear     = document.getElementById(this.id + "-next-year-but"); 
                        this.butNextMonth    = document.getElementById(this.id + "-next-month-but");
        
                        if(this.noToday) {
                                this.butToday.style.display = "none";        
                        };
                        
                        if(this.showWeeks) {
                                this.wkThs = this.table.getElementsByTagName('tbody')[0].getElementsByTagName('th');
                                this.div.className += " weeks-displayed";
                        };

                        tableBody = tableHead = tr = createThAndButton = createTH = null;

                        this.updateTableHeaders();
                        this.created = true;                                                                    
                        this.updateTable();                         
                        
                        if(this.staticPos) {                                 
                                this.visible = true;
                                this.opacity = this.opacityTo = this.finalOpacity;                                                                                              
                                this.div.style.visibility = "visible";                       
                                this.div.style.display = "block";
                                this.noFocus = true;                                                          
                                this.fade();
                        } else {                                     
                                this.reposition();
                                this.div.style.visibility = "visible";
                                this.fade();
                                this.noFocus = true;   
                        };   
                        
                        this.callback("domcreate", { "id":this.id });                                                   
                };                 
                this.fade = function() {
                        window.clearTimeout(o.fadeTimer);
                        o.fadeTimer = null;   
                        var diff = Math.round(o.opacity + ((o.opacityTo - o.opacity) / 4)); 
                        o.setOpacity(diff);  
                        if(Math.abs(o.opacityTo - diff) > 3 && !o.noFadeEffect) {                                 
                                o.fadeTimer = window.setTimeout(o.fade, 50);
                        } else {
                                o.setOpacity(o.opacityTo);
                                if(o.opacityTo == 0) {
                                        o.div.style.display    = "none";
                                        o.div.style.visibility = "hidden";
                                        setARIAProperty(o.div, "hidden", "true");
                                        o.visible = false;
                                } else {
                                        setARIAProperty(o.div, "hidden", "false");
                                        o.visible = true;                                        
                                };
                        };
                };                  
                this.trackDrag = function(e) {
                        e = e || window.event;
                        var diffx = (e.pageX?e.pageX:e.clientX?e.clientX:e.x) - o.mx;
                        var diffy = (e.pageY?e.pageY:e.clientY?e.clientY:e.Y) - o.my;
                        o.div.style.left = Math.round(o.x + diffx) > 0 ? Math.round(o.x + diffx) + 'px' : "0px";
                        o.div.style.top  = Math.round(o.y + diffy) > 0 ? Math.round(o.y + diffy) + 'px' : "0px";
                        /*@cc_on
                        @if(@_jscript_version <= 5.7)                         
                        if(o.staticPos || o.isIE7) {
                                return;
                        };
                        o.iePopUp.style.top    = o.div.style.top;
                        o.iePopUp.style.left   = o.div.style.left;
                        @end
                        @*/
                };
                this.stopDrag = function(e) {
                        var b = document.getElementsByTagName("body")[0];
                        removeClass(b, "fd-drag-active");
                        removeEvent(document,'mousemove',o.trackDrag, false);
                        removeEvent(document,'mouseup',o.stopDrag, false);
                        o.div.style.zIndex = 9999;
                }; 
                this.onmousedown = function(e) {
                        e = e || document.parentWindow.event;
                        var el     = e.target != null ? e.target : e.srcElement,
                            origEl = el,
                            hideDP = true,
                            reg    = new RegExp("^fd-(but-)?" + o.id + "$");
                        
                        o.mouseDownElem = null;
                       
                        // Are we within the wrapper div or the button    
                        while(el) {
                                if(el.id && el.id.length && el.id.search(reg) != -1) { 
                                        hideDP = false;
                                        break;
                                };
                                try { 
                                        el = el.parentNode; 
                                } catch(err) { 
                                        break; 
                                };
                        };
                        
                        // If not, then ...     
                        if(hideDP) {                                                        
                                hideAll();                                                            
                                return true;                                                                  
                        };
                        
                        if((o.div.className + origEl.className).search('fd-disabled') != -1) { 
                                return true; 
                        };                                                                                                            
                        
                        // We check the mousedown events on the buttons
                        if(origEl.id.search(new RegExp("^" + o.id + "(-prev-year-but|-prev-month-but|-next-month-but|-next-year-but)$")) != -1) {
                                
                                o.mouseDownElem = origEl;
                                
                                addEvent(document, "mouseup", o.clearTimer);
                                addEvent(origEl, "mouseout",  o.clearTimer); 
                                                                 
                                var incs = {
                                        "-prev-year-but":[0,-1,0],
                                        "-prev-month-but":[0,0,-1],
                                        "-next-year-but":[0,1,0],
                                        "-next-month-but":[0,0,1]
                                    },
                                    check = origEl.id.replace(o.id, ""),
                                    dateYYYYMM = Number(o.date.getFullYear() + pad(o.date.getMonth()+1));
                                
                                o.timerInc      = 800;
                                o.timerSet      = true;
                                o.dayInc        = incs[check][0];
                                o.yearInc       = incs[check][1];
                                o.monthInc      = incs[check][2]; 
                                o.accellerator  = 1;
                                
                                if(!(o.currentYYYYMM == dateYYYYMM)) {
                                        if((o.currentYYYYMM < dateYYYYMM && (o.yearInc == -1 || o.monthInc == -1)) || (o.currentYYYYMM > dateYYYYMM && (o.yearInc == 1 || o.monthInc == 1))) {
                                                o.delayedUpdate = false; 
                                                o.timerInc = 1200;                                                
                                        } else {
                                                o.delayedUpdate = true;
                                                o.timerInc = 800;                                                
                                        };  
                                };
                                
                                o.updateTable();    
                                
                                return stopEvent(e);
                                                            
                        } else if(el.className.search("drag-enabled") != -1) {                                  
                                o.mx = e.pageX ? e.pageX : e.clientX ? e.clientX : e.x;
                                o.my = e.pageY ? e.pageY : e.clientY ? e.clientY : e.Y;
                                o.x  = parseInt(o.div.style.left);
                                o.y  = parseInt(o.div.style.top);
                                addEvent(document,'mousemove',o.trackDrag, false);
                                addEvent(document,'mouseup',o.stopDrag, false);
                                addClass(document.getElementsByTagName("body")[0], "fd-drag-active");
                                o.div.style.zIndex = 10000;
                                
                                return stopEvent(e);
                        };
                        return true;                                                                      
                }; 
                this.onclick = function(e) {
                        if(o.opacity != o.opacityTo || o.disabled) {
                                return stopEvent(e);
                        };
                        
                        e = e || document.parentWindow.event;
                        var el = e.target != null ? e.target : e.srcElement;                         
                          
                        while(el.parentNode) {
                                // Are we within a valid i.e. clickable TD node  
                                if(el.tagName && el.tagName.toLowerCase() == "td") {   
                                                                        
                                        if(el.className.search(/cd-([0-9]{8})/) == -1 || el.className.search(noSelectionRegExp) != -1) {
                                                return stopEvent(e);
                                        };
                                        
                                        var cellDate = el.className.match(/cd-([0-9]{8})/)[1];                                                                                                                                                                           
                                        o.date       = new Date(cellDate.substr(0,4),cellDate.substr(4,2)-1,cellDate.substr(6,2));                                                                                
                                        o.dateSet    = new Date(o.date); 
                                        o.noFocus    = true;                                                                       
                                        o.callback("dateset", { "id":o.id, "date":o.dateSet, "dd":o.dateSet.getDate(), "mm":o.dateSet.getMonth() + 1, "yyyy":o.dateSet.getFullYear() });                                          
                                        o.returnFormattedDate();
                                        o.hide();                  
                                                
                                        o.stopTimer();
                                        
                                        break;   
                                // Today button pressed             
                                } else if(el.id && el.id == o.id + "-today-but") {                                 
                                        o.date = new Date(); 
                                        o.updateTable();
                                        o.stopTimer();
                                        break; 
                                // Day headers clicked, change the first day of the week      
                                } else if(el.className.search(/date-picker-day-header/) != -1) {
                                        var cnt = o.showWeeks ? -1 : 0,
                                        elem = el;
                                        
                                        while(elem.previousSibling) {
                                                elem = elem.previousSibling;
                                                if(elem.tagName && elem.tagName.toLowerCase() == "th") {
                                                        cnt++;
                                                };
                                        };
                                        
                                        o.firstDayOfWeek = (o.firstDayOfWeek + cnt) % 7;
                                        o.updateTableHeaders();
                                        break;     
                                };
                                try { 
                                        el = el.parentNode; 
                                } catch(err) { 
                                        break; 
                                };
                        };
                        
                        return stopEvent(e);                                                
                };
                
                this.show = function(autoFocus) {                         
                        if(this.staticPos) { 
                                return; 
                        };
                        
                        var elem, elemID;
                        for(elemID in this.formElements) {
                                elem = document.getElementById(this.id);
                                if(!elem || (elem && elem.disabled)) { 
                                        return; 
                                };   
                        };
                        
                        this.noFocus = true; 
                        
                        // If the datepicker doesn't exist in the dom  
                        if(!this.created || !document.getElementById('fd-' + this.id)) {                          
                                this.created    = false;
                                this.fullCreate = false;                                                                                             
                                this.create();                                 
                                this.fullCreate = true;                                                            
                        } else {                                                        
                                this.setDateFromInput();                                                               
                                this.reposition();                                 
                        };                      
                        
                        this.noFocus = !!!autoFocus;                          
                        
                        if(this.noFocus) { 
                                this.clickActivated = true;
                                addEvent(document, "mousedown", this.onmousedown); 
                                if(mouseWheel) {
                                        if (window.addEventListener && !window.devicePixelRatio) {
                                                window.addEventListener('DOMMouseScroll', this.onmousewheel, false);
                                        } else {
                                                addEvent(document, "mousewheel", this.onmousewheel);
                                                addEvent(window,   "mousewheel", this.onmousewheel);
                                        };
                                };     
                        } else {
                                this.clickActivated = false;
                        };    
                        
                        this.opacityTo = this.finalOpacity;
                        this.div.style.display = "block";                        
                                                        
                        /*@cc_on
                        @if(@_jscript_version <= 5.7)                          
                        if(!o.isIE7) {
                                this.iePopUp.style.width = this.div.offsetWidth + "px";
                                this.iePopUp.style.height = this.div.offsetHeight + "px";
                                this.iePopUp.style.display = "block";
                        };                                
                        @end
                        @*/                               
                        
                        this.setNewFocus(); 
                        this.fade();
                        var butt = document.getElementById('fd-but-' + this.id);
                        if(butt) { 
                                  addClass(butt, "date-picker-button-active");
                        };                                                
                };
                this.hide = function() {                        
                        if(!this.visible || !this.created || !document.getElementById('fd-' + this.id)) {
                                return;
                        };
                        
                        this.kbEvent = false;
                        
                        removeClass(o.div, "date-picker-focus");
                        
                        this.stopTimer();
                        this.removeOnFocusEvents();
                        this.clickActivated = false;
                        this.noFocus = true;
                        this.setNewFocus();
                        
                        if(this.staticPos) {                                                                 
                                return; 
                        };

                        // Update status bar                                
                        if(this.statusBar) { 
                                this.updateStatus(getTitleTranslation(9)); 
                        };    
                        
                        var butt = document.getElementById('fd-but-' + this.id);
                        if(butt) {
                                removeClass(butt, "date-picker-button-active");                                
                        };
                
                        removeEvent(document, "mousedown", this.onmousedown);
                        
                        if(mouseWheel) {
                                if (window.addEventListener && !window.devicePixelRatio) {
                                        try { 
                                                window.removeEventListener('DOMMouseScroll', this.onmousewheel, false);
                                        } catch(err) {};                                 
                                } else {
                                        removeEvent(document, "mousewheel", this.onmousewheel);
                                        removeEvent(window,   "mousewheel", this.onmousewheel);
                                }; 
                        };
                        
                        /*@cc_on
                        @if(@_jscript_version <= 5.7)
                        if(!this.isIE7) { this.iePopUp.style.display = "none"; };
                        @end
                        @*/

                        this.opacityTo = 0;
                        this.fade();                  
                };
                
                this.onblur = function(e) {                                                                                                  
                        o.hide();
                };
                // The current cursor cell gains focus
                this.onfocus = function(e) {                                               
                        o.noFocus = false;                        
                        addClass(o.div, "date-picker-focus"); 
                        if(o.statusBar) { 
                                o.updateStatus(printFormattedDate(o.date, o.statusFormat, true)); 
                        };                                                                                                     
                        o.addOnFocusEvents();                                                                        
                };   
                this.onmousewheel = function(e) {                        
                        e = e || document.parentWindow.event;
                        var delta = 0;
                        
                        if (e.wheelDelta) {
                                delta = e.wheelDelta/120;
                                if (isOpera && window.opera.version() < 9.2) {
                                        delta = -delta;
                                };
                        } else if(e.detail) {
                                delta = -e.detail/3;
                        };                          
                        
                        var n = o.date.getDate(),
                            d = new Date(o.date),
                            inc = delta > 0 ? 1 : -1;                         
                       
                        d.setDate(2);
                        d.setMonth(d.getMonth() + inc * 1);
                        d.setDate(Math.min(n, daysInMonth(d.getMonth(),d.getFullYear())));
                      
                        if(o.outOfRange(d)) { 
                                return stopEvent(e); 
                        };
                        
                        o.date = new Date(d);
                        
                        o.updateTable(); 
                        
                        if(o.statusBar) { 
                                o.updateStatus(printFormattedDate(o.date, o.statusFormat, true)); 
                        };
                        
                        return stopEvent(e);                                                       
                };                      
                this.onkeydown = function (e) {
                        o.stopTimer();
                        
                        if(!o.visible) {
                                return false;
                        };
                                
                        e = e || document.parentWindow.event;
                        
                        var kc = e.keyCode ? e.keyCode : e.charCode;
                                
                        if(kc == 13) {
                                // RETURN/ENTER: close & select the date
                                var td = document.getElementById(o.id + "-date-picker-hover");                                         
                                if(!td || td.className.search(/cd-([0-9]{8})/) == -1 || td.className.search(/out-of-range|day-disabled/) != -1) {
                                        return stopEvent(e);
                                };
                                o.dateSet = new Date(o.date);
                                o.callback("dateset", o.createCbArgObj()); 
                                o.returnFormattedDate();    
                                o.hide();
                                return stopEvent(e);
                        } else if(kc == 27) {
                                // ESC: close, no date selection 
                                if(!o.staticPos) {
                                        o.hide();
                                        return stopEvent(e);
                                };
                                return true;
                        } else if(kc == 32 || kc == 0) {
                                // SPACE: goto todays date 
                                o.date = new Date();
                                o.updateTable();
                                return stopEvent(e);
                        } else if(kc == 9) {
                                // TAB: close, no date selection & focus back to associated button - popup datepickers only                                      
                                if(!o.staticPos) {
                                        return stopEvent(e);
                                };
                                return true;                                
                        };    
                        // TODO - test the need for the IE specific stuff in IE9
                                 
                        // Internet Explorer fires the keydown event faster than the JavaScript engine can
                        // update the interface. The following attempts to fix this.
                                
                        /*@cc_on
                        @if(@_win32)                                 
                        if(new Date().getTime() - o.interval.getTime() < 50) { return stopEvent(e); }; 
                        o.interval = new Date();                                 
                        @end
                        @*/
                        
                        // A number key has been pressed so change the first day of the week
                        if((kc > 49 && kc < 56) || (kc > 97 && kc < 104)) {
                                if(kc > 96) {
                                        kc -= (96-48);
                                };
                                kc -= 49;
                                o.firstDayOfWeek = (o.firstDayOfWeek + kc) % 7;
                                o.updateTableHeaders();
                                return stopEvent(e);
                        };

                        // If outside any other tested keycodes then let the keystroke pass
                        if(kc < 33 || kc > 40) {
                                return true;
                        };

                        var d = new Date(o.date),                            
                            cursorYYYYMM = o.date.getFullYear() + pad(o.date.getMonth()+1), 
                            tmp;
                             
                        // HOME: Set date to first day of current month
                        if(kc == 36) {
                                d.setDate(1); 
                        // END: Set date to last day of current month                                 
                        } else if(kc == 35) {
                                d.setDate(daysInMonth(d.getMonth(),d.getFullYear())); 
                        // PAGE UP & DOWN                                   
                        } else if ( kc == 33 || kc == 34) {
                                var inc = (kc == 34) ? 1 : -1; 
                                
                                // CTRL + PAGE UP/DOWN: Moves to the same date in the previous/next year
                                if(e.ctrlKey) {                                                                                                               
                                        d.setFullYear(d.getFullYear() + inc * 1);
                                // PAGE UP/DOWN: Moves to the same date in the previous/next month                                            
                                } else {                                          
                                        var n = o.date.getDate();                         
                       
                                        d.setDate(2);
                                        d.setMonth(d.getMonth() + inc * 1);
                                        d.setDate(Math.min(n, daysInMonth(d.getMonth(),d.getFullYear())));                                         
                                };                                                                    
                        // LEFT ARROW                                    
                        } else if ( kc == 37 ) {                                         
                                d = new Date(o.date.getFullYear(), o.date.getMonth(), o.date.getDate() - 1);                                       
                        // RIGHT ARROW
                        } else if ( kc == 39 || kc == 34) {                                         
                                d = new Date(o.date.getFullYear(), o.date.getMonth(), o.date.getDate() + 1 ); 
                        // UP ARROW                                        
                        } else if ( kc == 38 ) {                                          
                                d = new Date(o.date.getFullYear(), o.date.getMonth(), o.date.getDate() - 7);  
                        // DOWN ARROW                                        
                        } else if ( kc == 40 ) {                                          
                                d = new Date(o.date.getFullYear(), o.date.getMonth(), o.date.getDate() + 7);                                         
                        };

                        // If the new date is out of range then disallow action
                        if(o.outOfRange(d)) { 
                                return stopEvent(e); 
                        };
                        
                        // Otherwise set the new cursor date
                        o.date = d;
                        
                        // Update the status bar if needs be
                        if(o.statusBar) { 
                                o.updateStatus(o.getBespokeTitle(o.date.getFullYear(),o.date.getMonth() + 1,o.date.getDate()) || printFormattedDate(o.date, o.statusFormat, true));                                
                        };                     
                        
                        // YYYYMMDD format String of the current cursor date
                        var t = String(o.date.getFullYear()) + pad(o.date.getMonth()+1) + pad(o.date.getDate());

                        // If we need to redraw the UI completely
                        if(e.ctrlKey || (kc == 33 || kc == 34) || t < o.firstDateShown || t > o.lastDateShown) {                                                                       
                                o.updateTable(); 
                                /*@cc_on
                                @if(@_win32)
                                o.interval = new Date();                        
                                @end
                                @*/
                        // Just highlight current cell                                                
                        } else { 
                                // Do we need to disable the today button for this date                                   
                                if(!o.noToday) { 
                                        o.disableTodayButton(); 
                                };
                                // Remove focus from the previous cell                                        
                                o.removeOldFocus();
                                // Show/hide the month & year buttons
                                o.showHideButtons(o.date);
                                
                                // Locate this TD             
                                for(var i = 0, td; td = o.tds[i]; i++) {                                                                                             
                                        if(td.className.search("cd-" + t) == -1) {                                                          
                                                continue;
                                        };                                                
                                       
                                        td.id = o.id + "-date-picker-hover";                                                
                                        o.setNewFocus();
                                        break;
                                };
                        };

                        return stopEvent(e);
                }; 
                this.onmouseout = function(e) {
                        e = e || document.parentWindow.event;
                        var p = e.toElement || e.relatedTarget;
                        while(p && p != this) {
                                try { 
                                        p = p.parentNode 
                                } catch(e) { 
                                        p = this; 
                                };
                        };
                        
                        if(p == this) {
                                return false;
                        };
                        
                        if(o.currentTR) {
                                o.currentTR.className = ""; 
                                o.currentTR = null;
                        };
                        
                        if(o.statusBar) { 
                                o.updateStatus(o.getBespokeTitle(o.date.getFullYear(),o.date.getMonth() + 1,o.date.getDate()) || printFormattedDate(o.date, o.statusFormat, true));                                
                        };                          
                };
                this.onmouseover = function(e) {
                        e = e || document.parentWindow.event;
                        var el = e.target != null ? e.target : e.srcElement;
                        while(el.nodeType != 1) { 
                                el = el.parentNode; 
                        }; 
                                
                        if(!el || ! el.tagName) { 
                                return; 
                        };                              
                        
                        o.noFocus = true;
                                
                        var statusText = getTitleTranslation(9);
                        
                        switch (el.tagName.toLowerCase()) {
                                case "td":                                            
                                        if(el.className.search(/date-picker-unused|out-of-range/) != -1) {
                                                statusText = getTitleTranslation(9);
                                        } if(el.className.search(/cd-([0-9]{8})/) != -1) {                                                                                               
                                                o.stopTimer();
                                                var cellDate = el.className.match(/cd-([0-9]{8})/)[1];                                                                                                                          
                                                
                                                o.removeOldFocus();
                                                el.id = o.id+"-date-picker-hover";
                                                o.setNewFocus();
                                                                                       
                                                o.date = new Date(+cellDate.substr(0,4),+cellDate.substr(4,2)-1,+cellDate.substr(6,2));                                                
                                                if(!o.noToday) { 
                                                        o.disableTodayButton(); 
                                                };
                                                
                                                statusText = o.getBespokeTitle(+cellDate.substr(0,4),+cellDate.substr(4,2),+cellDate.substr(6,2)) || printFormattedDate(o.date, o.statusFormat, true);                                                
                                        };
                                        break;
                                case "th":
                                        if(!o.statusBar) { 
                                                break; 
                                        };
                                        if(el.className.search(/drag-enabled/) != -1) {
                                                statusText = getTitleTranslation(10);
                                        } else if(el.className.search(/date-picker-week-header/) != -1) {
                                                var txt = el.firstChild ? el.firstChild.nodeValue : "";
                                                statusText = txt.search(/^(\d+)$/) != -1 ? getTitleTranslation(7, [txt, txt < 3 && o.date.getMonth() == 11 ? getWeeksInYear(o.date.getFullYear()) + 1 : getWeeksInYear(o.date.getFullYear())]) : getTitleTranslation(9);
                                        };
                                        break;
                                case "span":
                                        if(!o.statusBar) { 
                                                break; 
                                        };
                                        if(el.className.search(/drag-enabled/) != -1) {
                                                statusText = getTitleTranslation(10);
                                        } else if(el.className.search(/day-([0-6])/) != -1) {
                                                var day = el.className.match(/day-([0-6])/)[1];
                                                statusText = getTitleTranslation(11, [getDayTranslation(day, false)]);
                                        } else if(el.className.search(/prev-year/) != -1) {
                                                statusText = getTitleTranslation(2);
                                        } else if(el.className.search(/prev-month/) != -1) {
                                                statusText = getTitleTranslation(0);
                                        } else if(el.className.search(/next-year/) != -1) {
                                                statusText = getTitleTranslation(3);
                                        } else if(el.className.search(/next-month/) != -1) {
                                                statusText = getTitleTranslation(1);
                                        } else if(el.className.search(/today-but/) != -1 && el.className.search(/disabled/) == -1) {
                                                statusText = getTitleTranslation(12);
                                        };
                                        break;
                                default:
                                        statusText = "";
                        };
                        while(el.parentNode) {
                                el = el.parentNode;
                                if(el.nodeType == 1 && el.tagName.toLowerCase() == "tr") {                                                  
                                        if(o.currentTR) {
                                                if(el == o.currentTR) break;
                                                o.currentTR.className = ""; 
                                        };                                                 
                                        el.className = "dp-row-highlight";
                                        o.currentTR = el;
                                        break;
                                };
                        };                                                          
                        if(o.statusBar && statusText) { 
                                o.updateStatus(statusText); 
                        };                                 
                }; 
                this.clearTimer = function() {
                        o.stopTimer();
                        o.timerInc      = 800;
                        o.yearInc       = 0;
                        o.monthInc      = 0;
                        o.dayInc        = 0;
                        
                        removeEvent(document, "mouseup", o.clearTimer);
                        if(o.mouseDownElem != null) {
                                removeEvent(o.mouseDownElem, "mouseout",  o.clearTimer);
                        };
                        o.mouseDownElem = null;
                };    
                
                var o = this;                 
                
                this.setDateFromInput();
                
                if(this.staticPos) {                          
                        this.create();                                               
                } else { 
                        this.createButton();                                               
                };
                
                (function() {
                        var elemID, elem, elemCnt = 0;
                        
                        for(elemID in o.formElements) {                              
                                elem = document.getElementById(elemID);
                                if(elem && elem.tagName && elem.tagName.search(/select|input/i) != -1) {                                                                     
                                        addEvent(elem, "change", o.changeHandler); 
                                        if(elemCnt == 0 && elem.form) {
                                                addEvent(elem.form, "reset", o.reset);
                                        };
                                        elemCnt++;                               
                                };
                                
                                if(!elem || elem.disabled == true) {
                                        o.disableDatePicker();
                                };                         
                        };                                      
                })();   
                                        
                // We have fully created the datepicker...
                this.fullCreate = true;
        };
        datePicker.prototype.addButtonEvents = function(but) {
               function buttonEvent (e) {
                        e = e || window.event;                      
                        
                        var inpId     = this.id.replace('fd-but-',''),
                            dpVisible = isVisible(inpId),
                            autoFocus = false,
                            kbEvent   = datePickers[inpId].kbEvent;
                            
                        if(kbEvent) {
                                datePickers[inpId].kbEvent = false;
                                return;
                        };

                        if(e.type == "keydown") {
                                datePickers[inpId].kbEvent = true;
                                var kc = e.keyCode != null ? e.keyCode : e.charCode;
                                if(kc != 13) return true; 
                                if(dpVisible) {
                                        //this.className = this.className.replace("date-picker-button-active", "");
                                        removeClass(this, "date-picker-button-active")                                          
                                        hideAll();
                                        return stopEvent(e);
                                };                                   
                                autoFocus = true;
                        } else {
                                datePickers[inpId].kbEvent = false;
                        };

                        //this.className = this.className.replace("date-picker-button-active", "");
                        
                        if(!dpVisible) {                                 
                                //this.className += " date-picker-button-active";
                                addClass(this, "date-picker-button-active")
                                hideAll(inpId);                                                             
                                showDatePicker(inpId, autoFocus);
                        } else {
                                removeClass(this, "date-picker-button-active");                        
                                hideAll();
                        };
                
                        return stopEvent(e);
                };
                
                but.onkeydown = buttonEvent;
                but.onclick   = buttonEvent;
                
                if(!buttonTabIndex || this.bespokeTabIndex === false) {
                        setTabIndex(but, -1); 
                        but.onkeydown = null; 
                        removeEvent(but, "keydown", buttonEvent);
                } else {
                        setTabIndex(but, this.bespokeTabIndex);
                };                              
        };
        
        datePicker.prototype.createButton = function() {
                
                if(this.staticPos || document.getElementById("fd-but-" + this.id)) { 
                        return; 
                };

                var inp         = document.getElementById(this.id),
                    span        = document.createElement('span'),
                    but         = document.createElement('a');

                but.href        = "#" + this.id;
                but.className   = "date-picker-control";
                but.title       = getTitleTranslation(5);
                but.id          = "fd-but-" + this.id;
                                
                span.appendChild(document.createTextNode(nbsp));
                but.appendChild(span);

                span = document.createElement('span');
                span.className = "fd-screen-reader";
                span.appendChild(document.createTextNode(but.title));
                but.appendChild(span);
                
                // Set the ARIA role to be "button"
                setARIARole(but, "button");                 
                
                // Set a "haspopup" ARIA property - should this not be a list if ID's????
                setARIAProperty(but, "haspopup", true);
                                             			                	
                if(this.positioned && document.getElementById(this.positioned)) {
                        document.getElementById(this.positioned).appendChild(but);
                } else {
                        inp.parentNode.insertBefore(but, inp.nextSibling);
                };                   
                
                this.addButtonEvents(but);

                but = null;
                
                this.callback("dombuttoncreate", {id:this.id});
        };
        datePicker.prototype.setBespokeTitles = function(titles) {                
                this.bespokeTitles = {};
                this.addBespokeTitles(titles);               
        }; 
        datePicker.prototype.addBespokeTitles = function(titles) {                
                for(var dt in titles) {
                        if(titles.hasOwnProperty(dt)) {
                                this.bespokeTitles[dt] = titles[dt];
                        };
                };              
        }; 
        datePicker.prototype.getBespokeTitle = function(y,m,d) {
                var dt, dtFull, yyyymmdd = y + String(pad(m)) + pad(d);
                
                // Try the datepickers bespoke titles
                for(dt in this.bespokeTitles) {
                        if(this.bespokeTitles.hasOwnProperty(dt)) {
                                dtFull = String(dt).replace(/^(\*\*\*\*)/, y).replace(/^(\d\d\d\d)(\*\*)/, "$1"+ pad(m));        
                                if(dtFull == yyyymmdd) {
                                        return this.bespokeTitles[dt];
                                };
                        };
                };
                                
                // Try the generic bespoke titles
                for(dt in bespokeTitles) {
                        if(bespokeTitles.hasOwnProperty(dt)) {
                                dtFull = String(dt).replace(/^(\*\*\*\*)/, y).replace(/^(\d\d\d\d)(\*\*)/, "$1"+ pad(m));        
                                if(dtFull == yyyymmdd) {
                                        return bespokeTitles[dt];
                                };
                        };
                };
                
                return false;             
        };
        datePicker.prototype.returnSelectedDate = function() {                
                return this.dateSet;                
        };   
        datePicker.prototype.setRangeLow = function(range) {
                if(String(range).search(rangeRegExp) == -1) {
                        if(debug) {
                                throw "Invalid value passed to setRangeLow method: " + range;
                        };
                        return false;
                };
                this.rangeLow = range;
                if(!this.inUpdate) {
                        this.setDateFromInput();
                };                
        };
        datePicker.prototype.setRangeHigh = function(range) {
                if(String(range).search(rangeRegExp) == -1) {
                        if(debug) {
                                throw "Invalid value passed to setRangeHigh method: " + range;
                        };
                        return false;
                };
                this.rangeHigh = range;                                               
                if(!this.inUpdate) {
                        this.setDateFromInput();
                };                
        };
        datePicker.prototype.setDisabledDays = function(dayArray) {
                if(!dayArray.length || dayArray.join("").search(/^([0|1]{7})$/) == -1) {
                        if(debug) {
                                throw "Invalid values located when attempting to call setDisabledDays";
                        };
                        return false;
                };                
                this.disabledDays = dayArray;                 
                if(!this.inUpdate) {
                        this.setDateFromInput();
                };    
        };
        
        datePicker.prototype.setDisabledDates = function(dateObj) {                      
                this.filterDateList(dateObj, true);                
        }; 
        datePicker.prototype.setEnabledDates = function(dateObj) {
                this.filterDateList(dateObj, false);                               
        };         
        datePicker.prototype.addDisabledDates = function(dateObj) {                    
                this.addDatesToList(dateObj, true);                                                                
        };
        datePicker.prototype.addEnabledDates = function(dateObj) {
                this.addDatesToList(dateObj, false);
        };
        datePicker.prototype.filterDateList = function(dateObj, type) {                                                              
                var tmpDates = [];
                for(var i = 0; i < this.dateList.length; i++) {
                        if(this.dateList[i].type != type) {
                                tmpDates.push(this.dateList[i]);                        
                        };
                };
                
                this.dateList = tmpDates.concat();
                this.addDatesToList(dateObj, type);                
        };
        datePicker.prototype.addDatesToList = function(dateObj, areDisabled) {                                    
                var startD;
                for(startD in dateObj) {
                        if(String(startD).search(wcDateRegExp) != -1 && (dateObj[startD] == 1 || String(dateObj[startD]).search(wcDateRegExp) != -1)) {
                                
                                if(dateObj[startD] != 1 && Number(String(startD).replace(/^\*\*\*\*/, 2010).replace(/^(\d\d\d\d)(\*\*)/, "$1"+"22")) > Number(String(dateObj[startD]).replace(/^\*\*\*\*/, 2010).replace(/^(\d\d\d\d)(\*\*)/, "$1"+"22"))) {
                                        continue;
                                };
                                
                                this.dateList.push({
                                        type:!!(areDisabled),
                                        rLow:startD,
                                        rHigh:dateObj[startD]
                                });                                
                        };
                };
                
                if(!this.inUpdate) {
                        this.setDateFromInput();
                };                                                                
        };
        datePicker.prototype.setSelectedDate = function(yyyymmdd) {                                             
                if(String(yyyymmdd).search(wcDateRegExp) == -1) {
                        return false;
                };  
                
                var match = yyyymmdd.match(rangeRegExp),
                    dt    = new Date(+match[2],+match[3]-1,+match[4]);
                
                if(!dt || isNaN(dt) || !this.canDateBeSelected(dt)) {
                        return false;
                };
                    
                this.dateSet = new Date(dt);
                
                if(!this.inUpdate) {
                        this.updateTable();
                };
                
                this.callback("dateset", this.createCbArgObj());
                this.returnFormattedDate();                                         
        };
        datePicker.prototype.checkSelectedDate = function() {                
                if(this.dateSet && !this.canDateBeSelected(this.dateSet)) {                        
                        this.dateSet = null;
                };
                if(!this.inUpdate) {
                        this.updateTable();
                };
        };
        datePicker.prototype.addOnFocusEvents = function() {                              
                if(this.kbEventsAdded || this.noFocus) {                         
                        return;
                };
                
                addEvent(document, "keypress", this.onkeydown);
                addEvent(document, "mousedown", this.onmousedown);
                
                /*@cc_on
                @if(@_win32)
                removeEvent(document, "keypress", this.onkeydown);
                addEvent(document, "keydown", this.onkeydown);                 
                @end
                @*/
                if(window.devicePixelRatio) {
                        removeEvent(document, "keypress", this.onkeydown);
                        addEvent(document, "keydown", this.onkeydown);
                };             
                this.noFocus = false;   
                this.kbEventsAdded = true;                
        };         
        datePicker.prototype.removeOnFocusEvents = function() {
                
                if(!this.kbEventsAdded) { 
                        return; 
                };
                
                removeEvent(document, "keypress",  this.onkeydown);
                removeEvent(document, "keydown",   this.onkeydown);
                removeEvent(document, "mousedown", this.onmousedown);                 
                
                this.kbEventsAdded = false;                 
        };         
        datePicker.prototype.stopTimer = function() {
                this.timerSet = false;
                window.clearTimeout(this.timer);
        };
        datePicker.prototype.setOpacity = function(op) {
                this.div.style.opacity = op/100;
                this.div.style.filter = 'alpha(opacity=' + op + ')';
                this.opacity = op;
        };              
        datePicker.prototype.truePosition = function(element) {
                var pos = this.cumulativeOffset(element);
                if(isOpera) { 
                        return pos; 
                };
                var iebody      = (document.compatMode && document.compatMode != "BackCompat")? document.documentElement : document.body,
                    dsocleft    = document.all ? iebody.scrollLeft : window.pageXOffset,
                    dsoctop     = document.all ? iebody.scrollTop  : window.pageYOffset,
                    posReal     = this.realOffset(element);
                return [pos[0] - posReal[0] + dsocleft, pos[1] - posReal[1] + dsoctop];
        };
        datePicker.prototype.realOffset = function(element) {
                var t = 0, l = 0;
                do {
                        t += element.scrollTop  || 0;
                        l += element.scrollLeft || 0;
                        element = element.parentNode;
                } while(element);
                return [l, t];
        };
        datePicker.prototype.cumulativeOffset = function(element) {
                var t = 0, l = 0;
                do {
                        t += element.offsetTop  || 0;
                        l += element.offsetLeft || 0;
                        element = element.offsetParent;
                } while(element);
                return [l, t];
        };
        datePicker.prototype.outOfRange = function(tmpDate) {
                
                if(!this.rangeLow && !this.rangeHigh) { 
                        return false; 
                };
                
                var level = false;
                
                if(!tmpDate) {
                        level   = true;
                        tmpDate = this.date;
                };

                var d  = pad(tmpDate.getDate()),
                    m  = pad(tmpDate.getMonth() + 1),
                    y  = tmpDate.getFullYear(),
                    dt = String(y)+String(m)+String(d);

                if(this.rangeLow && +dt < +this.rangeLow) {
                        if(!level) { 
                                return true; 
                        };
                        this.date = new Date(this.rangeLow.substr(0,4), this.rangeLow.substr(4,2)-1, this.rangeLow.substr(6,2), 5, 0, 0);
                        return false;
                };
                if(this.rangeHigh && +dt > +this.rangeHigh) {
                        if(!level) { 
                                return true; 
                        };
                        this.date = new Date(this.rangeHigh.substr(0,4), this.rangeHigh.substr(4,2)-1, this.rangeHigh.substr(6,2), 5, 0, 0);
                };
                return false;
        };  
        datePicker.prototype.canDateBeSelected = function(tmpDate) {
                if(!tmpDate || isNaN(tmpDate)) {
                        return false;
                };
                                                               
                var d  = pad(tmpDate.getDate()),
                    m  = pad(tmpDate.getMonth() + 1),
                    y  = tmpDate.getFullYear(),
                    dt = y + "" + m + "" + d,
                    dd = this.getDateExceptions(y, m),                    
                    wd = tmpDate.getDay() == 0 ? 7 : tmpDate.getDay();               
                
                // If date out of range
                if((this.rangeLow && +dt < +this.rangeLow) 
                   || 
                   (this.rangeHigh && +dt > +this.rangeHigh) 
                   ||
                   // or the date has been explicitly disabled 
                   ((dt in dd) && dd[dt] == 1) 
                   ||
                   // or the date lies on a disabled weekday and it hasn't been explicitly enabled 
                   (this.disabledDays[wd-1] && (!(dt in dd) || ((dt in dd) && dd[dt] == 1)))) {
                        return false;
                };
                
                return true;
        };        
        datePicker.prototype.updateStatus = function(msg) {                                
                while(this.statusBar.firstChild) { 
                        this.statusBar.removeChild(this.statusBar.firstChild); 
                };
                // All this arseing about just for sups in the footer... nice typography and all that...
                if(msg && this.statusFormat.search(/%S/) != -1 && msg.search(/([0-9]{1,2})(st|nd|rd|th)/) != -1) {                
                        msg = cbSplit(msg.replace(/([0-9]{1,2})(st|nd|rd|th)/, "$1<sup>$2</sup>"), /<sup>|<\/sup>/);                                                 
                        var dc = document.createDocumentFragment();
                        for(var i = 0, nd; nd = msg[i]; i++) {
                                if(/^(st|nd|rd|th)$/.test(nd)) {
                                        var sup = document.createElement("sup");
                                        sup.appendChild(document.createTextNode(nd));
                                        dc.appendChild(sup);
                                } else {
                                        dc.appendChild(document.createTextNode(nd));
                                };
                        };
                        this.statusBar.appendChild(dc);                        
                } else {                        
                        this.statusBar.appendChild(document.createTextNode(msg ? msg : getTitleTranslation(9)));                                                 
                };                                    
        };
        
        /* So needs rewritten */
        datePicker.prototype.setDateFromInput = function() {
                var origDateSet = this.dateSet,
                    m           = false,
                    but         = this.staticPos ? false : document.getElementById("fd-but-" + this.id),
                    i, dt, elemID, elem, elemFmt, d, y, elemVal, dp, mp, yp, dpt;
                
                // Reset the internal dateSet variable
                this.dateSet = null;
                
                // Try and get a year, month and day from the form element values   
                for(elemID in this.formElements) {
                
                        elem = document.getElementById(elemID);
                        
                        if(!elem) {
                                return false;
                        };
                        
                        elemVal = String(elem.value);
                        elemFmt = this.formElements[elemID];
                        dt      = false;
                        
                        dp = elemFmt.search(dPartsRegExp) != -1 ? 1 : 0;
                        mp = elemFmt.search(mPartsRegExp) != -1 ? 1 : 0;
                        yp = elemFmt.search(yPartsRegExp) != -1 ? 1 : 0;
                        
                        dpt = dp + mp + yp;
                        
                        allFormats = [];
                        allFormats.push(elemFmt);
                        
                        // If year, month & day required
                        if(dp && mp && yp) {
                                // Inject some common formats, placing the easiest
                                // to spot at the beginning.
                                allFormats = allFormats.concat([
                                        "%Y%m%d",       // 20110113
                                        "%Y/%m/%d",     // 2011/01/13
                                        "%Y/%n/%d",     // 2011/1/13
                                        "%Y/%n/%j",     // 2011/1/13
                                        "%d/%m/%Y",     // 13/01/2011
                                        "%j/%m/%Y",     // 13/01/2011
                                        "%j/%n/%Y",
                                        "%d/%m/%y",
                                        "%d/%M/%Y",
                                        "%d/%F/%Y",
                                        "%d/%M/%y",
                                        "%d/%F/%y"                                        
                                        ]);        
                        } else if(yp) {
                                allFormats = allFormats.concat([
                                        "%Y",
                                        "%y"
                                        ]);
                        } else if(mp) {
                                allFormats = allFormats.concat([
                                        "%M",
                                        "%F",
                                        "%m",
                                        "%n"
                                        ]);
                        } else if(dp) {
                                allFormats = allFormats.concat([
                                        "%d%",
                                        "%j"
                                        ]);
                        };
                        
                        for(i = 0; i < allFormats.length; i++) { 
                                dt = parseDateString(elemVal, allFormats[i]); 
                                
                                //console.log("parseDateString returned:");
                                //console.log(dt);
                                if(dt) {
                                        if(!d && dp && dt.d) {
                                                d = dt.d;        
                                        };
                                        if(m === false && mp && dt.m) { 
                                                m = dt.m;                                               
                                        };
                                        if(!y && yp && dt.y) {
                                                y = dt.y;        
                                        };                        
                                };
                                
                                if(((dp && d) || !dp)
                                   &&
                                   ((mp && !m === false) || !mp)
                                   &&
                                   ((yp && y) || !yp)) { 
                                        break;
                                };
                        };                                            
                };
                
                dt = false;
                
                if(d && !(m === false) && y) {                                            
                        if(+d > daysInMonth(+m, +y)) {
                                d  = daysInMonth(+m, +y);
                                dt = false;
                        } else {
                                dt = new Date(+y, +m - 1, +d);
                        };
                };
                
                if(but) {
                        removeClass(but, "date-picker-dateval");
                };
                        
                if(!dt || isNaN(dt)) {                        
                        var newDate = new Date(y || new Date().getFullYear(), !(m === false) ? m - 1 : new Date().getMonth(), 1);
                        this.date = this.cursorDate ? new Date(+this.cursorDate.substr(0,4), +this.cursorDate.substr(4,2) - 1, +this.cursorDate.substr(6,2)) : new Date(newDate.getFullYear(), newDate.getMonth(), Math.min(+d || new Date().getDate(), daysInMonth(newDate.getMonth(), newDate.getFullYear())));
                        
                        this.date.setHours(5);
                        this.outOfRange();                         
                        if(this.fullCreate) {
                                this.updateTable();
                        };  
                        
                                           
                        return;
                };
        
                // Skip daylight savings time sillyness
                dt.setHours(5);
                this.date = new Date(dt);                            
                this.outOfRange();                 
                
                if(dt.getTime() == this.date.getTime() && this.canDateBeSelected(this.date)) {                                              
                        this.dateSet = new Date(this.date);
                        if(but) {
                                addClass(but, "date-picker-dateval");
                        };                        
                };
                
                if(this.fullCreate) {
                        this.updateTable();
                };
                
                this.returnFormattedDate(true);
        };
        
        datePicker.prototype.setSelectIndex = function(elem, indx) {
                for(var opt = elem.options.length-1; opt >= 0; opt--) {
                        if(elem.options[opt].value == indx) {
                                elem.selectedIndex = opt;
                                return;
                        };
                };
        };
        datePicker.prototype.returnFormattedDate = function(noFocus) {     
                var but = this.staticPos ? false : document.getElementById("fd-but-" + this.id);
                
                if(!this.dateSet) {
                        if(but) {
                                removeClass(but, "date-picker-dateval");
                        };                                
                        return;
                };
                
                var d   = pad(this.dateSet.getDate()),
                    m   = pad(this.dateSet.getMonth() + 1),
                    y   = this.dateSet.getFullYear(),
                    el  = false, 
                    elemID, elem, elemFmt, fmtDate;
                
                noFocus = !!noFocus;
                 
                for(elemID in this.formElements) {
                        elem    = document.getElementById(elemID);
                        
                        if(!elem) {
                                return;
                        };
                        
                        if(!el) {
                                el = elem;
                        };
                        
                        elemFmt = this.formElements[elemID];
                        
                        fmtDate = printFormattedDate(this.dateSet, elemFmt, returnLocaleDate);                   
                        if(elem.tagName.toLowerCase() == "input") {
                                elem.value = fmtDate; 
                        } else {  
                                this.setSelectIndex(elem, fmtDate);                              
                        };
                };
                
                if(this.staticPos) { 
                        this.noFocus = true;
                        this.updateTable(); 
                        this.noFocus = false;
                } else if(but) {
                        addClass(but, "date-picker-dateval");
                };                         
                
                if(this.fullCreate) {
                        if(el.type && el.type != "hidden" && !noFocus) { 
                                el.focus(); 
                        };                                                                                                                                             
                };         
        };
        datePicker.prototype.disableDatePicker = function() {
                if(this.disabled) {
                        return;
                };
                
                if(this.staticPos) {
                        this.removeOnFocusEvents();
                        this.removeOldFocus();
                        this.noFocus = true;
                        addClass(this.div, "date-picker-disabled")  
                        this.table.onmouseover = this.table.onclick = this.table.onmouseout = this.table.onmousedown = null;                                      
                        removeEvent(document, "mousedown", this.onmousedown);                         
                        removeEvent(document, "mouseup",   this.clearTimer);                       
                } else {  
                        if(this.visible) {
                                this.hide();
                        };                        
                        var but = document.getElementById("fd-but-" + this.id);
                        if(but) {
                                addClass(but, "date-picker-control-disabled");
                                // Set a "disabled" ARIA state
                                setARIAProperty(but, "disabled", true);                               
                                but.onkeydown = but.onclick = function() { 
                                        return false; 
                                }; 
                                setTabIndex(but, -1);                
                        };                         
                };               
                                
                clearTimeout(this.timer);                
                this.disabled = true;  
        }; 
        datePicker.prototype.enableDatePicker = function() {
                if(!this.disabled) {
                        return;
                };
                
                if(this.staticPos) {
                        this.removeOldFocus();
                        
                        // Reset the cursor to the selected date
                        if(this.dateSet != null) {
                                this.date = this.dateSet;
                        };
                        this.noFocus = true;                        
                        this.updateTable();                        
                        removeClass(this.div, "date-picker-disabled");
                        this.disabled = false;                         
                        this.table.onmouseover = this.onmouseover;
                        this.table.onmouseout  = this.onmouseout;
                        this.table.onclick     = this.onclick;                         
                        this.table.onmousedown = this.onmousedown;                                                                    
                } else {                         
                        var but = document.getElementById("fd-but-" + this.id);
                        if(but) {                                
                                removeClass(but, "date-picker-control-disabled");
                                // Reset the "disabled" ARIA state
                                setARIAProperty(but, "disabled", false);
                                this.addButtonEvents(but);                                                
                        };                         
                };
                
                this.disabled = false;                
        };
        datePicker.prototype.disableTodayButton = function() {
                var today = new Date();                
                removeClass(this.butToday, "fd-disabled");
                if(this.outOfRange(today) 
                   || 
                   (this.date.getDate() == today.getDate() 
                    && 
                    this.date.getMonth() == today.getMonth() 
                    && 
                    this.date.getFullYear() == today.getFullYear())
                    ) {
                        addClass(this.butToday, "fd-disabled");                          
                };
        };
        datePicker.prototype.updateTableHeaders = function() {
                var colspanTotal = this.showWeeks ? 8 : 7,
                    colOffset    = this.showWeeks ? 1 : 0,
                    d, but;

                for(var col = colOffset; col < colspanTotal; col++ ) {
                        d = (this.firstDayOfWeek + (col - colOffset)) % 7;
                        this.ths[col].title = getDayTranslation(d, false);

                        if(col > colOffset) {
                                but = this.ths[col].getElementsByTagName("span")[0];
                                while(but.firstChild) { 
                                        but.removeChild(but.firstChild); 
                                };
                                but.appendChild(document.createTextNode(getDayTranslation(d, true)));
                                but.title = this.ths[col].title;                               
                                but = null;
                        } else {
                                while(this.ths[col].firstChild) { 
                                        this.ths[col].removeChild(this.ths[col].firstChild); 
                                };
                                this.ths[col].appendChild(document.createTextNode(getDayTranslation(d, true)));
                        };

                        removeClass(this.ths[col], "date-picker-highlight");
                        if(this.highlightDays[d]) {
                                addClass(this.ths[col], "date-picker-highlight");
                        };
                };
                
                if(this.created) { 
                        this.updateTable(); 
                };
        }; 
        datePicker.prototype.callback = function(type, args) {   
                if(!type || !(type in this.callbacks)) { 
                        return false; 
                };
                
                var ret = false,
                    func;
                                       
                for(func = 0; func < this.callbacks[type].length; func++) {                         
                        ret = this.callbacks[type][func](args || this.id);                        
                };
                                      
                return ret;
        };      
        datePicker.prototype.showHideButtons = function(tmpDate) {
                if(!this.butPrevYear) { return; };
                
                var tdm = tmpDate.getMonth(),
                    tdy = tmpDate.getFullYear();

                if(this.outOfRange(new Date((tdy - 1), tdm, daysInMonth(+tdm, tdy-1)))) {                                                    
                        addClass(this.butPrevYear, "fd-disabled");
                        if(this.yearInc == -1) {
                                this.stopTimer();
                        };
                } else {
                        removeClass(this.butPrevYear, "fd-disabled");
                };                 
                
                if(this.outOfRange(new Date(tdy, (+tdm - 1), daysInMonth(+tdm-1, tdy)))) {                           
                        addClass(this.butPrevMonth, "fd-disabled");
                        if(this.monthInc == -1) {
                                this.stopTimer();
                        };
                } else {
                        removeClass(this.butPrevMonth, "fd-disabled");
                };
         
                if(this.outOfRange(new Date((tdy + 1), +tdm, 1))) {                            
                        addClass(this.butNextYear, "fd-disabled");
                        if(this.yearInc == 1) {
                                this.stopTimer();
                        };
                } else {
                        removeClass(this.butNextYear, "fd-disabled");
                };                
                
                if(this.outOfRange(new Date(tdy, +tdm + 1, 1))) {
                        addClass(this.butNextMonth, "fd-disabled");
                        if(this.monthInc == 1) {
                                this.stopTimer();
                        };
                } else {
                        removeClass(this.butNextMonth, "fd-disabled");
                };
        };        
        var localeDefaults = {
                fullMonths:["January","February","March","April","May","June","July","August","September","October","November","December"],
                monthAbbrs:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],
                fullDays:  ["Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"],
                dayAbbrs:  ["Mon","Tue","Wed","Thu","Fri","Sat","Sun"],
                titles:    ["Previous month","Next month","Previous year","Next year", "Today", "Show Calendar", "wk", "Week [[%0%]] of [[%1%]]", "Week", "Select a date", "Click \u0026 Drag to move", "Display \u201C[[%0%]]\u201D first", "Go to Today\u2019s date", "Disabled date :"],
                firstDayOfWeek:0,
                imported:  false
        };        
        var joinNodeLists = function() {
                if(!arguments.length) { 
                        return []; 
                };
                var nodeList = [];
                for (var i = 0; i < arguments.length; i++) {
                        for (var j = 0, item; item = arguments[i][j]; j++) {
                                nodeList[nodeList.length] = item;
                        };
                };
                return nodeList;
        };
        var cleanUp = function() {
                var dp, fe;
                for(dp in datePickers) {
                        for(fe in datePickers[dp].formElements) {
                                if(!document.getElementById(fe)) {
                                        datePickers[dp].destroy();
                                        datePickers[dp] = null;
                                        delete datePickers[dp];
                                        break;
                                };
                        };
                };
        };         
        var hideAll = function(exception) {
                var dp;
                for(dp in datePickers) {
                        if(!datePickers[dp].created || (exception && exception == datePickers[dp].id)) {
                                continue;
                        };
                        datePickers[dp].hide();
                };
        };
        var hideDatePicker = function(inpID) {                
                if(inpID in datePickers) {
                        if(!datePickers[inpID].created || datePickers[inpID].staticPos) {
                                return;
                        };
                        datePickers[inpID].hide();
                };
        };
        var showDatePicker = function(inpID, autoFocus) {                
                if(!(inpID in datePickers)) {
                        return false;
                };   
                
                datePickers[inpID].clickActivated = !!!autoFocus;             
                datePickers[inpID].show(autoFocus);
                return true;        
        };
        var destroy = function(e) {
                e = e || window.event;
                
                // Don't remove datepickers if it's a pagehide/pagecache event (webkit et al)
                if(e.persisted) {
                        return;
                };
                
                for(dp in datePickers) {
                        datePickers[dp].destroy();
                        datePickers[dp] = null;
                        delete datePickers[dp];
                };
                datePickers = null;
                
                removeEvent(window, 'unload', datePickerController.destroy);
        }; 
        var destroySingleDatePicker = function(id) {
                if(id && (id in datePickers)) {
                        datePickers[id].destroy();
                        datePickers[id] = null;
                        delete datePickers[id];        
                };
        };
        var getTitleTranslation = function(num, replacements) {
                replacements = replacements || [];
                if(localeImport.titles.length > num) {
                         var txt = localeImport.titles[num];
                         if(replacements && replacements.length) {
                                for(var i = 0; i < replacements.length; i++) {
                                        txt = txt.replace("[[%" + i + "%]]", replacements[i]);
                                };
                         };
                         return txt.replace(/[[%(\d)%]]/g,"");
                };
                return "";
        };
        var getDayTranslation = function(day, abbreviation) {
                var titles = localeImport[abbreviation ? "dayAbbrs" : "fullDays"];
                return titles.length && titles.length > day ? titles[day] : "";
        };
        var getMonthTranslation = function(month, abbreviation) {
                var titles = localeImport[abbreviation ? "monthAbbrs" : "fullMonths"];
                return titles.length && titles.length > month ? titles[month] : "";
        };
        var daysInMonth = function(nMonth, nYear) {
                nMonth = (nMonth + 12) % 12;
                return (((0 == (nYear%4)) && ((0 != (nYear%100)) || (0 == (nYear%400)))) && nMonth == 1) ? 29: [31,28,31,30,31,30,31,31,30,31,30,31][nMonth];
        };
        
        var getWeeksInYear = function(Y) {
                if(Y in weeksInYearCache) {
                        return weeksInYearCache[Y];
                };
                
                var X1 = new Date(Y, 0, 4),
                    X2 = new Date(Y, 11, 28);
                
                X1.setDate(X1.getDate() - (6 + X1.getDay()) % 7);
                X2.setDate(X2.getDate() + (7 - X2.getDay()) % 7);
                
                weeksInYearCache[Y] = Math.round((X2 - X1) / 604800000);
                
                return weeksInYearCache[Y];
        };

        var getWeekNumber = function(y,m,d) {
                var d = new Date(y, m, d, 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;
        };
        
        var printFormattedDate = function(date, fmt, useImportedLocale) {
                if(!date || isNaN(date)) { 
                        return fmt; 
                };                
                
                var d           = date.getDate(),
                    D           = date.getDay(),
                    m           = date.getMonth(),
                    y           = date.getFullYear(),
                    locale      = useImportedLocale ? localeImport : localeDefaults,
                    fmtParts    = String(fmt).split(formatSplitRegExp),
                    fmtParts    = cbSplit(fmt, formatSplitRegExp), 
                    fmtNewParts = [],
                    flags       = {
                                "d":pad(d),
                                "D":locale.dayAbbrs[D == 0 ? 6 : D - 1],
                                "l":locale.fullDays[D == 0 ? 6 : D - 1],
                                "j":d,
                                "N":D == 0 ? 7 : D,
                                "w":D,                                
                                "W":getWeekNumber(y,m,d),
                                "M":locale.monthAbbrs[m],
                                "F":locale.fullMonths[m],
                                "m":pad(m + 1),
                                "n":m + 1,
                                "t":daysInMonth(m, y),
                                "y":String(y).substr(2,2),                                
                                "Y":y,
                                "S":["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
                                },
                    len         = fmtParts.length,
                    currFlag, f;    
                
                
                for(f = 0; f < len; f++) {
                        currFlag = fmtParts[f];                                       
                        fmtNewParts.push(currFlag in flags ? flags[currFlag] : currFlag);                        
                };
                
                return fmtNewParts.join("");
        };
        var parseDateString = function(str, fmt) {
                var d     = false,
                    m     = false,
                    y     = false,
                    dp    = fmt.search(dPartsRegExp) != -1 ? 1 : 0,
                    mp    = fmt.search(mPartsRegExp) != -1 ? 1 : 0,
                    yp    = fmt.search(yPartsRegExp) != -1 ? 1 : 0,                        
                    now   = new Date(),
                    parts = String(fmt).split(formatSplitRegExp),
                    parts = cbSplit(fmt, formatSplitRegExp),
                    str   = "" + str,
                    len   = parts.length,
                    pt, part;
                
                        
                //console.log("attempting to parse " + fmt + " from string " + str)
                    
                loopLabel:
                for(pt = 0; pt < len; pt++) {
                        part = parts[pt];
                        
                        if(part === "") {
                                continue loopLabel;
                        };
                        
                        //console.log("parsing " + part + " from " + str)
                        
                        if(str.length == 0) { 
                                break; 
                        };
                              
                        switch(part) {
                                // Dividers - be easy on them all i.e. accept them all when parsing...                                
                                case "/":
                                case ".":
                                case " ":
                                case "-":
                                case ",":
                                case ":":       
                                                str = str.substr(1);                                     
                                                break;                                             
                                // DAY
                                case "d": // Day of the month, 2 digits with leading zeros (01 - 31)
                                                if(str.search(/^(3[01]|[12][0-9]|0[1-9])/) != -1) {
                                                        d = str.substr(0,2);
                                                        str = str.substr(2);                                                        
                                                        //console.log("d and str: " + d + " " + str)
                                                        break;
                                                } else {                                                        
                                                        return false;
                                                };
                                case "j": // Day of the month without leading zeros (1 - 31)  
                                                if(str.search(/^(3[01]|[12][0-9]|[1-9])/) != -1) {
                                                        d = +str.match(/^(3[01]|[12][0-9]|[1-9])/)[0];
                                                        str = str.substr(str.match(/^(3[01]|[12][0-9]|[1-9])/)[0].length);                                                        
                                                        break;
                                                } else {                                                        
                                                        return false;
                                                };
                                case "D": // A textual representation of a day, three letters (Mon - Sun)
                                case "l": // A full textual representation of the day of the week (Monday - Sunday)
                                          // Accept English & imported locales and both modifiers                                                  
                                                l = localeDefaults.fullDays.concat(localeDefaults.dayAbbrs);                                                  
                                                if(localeImport.imported) {
                                                        l = l.concat(localeImport.fullDays).concat(localeImport.dayAbbrs);
                                                }; 
                                                
                                                for(var i = 0; i < l.length; i++) {
                                                        if(new RegExp("^" + l[i], "i").test(str)) {                                                                
                                                                str = str.substr(l[i].length);
                                                                continue loopLabel;
                                                        };
                                                };
                                                
                                                break;                                  
                                case "N": // ISO-8601 numeric representation of the day of the week (added in PHP 5.1.0) 1 (for Monday) through 7 (for Sunday)
                                case "w": // Numeric representation of the day of the week 0 (for Sunday) through 6 (for Saturday)
                                                if(str.search(part == "N" ? /^([1-7])/ : /^([0-6])/) != -1) {
                                                        str = str.substr(1);                                                        
                                                };
                                                break;
                                case "S": // English ordinal suffix for the day of the month, 2 characters: st, nd, rd or th
                                                if(str.search(/^(st|nd|rd|th)/i) != -1) {
                                                        str = str.substr(2);                                                        
                                                };
                                                break;                                
                                // WEEK
                                case "W": // ISO-8601 week number of year, weeks starting on Monday (added in PHP 4.1.0): 1 - 53
                                                if(str.search(/^([1-9]|[1234[0-9]|5[0-3])/) != -1) {
                                                        str = str.substr(str.match(/^([1-9]|[1234[0-9]|5[0-3])/)[0].length);                                                        
                                                };
                                                break;
                                // MONTH
                                case "M": // A short textual representation of a month, three letters
                                case "F": // A full textual representation of a month, such as January or March
                                          // Accept English & imported locales and both modifiers                                                    
                                                l = localeDefaults.fullMonths.concat(localeDefaults.monthAbbrs);
                                                if(localeImport.imported) {
                                                        l = l.concat(localeImport.fullMonths).concat(localeImport.monthAbbrs);
                                                };
                                                for(var i = 0; i < l.length; i++) {                                                        
                                                        if(str.search(new RegExp("^" + l[i],"i")) != -1) {
                                                                str = str.substr(l[i].length);
                                                                m = ((i + 12) % 12) + 1;                                                                 
                                                                continue loopLabel;
                                                        };
                                                };
                                                return false;
                                case "m": // Numeric representation of a month, with leading zeros
                                                l = /^(1[012]|0[1-9])/;
                                                if(str.search(l) != -1) {
                                                        m = +str.substr(0, 2);
                                                        str = str.substr(2);
                                                        break;
                                                } else {                                                        
                                                        return false;
                                                };
                                case "n": // Numeric representation of a month, without leading zeros
                                          // Accept either when parsing
                                                l = /^(1[012]|[1-9])/;
                                                if(str.search(l) != -1) {
                                                        m = +str.match(l)[0];
                                                        str = str.substr(str.match(l)[0].length);
                                                        break;
                                                } else {                                                        
                                                        return false;
                                                };
                                case "t": // Number of days in the given month: 28 through 31
                                                if(str.search(/2[89]|3[01]/) != -1) {
                                                        str = str.substr(2);
                                                        break;
                                                } else {                                                        
                                                        return false;
                                                };
                                // YEAR
                                
                                case "Y": // A full numeric representation of a year, 4 digits
                                                if(str.search(/^(\d{4})/) != -1) {
                                                        y = str.substr(0,4);
                                                        str = str.substr(4);
                                                        break;
                                                } else {                                                        
                                                        return false;
                                                };
                                
        
                                case "y": // A two digit representation of a year                                                
                                                if(str.search(/^(0[0-9]|[1-9][0-9])/) != -1) {
                                                        y = str.substr(0,2);
                                                        y = +y < 50 ? '20' + String(y) : '19' + String(y);
                                                        str = str.substr(2);
                                                        break;
                                                } else {
                                                        return false;
                                                };
                                       
                                default:
                                                str = str.substr(part.length);
                        };
                };   
                
                //console.log("dmy: " + d + " " + m + " " + y)
                if((dp && d === false) || (mp && m === false) || (yp && y === false)) {
                        return false;
                };                
                
                if(dp && mp && yp && +d > daysInMonth(+m, +y)) {
                        return false;
                };
                
                return {
                        "d":dp ? +d : false,
                        "m":mp ? +m : false,
                        "y":yp ? +y : false
                        };
        };      
                                    
        var findLabelForElement = function(element) {
                var label;
                if(element.parentNode && element.parentNode.tagName.toLowerCase() == "label") {
                        label = element.parentNode;
                } else {
                        var labelList = document.getElementsByTagName('label');
                        // loop through label array attempting to match each 'for' attribute to the id of the current element
                        for(var lbl = 0; lbl < labelList.length; lbl++) {
                                // Internet Explorer requires the htmlFor test
                                if((labelList[lbl]['htmlFor'] && labelList[lbl]['htmlFor'] == element.id) || (labelList[lbl].getAttribute('for') == element.id)) {
                                        label = labelList[lbl];
                                        break;
                                };
                        };
                };
                
                if(label && !label.id && element.id) { 
                        label.id = element.id + "_label"; 
                };
                
                return label;         
        };  
        var updateLanguage = function() {
                if(typeof(window.fdLocale) == "object" ) {                         
                        localeImport = {
                                titles          : fdLocale.titles,
                                fullMonths      : fdLocale.fullMonths,
                                monthAbbrs      : fdLocale.monthAbbrs,
                                fullDays        : fdLocale.fullDays,
                                dayAbbrs        : fdLocale.dayAbbrs,
                                firstDayOfWeek  : ("firstDayOfWeek" in fdLocale) ? fdLocale.firstDayOfWeek : 0,
                                imported        : true
                        };                                               
                } else if(!localeImport) {                        
                        localeImport = localeDefaults;
                };    
        };
        var loadLanguage = function() {
                updateLanguage();
                for(dp in datePickers) {
                        if(!datePickers[dp].created) {
                                continue;
                        };
                        datePickers[dp].updateTable();
                };   
        };
        var checkElem = function(elem) {                        
                return !(!elem || !elem.tagName || !((elem.tagName.toLowerCase() == "input" && (elem.type == "text" || elem.type == "hidden")) || elem.tagName.toLowerCase() == "select"));                
        };
        var addDatePicker = function(options) {  
                updateLanguage();
                
                if(!options.formElements) {
                        if(debug) {
                                throw "No form elements stipulated within initialisation parameters";
                        };
                        return;
                };
               
                options.id            = (options.id && (options.id in options.formElements)) ? options.id : "";
                options.enabledDates  = false;
                options.disabledDates = false;
                 
                var partsFound  = {d:0,m:0,y:0},
                    cursorDate  = false,
                    myMin       = 0,
                    myMax       = 0,               
                    fmt,
                    opts,
                    dtPartStr,
                    elemID,
                    elem;
                    
                for(elemID in options.formElements) {
                        elem = document.getElementById(elemID);
                        
                        if(!checkElem(elem)) {
                                if(debug) throw "Element '" + elemID + "' is of the wrong type or does not exist within the DOM";
                                return false;
                        };
                        
                        if(!(options.formElements[elemID].match(formatTestRegExp))) {
                                if(debug) throw "Element '" + elemID + "' has a date format that does not contain either a day (d|j), month (m|F|n) or year (y|Y) part: " + options.formElements[elemID];
                                return false;
                        };
                        
                        if(!options.id) {
                                options.id = elemID;
                        };
                        
                        options.formElements[elemID].defaultVal = elem.tagName == "select" ? elem.selectedIndex || 0 : elem.defaultValue;
                        
                        fmt             = {
                                "value":options.formElements[elemID]
                        };
                        
                        fmt.d = fmt.value.search(dPartsRegExp) != -1;
                        fmt.m = fmt.value.search(mPartsRegExp) != -1;
                        fmt.y = fmt.value.search(yPartsRegExp) != -1;
                                         
                        if(fmt.d) { 
                                partsFound.d++; 
                        };
                        if(fmt.m) { 
                                partsFound.m++; 
                        };
                        if(fmt.y) { 
                                partsFound.y++; 
                        };
                        
                        if(elem.tagName.toLowerCase() == "select") {                                
                                // If we have a selectList, then try to parse the higher and lower limits 
                                var selOptions = elem.options;
                                
                                // Check the yyyymmdd 
                                if(fmt.d && fmt.m && fmt.y) { 
                                        cursorDate = false;
                                        
                                        // Dynamically calculate the available "enabled" dates
                                        options.enabledDates = {};
                                        options.disabledDates = {};
                                            
                                        for(i = 0; i < selOptions.length; i++) {                                                                                                
                                                dt = parseDateString(selOptions[i].value, fmt.value);
                                                
                                                if(dt && dt.y && !(dt.m === false) && dt.d) {
                                                        
                                                        dtPartStr = dt.y + "" + pad(dt.m) + pad(dt.d);
                                                        if(!cursorDate) {
                                                                cursorDate = dtPartStr;
                                                        };
                                                        
                                                        options.enabledDates[dtPartStr] = 1;
                                                        
                                                        if(!myMin || +dtPartStr < +myMin) {
                                                                myMin = dtPartStr;
                                                        }; 
                                                        
                                                        if(!myMax || +dtPartStr > +myMax) {
                                                                myMax = dtPartStr;
                                                        };
                                                };                                     
                                        };  
                        
                                        // Automatically set cursor to first available date (if no bespoke cursorDate was set);                                        
                                        if(!options.cursorDate && cursorDate) {
                                                options.cursorDate = cursorDate;
                                        };
                                        
                                        options.disabledDates[myMin] = myMax;
                                          
                                } else if(fmt.m && fmt.y) {
                                         
                                        for(i = 0; i < selOptions.length; i++) {
                                                dt = parseDateString(selOptions[i].value, fmt.value);
                                                if(dt.y && !(dt.m === false)) {
                                                        dtPartStr = dt.y + "" + pad(dt.m);
                                                
                                                        if(!myMin || +dtPartStr < +myMin) {
                                                                myMin = dtPartStr;
                                                        }; 
                                                
                                                        if(!myMax || +dtPartStr > +myMax) {
                                                                myMax = dtPartStr;
                                                        };                                                
                                                };
                                                                                     
                                        };                                           
                                        
                                        // Round the min & max values to be used as rangeLow & rangeHigh
                                        myMin += "" + "01";
                                        myMax += "" + daysInMonth(+myMax.substr(4,2) - 1, +myMax.substr(0,4));
                                                                                
                                } else if(fmt.y) {
                                        for(i = 0; i < selOptions.length; i++) {
                                                dt = parseDateString(selOptions[i].value, fmt.value);
                                                if(dt.y) {                                                           
                                                         
                                                        if(!myMin || +dt.y < +myMin) {
                                                                myMin = dt.y;
                                                        }; 
                                                
                                                        if(!myMax || +dt.y > +myMax) {
                                                                myMax = dt.y;
                                                        }; 
                                                };                         
                                        };  
                                        
                                        // Round the min & max values to be used as rangeLow & rangeHigh
                                        myMin += "" + "0101";
                                        myMax += "" + "1231";                                                                                                    
                                };                                
                        };
                };
                
                if(!(partsFound.d == 1 && partsFound.m == 1 && partsFound.y == 1)) {
                        if(debug) {
                                throw "Could not find all of the required date parts within the date format for element: " + elem.id;
                        };
                        return false;
                }; 

                if(myMin && (!options.rangeLow  || (+options.rangeLow < +myMin))) { 
                        options.rangeLow = myMin; 
                };
                if(myMax && (!options.rangeHigh || (+options.rangeHigh > +myMin))) { 
                        options.rangeHigh = myMax; 
                };                                
                
                opts = {
                        formElements:options.formElements,
                        // Form element id
                        id:options.id,                       
                        // Non popup datepicker required
                        staticPos:!!(options.staticPos),
                        // Position static datepicker or popup datepicker's button
                        positioned:options.positioned && document.getElementById(options.positioned) ? options.positioned : "",
                        // Ranges stipulated in YYYYMMDD format       
                        rangeLow:options.rangeLow && String(options.rangeLow).search(rangeRegExp) != -1 ? options.rangeLow : "",
                        rangeHigh:options.rangeHigh && String(options.rangeHigh).search(rangeRegExp) != -1 ? options.rangeHigh : "",
                        // Status bar format
                        statusFormat:options.statusFormat || statusFormat,                                                                                 
                        // No fade in/out effect
                        noFadeEffect:!!(options.staticPos) ? true : !!(options.noFadeEffect),
                        // No drag functionality
                        dragDisabled:nodrag || !!(options.staticPos) ? true : !!(options.dragDisabled),
                        // Bespoke tabindex for this datePicker (or its activation button)
                        bespokeTabIndex:options.bespokeTabindex && typeof options.bespokeTabindex == 'number' ? parseInt(options.bespokeTabindex, 10) : 0,
                        // Bespoke titles
                        bespokeTitles:options.bespokeTitles || (bespokeTitles || {}),
                        // Final opacity 
                        finalOpacity:options.finalOpacity && typeof options.finalOpacity == 'number' && (options.finalOpacity > 20 && options.finalOpacity <= 100) ? parseInt(+options.finalOpacity, 10) : (!!(options.staticPos) ? 100 : finalOpacity),
                        // Do we hide the form elements on datepicker creation
                        hideInput:!!(options.hideInput),
                        // Do we hide the "today" button
                        noToday:!!(options.noTodayButton),
                        // Do we show week numbers
                        showWeeks:!!(options.showWeeks),
                        // Do we fill the entire grid with dates                                                  
                        fillGrid:!!(options.fillGrid),
                        // Do we constrain selection of dates outside the current month
                        constrainSelection:"constrainSelection" in options ? !!(options.constrainSelection) : true,
                        // The date to set the initial cursor to
                        cursorDate:options.cursorDate && String(options.cursorDate).search(rangeRegExp) != -1 ? options.cursorDate : "",                        
                        // Locate label to set the ARIA labelled-by property
                        labelledBy:findLabelForElement(elem),
                        // Have we been passed a describedBy to set the ARIA decribed-by property...
                        describedBy:(options.describedBy && document.getElementById(options.describedBy)) ? options.describedBy : describedBy && document.getElementById(describedBy) ? describedBy : "",
                        // Callback functions
                        callbacks:options.callbackFunctions ? options.callbackFunctions : {},
                        // Days of the week to highlight (normally the weekend)
                        highlightDays:options.highlightDays && options.highlightDays.length && options.highlightDays.length == 7 ? options.highlightDays : [0,0,0,0,0,1,1],
                        // Days of the week to disable
                        disabledDays:options.disabledDays && options.disabledDays.length && options.disabledDays.length == 7 ? options.disabledDays : [0,0,0,0,0,0,0]                                                                   
                };  
                
                datePickers[options.id] = new datePicker(opts);                         
                
                if("disabledDates" in options && !(options.disabledDates === false)) {
                        datePickers[options.id].setDisabledDates(options.disabledDates)
                };
                
                if("enabledDates" in options && !(options.enabledDates === false)) {
                        datePickers[options.id].setEnabledDates(options.enabledDates)
                };
                
                datePickers[options.id].callback("create", datePickers[options.id].createCbArgObj());                                  
        };

        // Used by the button to dictate whether to open or close the datePicker
        var isVisible = function(id) {
                return (!id || !(id in datePickers)) ? false : datePickers[id].visible;
        };  
        
        var updateStatic = function() {
                var dp;
                for(dp in datePickers) {
                        if(datePickers.hasOwnProperty(dp)) {
                                datePickers[dp].changeHandler();
                        };
                };
        };
        
        addEvent(window, 'unload', destroy);
        addEvent(window, "load", function() { setTimeout(updateStatic, 0); });
        
        // Add oldie class if needed for IE < 9
        /*@cc_on
        @if (@_jscript_version < 5.8)
                addClass(document.documentElement, "oldie-mhtml");
        @end
        @*/

        /*
        
        @if (@_jscript_version == 5.8)
                addClass(document.documentElement, "oldie-8"); 
        @elif (@_jscript_version == 5.7 && window.XMLHttpRequest)
                addClass(document.documentElement, "oldie-7");
        @else (@_jscript_version == 5.6 || (@_jscript_version == 5.7 && !window.XMLHttpRequest))
                addClass(document.documentElement, "oldie-6");
        */
        
        /*@cc_on  
        @if (@_jscript_version < 9)
                addClass(document.documentElement, "oldie");
        @end 
        @*/
        
        return {
                // General event functions...
                addEvent:               function(obj, type, fn) { return addEvent(obj, type, fn); },
                removeEvent:            function(obj, type, fn) { return removeEvent(obj, type, fn); },
                stopEvent:              function(e) { return stopEvent(e); },
                // Show a single popup datepicker
                show:                   function(inpID) { return showDatePicker(inpID, false); },
                // Hide a popup datepicker
                hide:                   function(inpID) { return hideDatePicker(inpID); },                
                // Create a new datepicker
                createDatePicker:       function(options) { addDatePicker(options); },
                // Destroy a datepicker (remove events and DOM nodes)               
                destroyDatePicker:      function(inpID) { destroySingleDatePicker(inpID); },
                // Check datePicker form elements exist, if not, destroy the datepicker
                cleanUp:                function() { cleanUp(); },                    
                // Pretty print a date object according to the format passed in               
                printFormattedDate:     function(dt, fmt, useImportedLocale) { return printFormattedDate(dt, fmt, useImportedLocale); },
                // Update the internal date using the form element value
                setDateFromInput:       function(inpID) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].setDateFromInput(); },
                // Set low and high date ranges
                setRangeLow:            function(inpID, yyyymmdd) { if(!inpID || !(inpID in datePickers)) { return false; }; datePickers[inpID].setRangeLow(dateToYYYYMMDD(yyyymmdd)); },
                setRangeHigh:           function(inpID, yyyymmdd) { if(!inpID || !(inpID in datePickers)) { return false; }; datePickers[inpID].setRangeHigh(dateToYYYYMMDD(yyyymmdd)); },
                // Set bespoke titles for a datepicker instance
                setBespokeTitles:       function(inpID, titles) {if(!inpID || !(inpID in datePickers)) { return false; }; datePickers[inpID].setBespokeTitles(titles); },
                // Add bespoke titles for a datepicker instance
                addBespokeTitles:       function(inpID, titles) {if(!inpID || !(inpID in datePickers)) { return false; }; datePickers[inpID].addBespokeTitles(titles); },                
                // Attempt to parse a valid date from a date string using the passed in format
                parseDateString:        function(str, format) { return parseDateString(str, format); },
                // Change global configuration parameters
                setGlobalOptions:       function(json) { affectJSON(json); },
                // Forces the datepickers "selected" date
                setSelectedDate:        function(inpID, yyyymmdd) { if(!inpID || !(inpID in datePickers)) { return false; }; datePickers[inpID].setSelectedDate(dateToYYYYMMDD(yyyymmdd)); },
                // Is the date valid for selection i.e. not outside ranges etc
                dateValidForSelection:  function(inpID, dt) { if(!inpID || !(inpID in datePickers)) return false; return datePickers[inpID].canDateBeSelected(dt); },
                // Add disabled and enabled dates
                addDisabledDates:       function(inpID, dts) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].addDisabledDates(dts); },
                setDisabledDates:       function(inpID, dts) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].setDisabledDates(dts); },
                addEnabledDates:        function(inpID, dts) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].addEnabledDates(dts); },
                setEnabledDates:        function(inpID, dts) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].setEnabledDates(dts); },
                // Disable and enable the datepicker
                disable:                function(inpID) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].disableDatePicker(); },
                enable:                 function(inpID) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].enableDatePicker(); },
                // Set the cursor date
                setCursorDate:          function(inpID, yyyymmdd) { if(!inpID || !(inpID in datePickers)) return false; datePickers[inpID].setCursorDate(dateToYYYYMMDD(yyyymmdd)); },
                // Whats the currently selected date
                getSelectedDate:        function(inpID) { return (!inpID || !(inpID in datePickers)) ? false : datePickers[inpID].returnSelectedDate(); },
                // Attempt to update the language (causes a redraw of all datepickers on the page)
                loadLanguage:           function() { loadLanguage(); },
                // Set the debug level i.e. throw errors or fail silently
                setDebug:               function(dbg) { debug = !!(dbg); },
                // Converts Date Object to a YYYYMMDD formatted String
                dateToYYYYMMDDStr:      function(dt) { return dateToYYYYMMDD(dt); }                                                            
        }; 
})();
