var Prototype={Version:"1.5.1.1",Browser:{IE:!!(window.attachEvent&&!window.opera),Opera:!!window.opera,WebKit:navigator.userAgent.indexOf("AppleWebKit/")>-1,Gecko:navigator.userAgent.indexOf("Gecko")>-1&&navigator.userAgent.indexOf("KHTML")==-1},BrowserFeatures:{XPath:!!document.evaluate,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:(document.createElement("div").__proto__!==document.createElement("form").__proto__)},ScriptFragment:"<script[^>]*>([\\S\\s]*?)</script>",JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){
},K:function(x){
return x;
}};
var Class={create:function(){
return function(){
this.initialize.apply(this,arguments);
};
}};
var Abstract=new Object();
Object.extend=function(_2,_3){
for(var _4 in _3){
_2[_4]=_3[_4];
}
return _2;
};
Object.extend(Object,{inspect:function(_5){
try{
if(_5===undefined){
return "undefined";
}
if(_5===null){
return "null";
}
return _5.inspect?_5.inspect():_5.toString();
}
catch(e){
if(e instanceof RangeError){
return "...";
}
throw e;
}
},toJSON:function(_6){
var _7=typeof _6;
switch(_7){
case "undefined":
case "function":
case "unknown":
return;
case "boolean":
return _6.toString();
}
if(_6===null){
return "null";
}
if(_6.toJSON){
return _6.toJSON();
}
if(_6.ownerDocument===document){
return;
}
var _8=[];
for(var _9 in _6){
var _a=Object.toJSON(_6[_9]);
if(_a!==undefined){
_8.push(_9.toJSON()+": "+_a);
}
}
return "{"+_8.join(", ")+"}";
},keys:function(_b){
var _c=[];
for(var _d in _b){
_c.push(_d);
}
return _c;
},values:function(_e){
var _f=[];
for(var _10 in _e){
_f.push(_e[_10]);
}
return _f;
},clone:function(_11){
return Object.extend({},_11);
}});
Function.prototype.bind=function(){
var _12=this,args=$A(arguments),object=args.shift();
return function(){
return _12.apply(object,args.concat($A(arguments)));
};
};
Function.prototype.bindAsEventListener=function(_13){
var _14=this,args=$A(arguments),_13=args.shift();
return function(_15){
return _14.apply(_13,[_15||window.event].concat(args));
};
};
Object.extend(Number.prototype,{toColorPart:function(){
return this.toPaddedString(2,16);
},succ:function(){
return this+1;
},times:function(_16){
$R(0,this,true).each(_16);
return this;
},toPaddedString:function(_17,_18){
var _19=this.toString(_18||10);
return "0".times(_17-_19.length)+_19;
},toJSON:function(){
return isFinite(this)?this.toString():"null";
}});
Date.prototype.toJSON=function(){
return "\""+this.getFullYear()+"-"+(this.getMonth()+1).toPaddedString(2)+"-"+this.getDate().toPaddedString(2)+"T"+this.getHours().toPaddedString(2)+":"+this.getMinutes().toPaddedString(2)+":"+this.getSeconds().toPaddedString(2)+"\"";
};
var Try={these:function(){
var _1a;
for(var i=0,length=arguments.length;i<length;i++){
var _1c=arguments[i];
try{
_1a=_1c();
break;
}
catch(e){
}
}
return _1a;
}};
var PeriodicalExecuter=Class.create();
PeriodicalExecuter.prototype={initialize:function(_1d,_1e){
this.callback=_1d;
this.frequency=_1e;
this.currentlyExecuting=false;
this.registerCallback();
},registerCallback:function(){
this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},stop:function(){
if(!this.timer){
return;
}
clearInterval(this.timer);
this.timer=null;
},onTimerEvent:function(){
if(!this.currentlyExecuting){
try{
this.currentlyExecuting=true;
this.callback(this);
}
finally{
this.currentlyExecuting=false;
}
}
}};
Object.extend(String,{interpret:function(_1f){
return _1f==null?"":String(_1f);
},specialChar:{"\b":"\\b","\t":"\\t","\n":"\\n","\f":"\\f","\r":"\\r","\\":"\\\\"}});
Object.extend(String.prototype,{gsub:function(_20,_21){
var _22="",source=this,match;
_21=arguments.callee.prepareReplacement(_21);
while(source.length>0){
if(match=source.match(_20)){
_22+=source.slice(0,match.index);
_22+=String.interpret(_21(match));
source=source.slice(match.index+match[0].length);
}else{
_22+=source,source="";
}
}
return _22;
},sub:function(_23,_24,_25){
_24=this.gsub.prepareReplacement(_24);
_25=_25===undefined?1:_25;
return this.gsub(_23,function(_26){
if(--_25<0){
return _26[0];
}
return _24(_26);
});
},scan:function(_27,_28){
this.gsub(_27,_28);
return this;
},truncate:function(_29,_2a){
_29=_29||30;
_2a=_2a===undefined?"...":_2a;
return this.length>_29?this.slice(0,_29-_2a.length)+_2a:this;
},strip:function(){
return this.replace(/^\s+/,"").replace(/\s+$/,"");
},stripTags:function(){
return this.replace(/<\/?[^>]+>/gi,"");
},stripScripts:function(){
return this.replace(new RegExp(Prototype.ScriptFragment,"img"),"");
},extractScripts:function(){
var _2b=new RegExp(Prototype.ScriptFragment,"img");
var _2c=new RegExp(Prototype.ScriptFragment,"im");
return (this.match(_2b)||[]).map(function(_2d){
return (_2d.match(_2c)||["",""])[1];
});
},evalScripts:function(){
return this.extractScripts().map(function(_2e){
return eval(_2e);
});
},escapeHTML:function(){
var _2f=arguments.callee;
_2f.text.data=this;
return _2f.div.innerHTML;
},unescapeHTML:function(){
var div=document.createElement("div");
div.innerHTML=this.stripTags();
return div.childNodes[0]?(div.childNodes.length>1?$A(div.childNodes).inject("",function(_31,_32){
return _31+_32.nodeValue;
}):div.childNodes[0].nodeValue):"";
},toQueryParams:function(_33){
var _34=this.strip().match(/([^?#]*)(#.*)?$/);
if(!_34){
return {};
}
return _34[1].split(_33||"&").inject({},function(_35,_36){
if((_36=_36.split("="))[0]){
var key=decodeURIComponent(_36.shift());
var _38=_36.length>1?_36.join("="):_36[0];
if(_38!=undefined){
_38=decodeURIComponent(_38);
}
if(key in _35){
if(_35[key].constructor!=Array){
_35[key]=[_35[key]];
}
_35[key].push(_38);
}else{
_35[key]=_38;
}
}
return _35;
});
},toArray:function(){
return this.split("");
},succ:function(){
return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1);
},times:function(_39){
var _3a="";
for(var i=0;i<_39;i++){
_3a+=this;
}
return _3a;
},camelize:function(){
var _3c=this.split("-"),len=_3c.length;
if(len==1){
return _3c[0];
}
var _3d=this.charAt(0)=="-"?_3c[0].charAt(0).toUpperCase()+_3c[0].substring(1):_3c[0];
for(var i=1;i<len;i++){
_3d+=_3c[i].charAt(0).toUpperCase()+_3c[i].substring(1);
}
return _3d;
},capitalize:function(){
return this.charAt(0).toUpperCase()+this.substring(1).toLowerCase();
},underscore:function(){
return this.gsub(/::/,"/").gsub(/([A-Z]+)([A-Z][a-z])/,"#{1}_#{2}").gsub(/([a-z\d])([A-Z])/,"#{1}_#{2}").gsub(/-/,"_").toLowerCase();
},dasherize:function(){
return this.gsub(/_/,"-");
},inspect:function(_3f){
var _40=this.gsub(/[\x00-\x1f\\]/,function(_41){
var _42=String.specialChar[_41[0]];
return _42?_42:"\\u00"+_41[0].charCodeAt().toPaddedString(2,16);
});
if(_3f){
return "\""+_40.replace(/"/g,"\\\"")+"\"";
}
return "'"+_40.replace(/'/g,"\\'")+"'";
},toJSON:function(){
return this.inspect(true);
},unfilterJSON:function(_43){
return this.sub(_43||Prototype.JSONFilter,"#{1}");
},isJSON:function(){
var str=this.replace(/\\./g,"@").replace(/"[^"\\\n\r]*"/g,"");
return (/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(str);
},evalJSON:function(_45){
var _46=this.unfilterJSON();
try{
if(!_45||_46.isJSON()){
return eval("("+_46+")");
}
}
catch(e){
}
throw new SyntaxError("Badly formed JSON string: "+this.inspect());
},include:function(_47){
return this.indexOf(_47)>-1;
},startsWith:function(_48){
return this.indexOf(_48)===0;
},endsWith:function(_49){
var d=this.length-_49.length;
return d>=0&&this.lastIndexOf(_49)===d;
},empty:function(){
return this=="";
},blank:function(){
return /^\s*$/.test(this);
}});
if(Prototype.Browser.WebKit||Prototype.Browser.IE){
Object.extend(String.prototype,{escapeHTML:function(){
return this.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;");
},unescapeHTML:function(){
return this.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">");
}});
}
String.prototype.gsub.prepareReplacement=function(_4b){
if(typeof _4b=="function"){
return _4b;
}
var _4c=new Template(_4b);
return function(_4d){
return _4c.evaluate(_4d);
};
};
String.prototype.parseQuery=String.prototype.toQueryParams;
Object.extend(String.prototype.escapeHTML,{div:document.createElement("div"),text:document.createTextNode("")});
with(String.prototype.escapeHTML){
div.appendChild(text);
}
var Template=Class.create();
Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;
Template.prototype={initialize:function(_4e,_4f){
this.template=_4e.toString();
this.pattern=_4f||Template.Pattern;
},evaluate:function(_50){
return this.template.gsub(this.pattern,function(_51){
var _52=_51[1];
if(_52=="\\"){
return _51[2];
}
return _52+String.interpret(_50[_51[3]]);
});
}};
var $break={},$continue=new Error("\"throw $continue\" is deprecated, use \"return\" instead");
var Enumerable={each:function(_53){
var _54=0;
try{
this._each(function(_55){
_53(_55,_54++);
});
}
catch(e){
if(e!=$break){
throw e;
}
}
return this;
},eachSlice:function(_56,_57){
var _58=-_56,slices=[],array=this.toArray();
while((_58+=_56)<array.length){
slices.push(array.slice(_58,_58+_56));
}
return slices.map(_57);
},all:function(_59){
var _5a=true;
this.each(function(_5b,_5c){
_5a=_5a&&!!(_59||Prototype.K)(_5b,_5c);
if(!_5a){
throw $break;
}
});
return _5a;
},any:function(_5d){
var _5e=false;
this.each(function(_5f,_60){
if(_5e=!!(_5d||Prototype.K)(_5f,_60)){
throw $break;
}
});
return _5e;
},collect:function(_61){
var _62=[];
this.each(function(_63,_64){
_62.push((_61||Prototype.K)(_63,_64));
});
return _62;
},detect:function(_65){
var _66;
this.each(function(_67,_68){
if(_65(_67,_68)){
_66=_67;
throw $break;
}
});
return _66;
},findAll:function(_69){
var _6a=[];
this.each(function(_6b,_6c){
if(_69(_6b,_6c)){
_6a.push(_6b);
}
});
return _6a;
},grep:function(_6d,_6e){
var _6f=[];
this.each(function(_70,_71){
var _72=_70.toString();
if(_72.match(_6d)){
_6f.push((_6e||Prototype.K)(_70,_71));
}
});
return _6f;
},include:function(_73){
var _74=false;
this.each(function(_75){
if(_75==_73){
_74=true;
throw $break;
}
});
return _74;
},inGroupsOf:function(_76,_77){
_77=_77===undefined?null:_77;
return this.eachSlice(_76,function(_78){
while(_78.length<_76){
_78.push(_77);
}
return _78;
});
},inject:function(_79,_7a){
this.each(function(_7b,_7c){
_79=_7a(_79,_7b,_7c);
});
return _79;
},invoke:function(_7d){
var _7e=$A(arguments).slice(1);
return this.map(function(_7f){
return _7f[_7d].apply(_7f,_7e);
});
},max:function(_80){
var _81;
this.each(function(_82,_83){
_82=(_80||Prototype.K)(_82,_83);
if(_81==undefined||_82>=_81){
_81=_82;
}
});
return _81;
},min:function(_84){
var _85;
this.each(function(_86,_87){
_86=(_84||Prototype.K)(_86,_87);
if(_85==undefined||_86<_85){
_85=_86;
}
});
return _85;
},partition:function(_88){
var _89=[],falses=[];
this.each(function(_8a,_8b){
((_88||Prototype.K)(_8a,_8b)?_89:falses).push(_8a);
});
return [_89,falses];
},pluck:function(_8c){
var _8d=[];
this.each(function(_8e,_8f){
_8d.push(_8e[_8c]);
});
return _8d;
},reject:function(_90){
var _91=[];
this.each(function(_92,_93){
if(!_90(_92,_93)){
_91.push(_92);
}
});
return _91;
},sortBy:function(_94){
return this.map(function(_95,_96){
return {value:_95,criteria:_94(_95,_96)};
}).sort(function(_97,_98){
var a=_97.criteria,b=_98.criteria;
return a<b?-1:a>b?1:0;
}).pluck("value");
},toArray:function(){
return this.map();
},zip:function(){
var _9a=Prototype.K,args=$A(arguments);
if(typeof args.last()=="function"){
_9a=args.pop();
}
var _9b=[this].concat(args).map($A);
return this.map(function(_9c,_9d){
return _9a(_9b.pluck(_9d));
});
},size:function(){
return this.toArray().length;
},inspect:function(){
return "#<Enumerable:"+this.toArray().inspect()+">";
}};
Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray});
var $A=Array.from=function(_9e){
if(!_9e){
return [];
}
if(_9e.toArray){
return _9e.toArray();
}else{
var _9f=[];
for(var i=0,length=_9e.length;i<length;i++){
_9f.push(_9e[i]);
}
return _9f;
}
};
if(Prototype.Browser.WebKit){
$A=Array.from=function(_a1){
if(!_a1){
return [];
}
if(!(typeof _a1=="function"&&_a1=="[object NodeList]")&&_a1.toArray){
return _a1.toArray();
}else{
var _a2=[];
for(var i=0,length=_a1.length;i<length;i++){
_a2.push(_a1[i]);
}
return _a2;
}
};
}
Object.extend(Array.prototype,Enumerable);
if(!Array.prototype._reverse){
Array.prototype._reverse=Array.prototype.reverse;
}
Object.extend(Array.prototype,{_each:function(_a4){
for(var i=0,length=this.length;i<length;i++){
_a4(this[i]);
}
},clear:function(){
this.length=0;
return this;
},first:function(){
return this[0];
},last:function(){
return this[this.length-1];
},compact:function(){
return this.select(function(_a6){
return _a6!=null;
});
},flatten:function(){
return this.inject([],function(_a7,_a8){
return _a7.concat(_a8&&_a8.constructor==Array?_a8.flatten():[_a8]);
});
},without:function(){
var _a9=$A(arguments);
return this.select(function(_aa){
return !_a9.include(_aa);
});
},indexOf:function(_ab){
for(var i=0,length=this.length;i<length;i++){
if(this[i]==_ab){
return i;
}
}
return -1;
},reverse:function(_ad){
return (_ad!==false?this:this.toArray())._reverse();
},reduce:function(){
return this.length>1?this:this[0];
},uniq:function(_ae){
return this.inject([],function(_af,_b0,_b1){
if(0==_b1||(_ae?_af.last()!=_b0:!_af.include(_b0))){
_af.push(_b0);
}
return _af;
});
},clone:function(){
return [].concat(this);
},size:function(){
return this.length;
},inspect:function(){
return "["+this.map(Object.inspect).join(", ")+"]";
},toJSON:function(){
var _b2=[];
this.each(function(_b3){
var _b4=Object.toJSON(_b3);
if(_b4!==undefined){
_b2.push(_b4);
}
});
return "["+_b2.join(", ")+"]";
}});
Array.prototype.toArray=Array.prototype.clone;
function $w(_b5){
_b5=_b5.strip();
return _b5?_b5.split(/\s+/):[];
}
if(Prototype.Browser.Opera){
Array.prototype.concat=function(){
var _b6=[];
for(var i=0,length=this.length;i<length;i++){
_b6.push(this[i]);
}
for(var i=0,length=arguments.length;i<length;i++){
if(arguments[i].constructor==Array){
for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++){
_b6.push(arguments[i][j]);
}
}else{
_b6.push(arguments[i]);
}
}
return _b6;
};
}
var Hash=function(_ba){
if(_ba instanceof Hash){
this.merge(_ba);
}else{
Object.extend(this,_ba||{});
}
};
Object.extend(Hash,{toQueryString:function(obj){
var _bc=[];
_bc.add=arguments.callee.addPair;
this.prototype._each.call(obj,function(_bd){
if(!_bd.key){
return;
}
var _be=_bd.value;
if(_be&&typeof _be=="object"){
if(_be.constructor==Array){
_be.each(function(_bf){
_bc.add(_bd.key,_bf);
});
}
return;
}
_bc.add(_bd.key,_be);
});
return _bc.join("&");
},toJSON:function(_c0){
var _c1=[];
this.prototype._each.call(_c0,function(_c2){
var _c3=Object.toJSON(_c2.value);
if(_c3!==undefined){
_c1.push(_c2.key.toJSON()+": "+_c3);
}
});
return "{"+_c1.join(", ")+"}";
}});
Hash.toQueryString.addPair=function(key,_c5,_c6){
key=encodeURIComponent(key);
if(_c5===undefined){
this.push(key);
}else{
this.push(key+"="+(_c5==null?"":encodeURIComponent(_c5)));
}
};
Object.extend(Hash.prototype,Enumerable);
Object.extend(Hash.prototype,{_each:function(_c7){
for(var key in this){
var _c9=this[key];
if(_c9&&_c9==Hash.prototype[key]){
continue;
}
var _ca=[key,_c9];
_ca.key=key;
_ca.value=_c9;
_c7(_ca);
}
},keys:function(){
return this.pluck("key");
},values:function(){
return this.pluck("value");
},merge:function(_cb){
return $H(_cb).inject(this,function(_cc,_cd){
_cc[_cd.key]=_cd.value;
return _cc;
});
},remove:function(){
var _ce;
for(var i=0,length=arguments.length;i<length;i++){
var _d0=this[arguments[i]];
if(_d0!==undefined){
if(_ce===undefined){
_ce=_d0;
}else{
if(_ce.constructor!=Array){
_ce=[_ce];
}
_ce.push(_d0);
}
}
delete this[arguments[i]];
}
return _ce;
},toQueryString:function(){
return Hash.toQueryString(this);
},inspect:function(){
return "#<Hash:{"+this.map(function(_d1){
return _d1.map(Object.inspect).join(": ");
}).join(", ")+"}>";
},toJSON:function(){
return Hash.toJSON(this);
}});
function $H(_d2){
if(_d2 instanceof Hash){
return _d2;
}
return new Hash(_d2);
}
if(function(){
var i=0,Test=function(_d4){
this.key=_d4;
};
Test.prototype.key="foo";
for(var _d5 in new Test("bar")){
i++;
}
return i>1;
}()){
Hash.prototype._each=function(_d6){
var _d7=[];
for(var key in this){
var _d9=this[key];
if((_d9&&_d9==Hash.prototype[key])||_d7.include(key)){
continue;
}
_d7.push(key);
var _da=[key,_d9];
_da.key=key;
_da.value=_d9;
_d6(_da);
}
};
}
ObjectRange=Class.create();
Object.extend(ObjectRange.prototype,Enumerable);
Object.extend(ObjectRange.prototype,{initialize:function(_db,end,_dd){
this.start=_db;
this.end=end;
this.exclusive=_dd;
},_each:function(_de){
var _df=this.start;
while(this.include(_df)){
_de(_df);
_df=_df.succ();
}
},include:function(_e0){
if(_e0<this.start){
return false;
}
if(this.exclusive){
return _e0<this.end;
}
return _e0<=this.end;
}});
var $R=function(_e1,end,_e3){
return new ObjectRange(_e1,end,_e3);
};
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(_e4){
this.responders._each(_e4);
},register:function(_e5){
if(!this.include(_e5)){
this.responders.push(_e5);
}
},unregister:function(_e6){
this.responders=this.responders.without(_e6);
},dispatch:function(_e7,_e8,_e9,_ea){
this.each(function(_eb){
if(typeof _eb[_e7]=="function"){
try{
_eb[_e7].apply(_eb,[_e8,_e9,_ea]);
}
catch(e){
}
}
});
}};
Object.extend(Ajax.Responders,Enumerable);
Ajax.Responders.register({onCreate:function(){
Ajax.activeRequestCount++;
},onComplete:function(){
Ajax.activeRequestCount--;
}});
Ajax.Base=function(){
};
Ajax.Base.prototype={setOptions:function(_ec){
this.options={method:"post",asynchronous:true,contentType:"application/x-www-form-urlencoded",encoding:"UTF-8",parameters:""};
Object.extend(this.options,_ec||{});
this.options.method=this.options.method.toLowerCase();
if(typeof this.options.parameters=="string"){
this.options.parameters=this.options.parameters.toQueryParams();
}
}};
Ajax.Request=Class.create();
Ajax.Request.Events=["Uninitialized","Loading","Loaded","Interactive","Complete"];
Ajax.Request.prototype=Object.extend(new Ajax.Base(),{_complete:false,initialize:function(url,_ee){
this.transport=Ajax.getTransport();
this.setOptions(_ee);
this.request(url);
},request:function(url){
this.url=url;
this.method=this.options.method;
var _f0=Object.clone(this.options.parameters);
if(!["get","post"].include(this.method)){
_f0["_method"]=this.method;
this.method="post";
}
this.parameters=_f0;
if(_f0=Hash.toQueryString(_f0)){
if(this.method=="get"){
this.url+=(this.url.include("?")?"&":"?")+_f0;
}else{
if(/Konqueror|Safari|KHTML/.test(navigator.userAgent)){
_f0+="&_=";
}
}
}
try{
if(this.options.onCreate){
this.options.onCreate(this.transport);
}
Ajax.Responders.dispatch("onCreate",this,this.transport);
this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);
if(this.options.asynchronous){
setTimeout(function(){
this.respondToReadyState(1);
}.bind(this),10);
}
this.transport.onreadystatechange=this.onStateChange.bind(this);
this.setRequestHeaders();
this.body=this.method=="post"?(this.options.postBody||_f0):null;
this.transport.send(this.body);
if(!this.options.asynchronous&&this.transport.overrideMimeType){
this.onStateChange();
}
}
catch(e){
this.dispatchException(e);
}
},onStateChange:function(){
var _f1=this.transport.readyState;
if(_f1>1&&!((_f1==4)&&this._complete)){
this.respondToReadyState(this.transport.readyState);
}
},setRequestHeaders:function(){
var _f2={"X-Requested-With":"XMLHttpRequest","X-Prototype-Version":Prototype.Version,"Accept":"text/javascript, text/html, application/xml, text/xml, */*"};
if(this.method=="post"){
_f2["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){
_f2["Connection"]="close";
}
}
if(typeof this.options.requestHeaders=="object"){
var _f3=this.options.requestHeaders;
if(typeof _f3.push=="function"){
for(var i=0,length=_f3.length;i<length;i+=2){
_f2[_f3[i]]=_f3[i+1];
}
}else{
$H(_f3).each(function(_f5){
_f2[_f5.key]=_f5.value;
});
}
}
for(var _f6 in _f2){
this.transport.setRequestHeader(_f6,_f2[_f6]);
}
},success:function(){
return !this.transport.status||(this.transport.status>=200&&this.transport.status<300);
},respondToReadyState:function(_f7){
var _f8=Ajax.Request.Events[_f7];
var _f9=this.transport,json=this.evalJSON();
if(_f8=="Complete"){
try{
this._complete=true;
(this.options["on"+this.transport.status]||this.options["on"+(this.success()?"Success":"Failure")]||Prototype.emptyFunction)(_f9,json);
}
catch(e){
this.dispatchException(e);
}
var _fa=this.getHeader("Content-type");
if(_fa&&_fa.strip().match(/^(text|application)\/(x-)?(java|ecma)script(;.*)?$/i)){
this.evalResponse();
}
}
try{
(this.options["on"+_f8]||Prototype.emptyFunction)(_f9,json);
Ajax.Responders.dispatch("on"+_f8,this,_f9,json);
}
catch(e){
this.dispatchException(e);
}
if(_f8=="Complete"){
this.transport.onreadystatechange=Prototype.emptyFunction;
}
},getHeader:function(_fb){
try{
return this.transport.getResponseHeader(_fb);
}
catch(e){
return null;
}
},evalJSON:function(){
try{
var _fc=this.getHeader("X-JSON");
return _fc?_fc.evalJSON():null;
}
catch(e){
return null;
}
},evalResponse:function(){
try{
return eval((this.transport.responseText||"").unfilterJSON());
}
catch(e){
this.dispatchException(e);
}
},dispatchException:function(_fd){
(this.options.onException||Prototype.emptyFunction)(this,_fd);
Ajax.Responders.dispatch("onException",this,_fd);
}});
Ajax.Updater=Class.create();
Object.extend(Object.extend(Ajax.Updater.prototype,Ajax.Request.prototype),{initialize:function(_fe,url,_100){
this.container={success:(_fe.success||_fe),failure:(_fe.failure||(_fe.success?null:_fe))};
this.transport=Ajax.getTransport();
this.setOptions(_100);
var _101=this.options.onComplete||Prototype.emptyFunction;
this.options.onComplete=(function(_102,_103){
this.updateContent();
_101(_102,_103);
}).bind(this);
this.request(url);
},updateContent:function(){
var _104=this.container[this.success()?"success":"failure"];
var _105=this.transport.responseText;
if(!this.options.evalScripts){
_105=_105.stripScripts();
}
if(_104=$(_104)){
if(this.options.insertion){
new this.options.insertion(_104,_105);
}else{
_104.update(_105);
}
}
if(this.success()){
if(this.onComplete){
setTimeout(this.onComplete.bind(this),10);
}
}
}});
Ajax.PeriodicalUpdater=Class.create();
Ajax.PeriodicalUpdater.prototype=Object.extend(new Ajax.Base(),{initialize:function(_106,url,_108){
this.setOptions(_108);
this.onComplete=this.options.onComplete;
this.frequency=(this.options.frequency||2);
this.decay=(this.options.decay||1);
this.updater={};
this.container=_106;
this.url=url;
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(_109){
if(this.options.decay){
this.decay=(_109.responseText==this.lastText?this.decay*this.options.decay:1);
this.lastText=_109.responseText;
}
this.timer=setTimeout(this.onTimerEvent.bind(this),this.decay*this.frequency*1000);
},onTimerEvent:function(){
this.updater=new Ajax.Updater(this.container,this.url,this.options);
}});
function $(_10a){
if(arguments.length>1){
for(var i=0,elements=[],length=arguments.length;i<length;i++){
elements.push($(arguments[i]));
}
return elements;
}
if(typeof _10a=="string"){
_10a=document.getElementById(_10a);
}
return Element.extend(_10a);
}
if(Prototype.BrowserFeatures.XPath){
document._getElementsByXPath=function(_10c,_10d){
var _10e=[];
var _10f=document.evaluate(_10c,$(_10d)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);
for(var i=0,length=_10f.snapshotLength;i<length;i++){
_10e.push(_10f.snapshotItem(i));
}
return _10e;
};
document.getElementsByClassName=function(_111,_112){
var q=".//*[contains(concat(' ', @class, ' '), ' "+_111+" ')]";
return document._getElementsByXPath(q,_112);
};
}else{
document.getElementsByClassName=function(_114,_115){
var _116=($(_115)||document.body).getElementsByTagName("*");
var _117=[],child,pattern=new RegExp("(^|\\s)"+_114+"(\\s|$)");
for(var i=0,length=_116.length;i<length;i++){
child=_116[i];
var _119=child.className;
if(_119.length==0){
continue;
}
if(_119==_114||_119.match(pattern)){
_117.push(Element.extend(child));
}
}
return _117;
};
}
if(!window.Element){
var Element={};
}
Element.extend=function(_11a){
var F=Prototype.BrowserFeatures;
if(!_11a||!_11a.tagName||_11a.nodeType==3||_11a._extended||F.SpecificElementExtensions||_11a==window){
return _11a;
}
var _11c={},tagName=_11a.tagName,cache=Element.extend.cache,T=Element.Methods.ByTag;
if(!F.ElementExtensions){
Object.extend(_11c,Element.Methods),Object.extend(_11c,Element.Methods.Simulated);
}
if(T[tagName]){
Object.extend(_11c,T[tagName]);
}
for(var _11d in _11c){
var _11e=_11c[_11d];
if(typeof _11e=="function"&&!(_11d in _11a)){
_11a[_11d]=cache.findOrStore(_11e);
}
}
_11a._extended=Prototype.emptyFunction;
return _11a;
};
Element.extend.cache={findOrStore:function(_11f){
return this[_11f]=this[_11f]||function(){
return _11f.apply(null,[this].concat($A(arguments)));
};
}};
Element.Methods={visible:function(_120){
return $(_120).style.display!="none";
},toggle:function(_121){
_121=$(_121);
Element[Element.visible(_121)?"hide":"show"](_121);
return _121;
},hide:function(_122){
$(_122).style.display="none";
return _122;
},show:function(_123){
$(_123).style.display="";
return _123;
},remove:function(_124){
_124=$(_124);
_124.parentNode.removeChild(_124);
return _124;
},update:function(_125,html){
html=typeof html=="undefined"?"":html.toString();
$(_125).innerHTML=html.stripScripts();
setTimeout(function(){
html.evalScripts();
},10);
return _125;
},replace:function(_127,html){
_127=$(_127);
html=typeof html=="undefined"?"":html.toString();
if(_127.outerHTML){
_127.outerHTML=html.stripScripts();
}else{
var _129=_127.ownerDocument.createRange();
_129.selectNodeContents(_127);
_127.parentNode.replaceChild(_129.createContextualFragment(html.stripScripts()),_127);
}
setTimeout(function(){
html.evalScripts();
},10);
return _127;
},inspect:function(_12a){
_12a=$(_12a);
var _12b="<"+_12a.tagName.toLowerCase();
$H({"id":"id","className":"class"}).each(function(pair){
var _12d=pair.first(),attribute=pair.last();
var _12e=(_12a[_12d]||"").toString();
if(_12e){
_12b+=" "+attribute+"="+_12e.inspect(true);
}
});
return _12b+">";
},recursivelyCollect:function(_12f,_130){
_12f=$(_12f);
var _131=[];
while(_12f=_12f[_130]){
if(_12f.nodeType==1){
_131.push(Element.extend(_12f));
}
}
return _131;
},ancestors:function(_132){
return $(_132).recursivelyCollect("parentNode");
},descendants:function(_133){
return $A($(_133).getElementsByTagName("*")).each(Element.extend);
},firstDescendant:function(_134){
_134=$(_134).firstChild;
while(_134&&_134.nodeType!=1){
_134=_134.nextSibling;
}
return $(_134);
},immediateDescendants:function(_135){
if(!(_135=$(_135).firstChild)){
return [];
}
while(_135&&_135.nodeType!=1){
_135=_135.nextSibling;
}
if(_135){
return [_135].concat($(_135).nextSiblings());
}
return [];
},previousSiblings:function(_136){
return $(_136).recursivelyCollect("previousSibling");
},nextSiblings:function(_137){
return $(_137).recursivelyCollect("nextSibling");
},siblings:function(_138){
_138=$(_138);
return _138.previousSiblings().reverse().concat(_138.nextSiblings());
},match:function(_139,_13a){
if(typeof _13a=="string"){
_13a=new Selector(_13a);
}
return _13a.match($(_139));
},up:function(_13b,_13c,_13d){
_13b=$(_13b);
if(arguments.length==1){
return $(_13b.parentNode);
}
var _13e=_13b.ancestors();
return _13c?Selector.findElement(_13e,_13c,_13d):_13e[_13d||0];
},down:function(_13f,_140,_141){
_13f=$(_13f);
if(arguments.length==1){
return _13f.firstDescendant();
}
var _142=_13f.descendants();
return _140?Selector.findElement(_142,_140,_141):_142[_141||0];
},previous:function(_143,_144,_145){
_143=$(_143);
if(arguments.length==1){
return $(Selector.handlers.previousElementSibling(_143));
}
var _146=_143.previousSiblings();
return _144?Selector.findElement(_146,_144,_145):_146[_145||0];
},next:function(_147,_148,_149){
_147=$(_147);
if(arguments.length==1){
return $(Selector.handlers.nextElementSibling(_147));
}
var _14a=_147.nextSiblings();
return _148?Selector.findElement(_14a,_148,_149):_14a[_149||0];
},getElementsBySelector:function(){
var args=$A(arguments),element=$(args.shift());
return Selector.findChildElements(element,args);
},getElementsByClassName:function(_14c,_14d){
return document.getElementsByClassName(_14d,_14c);
},readAttribute:function(_14e,name){
_14e=$(_14e);
if(Prototype.Browser.IE){
if(!_14e.attributes){
return null;
}
var t=Element._attributeTranslations;
if(t.values[name]){
return t.values[name](_14e,name);
}
if(t.names[name]){
name=t.names[name];
}
var _151=_14e.attributes[name];
return _151?_151.nodeValue:null;
}
return _14e.getAttribute(name);
},getHeight:function(_152){
return $(_152).getDimensions().height;
},getWidth:function(_153){
return $(_153).getDimensions().width;
},classNames:function(_154){
return new Element.ClassNames(_154);
},hasClassName:function(_155,_156){
if(!(_155=$(_155))){
return;
}
var _157=_155.className;
if(_157.length==0){
return false;
}
if(_157==_156||_157.match(new RegExp("(^|\\s)"+_156+"(\\s|$)"))){
return true;
}
return false;
},addClassName:function(_158,_159){
if(!(_158=$(_158))){
return;
}
Element.classNames(_158).add(_159);
return _158;
},removeClassName:function(_15a,_15b){
if(!(_15a=$(_15a))){
return;
}
Element.classNames(_15a).remove(_15b);
return _15a;
},toggleClassName:function(_15c,_15d){
if(!(_15c=$(_15c))){
return;
}
Element.classNames(_15c)[_15c.hasClassName(_15d)?"remove":"add"](_15d);
return _15c;
},observe:function(){
Event.observe.apply(Event,arguments);
return $A(arguments).first();
},stopObserving:function(){
Event.stopObserving.apply(Event,arguments);
return $A(arguments).first();
},cleanWhitespace:function(_15e){
_15e=$(_15e);
var node=_15e.firstChild;
while(node){
var _160=node.nextSibling;
if(node.nodeType==3&&!/\S/.test(node.nodeValue)){
_15e.removeChild(node);
}
node=_160;
}
return _15e;
},empty:function(_161){
return $(_161).innerHTML.blank();
},descendantOf:function(_162,_163){
_162=$(_162),_163=$(_163);
while(_162=_162.parentNode){
if(_162==_163){
return true;
}
}
return false;
},scrollTo:function(_164){
_164=$(_164);
var pos=Position.cumulativeOffset(_164);
window.scrollTo(pos[0],pos[1]);
return _164;
},getStyle:function(_166,_167){
_166=$(_166);
_167=_167=="float"?"cssFloat":_167.camelize();
var _168=_166.style[_167];
if(!_168){
var css=document.defaultView.getComputedStyle(_166,null);
_168=css?css[_167]:null;
}
if(_167=="opacity"){
return _168?parseFloat(_168):1;
}
return _168=="auto"?null:_168;
},getOpacity:function(_16a){
return $(_16a).getStyle("opacity");
},setStyle:function(_16b,_16c,_16d){
_16b=$(_16b);
var _16e=_16b.style;
for(var _16f in _16c){
if(_16f=="opacity"){
_16b.setOpacity(_16c[_16f]);
}else{
_16e[(_16f=="float"||_16f=="cssFloat")?(_16e.styleFloat===undefined?"cssFloat":"styleFloat"):(_16d?_16f:_16f.camelize())]=_16c[_16f];
}
}
return _16b;
},setOpacity:function(_170,_171){
_170=$(_170);
_170.style.opacity=(_171==1||_171==="")?"":(_171<0.00001)?0:_171;
return _170;
},getDimensions:function(_172){
_172=$(_172);
var _173=$(_172).getStyle("display");
if(_173!="none"&&_173!=null){
return {width:_172.offsetWidth,height:_172.offsetHeight};
}
var els=_172.style;
var _175=els.visibility;
var _176=els.position;
var _177=els.display;
els.visibility="hidden";
els.position="absolute";
els.display="block";
var _178=_172.clientWidth;
var _179=_172.clientHeight;
els.display=_177;
els.position=_176;
els.visibility=_175;
return {width:_178,height:_179};
},makePositioned:function(_17a){
_17a=$(_17a);
var pos=Element.getStyle(_17a,"position");
if(pos=="static"||!pos){
_17a._madePositioned=true;
_17a.style.position="relative";
if(window.opera){
_17a.style.top=0;
_17a.style.left=0;
}
}
return _17a;
},undoPositioned:function(_17c){
_17c=$(_17c);
if(_17c._madePositioned){
_17c._madePositioned=undefined;
_17c.style.position=_17c.style.top=_17c.style.left=_17c.style.bottom=_17c.style.right="";
}
return _17c;
},makeClipping:function(_17d){
_17d=$(_17d);
if(_17d._overflow){
return _17d;
}
_17d._overflow=_17d.style.overflow||"auto";
if((Element.getStyle(_17d,"overflow")||"visible")!="hidden"){
_17d.style.overflow="hidden";
}
return _17d;
},undoClipping:function(_17e){
_17e=$(_17e);
if(!_17e._overflow){
return _17e;
}
_17e.style.overflow=_17e._overflow=="auto"?"":_17e._overflow;
_17e._overflow=null;
return _17e;
}};
Object.extend(Element.Methods,{childOf:Element.Methods.descendantOf,childElements:Element.Methods.immediateDescendants});
if(Prototype.Browser.Opera){
Element.Methods._getStyle=Element.Methods.getStyle;
Element.Methods.getStyle=function(_17f,_180){
switch(_180){
case "left":
case "top":
case "right":
case "bottom":
if(Element._getStyle(_17f,"position")=="static"){
return null;
}
default:
return Element._getStyle(_17f,_180);
}
};
}else{
if(Prototype.Browser.IE){
Element.Methods.getStyle=function(_181,_182){
_181=$(_181);
_182=(_182=="float"||_182=="cssFloat")?"styleFloat":_182.camelize();
var _183=_181.style[_182];
if(!_183&&_181.currentStyle){
_183=_181.currentStyle[_182];
}
if(_182=="opacity"){
if(_183=(_181.getStyle("filter")||"").match(/alpha\(opacity=(.*)\)/)){
if(_183[1]){
return parseFloat(_183[1])/100;
}
}
return 1;
}
if(_183=="auto"){
if((_182=="width"||_182=="height")&&(_181.getStyle("display")!="none")){
return _181["offset"+_182.capitalize()]+"px";
}
return null;
}
return _183;
};
Element.Methods.setOpacity=function(_184,_185){
_184=$(_184);
var _186=_184.getStyle("filter"),style=_184.style;
if(_185==1||_185===""){
style.filter=_186.replace(/alpha\([^\)]*\)/gi,"");
return _184;
}else{
if(_185<0.00001){
_185=0;
}
}
style.filter=_186.replace(/alpha\([^\)]*\)/gi,"")+"alpha(opacity="+(_185*100)+")";
return _184;
};
Element.Methods.update=function(_187,html){
_187=$(_187);
html=typeof html=="undefined"?"":html.toString();
var _189=_187.tagName.toUpperCase();
if(["THEAD","TBODY","TR","TD"].include(_189)){
var div=document.createElement("div");
switch(_189){
case "THEAD":
case "TBODY":
div.innerHTML="<table><tbody>"+html.stripScripts()+"</tbody></table>";
depth=2;
break;
case "TR":
div.innerHTML="<table><tbody><tr>"+html.stripScripts()+"</tr></tbody></table>";
depth=3;
break;
case "TD":
div.innerHTML="<table><tbody><tr><td>"+html.stripScripts()+"</td></tr></tbody></table>";
depth=4;
}
$A(_187.childNodes).each(function(node){
_187.removeChild(node);
});
depth.times(function(){
div=div.firstChild;
});
$A(div.childNodes).each(function(node){
_187.appendChild(node);
});
}else{
_187.innerHTML=html.stripScripts();
}
setTimeout(function(){
html.evalScripts();
},10);
return _187;
};
}else{
if(Prototype.Browser.Gecko){
Element.Methods.setOpacity=function(_18d,_18e){
_18d=$(_18d);
_18d.style.opacity=(_18e==1)?0.999999:(_18e==="")?"":(_18e<0.00001)?0:_18e;
return _18d;
};
}
}
}
Element._attributeTranslations={names:{colspan:"colSpan",rowspan:"rowSpan",valign:"vAlign",datetime:"dateTime",accesskey:"accessKey",tabindex:"tabIndex",enctype:"encType",maxlength:"maxLength",readonly:"readOnly",longdesc:"longDesc"},values:{_getAttr:function(_18f,_190){
return _18f.getAttribute(_190,2);
},_flag:function(_191,_192){
return $(_191).hasAttribute(_192)?_192:null;
},style:function(_193){
return _193.style.cssText.toLowerCase();
},title:function(_194){
var node=_194.getAttributeNode("title");
return node.specified?node.nodeValue:null;
}}};
(function(){
Object.extend(this,{href:this._getAttr,src:this._getAttr,type:this._getAttr,disabled:this._flag,checked:this._flag,readonly:this._flag,multiple:this._flag});
}).call(Element._attributeTranslations.values);
Element.Methods.Simulated={hasAttribute:function(_196,_197){
var t=Element._attributeTranslations,node;
_197=t.names[_197]||_197;
node=$(_196).getAttributeNode(_197);
return node&&node.specified;
}};
Element.Methods.ByTag={};
Object.extend(Element,Element.Methods);
if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement("div").__proto__){
window.HTMLElement={};
window.HTMLElement.prototype=document.createElement("div").__proto__;
Prototype.BrowserFeatures.ElementExtensions=true;
}
Element.hasAttribute=function(_199,_19a){
if(_199.hasAttribute){
return _199.hasAttribute(_19a);
}
return Element.Methods.Simulated.hasAttribute(_199,_19a);
};
Element.addMethods=function(_19b){
var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;
if(!_19b){
Object.extend(Form,Form.Methods);
Object.extend(Form.Element,Form.Element.Methods);
Object.extend(Element.Methods.ByTag,{"FORM":Object.clone(Form.Methods),"INPUT":Object.clone(Form.Element.Methods),"SELECT":Object.clone(Form.Element.Methods),"TEXTAREA":Object.clone(Form.Element.Methods)});
}
if(arguments.length==2){
var _19d=_19b;
_19b=arguments[1];
}
if(!_19d){
Object.extend(Element.Methods,_19b||{});
}else{
if(_19d.constructor==Array){
_19d.each(extend);
}else{
extend(_19d);
}
}
function extend(_19e){
_19e=_19e.toUpperCase();
if(!Element.Methods.ByTag[_19e]){
Element.Methods.ByTag[_19e]={};
}
Object.extend(Element.Methods.ByTag[_19e],_19b);
}
function copy(_19f,_1a0,_1a1){
_1a1=_1a1||false;
var _1a2=Element.extend.cache;
for(var _1a3 in _19f){
var _1a4=_19f[_1a3];
if(!_1a1||!(_1a3 in _1a0)){
_1a0[_1a3]=_1a2.findOrStore(_1a4);
}
}
}
function findDOMClass(_1a5){
var _1a6;
var _1a7={"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(_1a7[_1a5]){
_1a6="HTML"+_1a7[_1a5]+"Element";
}
if(window[_1a6]){
return window[_1a6];
}
_1a6="HTML"+_1a5+"Element";
if(window[_1a6]){
return window[_1a6];
}
_1a6="HTML"+_1a5.capitalize()+"Element";
if(window[_1a6]){
return window[_1a6];
}
window[_1a6]={};
window[_1a6].prototype=document.createElement(_1a5).__proto__;
return window[_1a6];
}
if(F.ElementExtensions){
copy(Element.Methods,HTMLElement.prototype);
copy(Element.Methods.Simulated,HTMLElement.prototype,true);
}
if(F.SpecificElementExtensions){
for(var tag in Element.Methods.ByTag){
var _1a9=findDOMClass(tag);
if(typeof _1a9=="undefined"){
continue;
}
copy(T[tag],_1a9.prototype);
}
}
Object.extend(Element,Element.Methods);
delete Element.ByTag;
};
var Toggle={display:Element.toggle};
Abstract.Insertion=function(_1aa){
this.adjacency=_1aa;
};
Abstract.Insertion.prototype={initialize:function(_1ab,_1ac){
this.element=$(_1ab);
this.content=_1ac.stripScripts();
if(this.adjacency&&this.element.insertAdjacentHTML){
try{
this.element.insertAdjacentHTML(this.adjacency,this.content);
}
catch(e){
var _1ad=this.element.tagName.toUpperCase();
if(["TBODY","TR"].include(_1ad)){
this.insertContent(this.contentFromAnonymousTable());
}else{
throw e;
}
}
}else{
this.range=this.element.ownerDocument.createRange();
if(this.initializeRange){
this.initializeRange();
}
this.insertContent([this.range.createContextualFragment(this.content)]);
}
setTimeout(function(){
_1ac.evalScripts();
},10);
},contentFromAnonymousTable:function(){
var div=document.createElement("div");
div.innerHTML="<table><tbody>"+this.content+"</tbody></table>";
return $A(div.childNodes[0].childNodes[0].childNodes);
}};
var Insertion=new Object();
Insertion.Before=Class.create();
Insertion.Before.prototype=Object.extend(new Abstract.Insertion("beforeBegin"),{initializeRange:function(){
this.range.setStartBefore(this.element);
},insertContent:function(_1af){
_1af.each((function(_1b0){
this.element.parentNode.insertBefore(_1b0,this.element);
}).bind(this));
}});
Insertion.Top=Class.create();
Insertion.Top.prototype=Object.extend(new Abstract.Insertion("afterBegin"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(true);
},insertContent:function(_1b1){
_1b1.reverse(false).each((function(_1b2){
this.element.insertBefore(_1b2,this.element.firstChild);
}).bind(this));
}});
Insertion.Bottom=Class.create();
Insertion.Bottom.prototype=Object.extend(new Abstract.Insertion("beforeEnd"),{initializeRange:function(){
this.range.selectNodeContents(this.element);
this.range.collapse(this.element);
},insertContent:function(_1b3){
_1b3.each((function(_1b4){
this.element.appendChild(_1b4);
}).bind(this));
}});
Insertion.After=Class.create();
Insertion.After.prototype=Object.extend(new Abstract.Insertion("afterEnd"),{initializeRange:function(){
this.range.setStartAfter(this.element);
},insertContent:function(_1b5){
_1b5.each((function(_1b6){
this.element.parentNode.insertBefore(_1b6,this.element.nextSibling);
}).bind(this));
}});
Element.ClassNames=Class.create();
Element.ClassNames.prototype={initialize:function(_1b7){
this.element=$(_1b7);
},_each:function(_1b8){
this.element.className.split(/\s+/).select(function(name){
return name.length>0;
})._each(_1b8);
},set:function(_1ba){
this.element.className=_1ba;
},add:function(_1bb){
if(this.include(_1bb)){
return;
}
this.set($A(this).concat(_1bb).join(" "));
},remove:function(_1bc){
if(!this.include(_1bc)){
return;
}
this.set($A(this).without(_1bc).join(" "));
},toString:function(){
return $A(this).join(" ");
}};
Object.extend(Element.ClassNames.prototype,Enumerable);
var Selector=Class.create();
Selector.prototype={initialize:function(_1bd){
this.expression=_1bd.strip();
this.compileMatcher();
},compileMatcher:function(){
if(Prototype.BrowserFeatures.XPath&&!(/\[[\w-]*?:/).test(this.expression)){
return this.compileXPathMatcher();
}
var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;
if(Selector._cache[e]){
this.matcher=Selector._cache[e];
return;
}
this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in ps){
p=ps[i];
if(m=e.match(p)){
this.matcher.push(typeof c[i]=="function"?c[i](m):new Template(c[i]).evaluate(m));
e=e.replace(m[0],"");
break;
}
}
}
this.matcher.push("return h.unique(n);\n}");
eval(this.matcher.join("\n"));
Selector._cache[this.expression]=this.matcher;
},compileXPathMatcher:function(){
var e=this.expression,ps=Selector.patterns,x=Selector.xpath,le,m;
if(Selector._cache[e]){
this.xpath=Selector._cache[e];
return;
}
this.matcher=[".//*"];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in ps){
if(m=e.match(ps[i])){
this.matcher.push(typeof x[i]=="function"?x[i](m):new Template(x[i]).evaluate(m));
e=e.replace(m[0],"");
break;
}
}
}
this.xpath=this.matcher.join("");
Selector._cache[this.expression]=this.xpath;
},findElements:function(root){
root=root||document;
if(this.xpath){
return document._getElementsByXPath(this.xpath,root);
}
return this.matcher(root);
},match:function(_1c3){
return this.findElements(document).include(_1c3);
},toString:function(){
return this.expression;
},inspect:function(){
return "#<Selector:"+this.expression.inspect()+">";
}};
Object.extend(Selector,{_cache:{},xpath:{descendant:"//*",child:"/*",adjacent:"/following-sibling::*[1]",laterSibling:"/following-sibling::*",tagName:function(m){
if(m[1]=="*"){
return "";
}
return "[local-name()='"+m[1].toLowerCase()+"' or local-name()='"+m[1].toUpperCase()+"']";
},className:"[contains(concat(' ', @class, ' '), ' #{1} ')]",id:"[@id='#{1}']",attrPresence:"[@#{1}]",attr:function(m){
m[3]=m[5]||m[6];
return new Template(Selector.xpath.operators[m[2]]).evaluate(m);
},pseudo:function(m){
var h=Selector.xpath.pseudos[m[1]];
if(!h){
return "";
}
if(typeof h==="function"){
return h(m);
}
return new Template(Selector.xpath.pseudos[m[1]]).evaluate(m);
},operators:{"=":"[@#{1}='#{3}']","!=":"[@#{1}!='#{3}']","^=":"[starts-with(@#{1}, '#{3}')]","$=":"[substring(@#{1}, (string-length(@#{1}) - string-length('#{3}') + 1))='#{3}']","*=":"[contains(@#{1}, '#{3}')]","~=":"[contains(concat(' ', @#{1}, ' '), ' #{3} ')]","|=":"[contains(concat('-', @#{1}, '-'), '-#{3}-')]"},pseudos:{"first-child":"[not(preceding-sibling::*)]","last-child":"[not(following-sibling::*)]","only-child":"[not(preceding-sibling::* or following-sibling::*)]","empty":"[count(*) = 0 and (count(text()) = 0 or translate(text(), ' \t\r\n', '') = '')]","checked":"[@checked]","disabled":"[@disabled]","enabled":"[not(@disabled)]","not":function(m){
var e=m[6],p=Selector.patterns,x=Selector.xpath,le,m,v;
var _1ca=[];
while(e&&le!=e&&(/\S/).test(e)){
le=e;
for(var i in p){
if(m=e.match(p[i])){
v=typeof x[i]=="function"?x[i](m):new Template(x[i]).evaluate(m);
_1ca.push("("+v.substring(1,v.length-1)+")");
e=e.replace(m[0],"");
break;
}
}
}
return "[not("+_1ca.join(" and ")+")]";
},"nth-child":function(m){
return Selector.xpath.pseudos.nth("(count(./preceding-sibling::*) + 1) ",m);
},"nth-last-child":function(m){
return Selector.xpath.pseudos.nth("(count(./following-sibling::*) + 1) ",m);
},"nth-of-type":function(m){
return Selector.xpath.pseudos.nth("position() ",m);
},"nth-last-of-type":function(m){
return Selector.xpath.pseudos.nth("(last() + 1 - position()) ",m);
},"first-of-type":function(m){
m[6]="1";
return Selector.xpath.pseudos["nth-of-type"](m);
},"last-of-type":function(m){
m[6]="1";
return Selector.xpath.pseudos["nth-last-of-type"](m);
},"only-of-type":function(m){
var p=Selector.xpath.pseudos;
return p["first-of-type"](m)+p["last-of-type"](m);
},nth:function(_1d4,m){
var mm,formula=m[6],predicate;
if(formula=="even"){
formula="2n+0";
}
if(formula=="odd"){
formula="2n+1";
}
if(mm=formula.match(/^(\d+)$/)){
return "["+_1d4+"= "+mm[1]+"]";
}
if(mm=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){
if(mm[1]=="-"){
mm[1]=-1;
}
var a=mm[1]?Number(mm[1]):1;
var b=mm[2]?Number(mm[2]):0;
predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";
return new Template(predicate).evaluate({fragment:_1d4,a:a,b:b});
}
}}},criteria:{tagName:"n = h.tagName(n, r, \"#{1}\", c);   c = false;",className:"n = h.className(n, r, \"#{1}\", c); c = false;",id:"n = h.id(n, r, \"#{1}\", c);        c = false;",attrPresence:"n = h.attrPresence(n, r, \"#{1}\"); c = false;",attr:function(m){
m[3]=(m[5]||m[6]);
return new Template("n = h.attr(n, r, \"#{1}\", \"#{3}\", \"#{2}\"); c = false;").evaluate(m);
},pseudo:function(m){
if(m[6]){
m[6]=m[6].replace(/"/g,"\\\"");
}
return new Template("n = h.pseudo(n, \"#{1}\", \"#{6}\", r, c); c = false;").evaluate(m);
},descendant:"c = \"descendant\";",child:"c = \"child\";",adjacent:"c = \"adjacent\";",laterSibling:"c = \"laterSibling\";"},patterns:{laterSibling:/^\s*~\s*/,child:/^\s*>\s*/,adjacent:/^\s*\+\s*/,descendant:/^\s/,tagName:/^\s*(\*|[\w\-]+)(\b|$)?/,id:/^#([\w\-\*]+)(\b|$)/,className:/^\.([\w\-\*]+)(\b|$)/,pseudo:/^:((first|last|nth|nth-last|only)(-child|-of-type)|empty|checked|(en|dis)abled|not)(\((.*?)\))?(\b|$|\s|(?=:))/,attrPresence:/^\[([\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\]]*?)\4|([^'"][^\]]*?)))?\]/},handlers:{concat:function(a,b){
for(var i=0,node;node=b[i];i++){
a.push(node);
}
return a;
},mark:function(_1de){
for(var i=0,node;node=_1de[i];i++){
node._counted=true;
}
return _1de;
},unmark:function(_1e0){
for(var i=0,node;node=_1e0[i];i++){
node._counted=undefined;
}
return _1e0;
},index:function(_1e2,_1e3,_1e4){
_1e2._counted=true;
if(_1e3){
for(var _1e5=_1e2.childNodes,i=_1e5.length-1,j=1;i>=0;i--){
node=_1e5[i];
if(node.nodeType==1&&(!_1e4||node._counted)){
node.nodeIndex=j++;
}
}
}else{
for(var i=0,j=1,_1e5=_1e2.childNodes;node=_1e5[i];i++){
if(node.nodeType==1&&(!_1e4||node._counted)){
node.nodeIndex=j++;
}
}
}
},unique:function(_1e7){
if(_1e7.length==0){
return _1e7;
}
var _1e8=[],n;
for(var i=0,l=_1e7.length;i<l;i++){
if(!(n=_1e7[i])._counted){
n._counted=true;
_1e8.push(Element.extend(n));
}
}
return Selector.handlers.unmark(_1e8);
},descendant:function(_1ea){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1ea[i];i++){
h.concat(results,node.getElementsByTagName("*"));
}
return results;
},child:function(_1ed){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1ed[i];i++){
for(var j=0,children=[],child;child=node.childNodes[j];j++){
if(child.nodeType==1&&child.tagName!="!"){
results.push(child);
}
}
}
return results;
},adjacent:function(_1f1){
for(var i=0,results=[],node;node=_1f1[i];i++){
var next=this.nextElementSibling(node);
if(next){
results.push(next);
}
}
return results;
},laterSibling:function(_1f4){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_1f4[i];i++){
h.concat(results,Element.nextSiblings(node));
}
return results;
},nextElementSibling:function(node){
while(node=node.nextSibling){
if(node.nodeType==1){
return node;
}
}
return null;
},previousElementSibling:function(node){
while(node=node.previousSibling){
if(node.nodeType==1){
return node;
}
}
return null;
},tagName:function(_1f9,root,_1fb,_1fc){
_1fb=_1fb.toUpperCase();
var _1fd=[],h=Selector.handlers;
if(_1f9){
if(_1fc){
if(_1fc=="descendant"){
for(var i=0,node;node=_1f9[i];i++){
h.concat(_1fd,node.getElementsByTagName(_1fb));
}
return _1fd;
}else{
_1f9=this[_1fc](_1f9);
}
if(_1fb=="*"){
return _1f9;
}
}
for(var i=0,node;node=_1f9[i];i++){
if(node.tagName.toUpperCase()==_1fb){
_1fd.push(node);
}
}
return _1fd;
}else{
return root.getElementsByTagName(_1fb);
}
},id:function(_200,root,id,_203){
var _204=$(id),h=Selector.handlers;
if(!_200&&root==document){
return _204?[_204]:[];
}
if(_200){
if(_203){
if(_203=="child"){
for(var i=0,node;node=_200[i];i++){
if(_204.parentNode==node){
return [_204];
}
}
}else{
if(_203=="descendant"){
for(var i=0,node;node=_200[i];i++){
if(Element.descendantOf(_204,node)){
return [_204];
}
}
}else{
if(_203=="adjacent"){
for(var i=0,node;node=_200[i];i++){
if(Selector.handlers.previousElementSibling(_204)==node){
return [_204];
}
}
}else{
_200=h[_203](_200);
}
}
}
}
for(var i=0,node;node=_200[i];i++){
if(node==_204){
return [_204];
}
}
return [];
}
return (_204&&Element.descendantOf(_204,root))?[_204]:[];
},className:function(_209,root,_20b,_20c){
if(_209&&_20c){
_209=this[_20c](_209);
}
return Selector.handlers.byClassName(_209,root,_20b);
},byClassName:function(_20d,root,_20f){
if(!_20d){
_20d=Selector.handlers.descendant([root]);
}
var _210=" "+_20f+" ";
for(var i=0,results=[],node,nodeClassName;node=_20d[i];i++){
nodeClassName=node.className;
if(nodeClassName.length==0){
continue;
}
if(nodeClassName==_20f||(" "+nodeClassName+" ").include(_210)){
results.push(node);
}
}
return results;
},attrPresence:function(_212,root,attr){
var _215=[];
for(var i=0,node;node=_212[i];i++){
if(Element.hasAttribute(node,attr)){
_215.push(node);
}
}
return _215;
},attr:function(_217,root,attr,_21a,_21b){
if(!_217){
_217=root.getElementsByTagName("*");
}
var _21c=Selector.operators[_21b],results=[];
for(var i=0,node;node=_217[i];i++){
var _21e=Element.readAttribute(node,attr);
if(_21e===null){
continue;
}
if(_21c(_21e,_21a)){
results.push(node);
}
}
return results;
},pseudo:function(_21f,name,_221,root,_223){
if(_21f&&_223){
_21f=this[_223](_21f);
}
if(!_21f){
_21f=root.getElementsByTagName("*");
}
return Selector.pseudos[name](_21f,_221,root);
}},pseudos:{"first-child":function(_224,_225,root){
for(var i=0,results=[],node;node=_224[i];i++){
if(Selector.handlers.previousElementSibling(node)){
continue;
}
results.push(node);
}
return results;
},"last-child":function(_228,_229,root){
for(var i=0,results=[],node;node=_228[i];i++){
if(Selector.handlers.nextElementSibling(node)){
continue;
}
results.push(node);
}
return results;
},"only-child":function(_22c,_22d,root){
var h=Selector.handlers;
for(var i=0,results=[],node;node=_22c[i];i++){
if(!h.previousElementSibling(node)&&!h.nextElementSibling(node)){
results.push(node);
}
}
return results;
},"nth-child":function(_231,_232,root){
return Selector.pseudos.nth(_231,_232,root);
},"nth-last-child":function(_234,_235,root){
return Selector.pseudos.nth(_234,_235,root,true);
},"nth-of-type":function(_237,_238,root){
return Selector.pseudos.nth(_237,_238,root,false,true);
},"nth-last-of-type":function(_23a,_23b,root){
return Selector.pseudos.nth(_23a,_23b,root,true,true);
},"first-of-type":function(_23d,_23e,root){
return Selector.pseudos.nth(_23d,"1",root,false,true);
},"last-of-type":function(_240,_241,root){
return Selector.pseudos.nth(_240,"1",root,true,true);
},"only-of-type":function(_243,_244,root){
var p=Selector.pseudos;
return p["last-of-type"](p["first-of-type"](_243,_244,root),_244,root);
},getIndices:function(a,b,_249){
if(a==0){
return b>0?[b]:[];
}
return $R(1,_249).inject([],function(memo,i){
if(0==(i-b)%a&&(i-b)/a>=0){
memo.push(i);
}
return memo;
});
},nth:function(_24c,_24d,root,_24f,_250){
if(_24c.length==0){
return [];
}
if(_24d=="even"){
_24d="2n+0";
}
if(_24d=="odd"){
_24d="2n+1";
}
var h=Selector.handlers,results=[],indexed=[],m;
h.mark(_24c);
for(var i=0,node;node=_24c[i];i++){
if(!node.parentNode._counted){
h.index(node.parentNode,_24f,_250);
indexed.push(node.parentNode);
}
}
if(_24d.match(/^\d+$/)){
_24d=Number(_24d);
for(var i=0,node;node=_24c[i];i++){
if(node.nodeIndex==_24d){
results.push(node);
}
}
}else{
if(m=_24d.match(/^(-?\d*)?n(([+-])(\d+))?/)){
if(m[1]=="-"){
m[1]=-1;
}
var a=m[1]?Number(m[1]):1;
var b=m[2]?Number(m[2]):0;
var _256=Selector.pseudos.getIndices(a,b,_24c.length);
for(var i=0,node,l=_256.length;node=_24c[i];i++){
for(var j=0;j<l;j++){
if(node.nodeIndex==_256[j]){
results.push(node);
}
}
}
}
}
h.unmark(_24c);
h.unmark(indexed);
return results;
},"empty":function(_259,_25a,root){
for(var i=0,results=[],node;node=_259[i];i++){
if(node.tagName=="!"||(node.firstChild&&!node.innerHTML.match(/^\s*$/))){
continue;
}
results.push(node);
}
return results;
},"not":function(_25d,_25e,root){
var h=Selector.handlers,selectorType,m;
var _261=new Selector(_25e).findElements(root);
h.mark(_261);
for(var i=0,results=[],node;node=_25d[i];i++){
if(!node._counted){
results.push(node);
}
}
h.unmark(_261);
return results;
},"enabled":function(_263,_264,root){
for(var i=0,results=[],node;node=_263[i];i++){
if(!node.disabled){
results.push(node);
}
}
return results;
},"disabled":function(_267,_268,root){
for(var i=0,results=[],node;node=_267[i];i++){
if(node.disabled){
results.push(node);
}
}
return results;
},"checked":function(_26b,_26c,root){
for(var i=0,results=[],node;node=_26b[i];i++){
if(node.checked){
results.push(node);
}
}
return results;
}},operators:{"=":function(nv,v){
return nv==v;
},"!=":function(nv,v){
return nv!=v;
},"^=":function(nv,v){
return nv.startsWith(v);
},"$=":function(nv,v){
return nv.endsWith(v);
},"*=":function(nv,v){
return nv.include(v);
},"~=":function(nv,v){
return (" "+nv+" ").include(" "+v+" ");
},"|=":function(nv,v){
return ("-"+nv.toUpperCase()+"-").include("-"+v.toUpperCase()+"-");
}},matchElements:function(_27d,_27e){
var _27f=new Selector(_27e).findElements(),h=Selector.handlers;
h.mark(_27f);
for(var i=0,results=[],element;element=_27d[i];i++){
if(element._counted){
results.push(element);
}
}
h.unmark(_27f);
return results;
},findElement:function(_281,_282,_283){
if(typeof _282=="number"){
_283=_282;
_282=false;
}
return Selector.matchElements(_281,_282||"*")[_283||0];
},findChildElements:function(_284,_285){
var _286=_285.join(","),_285=[];
_286.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){
_285.push(m[1].strip());
});
var _288=[],h=Selector.handlers;
for(var i=0,l=_285.length,selector;i<l;i++){
selector=new Selector(_285[i].strip());
h.concat(_288,selector.findElements(_284));
}
return (l>1)?h.unique(_288):_288;
}});
function $$(){
return Selector.findChildElements(document,$A(arguments));
}
var Form={reset:function(form){
$(form).reset();
return form;
},serializeElements:function(_28b,_28c){
var data=_28b.inject({},function(_28e,_28f){
if(!_28f.disabled&&_28f.name){
var key=_28f.name,value=$(_28f).getValue();
if(value!=null){
if(key in _28e){
if(_28e[key].constructor!=Array){
_28e[key]=[_28e[key]];
}
_28e[key].push(value);
}else{
_28e[key]=value;
}
}
}
return _28e;
});
return _28c?data:Hash.toQueryString(data);
}};
Form.Methods={serialize:function(form,_292){
return Form.serializeElements(Form.getElements(form),_292);
},getElements:function(form){
return $A($(form).getElementsByTagName("*")).inject([],function(_294,_295){
if(Form.Element.Serializers[_295.tagName.toLowerCase()]){
_294.push(Element.extend(_295));
}
return _294;
});
},getInputs:function(form,_297,name){
form=$(form);
var _299=form.getElementsByTagName("input");
if(!_297&&!name){
return $A(_299).map(Element.extend);
}
for(var i=0,matchingInputs=[],length=_299.length;i<length;i++){
var _29b=_299[i];
if((_297&&_29b.type!=_297)||(name&&_29b.name!=name)){
continue;
}
matchingInputs.push(Element.extend(_29b));
}
return matchingInputs;
},disable:function(form){
form=$(form);
Form.getElements(form).invoke("disable");
return form;
},enable:function(form){
form=$(form);
Form.getElements(form).invoke("enable");
return form;
},findFirstElement:function(form){
return $(form).getElements().find(function(_29f){
return _29f.type!="hidden"&&!_29f.disabled&&["input","select","textarea"].include(_29f.tagName.toLowerCase());
});
},focusFirstElement:function(form){
form=$(form);
form.findFirstElement().activate();
return form;
},request:function(form,_2a2){
form=$(form),_2a2=Object.clone(_2a2||{});
var _2a3=_2a2.parameters;
_2a2.parameters=form.serialize(true);
if(_2a3){
if(typeof _2a3=="string"){
_2a3=_2a3.toQueryParams();
}
Object.extend(_2a2.parameters,_2a3);
}
if(form.hasAttribute("method")&&!_2a2.method){
_2a2.method=form.method;
}
return new Ajax.Request(form.readAttribute("action"),_2a2);
}};
Form.Element={focus:function(_2a4){
$(_2a4).focus();
return _2a4;
},select:function(_2a5){
$(_2a5).select();
return _2a5;
}};
Form.Element.Methods={serialize:function(_2a6){
_2a6=$(_2a6);
if(!_2a6.disabled&&_2a6.name){
var _2a7=_2a6.getValue();
if(_2a7!=undefined){
var pair={};
pair[_2a6.name]=_2a7;
return Hash.toQueryString(pair);
}
}
return "";
},getValue:function(_2a9){
_2a9=$(_2a9);
var _2aa=_2a9.tagName.toLowerCase();
return Form.Element.Serializers[_2aa](_2a9);
},clear:function(_2ab){
$(_2ab).value="";
return _2ab;
},present:function(_2ac){
return $(_2ac).value!="";
},activate:function(_2ad){
_2ad=$(_2ad);
try{
_2ad.focus();
if(_2ad.select&&(_2ad.tagName.toLowerCase()!="input"||!["button","reset","submit"].include(_2ad.type))){
_2ad.select();
}
}
catch(e){
}
return _2ad;
},disable:function(_2ae){
_2ae=$(_2ae);
_2ae.blur();
_2ae.disabled=true;
return _2ae;
},enable:function(_2af){
_2af=$(_2af);
_2af.disabled=false;
return _2af;
}};
var Field=Form.Element;
var $F=Form.Element.Methods.getValue;
Form.Element.Serializers={input:function(_2b0){
switch(_2b0.type.toLowerCase()){
case "checkbox":
case "radio":
return Form.Element.Serializers.inputSelector(_2b0);
default:
return Form.Element.Serializers.textarea(_2b0);
}
},inputSelector:function(_2b1){
return _2b1.checked?_2b1.value:null;
},textarea:function(_2b2){
return _2b2.value;
},select:function(_2b3){
return this[_2b3.type=="select-one"?"selectOne":"selectMany"](_2b3);
},selectOne:function(_2b4){
var _2b5=_2b4.selectedIndex;
return _2b5>=0?this.optionValue(_2b4.options[_2b5]):null;
},selectMany:function(_2b6){
var _2b7,length=_2b6.length;
if(!length){
return null;
}
for(var i=0,_2b7=[];i<length;i++){
var opt=_2b6.options[i];
if(opt.selected){
_2b7.push(this.optionValue(opt));
}
}
return _2b7;
},optionValue:function(opt){
return Element.extend(opt).hasAttribute("value")?opt.value:opt.text;
}};
Abstract.TimedObserver=function(){
};
Abstract.TimedObserver.prototype={initialize:function(_2bb,_2bc,_2bd){
this.frequency=_2bc;
this.element=$(_2bb);
this.callback=_2bd;
this.lastValue=this.getValue();
this.registerCallback();
},registerCallback:function(){
setInterval(this.onTimerEvent.bind(this),this.frequency*1000);
},onTimerEvent:function(){
var _2be=this.getValue();
var _2bf=("string"==typeof this.lastValue&&"string"==typeof _2be?this.lastValue!=_2be:String(this.lastValue)!=String(_2be));
if(_2bf){
this.callback(this.element,_2be);
this.lastValue=_2be;
}
}};
Form.Element.Observer=Class.create();
Form.Element.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.Observer=Class.create();
Form.Observer.prototype=Object.extend(new Abstract.TimedObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
Abstract.EventObserver=function(){
};
Abstract.EventObserver.prototype={initialize:function(_2c0,_2c1){
this.element=$(_2c0);
this.callback=_2c1;
this.lastValue=this.getValue();
if(this.element.tagName.toLowerCase()=="form"){
this.registerFormCallbacks();
}else{
this.registerCallback(this.element);
}
},onElementEvent:function(){
var _2c2=this.getValue();
if(this.lastValue!=_2c2){
this.callback(this.element,_2c2);
this.lastValue=_2c2;
}
},registerFormCallbacks:function(){
Form.getElements(this.element).each(this.registerCallback.bind(this));
},registerCallback:function(_2c3){
if(_2c3.type){
switch(_2c3.type.toLowerCase()){
case "checkbox":
case "radio":
Event.observe(_2c3,"click",this.onElementEvent.bind(this));
break;
default:
Event.observe(_2c3,"change",this.onElementEvent.bind(this));
break;
}
}
}};
Form.Element.EventObserver=Class.create();
Form.Element.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.Element.getValue(this.element);
}});
Form.EventObserver=Class.create();
Form.EventObserver.prototype=Object.extend(new Abstract.EventObserver(),{getValue:function(){
return Form.serialize(this.element);
}});
if(!window.Event){
var Event=new Object();
}
Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,element:function(_2c4){
return $(_2c4.target||_2c4.srcElement);
},isLeftClick:function(_2c5){
return (((_2c5.which)&&(_2c5.which==1))||((_2c5.button)&&(_2c5.button==1)));
},pointerX:function(_2c6){
return _2c6.pageX||(_2c6.clientX+(document.documentElement.scrollLeft||document.body.scrollLeft));
},pointerY:function(_2c7){
return _2c7.pageY||(_2c7.clientY+(document.documentElement.scrollTop||document.body.scrollTop));
},stop:function(_2c8){
if(_2c8.preventDefault){
_2c8.preventDefault();
_2c8.stopPropagation();
}else{
_2c8.returnValue=false;
_2c8.cancelBubble=true;
}
},findElement:function(_2c9,_2ca){
var _2cb=Event.element(_2c9);
while(_2cb.parentNode&&(!_2cb.tagName||(_2cb.tagName.toUpperCase()!=_2ca.toUpperCase()))){
_2cb=_2cb.parentNode;
}
return _2cb;
},observers:false,_observeAndCache:function(_2cc,name,_2ce,_2cf){
if(!this.observers){
this.observers=[];
}
if(_2cc.addEventListener){
this.observers.push([_2cc,name,_2ce,_2cf]);
_2cc.addEventListener(name,_2ce,_2cf);
}else{
if(_2cc.attachEvent){
this.observers.push([_2cc,name,_2ce,_2cf]);
_2cc.attachEvent("on"+name,_2ce);
}
}
},unloadCache:function(){
if(!Event.observers){
return;
}
for(var i=0,length=Event.observers.length;i<length;i++){
Event.stopObserving.apply(this,Event.observers[i]);
Event.observers[i][0]=null;
}
Event.observers=false;
},observe:function(_2d1,name,_2d3,_2d4){
_2d1=$(_2d1);
_2d4=_2d4||false;
if(name=="keypress"&&(Prototype.Browser.WebKit||_2d1.attachEvent)){
name="keydown";
}
Event._observeAndCache(_2d1,name,_2d3,_2d4);
},stopObserving:function(_2d5,name,_2d7,_2d8){
_2d5=$(_2d5);
_2d8=_2d8||false;
if(name=="keypress"&&(Prototype.Browser.WebKit||_2d5.attachEvent)){
name="keydown";
}
if(_2d5.removeEventListener){
_2d5.removeEventListener(name,_2d7,_2d8);
}else{
if(_2d5.detachEvent){
try{
_2d5.detachEvent("on"+name,_2d7);
}
catch(e){
}
}
}
}});
if(Prototype.Browser.IE){
Event.observe(window,"unload",Event.unloadCache,false);
}
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;
},realOffset:function(_2d9){
var _2da=0,valueL=0;
do{
_2da+=_2d9.scrollTop||0;
valueL+=_2d9.scrollLeft||0;
_2d9=_2d9.parentNode;
}while(_2d9);
return [valueL,_2da];
},cumulativeOffset:function(_2db){
var _2dc=0,valueL=0;
do{
_2dc+=_2db.offsetTop||0;
valueL+=_2db.offsetLeft||0;
_2db=_2db.offsetParent;
}while(_2db);
return [valueL,_2dc];
},positionedOffset:function(_2dd){
var _2de=0,valueL=0;
do{
_2de+=_2dd.offsetTop||0;
valueL+=_2dd.offsetLeft||0;
_2dd=_2dd.offsetParent;
if(_2dd){
if(_2dd.tagName=="BODY"){
break;
}
var p=Element.getStyle(_2dd,"position");
if(p=="relative"||p=="absolute"){
break;
}
}
}while(_2dd);
return [valueL,_2de];
},offsetParent:function(_2e0){
if(_2e0.offsetParent){
return _2e0.offsetParent;
}
if(_2e0==document.body){
return _2e0;
}
while((_2e0=_2e0.parentNode)&&_2e0!=document.body){
if(Element.getStyle(_2e0,"position")!="static"){
return _2e0;
}
}
return document.body;
},within:function(_2e1,x,y){
if(this.includeScrollOffsets){
return this.withinIncludingScrolloffsets(_2e1,x,y);
}
this.xcomp=x;
this.ycomp=y;
this.offset=this.cumulativeOffset(_2e1);
return (y>=this.offset[1]&&y<this.offset[1]+_2e1.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+_2e1.offsetWidth);
},withinIncludingScrolloffsets:function(_2e4,x,y){
var _2e7=this.realOffset(_2e4);
this.xcomp=x+_2e7[0]-this.deltaX;
this.ycomp=y+_2e7[1]-this.deltaY;
this.offset=this.cumulativeOffset(_2e4);
return (this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+_2e4.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+_2e4.offsetWidth);
},overlap:function(mode,_2e9){
if(!mode){
return 0;
}
if(mode=="vertical"){
return ((this.offset[1]+_2e9.offsetHeight)-this.ycomp)/_2e9.offsetHeight;
}
if(mode=="horizontal"){
return ((this.offset[0]+_2e9.offsetWidth)-this.xcomp)/_2e9.offsetWidth;
}
},page:function(_2ea){
var _2eb=0,valueL=0;
var _2ec=_2ea;
do{
_2eb+=_2ec.offsetTop||0;
valueL+=_2ec.offsetLeft||0;
if(_2ec.offsetParent==document.body){
if(Element.getStyle(_2ec,"position")=="absolute"){
break;
}
}
}while(_2ec=_2ec.offsetParent);
_2ec=_2ea;
do{
if(!window.opera||_2ec.tagName=="BODY"){
_2eb-=_2ec.scrollTop||0;
valueL-=_2ec.scrollLeft||0;
}
}while(_2ec=_2ec.parentNode);
return [valueL,_2eb];
},clone:function(_2ed,_2ee){
var _2ef=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});
_2ed=$(_2ed);
var p=Position.page(_2ed);
_2ee=$(_2ee);
var _2f1=[0,0];
var _2f2=null;
if(Element.getStyle(_2ee,"position")=="absolute"){
_2f2=Position.offsetParent(_2ee);
_2f1=Position.page(_2f2);
}
if(_2f2==document.body){
_2f1[0]-=document.body.offsetLeft;
_2f1[1]-=document.body.offsetTop;
}
if(_2ef.setLeft){
_2ee.style.left=(p[0]-_2f1[0]+_2ef.offsetLeft)+"px";
}
if(_2ef.setTop){
_2ee.style.top=(p[1]-_2f1[1]+_2ef.offsetTop)+"px";
}
if(_2ef.setWidth){
_2ee.style.width=_2ed.offsetWidth+"px";
}
if(_2ef.setHeight){
_2ee.style.height=_2ed.offsetHeight+"px";
}
},absolutize:function(_2f3){
_2f3=$(_2f3);
if(_2f3.style.position=="absolute"){
return;
}
Position.prepare();
var _2f4=Position.positionedOffset(_2f3);
var top=_2f4[1];
var left=_2f4[0];
var _2f7=_2f3.clientWidth;
var _2f8=_2f3.clientHeight;
_2f3._originalLeft=left-parseFloat(_2f3.style.left||0);
_2f3._originalTop=top-parseFloat(_2f3.style.top||0);
_2f3._originalWidth=_2f3.style.width;
_2f3._originalHeight=_2f3.style.height;
_2f3.style.position="absolute";
_2f3.style.top=top+"px";
_2f3.style.left=left+"px";
_2f3.style.width=_2f7+"px";
_2f3.style.height=_2f8+"px";
},relativize:function(_2f9){
_2f9=$(_2f9);
if(_2f9.style.position=="relative"){
return;
}
Position.prepare();
_2f9.style.position="relative";
var top=parseFloat(_2f9.style.top||0)-(_2f9._originalTop||0);
var left=parseFloat(_2f9.style.left||0)-(_2f9._originalLeft||0);
_2f9.style.top=top+"px";
_2f9.style.left=left+"px";
_2f9.style.height=_2f9._originalHeight;
_2f9.style.width=_2f9._originalWidth;
}};
if(Prototype.Browser.WebKit){
Position.cumulativeOffset=function(_2fc){
var _2fd=0,valueL=0;
do{
_2fd+=_2fc.offsetTop||0;
valueL+=_2fc.offsetLeft||0;
if(_2fc.offsetParent==document.body){
if(Element.getStyle(_2fc,"position")=="absolute"){
break;
}
}
_2fc=_2fc.offsetParent;
}while(_2fc);
return [valueL,_2fd];
};
}
Element.addMethods();

String.prototype.parseColor=function(){
var _1="#";
if(this.slice(0,4)=="rgb("){
var _2=this.slice(4,this.length-1).split(",");
var i=0;
do{
_1+=parseInt(_2[i]).toColorPart();
}while(++i<3);
}else{
if(this.slice(0,1)=="#"){
if(this.length==4){
for(var i=1;i<4;i++){
_1+=(this.charAt(i)+this.charAt(i)).toLowerCase();
}
}
if(this.length==7){
_1=this.toLowerCase();
}
}
}
return (_1.length==7?_1:(arguments[0]||this));
};
Element.collectTextNodes=function(_5){
return $A($(_5).childNodes).collect(function(_6){
return (_6.nodeType==3?_6.nodeValue:(_6.hasChildNodes()?Element.collectTextNodes(_6):""));
}).flatten().join("");
};
Element.collectTextNodesIgnoreClass=function(_7,_8){
return $A($(_7).childNodes).collect(function(_9){
return (_9.nodeType==3?_9.nodeValue:((_9.hasChildNodes()&&!Element.hasClassName(_9,_8))?Element.collectTextNodesIgnoreClass(_9,_8):""));
}).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(_c){
return $(_c).style.opacity||"";
};
Element.forceRerendering=function(_d){
try{
_d=$(_d);
var n=document.createTextNode(" ");
_d.appendChild(n);
_d.removeChild(n);
}
catch(e){
}
};
Array.prototype.call=function(){
var _f=arguments;
this.each(function(f){
f.apply(this,_f);
});
};
var Effect={_elementDoesNotExistError:{name:"ElementDoesNotExistError",message:"The specified DOM element does not exist, but is required for this effect to operate"},tagifyText:function(_11){
if(typeof Builder=="undefined"){
throw ("Effect.tagifyText requires including script.aculo.us' builder.js library");
}
var _12="position:relative";
if(Prototype.Browser.IE){
_12+=";zoom:1";
}
_11=$(_11);
$A(_11.childNodes).each(function(_13){
if(_13.nodeType==3){
_13.nodeValue.toArray().each(function(_14){
_11.insertBefore(Builder.node("span",{style:_12},_14==" "?String.fromCharCode(160):_14),_13);
});
Element.remove(_13);
}
});
},multiple:function(_15,_16){
var _17;
if(((typeof _15=="object")||(typeof _15=="function"))&&(_15.length)){
_17=_15;
}else{
_17=$(_15).childNodes;
}
var _18=Object.extend({speed:0.1,delay:0},arguments[2]||{});
var _19=_18.delay;
$A(_17).each(function(_1a,_1b){
new _16(_1a,Object.extend(_18,{delay:_1b*_18.speed+_19}));
});
},PAIRS:{"slide":["SlideDown","SlideUp"],"blind":["BlindDown","BlindUp"],"appear":["Appear","Fade"]},toggle:function(_1c,_1d){
_1c=$(_1c);
_1d=(_1d||"appear").toLowerCase();
var _1e=Object.extend({queue:{position:"end",scope:(_1c.id||"global"),limit:1}},arguments[2]||{});
Effect[_1c.visible()?Effect.PAIRS[_1d][1]:Effect.PAIRS[_1d][0]](_1c,_1e);
}};
var Effect2=Effect;
Effect.Transitions={linear:Prototype.K,sinoidal:function(pos){
return (-Math.cos(pos*Math.PI)/2)+0.5;
},reverse:function(pos){
return 1-pos;
},flicker:function(pos){
var pos=((-Math.cos(pos*Math.PI)/4)+0.75)+Math.random()/4;
return (pos>1?1:pos);
},wobble:function(pos){
return (-Math.cos(pos*Math.PI*(9*pos))/2)+0.5;
},pulse:function(pos,_25){
_25=_25||5;
return (Math.round((pos%(1/_25))*_25)==0?((pos*_25*2)-Math.floor(pos*_25*2)):1-((pos*_25*2)-Math.floor(pos*_25*2)));
},none:function(pos){
return 0;
},full:function(pos){
return 1;
}};
Effect.ScopedQueue=Class.create();
Object.extend(Object.extend(Effect.ScopedQueue.prototype,Enumerable),{initialize:function(){
this.effects=[];
this.interval=null;
},_each:function(_28){
this.effects._each(_28);
},add:function(_29){
var _2a=new Date().getTime();
var _2b=(typeof _29.options.queue=="string")?_29.options.queue:_29.options.queue.position;
switch(_2b){
case "front":
this.effects.findAll(function(e){
return e.state=="idle";
}).each(function(e){
e.startOn+=_29.finishOn;
e.finishOn+=_29.finishOn;
});
break;
case "with-last":
_2a=this.effects.pluck("startOn").max()||_2a;
break;
case "end":
_2a=this.effects.pluck("finishOn").max()||_2a;
break;
}
_29.startOn+=_2a;
_29.finishOn+=_2a;
if(!_29.options.queue.limit||(this.effects.length<_29.options.queue.limit)){
this.effects.push(_29);
}
if(!this.interval){
this.interval=setInterval(this.loop.bind(this),15);
}
},remove:function(_2e){
this.effects=this.effects.reject(function(e){
return e==_2e;
});
if(this.effects.length==0){
clearInterval(this.interval);
this.interval=null;
}
},loop:function(){
var _30=new Date().getTime();
for(var i=0,len=this.effects.length;i<len;i++){
this.effects[i]&&this.effects[i].loop(_30);
}
}});
Effect.Queues={instances:$H(),get:function(_32){
if(typeof _32!="string"){
return _32;
}
if(!this.instances[_32]){
this.instances[_32]=new Effect.ScopedQueue();
}
return this.instances[_32];
}};
Effect.Queue=Effect.Queues.get("global");
Effect.DefaultOptions={transition:Effect.Transitions.sinoidal,duration:1,fps:100,sync:false,from:0,to:1,delay:0,queue:"parallel"};
Effect.Base=function(){
};
Effect.Base.prototype={position:null,start:function(_33){
function codeForEvent(_34,_35){
return ((_34[_35+"Internal"]?"this.options."+_35+"Internal(this);":"")+(_34[_35]?"this.options."+_35+"(this);":""));
}
if(_33.transition===false){
_33.transition=Effect.Transitions.linear;
}
this.options=Object.extend(Object.extend({},Effect.DefaultOptions),_33||{});
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;
eval("this.render = function(pos){ "+"if(this.state==\"idle\"){this.state=\"running\";"+codeForEvent(_33,"beforeSetup")+(this.setup?"this.setup();":"")+codeForEvent(_33,"afterSetup")+"};if(this.state==\"running\"){"+"pos=this.options.transition(pos)*"+this.fromToDelta+"+"+this.options.from+";"+"this.position=pos;"+codeForEvent(_33,"beforeUpdate")+(this.update?"this.update(pos);":"")+codeForEvent(_33,"afterUpdate")+"}}");
this.event("beforeStart");
if(!this.options.sync){
Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).add(this);
}
},loop:function(_36){
if(_36>=this.startOn){
if(_36>=this.finishOn){
this.render(1);
this.cancel();
this.event("beforeFinish");
if(this.finish){
this.finish();
}
this.event("afterFinish");
return;
}
var pos=(_36-this.startOn)/this.totalTime,frame=Math.round(pos*this.totalFrames);
if(frame>this.currentFrame){
this.render(pos);
this.currentFrame=frame;
}
}
},cancel:function(){
if(!this.options.sync){
Effect.Queues.get(typeof this.options.queue=="string"?"global":this.options.queue.scope).remove(this);
}
this.state="finished";
},event:function(_38){
if(this.options[_38+"Internal"]){
this.options[_38+"Internal"](this);
}
if(this.options[_38]){
this.options[_38](this);
}
},inspect:function(){
var _39=$H();
for(property in this){
if(typeof this[property]!="function"){
_39[property]=this[property];
}
}
return "#<Effect:"+_39.inspect()+",options:"+$H(this.options).inspect()+">";
}};
Effect.Parallel=Class.create();
Object.extend(Object.extend(Effect.Parallel.prototype,Effect.Base.prototype),{initialize:function(_3a){
this.effects=_3a||[];
this.start(arguments[1]);
},update:function(_3b){
this.effects.invoke("render",_3b);
},finish:function(_3c){
this.effects.each(function(_3d){
_3d.render(1);
_3d.cancel();
_3d.event("beforeFinish");
if(_3d.finish){
_3d.finish(_3c);
}
_3d.event("afterFinish");
});
}});
Effect.Event=Class.create();
Object.extend(Object.extend(Effect.Event.prototype,Effect.Base.prototype),{initialize:function(){
var _3e=Object.extend({duration:0},arguments[0]||{});
this.start(_3e);
},update:Prototype.emptyFunction});
Effect.Opacity=Class.create();
Object.extend(Object.extend(Effect.Opacity.prototype,Effect.Base.prototype),{initialize:function(_3f){
this.element=$(_3f);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){
this.element.setStyle({zoom:1});
}
var _40=Object.extend({from:this.element.getOpacity()||0,to:1},arguments[1]||{});
this.start(_40);
},update:function(_41){
this.element.setOpacity(_41);
}});
Effect.Move=Class.create();
Object.extend(Object.extend(Effect.Move.prototype,Effect.Base.prototype),{initialize:function(_42){
this.element=$(_42);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _43=Object.extend({x:0,y:0,mode:"relative"},arguments[1]||{});
this.start(_43);
},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(_44){
this.element.setStyle({left:Math.round(this.options.x*_44+this.originalLeft)+"px",top:Math.round(this.options.y*_44+this.originalTop)+"px"});
}});
Effect.MoveBy=function(_45,_46,_47){
return new Effect.Move(_45,Object.extend({x:_47,y:_46},arguments[3]||{}));
};
Effect.Scale=Class.create();
Object.extend(Object.extend(Effect.Scale.prototype,Effect.Base.prototype),{initialize:function(_48,_49){
this.element=$(_48);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _4a=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:"box",scaleFrom:100,scaleTo:_49},arguments[2]||{});
this.start(_4a);
},setup:function(){
this.restoreAfterFinish=this.options.restoreAfterFinish||false;
this.elementPositioning=this.element.getStyle("position");
this.originalStyle={};
["top","left","width","height","fontSize"].each(function(k){
this.originalStyle[k]=this.element.style[k];
}.bind(this));
this.originalTop=this.element.offsetTop;
this.originalLeft=this.element.offsetLeft;
var _4c=this.element.getStyle("font-size")||"100%";
["em","px","%","pt"].each(function(_4d){
if(_4c.indexOf(_4d)>0){
this.fontSize=parseFloat(_4c);
this.fontSizeType=_4d;
}
}.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(_4e){
var _4f=(this.options.scaleFrom/100)+(this.factor*_4e);
if(this.options.scaleContent&&this.fontSize){
this.element.setStyle({fontSize:this.fontSize*_4f+this.fontSizeType});
}
this.setDimensions(this.dims[0]*_4f,this.dims[1]*_4f);
},finish:function(_50){
if(this.restoreAfterFinish){
this.element.setStyle(this.originalStyle);
}
},setDimensions:function(_51,_52){
var d={};
if(this.options.scaleX){
d.width=Math.round(_52)+"px";
}
if(this.options.scaleY){
d.height=Math.round(_51)+"px";
}
if(this.options.scaleFromCenter){
var _54=(_51-this.dims[0])/2;
var _55=(_52-this.dims[1])/2;
if(this.elementPositioning=="absolute"){
if(this.options.scaleY){
d.top=this.originalTop-_54+"px";
}
if(this.options.scaleX){
d.left=this.originalLeft-_55+"px";
}
}else{
if(this.options.scaleY){
d.top=-_54+"px";
}
if(this.options.scaleX){
d.left=-_55+"px";
}
}
}
this.element.setStyle(d);
}});
Effect.Highlight=Class.create();
Object.extend(Object.extend(Effect.Highlight.prototype,Effect.Base.prototype),{initialize:function(_56){
this.element=$(_56);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _57=Object.extend({startcolor:"#ffff99"},arguments[1]||{});
this.start(_57);
},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(i){
return parseInt(this.options.startcolor.slice(i*2+1,i*2+3),16);
}.bind(this));
this._delta=$R(0,2).map(function(i){
return parseInt(this.options.endcolor.slice(i*2+1,i*2+3),16)-this._base[i];
}.bind(this));
},update:function(_5a){
this.element.setStyle({backgroundColor:$R(0,2).inject("#",function(m,v,i){
return m+(Math.round(this._base[i]+(this._delta[i]*_5a)).toColorPart());
}.bind(this))});
},finish:function(){
this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}));
}});
Effect.ScrollTo=Class.create();
Object.extend(Object.extend(Effect.ScrollTo.prototype,Effect.Base.prototype),{initialize:function(_5e){
this.element=$(_5e);
this.start(arguments[1]||{});
},setup:function(){
Position.prepare();
var _5f=Position.cumulativeOffset(this.element);
if(this.options.offset){
_5f[1]+=this.options.offset;
}
var max=window.innerHeight?window.height-window.innerHeight:document.body.scrollHeight-(document.documentElement.clientHeight?document.documentElement.clientHeight:document.body.clientHeight);
this.scrollStart=Position.deltaY;
this.delta=(_5f[1]>max?max:_5f[1])-this.scrollStart;
},update:function(_61){
Position.prepare();
window.scrollTo(Position.deltaX,this.scrollStart+(_61*this.delta));
}});
Effect.Fade=function(_62){
_62=$(_62);
var _63=_62.getInlineOpacity();
var _64=Object.extend({from:_62.getOpacity()||1,to:0,afterFinishInternal:function(_65){
if(_65.options.to!=0){
return;
}
_65.element.hide().setStyle({opacity:_63});
}},arguments[1]||{});
return new Effect.Opacity(_62,_64);
};
Effect.Appear=function(_66){
_66=$(_66);
var _67=Object.extend({from:(_66.getStyle("display")=="none"?0:_66.getOpacity()||0),to:1,afterFinishInternal:function(_68){
_68.element.forceRerendering();
},beforeSetup:function(_69){
_69.element.setOpacity(_69.options.from).show();
}},arguments[1]||{});
return new Effect.Opacity(_66,_67);
};
Effect.Puff=function(_6a){
_6a=$(_6a);
var _6b={opacity:_6a.getInlineOpacity(),position:_6a.getStyle("position"),top:_6a.style.top,left:_6a.style.left,width:_6a.style.width,height:_6a.style.height};
return new Effect.Parallel([new Effect.Scale(_6a,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(_6a,{sync:true,to:0})],Object.extend({duration:1,beforeSetupInternal:function(_6c){
Position.absolutize(_6c.effects[0].element);
},afterFinishInternal:function(_6d){
_6d.effects[0].element.hide().setStyle(_6b);
}},arguments[1]||{}));
};
Effect.BlindUp=function(_6e){
_6e=$(_6e);
_6e.makeClipping();
return new Effect.Scale(_6e,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(_6f){
_6f.element.hide().undoClipping();
}},arguments[1]||{}));
};
Effect.BlindDown=function(_70){
_70=$(_70);
var _71=_70.getDimensions();
return new Effect.Scale(_70,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:_71.height,originalWidth:_71.width},restoreAfterFinish:true,afterSetup:function(_72){
_72.element.makeClipping().setStyle({height:"0px"}).show();
},afterFinishInternal:function(_73){
_73.element.undoClipping();
}},arguments[1]||{}));
};
Effect.SwitchOff=function(_74){
_74=$(_74);
var _75=_74.getInlineOpacity();
return new Effect.Appear(_74,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(_76){
new Effect.Scale(_76.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(_77){
_77.element.makePositioned().makeClipping();
},afterFinishInternal:function(_78){
_78.element.hide().undoClipping().undoPositioned().setStyle({opacity:_75});
}});
}},arguments[1]||{}));
};
Effect.DropOut=function(_79){
_79=$(_79);
var _7a={top:_79.getStyle("top"),left:_79.getStyle("left"),opacity:_79.getInlineOpacity()};
return new Effect.Parallel([new Effect.Move(_79,{x:0,y:100,sync:true}),new Effect.Opacity(_79,{sync:true,to:0})],Object.extend({duration:0.5,beforeSetup:function(_7b){
_7b.effects[0].element.makePositioned();
},afterFinishInternal:function(_7c){
_7c.effects[0].element.hide().undoPositioned().setStyle(_7a);
}},arguments[1]||{}));
};
Effect.Shake=function(_7d){
_7d=$(_7d);
var _7e={top:_7d.getStyle("top"),left:_7d.getStyle("left")};
return new Effect.Move(_7d,{x:20,y:0,duration:0.05,afterFinishInternal:function(_7f){
new Effect.Move(_7f.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_80){
new Effect.Move(_80.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_81){
new Effect.Move(_81.element,{x:-40,y:0,duration:0.1,afterFinishInternal:function(_82){
new Effect.Move(_82.element,{x:40,y:0,duration:0.1,afterFinishInternal:function(_83){
new Effect.Move(_83.element,{x:-20,y:0,duration:0.05,afterFinishInternal:function(_84){
_84.element.undoPositioned().setStyle(_7e);
}});
}});
}});
}});
}});
}});
};
Effect.SlideDown=function(_85){
_85=$(_85).cleanWhitespace();
var _86=_85.down().getStyle("bottom");
var _87=_85.getDimensions();
return new Effect.Scale(_85,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:_87.height,originalWidth:_87.width},restoreAfterFinish:true,afterSetup:function(_88){
_88.element.makePositioned();
_88.element.down().makePositioned();
if(window.opera){
_88.element.setStyle({top:""});
}
_88.element.makeClipping().setStyle({height:"0px"}).show();
},afterUpdateInternal:function(_89){
_89.element.down().setStyle({bottom:(_89.dims[0]-_89.element.clientHeight)+"px"});
},afterFinishInternal:function(_8a){
_8a.element.undoClipping().undoPositioned();
_8a.element.down().undoPositioned().setStyle({bottom:_86});
}},arguments[1]||{}));
};
Effect.SlideUp=function(_8b){
_8b=$(_8b).cleanWhitespace();
var _8c=_8b.down().getStyle("bottom");
return new Effect.Scale(_8b,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:"box",scaleFrom:100,restoreAfterFinish:true,beforeStartInternal:function(_8d){
_8d.element.makePositioned();
_8d.element.down().makePositioned();
if(window.opera){
_8d.element.setStyle({top:""});
}
_8d.element.makeClipping().show();
},afterUpdateInternal:function(_8e){
_8e.element.down().setStyle({bottom:(_8e.dims[0]-_8e.element.clientHeight)+"px"});
},afterFinishInternal:function(_8f){
_8f.element.hide().undoClipping().undoPositioned().setStyle({bottom:_8c});
_8f.element.down().undoPositioned();
}},arguments[1]||{}));
};
Effect.Squish=function(_90){
return new Effect.Scale(_90,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(_91){
_91.element.makeClipping();
},afterFinishInternal:function(_92){
_92.element.hide().undoClipping();
}});
};
Effect.Grow=function(_93){
_93=$(_93);
var _94=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});
var _95={top:_93.style.top,left:_93.style.left,height:_93.style.height,width:_93.style.width,opacity:_93.getInlineOpacity()};
var _96=_93.getDimensions();
var _97,initialMoveY;
var _98,moveY;
switch(_94.direction){
case "top-left":
_97=initialMoveY=_98=moveY=0;
break;
case "top-right":
_97=_96.width;
initialMoveY=moveY=0;
_98=-_96.width;
break;
case "bottom-left":
_97=_98=0;
initialMoveY=_96.height;
moveY=-_96.height;
break;
case "bottom-right":
_97=_96.width;
initialMoveY=_96.height;
_98=-_96.width;
moveY=-_96.height;
break;
case "center":
_97=_96.width/2;
initialMoveY=_96.height/2;
_98=-_96.width/2;
moveY=-_96.height/2;
break;
}
return new Effect.Move(_93,{x:_97,y:initialMoveY,duration:0.01,beforeSetup:function(_99){
_99.element.hide().makeClipping().makePositioned();
},afterFinishInternal:function(_9a){
new Effect.Parallel([new Effect.Opacity(_9a.element,{sync:true,to:1,from:0,transition:_94.opacityTransition}),new Effect.Move(_9a.element,{x:_98,y:moveY,sync:true,transition:_94.moveTransition}),new Effect.Scale(_9a.element,100,{scaleMode:{originalHeight:_96.height,originalWidth:_96.width},sync:true,scaleFrom:window.opera?1:0,transition:_94.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(_9b){
_9b.effects[0].element.setStyle({height:"0px"}).show();
},afterFinishInternal:function(_9c){
_9c.effects[0].element.undoClipping().undoPositioned().setStyle(_95);
}},_94));
}});
};
Effect.Shrink=function(_9d){
_9d=$(_9d);
var _9e=Object.extend({direction:"center",moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});
var _9f={top:_9d.style.top,left:_9d.style.left,height:_9d.style.height,width:_9d.style.width,opacity:_9d.getInlineOpacity()};
var _a0=_9d.getDimensions();
var _a1,moveY;
switch(_9e.direction){
case "top-left":
_a1=moveY=0;
break;
case "top-right":
_a1=_a0.width;
moveY=0;
break;
case "bottom-left":
_a1=0;
moveY=_a0.height;
break;
case "bottom-right":
_a1=_a0.width;
moveY=_a0.height;
break;
case "center":
_a1=_a0.width/2;
moveY=_a0.height/2;
break;
}
return new Effect.Parallel([new Effect.Opacity(_9d,{sync:true,to:0,from:1,transition:_9e.opacityTransition}),new Effect.Scale(_9d,window.opera?1:0,{sync:true,transition:_9e.scaleTransition,restoreAfterFinish:true}),new Effect.Move(_9d,{x:_a1,y:moveY,sync:true,transition:_9e.moveTransition})],Object.extend({beforeStartInternal:function(_a2){
_a2.effects[0].element.makePositioned().makeClipping();
},afterFinishInternal:function(_a3){
_a3.effects[0].element.hide().undoClipping().undoPositioned().setStyle(_9f);
}},_9e));
};
Effect.Pulsate=function(_a4){
_a4=$(_a4);
var _a5=arguments[1]||{};
var _a6=_a4.getInlineOpacity();
var _a7=_a5.transition||Effect.Transitions.sinoidal;
var _a8=function(pos){
return _a7(1-Effect.Transitions.pulse(pos,_a5.pulses));
};
_a8.bind(_a7);
return new Effect.Opacity(_a4,Object.extend(Object.extend({duration:2,from:0,afterFinishInternal:function(_aa){
_aa.element.setStyle({opacity:_a6});
}},_a5),{transition:_a8}));
};
Effect.Fold=function(_ab){
_ab=$(_ab);
var _ac={top:_ab.style.top,left:_ab.style.left,width:_ab.style.width,height:_ab.style.height};
_ab.makeClipping();
return new Effect.Scale(_ab,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(_ad){
new Effect.Scale(_ab,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(_ae){
_ae.element.hide().undoClipping().setStyle(_ac);
}});
}},arguments[1]||{}));
};
Effect.Morph=Class.create();
Object.extend(Object.extend(Effect.Morph.prototype,Effect.Base.prototype),{initialize:function(_af){
this.element=$(_af);
if(!this.element){
throw (Effect._elementDoesNotExistError);
}
var _b0=Object.extend({style:{}},arguments[1]||{});
if(typeof _b0.style=="string"){
if(_b0.style.indexOf(":")==-1){
var _b1="",selector="."+_b0.style;
$A(document.styleSheets).reverse().each(function(_b2){
if(_b2.cssRules){
cssRules=_b2.cssRules;
}else{
if(_b2.rules){
cssRules=_b2.rules;
}
}
$A(cssRules).reverse().each(function(_b3){
if(selector==_b3.selectorText){
_b1=_b3.style.cssText;
throw $break;
}
});
if(_b1){
throw $break;
}
});
this.style=_b1.parseStyle();
_b0.afterFinishInternal=function(_b4){
_b4.element.addClassName(_b4.options.style);
_b4.transforms.each(function(_b5){
if(_b5.style!="opacity"){
_b4.element.style[_b5.style]="";
}
});
};
}else{
this.style=_b0.style.parseStyle();
}
}else{
this.style=$H(_b0.style);
}
this.start(_b0);
},setup:function(){
function parseColor(_b6){
if(!_b6||["rgba(0, 0, 0, 0)","transparent"].include(_b6)){
_b6="#ffffff";
}
_b6=_b6.parseColor();
return $R(0,2).map(function(i){
return parseInt(_b6.slice(i*2+1,i*2+3),16);
});
}
this.transforms=this.style.map(function(_b8){
var _b9=_b8[0],value=_b8[1],unit=null;
if(value.parseColor("#zzzzzz")!="#zzzzzz"){
value=value.parseColor();
unit="color";
}else{
if(_b9=="opacity"){
value=parseFloat(value);
if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout)){
this.element.setStyle({zoom:1});
}
}else{
if(Element.CSS_LENGTH.test(value)){
var _ba=value.match(/^([\+\-]?[0-9\.]+)(.*)$/);
value=parseFloat(_ba[1]);
unit=(_ba.length==3)?_ba[2]:null;
}
}
}
var _bb=this.element.getStyle(_b9);
return {style:_b9.camelize(),originalValue:unit=="color"?parseColor(_bb):parseFloat(_bb||0),targetValue:unit=="color"?parseColor(value):value,unit:unit};
}.bind(this)).reject(function(_bc){
return ((_bc.originalValue==_bc.targetValue)||(_bc.unit!="color"&&(isNaN(_bc.originalValue)||isNaN(_bc.targetValue))));
});
},update:function(_bd){
var _be={},transform,i=this.transforms.length;
while(i--){
_be[(transform=this.transforms[i]).style]=transform.unit=="color"?"#"+(Math.round(transform.originalValue[0]+(transform.targetValue[0]-transform.originalValue[0])*_bd)).toColorPart()+(Math.round(transform.originalValue[1]+(transform.targetValue[1]-transform.originalValue[1])*_bd)).toColorPart()+(Math.round(transform.originalValue[2]+(transform.targetValue[2]-transform.originalValue[2])*_bd)).toColorPart():transform.originalValue+Math.round(((transform.targetValue-transform.originalValue)*_bd)*1000)/1000+transform.unit;
}
this.element.setStyle(_be,true);
}});
Effect.Transform=Class.create();
Object.extend(Effect.Transform.prototype,{initialize:function(_bf){
this.tracks=[];
this.options=arguments[1]||{};
this.addTracks(_bf);
},addTracks:function(_c0){
_c0.each(function(_c1){
var _c2=$H(_c1).values().first();
this.tracks.push($H({ids:$H(_c1).keys().first(),effect:Effect.Morph,options:{style:_c2}}));
}.bind(this));
return this;
},play:function(){
return new Effect.Parallel(this.tracks.map(function(_c3){
var _c4=[$(_c3.ids)||$$(_c3.ids)].flatten();
return _c4.map(function(e){
return new _c3.effect(e,Object.extend({sync:true},_c3.options));
});
}).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.prototype.parseStyle=function(){
var _c6=document.createElement("div");
_c6.innerHTML="<div style=\""+this+"\"></div>";
var _c7=_c6.childNodes[0].style,styleRules=$H();
Element.CSS_PROPERTIES.each(function(_c8){
if(_c7[_c8]){
styleRules[_c8]=_c7[_c8];
}
});
if(Prototype.Browser.IE&&this.indexOf("opacity")>-1){
styleRules.opacity=this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1];
}
return styleRules;
};
Element.morph=function(_c9,_ca){
new Effect.Morph(_c9,Object.extend({style:_ca},arguments[2]||{}));
return _c9;
};
["getInlineOpacity","forceRerendering","setContentZoom","collectTextNodes","collectTextNodesIgnoreClass","morph"].each(function(f){
Element.Methods[f]=Element[f];
});
Element.Methods.visualEffect=function(_cc,_cd,_ce){
s=_cd.dasherize().camelize();
effect_class=s.charAt(0).toUpperCase()+s.substring(1);
new Effect[effect_class](_cc,_ce);
return $(_cc);
};
Element.addMethods();
// lightwindow.js v2.0
//
// Copyright (c) 2007 stickmanlabs
// Author: Kevin P Miller | http://www.stickmanlabs.com
// 
// LightWindow is freely distributable under the terms of an MIT-style license.
//
// I don't care what you think about the file size...
//   Be a pro: 
//	    http://www.thinkvitamin.com/features/webapps/serving-javascript-fast
//      http://rakaz.nl/item/make_your_pages_load_faster_by_combining_and_compressing_javascript_and_css_files
//

/*-----------------------------------------------------------------------------------------------*/

if(typeof Effect == 'undefined')
  throw("lightwindow.js requires including script.aculo.us' effects.js library!");

// This will stop image flickering in IE6 when elements with images are moved
try {
	document.execCommand("BackgroundImageCache", false, true);
} catch(e) {}

var lightwindow = Class.create();	
lightwindow.prototype = {
	//
	//	Setup Variables
	//
	element : null,
	contentToFetch : null,
	windowActive : false,
	dataEffects : [],
	dimensions : {
		cruft : null,
		container : null,
		viewport : {
			height : null,
			width : null,
			offsetTop : null,
			offsetLeft : null
		}
	},
	pagePosition : {
		x : 0,
		y : 0
	},
	pageDimensions : {
		width : null,
		height : null
	},
	preloadImage : [],
	preloadedImage : [],
	galleries : [],
	resizeTo : {
		height : null,
		heightPercent : null,
		width : null,
		widthPercent : null,
		fixedTop : null,
		fixedLeft : null
	},
	scrollbarOffset : 18,
	navigationObservers : {
		previous : null,
		next : null
	},
	containerChange : {
		height : 0,
		width : 0
	},
	activeGallery : false,
	galleryLocation : {
		current : 0,
		total : 0
	},
	//
	//	Initialize the lightwindow.
	//
	initialize : function(options) {
		this.options = Object.extend({
			resizeSpeed : 8,
			contentOffset : {
				height : 20,
				width : 20
			},
			dimensions : {
				image : {height : 250, width : 250},
				page : {height : 250, width : 250},
				inline : {height : 250, width : 250},
				media : {height : 250, width : 250},
				external : {height : 250, width : 250},
				titleHeight : 25
			},
			classNames : {	
				standard : 'lightwindow',
				action : 'lightwindow_action'
			},
			fileTypes : {
				page : ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php4', 'php3', 'php', 'php5', 'phtml', 'rhtml', 'shtml', 'txt', 'vbs', 'rb'],
				media : ['aif', 'aiff', 'asf', 'avi', 'divx', 'm1v', 'm2a', 'm2v', 'm3u', 'mid', 'midi', 'mov', 'moov', 'movie', 'mp2', 'mp3', 'mpa', 'mpa', 'mpe', 'mpeg', 'mpg', 'mpg', 'mpga', 'pps', 'qt', 'rm', 'ram', 'swf', 'viv', 'vivo', 'wav'],
				image : ['bmp', 'gif', 'jpg', 'png', 'tiff']
			},
			mimeTypes : {
				avi : 'video/avi',
				aif : 'audio/aiff',
				aiff : 'audio/aiff',
				gif : 'image/gif',
				bmp : 'image/bmp',
				jpeg : 'image/jpeg',
				m1v : 'video/mpeg',
				m2a : 'audio/mpeg',
				m2v : 'video/mpeg',
				m3u : 'audio/x-mpequrl',
				mid : 'audio/x-midi',
				midi : 'audio/x-midi',
				mjpg : 'video/x-motion-jpeg',
				moov : 'video/quicktime',
				mov : 'video/quicktime',
				movie : 'video/x-sgi-movie',
				mp2 : 'audio/mpeg',
				mp3 : 'audio/mpeg3',
				mpa : 'audio/mpeg',
				mpa : 'video/mpeg',
				mpe : 'video/mpeg',
				mpeg : 'video/mpeg',
				mpg : 'audio/mpeg',
				mpg : 'video/mpeg',
				mpga : 'audio/mpeg',
				pdf : 'application/pdf',
				png : 'image/png',
				pps : 'application/mspowerpoint',
				qt : 'video/quicktime',
				ram : 'audio/x-pn-realaudio-plugin',
				rm : 'application/vnd.rn-realmedia',
				swf	: 'application/x-shockwave-flash',
				tiff : 'image/tiff',
				viv : 'video/vivo',
				vivo : 'video/vivo',
				wav : 'audio/wav',
				wmv : 'application/x-mplayer2'			
			},	
			classids : {
				mov : 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B',
				swf : 'clsid:D27CDB6E-AE6D-11cf-96B8-444553540000',
				wmv : 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6'
			},
			codebases : {
				mov : 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0',
				swf : 'http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0',
				wmv : 'http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715'
			},	
			viewportPadding : 10,
			EOLASFix : 'swf,wmv,fla,flv',
			overlay : {
				opacity : 0.7,
				image : '../includes3p/lightwindow/images/black.png',
				presetImage : '../includes3p/lightwindow/images/black-70.png'
			},
			skin : 	{
				main : 	'<div id="lightwindow_container" >'+
							'<div id="lightwindow_title_bar" >'+
								'<div id="lightwindow_title_bar_inner" >'+
									'<span id="lightwindow_title_bar_title"></span>'+
									'<a id="lightwindow_title_bar_close_link" >sluiten</a>'+
								'</div>'+
							'</div>'+
							'<div id="lightwindow_stage" >'+
								'<div id="lightwindow_contents" >'+
								'</div>'+
								'<div id="lightwindow_navigation" >'+
									'<a href="#" id="lightwindow_previous" >'+
										'<span id="lightwindow_previous_title"></span>'+
									'</a>'+
									'<a href="#" id="lightwindow_next" >'+
										'<span id="lightwindow_next_title"></span>'+
									'</a>'+
									'<iframe name="lightwindow_navigation_shim" id="lightwindow_navigation_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
								'</div>'+								
								'<div id="lightwindow_galleries">'+
									'<div id="lightwindow_galleries_tab_container" >'+
										'<a href="#" id="lightwindow_galleries_tab" >'+
											'<span id="lightwindow_galleries_tab_span" class="up" >Galleries</span>'+
										'</a>'+
									'</div>'+
									'<div id="lightwindow_galleries_list" >'+
									'</div>'+
								'</div>'+
							'</div>'+
							'<div id="lightwindow_data_slide" >'+
								'<div id="lightwindow_data_slide_inner" >'+
									'<div id="lightwindow_data_details" >'+
										'<div id="lightwindow_data_gallery_container" >'+
											'<span id="lightwindow_data_gallery_current"></span>'+
											' of '+
											'<span id="lightwindow_data_gallery_total"></span>'+
										'</div>'+
										'<div id="lightwindow_data_author_container" >'+
											'<span id="lightwindow_data_author"></span>'+
										'</div>'+
									'</div>'+
									'<div id="lightwindow_data_caption" >'+
									'</div>'+
								'</div>'+
							'</div>'+
						'</div>',	
				loading : 	'<div id="lightwindow_loading" >'+
								'<img src="../includes3p/lightwindow/images/ajax-loading.gif" alt="loading" />'+
								'<span>Laden of <a href="javascript: myLightWindow.deactivate();">Afbreken</a></span>'+
								'<iframe name="lightwindow_loading_shim" id="lightwindow_loading_shim" src="javascript:false;" frameBorder="0" scrolling="no"></iframe>'+
							'</div>',
				iframe : 	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">'+
							'<html xmlns="http://www.w3.org/1999/xhtml">'+
								'<body>'+
									'{body_replace}'+
								'</body>'+
							'</html>',
				gallery : {
					top :		'<div class="lightwindow_galleries_list">'+
									'<h1>{gallery_title_replace}</h1>'+
									'<ul>',
					middle : 			'<li>'+
											'{gallery_link_replace}'+
										'</li>',
					bottom : 		'</ul>'+
								'</div>'
				}
			},
			formMethod : 'get',
			hideFlash : false,
			hideGalleryTab : false,
			showTitleBar : true,
			animationHandler : false,
			navigationHandler : false,
			transitionHandler : false,
			finalAnimationHandler : false,
			formHandler : false,
			galleryAnimationHandler : false,
			showGalleryCount : true
		}, options || {});
		this.duration = ((11-this.options.resizeSpeed)*0.15);
		this._setupLinks();
		this._getScroll();
		this._getPageDimensions();
		this._browserDimensions();
		this._addLightWindowMarkup(false);
		this._setupDimensions(); 
		this.buildGalleryList();
	},
	//
	//	Activate the lightwindow.
	//
	activate : function(e, link){		
		// Clear out the window Contents
		this._clearWindowContents(true);
			
		// Add back in out loading panel
		this._addLoadingWindowMarkup();

		// Setup the element properties
		this._setupWindowElements(link);
		
		// Setup everything
		this._getScroll();
		this._browserDimensions();
		this._setupDimensions();
		this._toggleTroubleElements('hidden', false);
		this._displayLightWindow('block', 'hidden');
		this._setStatus(true);
		this._monitorKeyboard(true);
		this._prepareIE(true);
		this._loadWindow();
	},
	//
	//	Turn off the window
	//
	deactivate : function(){
		// The window is not active
		this.windowActive = false;
		
		// There is no longer a gallery active
		this.activeGallery = false;
		if (!this.options.hideGalleryTab) {
			this._handleGalleryAnimation(false);
		}
		
		// Kill the animation
		this.animating = false;
		
		// Clear our element
		this.element = null;
		
		// hide the window.
		this._displayLightWindow('none', 'visible');
		
		// Clear out the window Contents
		this._clearWindowContents(false);
		
		// Stop all animation
		var queue = Effect.Queues.get('lightwindowAnimation').each(function(e){e.cancel();});
		
		// Undo the setup
		this._prepareIE(false);
		this._setupDimensions();
		this._toggleTroubleElements('visible', false);	
		this._monitorKeyboard(false);	
	},
	//
	//  Initialize specific window
	//
	createWindow : function(element, attributes) {
		this._processLink($(element));
	},
	//
	//  Open a Window from a hash of attributes
	//
	activateWindow : function(options) {
		this.element = Object.extend({
			href : null,
			title : null,
			author : null,
			caption : null,
			rel : null,
			top : null,
			left : null,
			type : null,
			showImages : null,
			height : null,
			width : null,
			loadingAnimation : null,
			iframeEmbed : null,
			form : null
		}, options || {});
		
		// Set the window type
		this.contentToFetch = this.element.href;
		this.windowType = this.element.type ? this.element.type : this._fileType(this.element.href);	
		
		// Clear out the window Contents
		this._clearWindowContents(true);
			
		// Add back in out loading panel
		this._addLoadingWindowMarkup();
		
		// Setup everything
		this._getScroll();
		this._browserDimensions();
		this._setupDimensions();
		this._toggleTroubleElements('hidden', false);
		this._displayLightWindow('block', 'hidden');
		this._setStatus(true);
		this._monitorKeyboard(true);
		this._prepareIE(true);
		this._loadWindow();
	},
	//
	//  Fire off our Form handler
	//
	submitForm : function(e) {
		if (this.options.formHandler) {
			this.options.formHandler(e);
		} else {
			this._defaultFormHandler(e);
		}
	},
	//
	//	Reload the window with another location
	//
	openWindow : function(element) {
		var element = $(element);

		// The window is active
		this.windowActive = true;
		
		// Clear out the window Contents
		this._clearWindowContents(true);
		
		// Add back in out loading panel
		this._addLoadingWindowMarkup();
		
		// Setup the element properties
		this._setupWindowElements(element);

		this._setStatus(true);
		this._handleTransition();
	},
	//
	//  Navigate the window
	//
	navigateWindow : function(direction) {
		this._handleNavigation(false);
		if (direction == 'previous') {
			this.openWindow(this.navigationObservers.previous);
		} else if (direction == 'next'){ 
			this.openWindow(this.navigationObservers.next);
		}
	},
	//
	//  Build the Gallery List and Load it
	//
	buildGalleryList : function() {
		var output = '';
		var galleryLink;
		for (i in this.galleries) {
			if (typeof this.galleries[i] == 'object') {
				output += (this.options.skin.gallery.top).replace('{gallery_title_replace}', unescape(i));
				for (j in this.galleries[i]) {
					if (typeof this.galleries[i][j] == 'object') {						
						galleryLink = '<a href="#" id="lightwindow_gallery_'+i+'_'+j+'" >'+unescape(j)+'</a>';
						output += (this.options.skin.gallery.middle).replace('{gallery_link_replace}', galleryLink);
					}
				}
				output += this.options.skin.gallery.bottom;
			}
		}
		new Insertion.Top('lightwindow_galleries_list', output);
		
		// Attach Events
		for (i in this.galleries) {
			if (typeof this.galleries[i] == 'object') {
				for (j in this.galleries[i]) {
					if (typeof this.galleries[i][j] == 'object') {
						Event.observe($('lightwindow_gallery_'+i+'_'+j), 'click', this.openWindow.bind(this, this.galleries[i][j][0]), false);
						$('lightwindow_gallery_'+i+'_'+j).onclick = function() {return false;};	
					}
				}
			}
		}
	},
	// 
	//  Set Links Up
	//
	_setupLinks : function() {
		var links = $$('.'+this.options.classNames.standard);
		links.each(function(link) {
			this._processLink(link);
		}.bind(this));	
	},
	//
	//  Process a Link
	//
	_processLink : function(link) {
		if ((this._fileType(link.getAttribute('href')) == 'image' || this._fileType(link.getAttribute('href')) == 'media')) {
			if (gallery = this._getGalleryInfo(link.rel)) {
				if (!this.galleries[gallery[0]]) {
					this.galleries[gallery[0]] = new Array();
				}
				if (!this.galleries[gallery[0]][gallery[1]]) {
					this.galleries[gallery[0]][gallery[1]] = new Array();
				}
				this.galleries[gallery[0]][gallery[1]].push(link);
			}
		}
		
		// Take care of our inline content
		var url = link.getAttribute('href');
		if (url.indexOf('?') > -1) {
			url = url.substring(0, url.indexOf('?'));
		}
		
		var container = url.substring(url.indexOf('#')+1);
		if($(container)) {
			$(container).setStyle({
				display : 'none'
			});
		}
		
		Event.observe(link, 'click', this.activate.bindAsEventListener(this, link), false);
		link.onclick = function() {return false;};		
	},
	//
	//	Setup our actions
	//
	_setupActions : function() {
		var links = $$('#lightwindow_container .'+this.options.classNames.action);
		links.each(function(link) {
			Event.observe(link, 'click', this[link.getAttribute('rel')].bindAsEventListener(this, link), false);
			link.onclick = function() {return false;};
		}.bind(this));
	},
	//
	//	Add the markup to the page.
	//
	_addLightWindowMarkup : function(rebuild) {
 if (!$('lightwindow')){ 
		var overlay = Element.extend(document.createElement('div'));
		overlay.setAttribute('id', 'lightwindow_overlay');		
		// FF Mac has a problem with putting Flash above a layer without a 100% opacity background, so we need to use a pre-made
		if (Prototype.Browser.Gecko) {
			overlay.setStyle({
				backgroundImage: 'url('+this.options.overlay.presetImage+')',
				backgroundRepeat: 'repeat',
				height: this.pageDimensions.height+'px'
			});			
		} else {
			overlay.setStyle({
				opacity: this.options.overlay.opacity,
				backgroundImage: 'url('+this.options.overlay.image+')',
				backgroundRepeat: 'repeat',
				height: this.pageDimensions.height+'px'
			});
		}
		
		var lw = document.createElement('div');
		lw.setAttribute('id', 'lightwindow');
		lw.innerHTML = this.options.skin.main;
		
		var body = document.getElementsByTagName('body')[0];
		body.appendChild(overlay);
		body.appendChild(lw);	
} else {
        var overlay = Element.extend(document.createElement('div'));
    }


		if ($('lightwindow_title_bar_close_link')) {
			Event.observe('lightwindow_title_bar_close_link', 'click', this.deactivate.bindAsEventListener(this));
			$('lightwindow_title_bar_close_link').onclick = function() {return false;};
		}
			
		Event.observe($('lightwindow_previous'), 'click', this.navigateWindow.bind(this, 'previous'), false);
		$('lightwindow_previous').onclick = function() {return false;};		
		Event.observe($('lightwindow_next'), 'click', this.navigateWindow.bind(this, 'next'), false);
		$('lightwindow_next').onclick = function() {return false;};

		if (!this.options.hideGalleryTab) {
			Event.observe($('lightwindow_galleries_tab'), 'click', this._handleGalleryAnimation.bind(this, true), false);
			$('lightwindow_galleries_tab').onclick = function() {return false;};
		}
		
		// Because we use position absolute, kill the scroll Wheel on animations
		if (Prototype.Browser.IE) {
			Event.observe(document, 'mousewheel', this._stopScrolling.bindAsEventListener(this), false);
		} else {
			Event.observe(window, 'DOMMouseScroll', this._stopScrolling.bindAsEventListener(this), false);
		}
				
		Event.observe(overlay, 'click', this.deactivate.bindAsEventListener(this), false);
		overlay.onclick = function() {return false;};
	},
	//
	//  Add loading window markup
	//
	_addLoadingWindowMarkup : function() {
		$('lightwindow_contents').innerHTML += this.options.skin.loading;
	},
	//
	//  Setup the window elements
	//
	_setupWindowElements : function(link) {
		this.element = link;
		this.element.title = null ? '' : link.getAttribute('title');
		this.element.author = null ? '' : link.getAttribute('author');
		this.element.caption = null ? '' : link.getAttribute('caption');
		this.element.rel = null ? '' : link.getAttribute('rel');
		this.element.params = null ? '' : link.getAttribute('params');

		// Set the window type
		this.contentToFetch = this.element.href;
		this.windowType = this._getParameter('lightwindow_type') ? this._getParameter('lightwindow_type') : this._fileType(this.contentToFetch);	
	},
	//
	//  Clear the window contents out
	//
	_clearWindowContents : function(contents) {
		// If there is an iframe, its got to go
		if ($('lightwindow_iframe')) {
			Element.remove($('lightwindow_iframe'));
		}

		// Stop playing an object if its still around
		if ($('lightwindow_media_primary')) {
			try {
				$('lightwindow_media_primary').Stop();
			} catch(e) {}
			Element.remove($('lightwindow_media_primary'));
		}

		// Stop playing an object if its still around		
		if ($('lightwindow_media_secondary')) {
			try {
				$('lightwindow_media_secondary').Stop();
			} catch(e) {}
			Element.remove($('lightwindow_media_secondary'));
		}
		
		this.activeGallery = false;
		this._handleNavigation(this.activeGallery);
		
		if (contents) {
			// Empty the contents
			$('lightwindow_contents').innerHTML = '';
			
			// Reset the scroll bars
			$('lightwindow_contents').setStyle({
				overflow: 'hidden'
			});		
			
			if (!this.windowActive) {
				$('lightwindow_data_slide_inner').setStyle({
					display: 'none'
				});

				$('lightwindow_title_bar_title').innerHTML = '';
			}

			// Because of browser differences and to maintain flexible captions we need to reset this height at close
			$('lightwindow_data_slide').setStyle({
				height: 'auto'
			});
		}
		
		this.resizeTo.height = null;
		this.resizeTo.width = null;
	},
	//
	//	Set the status of our animation to keep things from getting clunky
	//
	_setStatus : function(status) {
		this.animating = status;
		if (status) {
			Element.show('lightwindow_loading');
		}
		if (!(/MSIE 6./i.test(navigator.userAgent))) {
			this._fixedWindow(status);
		}
	},
	//
	//  Make this window Fixed
	//
	_fixedWindow : function(status) {
		if (status) {
			if (this.windowActive) {
				this._getScroll();
				$('lightwindow').setStyle({
					position: 'absolute',
					top: parseFloat($('lightwindow').getStyle('top'))+this.pagePosition.y+'px',
					left: parseFloat($('lightwindow').getStyle('left'))+this.pagePosition.x+'px'
				});		
			} else {
				$('lightwindow').setStyle({
					position: 'absolute'
				});						
			}
		} else {
			if (this.windowActive) {
				this._getScroll();
				$('lightwindow').setStyle({
					position: 'fixed',
					top: parseFloat($('lightwindow').getStyle('top'))-this.pagePosition.y+'px',
					left: parseFloat($('lightwindow').getStyle('left'))-this.pagePosition.x+'px'
				});		
			} else {
				if ($('lightwindow_iframe')) {
					// Ideally here we would set a 50% value for top and left, but Safari rears it ugly head again and we need to do it by pixels
					this._browserDimensions();
				}
				$('lightwindow').setStyle({
					position: 'fixed',
					top: (parseFloat(this._getParameter('lightwindow_top')) ? parseFloat(this._getParameter('lightwindow_top'))+'px' : this.dimensions.viewport.height/2+'px'),
					left: (parseFloat(this._getParameter('lightwindow_left')) ? parseFloat(this._getParameter('lightwindow_left'))+'px' : this.dimensions.viewport.width/2+'px')
				});
			}
		}
	},
	//
	//	Prepare the window for IE.
	//
	_prepareIE : function(setup) {
		if (Prototype.Browser.IE) {
			var height, overflowX, overflowY;
			if (setup) { 
				var height = '100%';
			} else {
				var height = 'auto';
			}
			var body = document.getElementsByTagName('body')[0];
			var html = document.getElementsByTagName('html')[0];
			html.style.height = body.style.height = height;
		}
	},
	_stopScrolling : function(e) {
		if (this.animating) {
			if (e.preventDefault) {
				e.preventDefault();
			}
			e.returnValue = false;		
		}
	},
	//
	//	Get the scroll for the page.
	//
	_getScroll : function(){
      	if(typeof(window.pageYOffset) == 'number') {
        	this.pagePosition.x = window.pageXOffset;
        	this.pagePosition.y = window.pageYOffset;
      	} else if(document.body && (document.body.scrollLeft || document.body.scrollTop)) {
	       	this.pagePosition.x = document.body.scrollLeft;
        	this.pagePosition.y = document.body.scrollTop;
		} else if(document.documentElement) {
        	this.pagePosition.x = document.documentElement.scrollLeft;
        	this.pagePosition.y = document.documentElement.scrollTop;
      	}
	},
	//
	//	Reset the scroll.
	//
	_setScroll : function(x, y) {
		document.documentElement.scrollLeft = x; 
		document.documentElement.scrollTop = y; 
	},
	//
	//	Hide Selects from the page because of IE.
	//     We could use iframe shims instead here but why add all the extra markup for one browser when this is much easier and cleaner
	//
	_toggleTroubleElements : function(visibility, content){
		
		if (content) {
			var selects = $('lightwindow_contents').getElementsByTagName('select');
		} else {
			var selects = document.getElementsByTagName('select');
		}
		
		for(var i = 0; i < selects.length; i++) {
			selects[i].style.visibility = visibility;
		}
		
		if (!content) {
			if (this.options.hideFlash){
				var objects = document.getElementsByTagName('object');
				for (i = 0; i != objects.length; i++) {
					objects[i].style.visibility = visibility;
				}
				var embeds = document.getElementsByTagName('embed');
				for (i = 0; i != embeds.length; i++) {
					embeds[i].style.visibility = visibility;
				}
			}
			var iframes = document.getElementsByTagName('iframe');
			for (i = 0; i != iframes.length; i++) {
				iframes[i].style.visibility = visibility;
			}
		}
	},
	// 
	//  Get the actual page size
	//
	_getPageDimensions : function() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = document.body.scrollWidth;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ 
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { 
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}

		var windowWidth, windowHeight;
		if (self.innerHeight) {	
			windowWidth = self.innerWidth;
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { 
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { 
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	

		if(yScroll < windowHeight){
			this.pageDimensions.height = windowHeight;
		} else { 
			this.pageDimensions.height = yScroll;
		}

		if(xScroll < windowWidth){	
			this.pageDimensions.width = windowWidth;
		} else {
			this.pageDimensions.width = xScroll;
		}
	},
	//
	//	Display the lightWindow.
	//
	_displayLightWindow : function(display, visibility) {
		$('lightwindow_overlay').style.display = $('lightwindow').style.display = $('lightwindow_container').style.display = display;	
		$('lightwindow_overlay').style.visibility = $('lightwindow').style.visibility = $('lightwindow_container').style.visibility = visibility;
	},
	//
	//	Setup Dimensions of lightwindow.

	//
	_setupDimensions : function() {

		var originalHeight, originalWidth;
		switch (this.windowType) {
			case 'page' :
				originalHeight = this.options.dimensions.page.height;
				originalWidth = this.options.dimensions.page.width;
				break;

			case 'image' :
				originalHeight = this.options.dimensions.image.height;
				originalWidth = this.options.dimensions.image.width;
				break;
				
			case 'media' :
				originalHeight = this.options.dimensions.media.height;
				originalWidth = this.options.dimensions.media.width;
				break;
			
			case 'external' : 
				originalHeight = this.options.dimensions.external.height;
				originalWidth = this.options.dimensions.external.width;
				break;
				
			case 'inline' :
				originalHeight = this.options.dimensions.inline.height;
				originalWidth = this.options.dimensions.inline.width;
				break;
				
			default :
				originalHeight = this.options.dimensions.page.height;
				originalWidth = this.options.dimensions.page.width;
				break;
				
		}

		var offsetHeight = this._getParameter('lightwindow_top') ? parseFloat(this._getParameter('lightwindow_top'))+this.pagePosition.y : this.dimensions.viewport.height/2+this.pagePosition.y;
		var offsetWidth = this._getParameter('lightwindow_left') ? parseFloat(this._getParameter('lightwindow_left'))+this.pagePosition.x : this.dimensions.viewport.width/2+this.pagePosition.x;
		
		// So if a theme has say shadowed edges, they should be consistant and take care of in the contentOffset
		$('lightwindow').setStyle({
			top: offsetHeight+'px',
			left: offsetWidth+'px'
		});
		
		$('lightwindow_container').setStyle({
			height: originalHeight+'px',
			width: originalWidth+'px',
			left: -(originalWidth/2)+'px',
			top: -(originalHeight/2)+'px'
		});

		$('lightwindow_contents').setStyle({
			height: originalHeight+'px',
			width: originalWidth+'px'
		});
	},
	//
	//	Get the type of file.
	//
	_fileType : function(url) {
		var image = new RegExp("[^\.]\.("+this.options.fileTypes.image.join('|')+")\s*$", "i");
		if (image.test(url)) return 'image';
		if (url.indexOf('#') > -1 && (document.domain == this._getDomain(url))) return 'inline';		
		if (url.indexOf('?') > -1) url = url.substring(0, url.indexOf('?'));
		var type = 'unknown';
		var page = new RegExp("[^\.]\.("+this.options.fileTypes.page.join('|')+")\s*$", "i");
		var media = new RegExp("[^\.]\.("+this.options.fileTypes.media.join('|')+")\s*$", "i");
		if (document.domain != this._getDomain(url)) type = 'external';
	  	if (media.test(url)) type = 'media';
		if (type == 'external' || type == 'media') return type;
	  	if (page.test(url) || url.substr((url.length-1), url.length) == '/') type = 'page';
		return type;
	},
	//
	//  Get file Extension
	//
	_fileExtension : function(url) {
		if (url.indexOf('?') > -1) {
			url = url.substring(0, url.indexOf('?'));
		}
		var extenstion = '';
		for (var x = (url.length-1); x > -1; x--) {
			if (url.charAt(x) == '.') {
				return extenstion;
			}
			extenstion = url.charAt(x)+extenstion;
		}
	},
	//
	//	Monitor the keyboard while this lightwindow is up
	//
	_monitorKeyboard : function(status) {
		if (status) document.onkeydown = this._eventKeypress.bind(this); 
		else document.onkeydown = '';
	},
	//
	//  Perform keyboard actions
	//
	_eventKeypress : function(e) {
		if (e == null) {
			var keycode = event.keyCode;
		} else {
			var keycode = e.which;
		}
		
		switch (keycode) { 
			case 27: 
				this.deactivate(); 
				break;
			
			case 13:
				return;
				
			default:
				break;
		}
	
		// Gotta stop those quick fingers
		if (this.animating) {
			return false;
		}
		
		switch (String.fromCharCode(keycode).toLowerCase()) {
			case 'p':
				if (this.navigationObservers.previous) {
					this.navigateWindow('previous');
				}
				break;
				
			case 'n':
				if (this.navigationObservers.next) {
					this.navigateWindow('next');
				}
				break;
				
			default:
				break;
		}
	},
	//
	//	Get Gallery Information
	//
	_getGalleryInfo : function(rel) {
		if (!rel) return false;
		if (rel.indexOf('[') > -1) {
			return new Array(escape(rel.substring(0, rel.indexOf('['))), escape(rel.substring(rel.indexOf('[')+1, rel.indexOf(']'))));
		} else {
			return false;
		}
	},
	//
	//	Get the domain from a string.
	//
	_getDomain : function(url) {    
        var leadSlashes = url.indexOf('//');
        var domainStart = leadSlashes+2;
        var withoutResource = url.substring(domainStart, url.length);
        var nextSlash = withoutResource.indexOf('/');
        var domain = withoutResource.substring(0, nextSlash);
		if (domain.indexOf(':') > -1){
			var portColon = domain.indexOf(':');
			domain = domain.substring(0, portColon);
       	}
		return domain;
    },
	//
	//	Get the value from the params attribute string.
	//
	_getParameter : function(parameter, parameters) {
		if (!this.element) return false;
		if (parameter == 'lightwindow_top' && this.element.top) {
			return unescape(this.element.top);
		} else if (parameter == 'lightwindow_left' && this.element.left) {
			return unescape(this.element.left);
		} else if (parameter == 'lightwindow_type' && this.element.type) {
			return unescape(this.element.type);
		} else if (parameter == 'lightwindow_show_images' && this.element.showImages) {
			return unescape(this.element.showImages);
		} else if (parameter == 'lightwindow_height' && this.element.height) {
			return unescape(this.element.height);
		} else if (parameter == 'lightwindow_width' && this.element.width) {
			return unescape(this.element.width);
		} else if (parameter == 'lightwindow_loading_animation' && this.element.loadingAnimation) {
			return unescape(this.element.loadingAnimation);
		} else if (parameter == 'lightwindow_iframe_embed' && this.element.iframeEmbed) {
			return unescape(this.element.iframeEmbed);
		} else if (parameter == 'lightwindow_form' && this.element.form) {
			return unescape(this.element.form);
		} else {
			if (!parameters) {
				if (this.element.params) parameters = this.element.params;
				else return;
			}
			var value;
			var parameterArray = parameters.split(',');
			var compareString = parameter+'=';
			var compareLength = compareString.length;
			for (var i = 0; i < parameterArray.length; i++) {
				if (parameterArray[i].substr(0, compareLength) == compareString) {
					var currentParameter = parameterArray[i].split('=');
					value = currentParameter[1];
					break;
				}
			}
			if (!value) return false;
			else return unescape(value);
		}
	},
	//
	//  Get the Browser Viewport Dimensions
	//
	_browserDimensions : function() {
		if (Prototype.Browser.IE) {
            this.dimensions.viewport.height = document.documentElement.clientHeight;
            this.dimensions.viewport.width = document.documentElement.clientWidth;   
        } else {
            this.dimensions.viewport.height = window.innerHeight;
            this.dimensions.viewport.width = document.width || document.body.offsetWidth;
        }
	},
	//
	//  Get the scrollbar offset, I don't like this method but there is really no other way I can find.
	//
	_getScrollerWidth : function() {
	    var scrollDiv = Element.extend(document.createElement('div'));
		scrollDiv.setAttribute('id', 'lightwindow_scroll_div');
		scrollDiv.setStyle({
			position: 'absolute',
			top: '-10000px',
			left: '-10000px',
			width: '100px',
			height: '100px',
			overflow: 'hidden'
		});



	    var contentDiv = Element.extend(document.createElement('div'));
		contentDiv.setAttribute('id', 'lightwindow_content_scroll_div');
		contentDiv.setStyle({
			width: '100%',
			height: '200px'
		});

	    scrollDiv.appendChild(contentDiv);

		var body = document.getElementsByTagName('body')[0];
		body.appendChild(scrollDiv);

	    var noScroll = $('lightwindow_content_scroll_div').offsetWidth;
	    scrollDiv.style.overflow = 'auto';
    	var withScroll = $('lightwindow_content_scroll_div').offsetWidth;

	   	Element.remove($('lightwindow_scroll_div'));

	    this.scrollbarOffset = noScroll-withScroll;
	},
	

	//
	//  Add a param to an object dynamically created
	//
	_addParamToObject : function(name, value, object, id) {
		var param = document.createElement('param');
		param.setAttribute('value', value);
		param.setAttribute('name', name);
		if (id) {
			param.setAttribute('id', id);
		}
		object.appendChild(param);
		return object;
	},
	//
	//  Get the outer HTML of an object CROSS BROWSER
	//
	_outerHTML : function(object) {
 		if (Prototype.Browser.IE) {
			return object.outerHTML;
		} else {
			var clone = object.cloneNode(true);
			var cloneDiv = document.createElement('div');
			cloneDiv.appendChild(clone);
			return cloneDiv.innerHTML;
		}
	},
	//
	//  Convert an object to markup
	//
	_convertToMarkup : function(object, closeTag) {
		var markup = this._outerHTML(object).replace('</'+closeTag+'>', '');
		if (Prototype.Browser.IE) {
			for (var i = 0; i < object.childNodes.length; i++){
				markup += this._outerHTML(object.childNodes[i]);
			}
			markup += '</'+closeTag+'>';
		}
		return markup;
	},
	//
	//  Depending what type of browser it is we have to append the object differently... DAMN YOU IE!!
	//
	_appendObject : function(object, closeTag, appendTo) {
		if (Prototype.Browser.IE) {
			appendTo.innerHTML += this._convertToMarkup(object, closeTag);
			
			// Fix the Eolas activate thing but only for specified media, for example doing this to a quicktime film breaks it.
			if (this.options.EOLASFix.indexOf(this._fileType(this.element.href)) > -1) {
				var objectElements = document.getElementsByTagName('object');
				for (var i = 0; i < objectElements.length; i++) {
					if (objectElements[i].getAttribute("data")) objectElements[i].removeAttribute('data');
					objectElements[i].outerHTML = objectElements[i].outerHTML;
					objectElements[i].style.visibility = "visible";
				}
			}
		} else {
			appendTo.appendChild(object);	
		}	
	},
	//
	//  Add in iframe
	//
	_appendIframe : function(scroll) {
		var iframe = document.createElement('iframe');
		iframe.setAttribute('id', 'lightwindow_iframe');
		iframe.setAttribute('name', 'lightwindow_iframe');
		iframe.setAttribute('src', 'about:blank');
		iframe.setAttribute('height', '100%');
		iframe.setAttribute('width', '100%');
		iframe.setAttribute('frameborder', '0');
		iframe.setAttribute('marginwidth', '0');
		iframe.setAttribute('marginheight', '0');
		iframe.setAttribute('scrolling', scroll);	
		
		this._appendObject(iframe, 'iframe', $('lightwindow_contents'));
	},
	//
	//  Write Content to the iframe using the skin
	//
	_writeToIframe : function(content) {
		var template = this.options.skin.iframe;
		template = template.replace('{body_replace}', content); 
		if ($('lightwindow_iframe').contentWindow){
			$('lightwindow_iframe').contentWindow.document.open();
			$('lightwindow_iframe').contentWindow.document.write(template);
			$('lightwindow_iframe').contentWindow.document.close();
		} else {
			$('lightwindow_iframe').contentDocument.open();
			$('lightwindow_iframe').contentDocument.write(template);
			$('lightwindow_iframe').contentDocument.close();
		}
	},
	//
	//  Load the window Information
	//  
	_loadWindow : function() {
		switch (this.windowType) {
			case 'image' :

				var current = 0;
				var images = [];
				this.checkImage = [];
				this.resizeTo.height = this.resizeTo.width = 0;
				this.imageCount = this._getParameter('lightwindow_show_images') ? parseInt(this._getParameter('lightwindow_show_images')) : 1;

				// If there is a gallery get it
				if (gallery = this._getGalleryInfo(this.element.rel)) {	
					for (current = 0; current < this.galleries[gallery[0]][gallery[1]].length; current++) {
						if (this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href) > -1) {
							break;
						}
					}
					if (this.galleries[gallery[0]][gallery[1]][current-this.imageCount]) {
						this.navigationObservers.previous = this.galleries[gallery[0]][gallery[1]][current-this.imageCount];
					} else {
						this.navigationObservers.previous = false;
					}
					if (this.galleries[gallery[0]][gallery[1]][current+this.imageCount]) {
						this.navigationObservers.next = this.galleries[gallery[0]][gallery[1]][current+this.imageCount];
					} else {
						this.navigationObservers.next = false;
					}
					
					this.activeGallery = true;
				} else {
					this.navigationObservers.previous = false;
					this.navigationObservers.next = false;					

					this.activeGallery = false;
				}
				
				for (var i = current; i < (current+this.imageCount); i++) {
		
					if (gallery && this.galleries[gallery[0]][gallery[1]][i]) {
						this.contentToFetch = this.galleries[gallery[0]][gallery[1]][i].href;
						
						this.galleryLocation = {current: (i+1)/this.imageCount, total: (this.galleries[gallery[0]][gallery[1]].length)/this.imageCount};
											
						if (!this.galleries[gallery[0]][gallery[1]][i+this.imageCount]) {
							$('lightwindow_next').setStyle({
								display: 'none'
							});
						} else {
							$('lightwindow_next').setStyle({
								display: 'block'
							});
							$('lightwindow_next_title').innerHTML = this.galleries[gallery[0]][gallery[1]][i+this.imageCount].title;
						}
						
						if (!this.galleries[gallery[0]][gallery[1]][i-this.imageCount]) {
							$('lightwindow_previous').setStyle({
								display: 'none'
							});
						} else {
							$('lightwindow_previous').setStyle({
								display: 'block'
							});
							$('lightwindow_previous_title').innerHTML = this.galleries[gallery[0]][gallery[1]][i-this.imageCount].title;
						}
					}

					images[i] = document.createElement('img');
					images[i].setAttribute('id', 'lightwindow_image_'+i);
					images[i].setAttribute('border', '0');
					images[i].setAttribute('src', this.contentToFetch);
					$('lightwindow_contents').appendChild(images[i]);

					// We have to do this instead of .onload 
					this.checkImage[i] = new PeriodicalExecuter(function(i) {
//						if (!(typeof $('lightwindow_image_'+i).naturalWidth != "undefined" && $('lightwindow_image_'+i).naturalWidth == 0)) {
                        // HACK:
                        if ($('lightwindow_image_'+i).complete && !(typeof $('lightwindow_image_'+i).naturalWidth != "undefined" && $('lightwindow_image_'+i).naturalWidth == 0)) {
	
							this.checkImage[i].stop();
	
							var imageHeight = $('lightwindow_image_'+i).getHeight();
							if (imageHeight > this.resizeTo.height) {
								this.resizeTo.height = imageHeight;
							}
							this.resizeTo.width += $('lightwindow_image_'+i).getWidth();
							this.imageCount--;
	
							$('lightwindow_image_'+i).setStyle({
								height: '100%', width: '100%'
							});
	
						 	if (this.imageCount == 0) {
								this._processWindow();
						 	}
						}
					
					}.bind(this, i), 1);			
				}


			break;
		
		case 'media' :			
		
			var current = 0;
			this.resizeTo.height = this.resizeTo.width = 0;

			// If there is a gallery get it
			if (gallery = this._getGalleryInfo(this.element.rel)) {	
				for (current = 0; current < this.galleries[gallery[0]][gallery[1]].length; current++) {
					if (this.contentToFetch.indexOf(this.galleries[gallery[0]][gallery[1]][current].href) > -1) {
						break;
					}
				}
				
				if (this.galleries[gallery[0]][gallery[1]][current-1]) {
					this.navigationObservers.previous = this.galleries[gallery[0]][gallery[1]][current-1];
				} else {
					this.navigationObservers.previous = false;
				}
				if (this.galleries[gallery[0]][gallery[1]][current+1]) {
					this.navigationObservers.next = this.galleries[gallery[0]][gallery[1]][current+1];
				} else {
					this.navigationObservers.next = false;
				}
		
				this.activeGallery = true;
			} else {
				this.navigationObservers.previous = false;
				this.navigationObservers.next = false;
				
				this.activeGallery = false;
			}
		

			if (gallery && this.galleries[gallery[0]][gallery[1]][current]) {
				this.contentToFetch = this.galleries[gallery[0]][gallery[1]][current].href;

				this.galleryLocation = {current: current+1, total: this.galleries[gallery[0]][gallery[1]].length};
				
				if (!this.galleries[gallery[0]][gallery[1]][current+1]) {
					$('lightwindow_next').setStyle({
						display: 'none'
					});
				} else {
					$('lightwindow_next').setStyle({
						display: 'block'
					});
					$('lightwindow_next_title').innerHTML = this.galleries[gallery[0]][gallery[1]][current+1].title;
				}
				
				if (!this.galleries[gallery[0]][gallery[1]][current-1]) {
					$('lightwindow_previous').setStyle({
						display: 'none'
					});
				} else {
					$('lightwindow_previous').setStyle({
						display: 'block'
					});
					$('lightwindow_previous_title').innerHTML = this.galleries[gallery[0]][gallery[1]][current-1].title;
				}
			}
			
			if (this._getParameter('lightwindow_iframe_embed')) {
				this.resizeTo.height = this.dimensions.viewport.height;
				this.resizeTo.width = this.dimensions.viewport.width;	
			} else {
				this.resizeTo.height = this._getParameter('lightwindow_height');
				this.resizeTo.width = this._getParameter('lightwindow_width');				
			}
			
			this._processWindow();
			
			break;

		case 'external' :		

			this._appendIframe('auto');

			this.resizeTo.height = this.dimensions.viewport.height;
			this.resizeTo.width = this.dimensions.viewport.width;
						
			this._processWindow();

			break;
				
		case 'page' :	
			
			var newAJAX = new Ajax.Request(
				this.contentToFetch, {
					method: 'get', 
					parameters: '', 
					onComplete: function(response) {
						$('lightwindow_contents').innerHTML += response.responseText;
						this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
						this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
						this._processWindow();
					}.bind(this)
				}
			);
			
			break;
			
		case 'inline' : 
		
			var content = this.contentToFetch;
			if (content.indexOf('?') > -1) {
				content = content.substring(0, content.indexOf('?'));
			}
			content = content.substring(content.indexOf('#')+1);
			
			new Insertion.Top($('lightwindow_contents'), $(content).innerHTML);
			
			this.resizeTo.height = $('lightwindow_contents').scrollHeight+(this.options.contentOffset.height);
			this.resizeTo.width = $('lightwindow_contents').scrollWidth+(this.options.contentOffset.width);
			
			this._toggleTroubleElements('hidden', true); 			
			this._processWindow();
			
			break;
			
		default : 
			throw("Page Type could not be determined, please amend this lightwindow URL "+this.contentToFetch);
			break;
		}
	},
	//
	//  Resize the Window to fit the viewport if necessary
	//
	_resizeWindowToFit : function() {
		if (this.resizeTo.height+this.dimensions.cruft.height > this.dimensions.viewport.height) {
			var heightRatio = this.resizeTo.height/this.resizeTo.width;
			this.resizeTo.height = this.dimensions.viewport.height-this.dimensions.cruft.height-(2*this.options.viewportPadding);
			// We only care about ratio's with this window type			
			if (this.windowType == 'image' || (this.windowType == 'media' && !this._getParameter('lightwindow_iframe_embed'))) {
				this.resizeTo.width = this.resizeTo.height/heightRatio;
				$('lightwindow_data_slide_inner').setStyle({
					width: this.resizeTo.width+'px'
				});			
			}
		} 
		if (this.resizeTo.width+this.dimensions.cruft.width > this.dimensions.viewport.width) {
			var widthRatio = this.resizeTo.width/this.resizeTo.height;
			this.resizeTo.width = this.dimensions.viewport.width-2*this.dimensions.cruft.width-(2*this.options.viewportPadding);
			// We only care about ratio's with this window type
			if (this.windowType == 'image' || (this.windowType == 'media' && !this._getParameter('lightwindow_iframe_embed'))) {
				this.resizeTo.height = this.resizeTo.width/widthRatio;
				$('lightwindow_data_slide_inner').setStyle({
					height: this.resizeTo.height+'px'
				});
			}
		}
			
	},
	//
	//  Set the Window to a preset size
	//
	_presetWindowSize : function() {
		if (this._getParameter('lightwindow_height')) {
			this.resizeTo.height = parseFloat(this._getParameter('lightwindow_height'));
		}
		if (this._getParameter('lightwindow_width')) {
			this.resizeTo.width = parseFloat(this._getParameter('lightwindow_width'));
		}
	},
	//
	//  Process the Window
	//
	_processWindow : function() {
		// Clean out our effects
		this.dimensions.dataEffects = [];

		// Set up the data-slide if we have caption information
		if (this.element.caption || this.element.author || (this.activeGallery && this.options.showGalleryCount)) {
			if (this.element.caption) {
				$('lightwindow_data_caption').innerHTML = this.element.caption;
				$('lightwindow_data_caption').setStyle({
					display: 'block'
				});
			} else {
				$('lightwindow_data_caption').setStyle({
					display: 'none'
				});				
			}
			if (this.element.author) {
				$('lightwindow_data_author').innerHTML = this.element.author;
				$('lightwindow_data_author_container').setStyle({
					display: 'block'
				});
			} else {
				$('lightwindow_data_author_container').setStyle({
					display: 'none'
				});				
			}
			if (this.activeGallery && this.options.showGalleryCount) {
				$('lightwindow_data_gallery_current').innerHTML = this.galleryLocation.current;
				$('lightwindow_data_gallery_total').innerHTML = this.galleryLocation.total;
				$('lightwindow_data_gallery_container').setStyle({
					display: 'block'
				});
			} else {
				$('lightwindow_data_gallery_container').setStyle({
					display: 'none'
				});				
			}

			$('lightwindow_data_slide_inner').setStyle({
				width: this.resizeTo.width+'px',
				height: 'auto',
				visibility: 'visible',
				display: 'block'
			});
			$('lightwindow_data_slide').setStyle({
				height: $('lightwindow_data_slide').getHeight()+'px',
				width: '1px',
				overflow: 'hidden',
				display: 'block'
			});
		} else {
			$('lightwindow_data_slide').setStyle({
				display: 'none',
				width: 'auto'
			});
			$('lightwindow_data_slide_inner').setStyle({
				display: 'none',
				visibility: 'hidden',
				width: this.resizeTo.width+'px',
				height: '0px'
			});
		}
				
		if (this.element.title != 'null') {		
			$('lightwindow_title_bar_title').innerHTML = this.element.title;
		} else {
			$('lightwindow_title_bar_title').innerHTML = '';
		}
		
		var originalContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
		// Position the window
    	$('lightwindow_container').setStyle({
			height: 'auto',
			// We need to set the width to a px not auto as opera has problems with it
			width: $('lightwindow_container').getWidth()+this.options.contentOffset.width-(this.windowActive ? this.options.contentOffset.width : 0)+'px'
		});
		var newContainerDimensions = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
 		
		// We need to record the container dimension changes
		this.containerChange = {height: originalContainerDimensions.height-newContainerDimensions.height, width: originalContainerDimensions.width-newContainerDimensions.width};

		// Get out general dimensions
		this.dimensions.container = {height: $('lightwindow_container').getHeight(), width: $('lightwindow_container').getWidth()};
		this.dimensions.cruft = {height: this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.options.contentOffset.height, width: this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.options.contentOffset.width};
		
		// Set Sizes if we need too
		this._presetWindowSize();
		this._resizeWindowToFit(); // Even if the window is preset we still don't want it to go outside of the viewport

		if (!this.windowActive) {
			// Position the window
		   	$('lightwindow_container').setStyle({
				left: -(this.dimensions.container.width/2)+'px',
				top: -(this.dimensions.container.height/2)+'px'
			});
		}
	   	$('lightwindow_container').setStyle({
			height: this.dimensions.container.height+'px',
			width: this.dimensions.container.width+'px'
		});
		
		// We are ready, lets show this puppy off!
		this._displayLightWindow('block', 'visible');
		this._animateLightWindow();
	},
	//
	//  Fire off our animation handler
	//
	_animateLightWindow : function() {
		if (this.options.animationHandler) {
			this.options.animationHandler().bind(this);
		} else {
			this._defaultAnimationHandler();
		}
	},
	//
	//  Fire off our transition handler
	//
	_handleNavigation : function(display) {
		if (this.options.navigationHandler) {
			this.options.navigationHandler().bind(this, display);
		} else {
			this._defaultDisplayNavigation(display);
		}
	},
	//
	//  Fire off our transition handler
	//
	_handleTransition : function() {
		if (this.options.transitionHandler) {
			this.options.transitionHandler().bind(this);
		} else {
			this._defaultTransitionHandler();
		}
	},
	//
	//  Handle the finish of the window animation
	// 
	_handleFinalWindowAnimation : function(delay) {
		if (this.options.finalAnimationHandler) {
			this.options.finalAnimationHandler().bind(this, delay);
		} else {
			this._defaultfinalWindowAnimationHandler(delay);
		}		
	},
	//
	//  Handle the gallery Animation
	// 
	_handleGalleryAnimation : function(list) {
		if (this.options.galleryAnimationHandler) {
			this.options.galleryAnimationHandler().bind(this, list);
		} else {
			this._defaultGalleryAnimationHandler(list);
		}		
	},
	//
	//  Display the navigation 
	//
	_defaultDisplayNavigation : function(display) {
		if (display) {
			$('lightwindow_navigation').setStyle({
				display: 'block',
				height: $('lightwindow_contents').getHeight()+'px',
				width: '100%',
				marginTop: this.options.dimensions.titleHeight+'px'
			});			
		} else {
			$('lightwindow_navigation').setStyle({
				display: 'none',
				height: 'auto',
				width: 'auto'
			});			
		}
	},
	//
	//  This is the default animation handler for LightWindow
	//
	_defaultAnimationHandler : function() {	
		// Now that we have figures out the cruft lets make the caption go away and add its effects
		if (this.element.caption || this.element.author || (this.activeGallery && this.options.showGalleryCount)) {
			$('lightwindow_data_slide').setStyle({
				display: 'none',
				width: 'auto'
			});
			this.dimensions.dataEffects.push(
				new Effect.SlideDown('lightwindow_data_slide', {sync: true}),
				new Effect.Appear('lightwindow_data_slide', {sync: true, from: 0.0, to: 1.0})
			);
		}

		// Set up the Title if we have one
		$('lightwindow_title_bar_inner').setStyle({
			height: '0px',
			marginTop: this.options.dimensions.titleHeight+'px'
		});
		
		// We always want the title bar as well
		this.dimensions.dataEffects.push(
			new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: this.options.dimensions.titleHeight+'px', marginTop: '0px'}}),
		 	new Effect.Appear('lightwindow_title_bar_inner', {sync: true, from: 0.0, to: 1.0})
		);		
		
		if (!this.options.hideGalleryTab) {
			this._handleGalleryAnimation(false);
			if ($('lightwindow_galleries_tab_container').getHeight() == 0) {
				this.dimensions.dataEffects.push(
					new Effect.Morph('lightwindow_galleries_tab_container', {sync: true, style: {height: '20px', marginTop: '0px'}})
				);
				$('lightwindow_galleries').setStyle({
					width: '0px'
				});
			}
		}
		
		var resized = false;
		var ratio = this.dimensions.container.width-$('lightwindow_contents').getWidth()+this.resizeTo.width+this.options.contentOffset.width;
		if (ratio != $('lightwindow_container').getWidth()) {
			new Effect.Parallel([
					new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.width/$('lightwindow_contents').getWidth()), {scaleFrom: 100*($('lightwindow_contents').getWidth()/($('lightwindow_contents').getWidth()+(this.options.contentOffset.width))), sync: true,  scaleY: false, scaleContent: false}),
					new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.width)), {sync: true, scaleY: false, scaleFromCenter: true, scaleContent: false})
				], {
					duration: this.duration, 
					delay: 0.25,
					queue: {position: 'end', scope: 'lightwindowAnimation'}
				}
			);		
		}
		
		ratio = this.dimensions.container.height-$('lightwindow_contents').getHeight()+this.resizeTo.height+this.options.contentOffset.height;
		if (ratio != $('lightwindow_container').getHeight()) {
			new Effect.Parallel([
					new Effect.Scale('lightwindow_contents', 100*(this.resizeTo.height/$('lightwindow_contents').getHeight()), {scaleFrom: 100*($('lightwindow_contents').getHeight()/($('lightwindow_contents').getHeight()+(this.options.contentOffset.height))), sync: true, scaleX: false, scaleContent: false}),
					new Effect.Scale('lightwindow_container', 100*(ratio/(this.dimensions.container.height)), {sync: true, scaleX: false, scaleFromCenter: true, scaleContent: false})
				], {
					duration: this.duration, 
					afterFinish: function() {				
						if (this.dimensions.dataEffects.length > 0) {
							if (!this.options.hideGalleryTab) {
								$('lightwindow_galleries').setStyle({
									width: this.resizeTo.width+'px'
								});
							}
							new Effect.Parallel(this.dimensions.dataEffects, {
									duration: this.duration,
									afterFinish: function() {
										this._finishWindow();
									}.bind(this),
									queue: {position: 'end', scope: 'lightwindowAnimation'} 
								}
							);
						}
					}.bind(this), 
					queue: {position: 'end', scope: 'lightwindowAnimation'} 
				}
			);
			resized = true;
		}
		
		// We need to do our data effect since there was no resizing
		if (!resized && this.dimensions.dataEffects.length > 0) {	
			new Effect.Parallel(this.dimensions.dataEffects, {
					duration: this.duration,
					beforeStart: function() {
						if (!this.options.hideGalleryTab) {
							$('lightwindow_galleries').setStyle({
								width: this.resizeTo.width+'px'
							});
						}
						if (this.containerChange.height != 0 || this.containerChange.width != 0) {
							new Effect.MoveBy('lightwindow_container', this.containerChange.height, this.containerChange.width, {transition: Effect.Transitions.sinoidal});
						}
					}.bind(this),			
					afterFinish: function() {
						this._finishWindow();
					}.bind(this),
					queue: {position: 'end', scope: 'lightwindowAnimation'} 
				}
			);
		}			
		
	},
	//
	//  Finish up Window Animation
	//
	_defaultfinalWindowAnimationHandler : function(delay) {
		if (this.windowType == 'media' || this._getParameter('lightwindow_loading_animation')) {	
			// Because of major flickering with the overlay we just hide it in this case
			Element.hide('lightwindow_loading');
			this._handleNavigation(this.activeGallery);
			this._setStatus(false);
		} else {
			Effect.Fade('lightwindow_loading', {
				duration: 0.75,
				delay: 1.0, 
				afterFinish: function() {
					// Just in case we need some scroll goodness (this also avoids the swiss cheese effect)
					if (this.windowType != 'image' && this.windowType != 'media' && this.windowType != 'external') {
						$('lightwindow_contents').setStyle({
							overflow: 'auto'
						});
					}
					this._handleNavigation(this.activeGallery);
					this._defaultGalleryAnimationHandler();
					this._setStatus(false);
				}.bind(this),
				queue: {position: 'end', scope: 'lightwindowAnimation'}
			});
		}
	},
	//
	//  Handle the gallery Animation
	//
	_defaultGalleryAnimationHandler : function(list) {
		if (this.activeGallery) {
			$('lightwindow_galleries').setStyle({
				display: 'block',
				marginBottom: $('lightwindow_data_slide').getHeight()+this.options.contentOffset.height/2+'px'
			});
			$('lightwindow_navigation').setStyle({
				height: $('lightwindow_contents').getHeight()-20+'px'
			});
		} else {
			$('lightwindow_galleries').setStyle({
				display: 'none'
			});	
			$('lightwindow_galleries_tab_container').setStyle({
				height: '0px',
				marginTop: '20px'
			});
			$('lightwindow_galleries_list').setStyle({
				height: '0px'
			});
			return false;
		}
		
		if (list) {
			if ($('lightwindow_galleries_list').getHeight() == 0) {
				var height = $('lightwindow_contents').getHeight()*0.80;
				$('lightwindow_galleries_tab_span').className = 'down';
			} else {
				var height = 0;
				$('lightwindow_galleries_tab_span').className = 'up';
			}

			new Effect.Morph('lightwindow_galleries_list', {
				duration: this.duration,
				transition: Effect.Transitions.sinoidal,
				style: {height: height+'px'},
				beforeStart: function() {
					$('lightwindow_galleries_list').setStyle({
						overflow: 'hidden'
					});					
				},
				afterFinish: function() {
					$('lightwindow_galleries_list').setStyle({
						overflow: 'auto'
					});
				},
				queue: {position: 'end', scope: 'lightwindowAnimation'}
			});	
		}
		
		
	},
	//
	//  Default Transition Handler
	//
	_defaultTransitionHandler : function() {
		// Clean out our effects
		this.dimensions.dataEffects = [];

		// Now that we have figures out the cruft lets make the caption go away and add its effects
		if ($('lightwindow_data_slide').getStyle('display') != 'none') {
			this.dimensions.dataEffects.push(
				new Effect.SlideUp('lightwindow_data_slide', {sync: true}),
				new Effect.Fade('lightwindow_data_slide', {sync: true, from: 1.0, to: 0.0})
			);
		}
		
		if (!this.options.hideGalleryTab) {
			if ($('lightwindow_galleries').getHeight() != 0 && !this.options.hideGalleryTab) {
				this.dimensions.dataEffects.push(
					new Effect.Morph('lightwindow_galleries_tab_container', {sync: true, style: {height: '0px', marginTop: '20px'}})
				);
			}
			
			if ($('lightwindow_galleries_list').getHeight() != 0) {
				$('lightwindow_galleries_tab_span').className = 'up';
				this.dimensions.dataEffects.push(
					new Effect.Morph('lightwindow_galleries_list', {
						sync: true, 
						style: {height: '0px'},
						transition: Effect.Transitions.sinoidal,
						beforeStart: function() {
							$('lightwindow_galleries_list').setStyle({
								overflow: 'hidden'
							});					
						},
						afterFinish: function() {
							$('lightwindow_galleries_list').setStyle({
								overflow: 'auto'
							});
						}
					})
				);
			}
		}
		
		// We always want the title bar as well
		this.dimensions.dataEffects.push(
			new Effect.Morph('lightwindow_title_bar_inner', {sync: true, style: {height: '0px', marginTop: this.options.dimensions.titleHeight+'px'}}),
		 	new Effect.Fade('lightwindow_title_bar_inner', {sync: true, from: 1.0, to: 0.0})
		);

		new Effect.Parallel(this.dimensions.dataEffects, {
				duration: this.duration,
				afterFinish: function() {
					this._loadWindow();
				}.bind(this),
				queue: {position: 'end', scope: 'lightwindowAnimation'} 
			}
		);	
	},
	//
	//	Default Form handler for LightWindow
	//
	_defaultFormHandler : function(e) {
		var element = Event.element(e).parentNode;
		var parameterString = Form.serialize(this._getParameter('lightwindow_form', element.getAttribute('params')));
		if (this.options.formMethod == 'post') {
			var newAJAX = new Ajax.Request(element.href, { 
				method: 'post', 
				postBody: parameterString, 
				onComplete: this.openWindow.bind(this, element)
			});
		} else if (this.options.formMethod == 'get') {
			var newAJAX = new Ajax.Request(element.href, { 
				method: 'get', 
				parameters: parameterString, 
				onComplete: this.openWindow.bind(this, element)
			});
		}
	},
	// 
	//  Wrap everything up
	//
	_finishWindow : function() {
		if (this.windowType == 'external') {
			// We set the externals source here because it allows for a much smoother animation
			$('lightwindow_iframe').setAttribute('src', this.element.href);
			this._handleFinalWindowAnimation(1);	
		} else if (this.windowType == 'media') {

			var outerObject = document.createElement('object');
			outerObject.setAttribute('classid', this.options.classids[this._fileExtension(this.contentToFetch)]);
			outerObject.setAttribute('codebase', this.options.codebases[this._fileExtension(this.contentToFetch)]);
			outerObject.setAttribute('id', 'lightwindow_media_primary');
			outerObject.setAttribute('name', 'lightwindow_media_primary');
			outerObject.setAttribute('width', this.resizeTo.width);
			outerObject.setAttribute('height', this.resizeTo.height);
			outerObject = this._addParamToObject('movie', this.contentToFetch, outerObject);
			outerObject = this._addParamToObject('src', this.contentToFetch, outerObject);
			outerObject = this._addParamToObject('controller', 'true', outerObject);
			outerObject = this._addParamToObject('wmode', 'transparent', outerObject);
			outerObject = this._addParamToObject('cache', 'false', outerObject);
			outerObject = this._addParamToObject('quality', 'high', outerObject);

			if (!Prototype.Browser.IE) {
				var innerObject = document.createElement('object');
				innerObject.setAttribute('type', this.options.mimeTypes[this._fileExtension(this.contentToFetch)]);
				innerObject.setAttribute('data', this.contentToFetch);
				innerObject.setAttribute('id', 'lightwindow_media_secondary');
				innerObject.setAttribute('name', 'lightwindow_media_secondary');
				innerObject.setAttribute('width', this.resizeTo.width);
				innerObject.setAttribute('height', this.resizeTo.height);
				innerObject = this._addParamToObject('controller', 'true', innerObject);
				innerObject = this._addParamToObject('wmode', 'transparent', innerObject);
				innerObject = this._addParamToObject('cache', 'false', innerObject);
				innerObject = this._addParamToObject('quality', 'high', innerObject);
			
				outerObject.appendChild(innerObject);
			}	
			
			if (this._getParameter('lightwindow_iframe_embed')) {
				this._appendIframe('no');
				this._writeToIframe(this._convertToMarkup(outerObject, 'object'));
			} else {
				this._appendObject(outerObject, 'object', $('lightwindow_contents'));
			}

			this._handleFinalWindowAnimation(0);
		} else {
			this._handleFinalWindowAnimation(0);
		}

		// Initialize any actions
		this._setupActions();
	}
}

/*-----------------------------------------------------------------------------------------------*/

Event.observe(window, 'load', lightwindowInit, false);

//
//	Set up all of our links
//
var myLightWindow = null;
function lightwindowInit() {
	myLightWindow = new lightwindow();
}

