/*  Prototype JavaScript framework, version 1.6.0.3 */

var Prototype={Version:'1.6.0.3',Browser:{IE:!!(window.attachEvent&&navigator.userAgent.indexOf('Opera')===-1),Opera:navigator.userAgent.indexOf('Opera')>-1,WebKit:navigator.userAgent.indexOf('AppleWebKit/')>-1,Gecko:navigator.userAgent.indexOf('Gecko')>-1&&navigator.userAgent.indexOf('KHTML')===-1,MobileSafari:!!navigator.userAgent.match(/Apple.*Mobile.*Safari/)},BrowserFeatures:{XPath:!!document.evaluate,SelectorsAPI:!!document.querySelector,ElementExtensions:!!window.HTMLElement,SpecificElementExtensions:document.createElement('div')['__proto__']&&document.createElement('div')['__proto__']!==document.createElement('form')['__proto__']},ScriptFragment:'<script[^>]*>([\\S\\s]*?)<\/script>',JSONFilter:/^\/\*-secure-([\s\S]*)\*\/\s*$/,emptyFunction:function(){},K:function(x){return x}};if(Prototype.Browser.MobileSafari)Prototype.BrowserFeatures.SpecificElementExtensions=false;var Class={create:function(){var a=null,properties=$A(arguments);if(Object.isFunction(properties[0]))a=properties.shift();function klass(){this.initialize.apply(this,arguments)}Object.extend(klass,Class.Methods);klass.superclass=a;klass.subclasses=[];if(a){var b=function(){};b.prototype=a.prototype;klass.prototype=new b;a.subclasses.push(klass)}for(var i=0;i<properties.length;i++)klass.addMethods(properties[i]);if(!klass.prototype.initialize)klass.prototype.initialize=Prototype.emptyFunction;klass.prototype.constructor=klass;return klass}};Class.Methods={addMethods:function(a){var b=this.superclass&&this.superclass.prototype;var c=Object.keys(a);if(!Object.keys({toString:true}).length)c.push("toString","valueOf");for(var i=0,length=c.length;i<length;i++){var d=c[i],value=a[d];if(b&&Object.isFunction(value)&&value.argumentNames().first()=="$super"){var e=value;value=(function(m){return function(){return b[m].apply(this,arguments)}})(d).wrap(e);value.valueOf=e.valueOf.bind(e);value.toString=e.toString.bind(e)}this.prototype[d]=value}return this}};var Abstract={};Object.extend=function(a,b){for(var c in b)a[c]=b[c];return a};Object.extend(Object,{inspect:function(a){try{if(Object.isUndefined(a))return'undefined';if(a===null)return'null';return a.inspect?a.inspect():String(a)}catch(e){if(e instanceof RangeError)return'...';throw e;}},toJSON:function(a){var b=typeof a;switch(b){case'undefined':case'function':case'unknown':return;case'boolean':return a.toString()}if(a===null)return'null';if(a.toJSON)return a.toJSON();if(Object.isElement(a))return;var c=[];for(var d in a){var e=Object.toJSON(a[d]);if(!Object.isUndefined(e))c.push(d.toJSON()+': '+e)}return'{'+c.join(', ')+'}'},toQueryString:function(a){return $H(a).toQueryString()},toHTML:function(a){return a&&a.toHTML?a.toHTML():String.interpret(a)},keys:function(a){var b=[];for(var c in a)b.push(c);return b},values:function(a){var b=[];for(var c in a)b.push(a[c]);return b},clone:function(a){return Object.extend({},a)},isElement:function(a){return!!(a&&a.nodeType==1)},isArray:function(a){return a!=null&&typeof a=="object"&&'splice'in a&&'join'in a},isHash:function(a){return a instanceof Hash},isFunction:function(a){return typeof a=="function"},isString:function(a){return typeof a=="string"},isNumber:function(a){return typeof a=="number"},isUndefined:function(a){return typeof a=="undefined"}});Object.extend(Function.prototype,{argumentNames:function(){var a=this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1].replace(/\s+/g,'').split(',');return a.length==1&&!a[0]?[]:a},bind:function(){if(arguments.length<2&&Object.isUndefined(arguments[0]))return this;var a=this,args=$A(arguments),object=args.shift();return function(){return a.apply(object,args.concat($A(arguments)))}},bindAsEventListener:function(){var b=this,args=$A(arguments),object=args.shift();return function(a){return b.apply(object,[a||window.event].concat(args))}},curry:function(){if(!arguments.length)return this;var a=this,args=$A(arguments);return function(){return a.apply(this,args.concat($A(arguments)))}},delay:function(){var a=this,args=$A(arguments),timeout=args.shift()*1000;return window.setTimeout(function(){return a.apply(a,args)},timeout)},defer:function(){var a=[0.01].concat($A(arguments));return this.delay.apply(this,a)},wrap:function(a){var b=this;return function(){return a.apply(this,[b.bind(this)].concat($A(arguments)))}},methodize:function(){if(this._methodized)return this._methodized;var a=this;return this._methodized=function(){return a.apply(null,[this].concat($A(arguments)))}}});Date.prototype.toJSON=function(){return'"'+this.getUTCFullYear()+'-'+(this.getUTCMonth()+1).toPaddedString(2)+'-'+this.getUTCDate().toPaddedString(2)+'T'+this.getUTCHours().toPaddedString(2)+':'+this.getUTCMinutes().toPaddedString(2)+':'+this.getUTCSeconds().toPaddedString(2)+'Z"'};var Try={these:function(){var a;for(var i=0,length=arguments.length;i<length;i++){var b=arguments[i];try{a=b();break}catch(e){}}return a}};RegExp.prototype.match=RegExp.prototype.test;RegExp.escape=function(a){return String(a).replace(/([.*+?^=!:${}()|[\]\/\\])/g,'\\$1')};var PeriodicalExecuter=Class.create({initialize:function(a,b){this.callback=a;this.frequency=b;this.currentlyExecuting=false;this.registerCallback()},registerCallback:function(){this.timer=setInterval(this.onTimerEvent.bind(this),this.frequency*1000)},execute:function(){this.callback(this)},stop:function(){if(!this.timer)return;clearInterval(this.timer);this.timer=null},onTimerEvent:function(){if(!this.currentlyExecuting){try{this.currentlyExecuting=true;this.execute()}finally{this.currentlyExecuting=false}}}});Object.extend(String,{interpret:function(a){return a==null?'':String(a)},specialChar:{'\b':'\\b','\t':'\\t','\n':'\\n','\f':'\\f','\r':'\\r','\\':'\\\\'}});Object.extend(String.prototype,{gsub:function(a,b){var c='',source=this,match;b=arguments.callee.prepareReplacement(b);while(source.length>0){if(match=source.match(a)){c+=source.slice(0,match.index);c+=String.interpret(b(match));source=source.slice(match.index+match[0].length)}else{c+=source,source=''}}return c},sub:function(b,c,d){c=this.gsub.prepareReplacement(c);d=Object.isUndefined(d)?1:d;return this.gsub(b,function(a){if(--d<0)return a[0];return c(a)})},scan:function(a,b){this.gsub(a,b);return String(this)},truncate:function(a,b){a=a||30;b=Object.isUndefined(b)?'...':b;return this.length>a?this.slice(0,a-b.length)+b:String(this)},strip:function(){return this.replace(/^\s+/,'').replace(/\s+$/,'')},stripTags:function(){return this.replace(/<\/?[^>]+>/gi,'')},stripScripts:function(){return this.replace(new RegExp(Prototype.ScriptFragment,'img'),'')},extractScripts:function(){var b=new RegExp(Prototype.ScriptFragment,'img');var c=new RegExp(Prototype.ScriptFragment,'im');return(this.match(b)||[]).map(function(a){return(a.match(c)||['',''])[1]})},evalScripts:function(){return this.extractScripts().map(function(a){return eval(a)})},escapeHTML:function(){var a=arguments.callee;a.text.data=this;return a.div.innerHTML},unescapeHTML:function(){var c=new Element('div');c.innerHTML=this.stripTags();return c.childNodes[0]?(c.childNodes.length>1?$A(c.childNodes).inject('',function(a,b){return a+b.nodeValue}):c.childNodes[0].nodeValue):''},toQueryParams:function(e){var f=this.strip().match(/([^?#]*)(#.*)?$/);if(!f)return{};return f[1].split(e||'&').inject({},function(a,b){if((b=b.split('='))[0]){var c=decodeURIComponent(b.shift());var d=b.length>1?b.join('='):b[0];if(d!=undefined)d=decodeURIComponent(d);if(c in a){if(!Object.isArray(a[c]))a[c]=[a[c]];a[c].push(d)}else a[c]=d}return a})},toArray:function(){return this.split('')},succ:function(){return this.slice(0,this.length-1)+String.fromCharCode(this.charCodeAt(this.length-1)+1)},times:function(a){return a<1?'':new Array(a+1).join(this)},camelize:function(){var a=this.split('-'),len=a.length;if(len==1)return a[0];var b=this.charAt(0)=='-'?a[0].charAt(0).toUpperCase()+a[0].substring(1):a[0];for(var i=1;i<len;i++)b+=a[i].charAt(0).toUpperCase()+a[i].substring(1);return b},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(c){var d=this.gsub(/[\x00-\x1f\\]/,function(a){var b=String.specialChar[a[0]];return b?b:'\\u00'+a[0].charCodeAt().toPaddedString(2,16)});if(c)return'"'+d.replace(/"/g,'\\"')+'"';return"'"+d.replace(/'/g,'\\\'')+"'"},toJSON:function(){return this.inspect(true)},unfilterJSON:function(a){return this.sub(a||Prototype.JSONFilter,'#{1}')},isJSON:function(){var a=this;if(a.blank())return false;a=this.replace(/\\./g,'@').replace(/"[^"\\\n\r]*"/g,'');return(/^[,:{}\[\]0-9.\-+Eaeflnr-u \n\r\t]*$/).test(a)},evalJSON:function(a){var b=this.unfilterJSON();try{if(!a||b.isJSON())return eval('('+b+')')}catch(e){}throw new SyntaxError('Badly formed JSON string: '+this.inspect());},include:function(a){return this.indexOf(a)>-1},startsWith:function(a){return this.indexOf(a)===0},endsWith:function(a){var d=this.length-a.length;return d>=0&&this.lastIndexOf(a)===d},empty:function(){return this==''},blank:function(){return/^\s*$/.test(this)},interpolate:function(a,b){return new Template(this,b).evaluate(a)}});if(Prototype.Browser.WebKit||Prototype.Browser.IE)Object.extend(String.prototype,{escapeHTML:function(){return this.replace(/&/g,'&amp;').replace(/</g,'&lt;').replace(/>/g,'&gt;')},unescapeHTML:function(){return this.stripTags().replace(/&amp;/g,'&').replace(/&lt;/g,'<').replace(/&gt;/g,'>')}});String.prototype.gsub.prepareReplacement=function(b){if(Object.isFunction(b))return b;var c=new Template(b);return function(a){return c.evaluate(a)}};String.prototype.parseQuery=String.prototype.toQueryParams;Object.extend(String.prototype.escapeHTML,{div:document.createElement('div'),text:document.createTextNode('')});String.prototype.escapeHTML.div.appendChild(String.prototype.escapeHTML.text);var Template=Class.create({initialize:function(a,b){this.template=a.toString();this.pattern=b||Template.Pattern},evaluate:function(f){if(Object.isFunction(f.toTemplateReplacements))f=f.toTemplateReplacements();return this.template.gsub(this.pattern,function(a){if(f==null)return'';var b=a[1]||'';if(b=='\\')return a[2];var c=f,expr=a[3];var d=/^([^.[]+|\[((?:.*?[^\\])?)\])(\.|\[|$)/;a=d.exec(expr);if(a==null)return b;while(a!=null){var e=a[1].startsWith('[')?a[2].gsub('\\\\]',']'):a[1];c=c[e];if(null==c||''==a[3])break;expr=expr.substring('['==a[3]?a[1].length:a[0].length);a=d.exec(expr)}return b+String.interpret(c)})}});Template.Pattern=/(^|.|\r|\n)(#\{(.*?)\})/;var $break={};var Enumerable={each:function(b,c){var d=0;try{this._each(function(a){b.call(c,a,d++)})}catch(e){if(e!=$break)throw e;}return this},eachSlice:function(a,b,c){var d=-a,slices=[],array=this.toArray();if(a<1)return array;while((d+=a)<array.length)slices.push(array.slice(d,d+a));return slices.collect(b,c)},all:function(c,d){c=c||Prototype.K;var e=true;this.each(function(a,b){e=e&&!!c.call(d,a,b);if(!e)throw $break;});return e},any:function(c,d){c=c||Prototype.K;var e=false;this.each(function(a,b){if(e=!!c.call(d,a,b))throw $break;});return e},collect:function(c,d){c=c||Prototype.K;var e=[];this.each(function(a,b){e.push(c.call(d,a,b))});return e},detect:function(c,d){var e;this.each(function(a,b){if(c.call(d,a,b)){e=a;throw $break;}});return e},findAll:function(c,d){var e=[];this.each(function(a,b){if(c.call(d,a,b))e.push(a)});return e},grep:function(c,d,e){d=d||Prototype.K;var f=[];if(Object.isString(c))c=new RegExp(c);this.each(function(a,b){if(c.match(a))f.push(d.call(e,a,b))});return f},include:function(b){if(Object.isFunction(this.indexOf))if(this.indexOf(b)!=-1)return true;var c=false;this.each(function(a){if(a==b){c=true;throw $break;}});return c},inGroupsOf:function(b,c){c=Object.isUndefined(c)?null:c;return this.eachSlice(b,function(a){while(a.length<b)a.push(c);return a})},inject:function(c,d,e){this.each(function(a,b){c=d.call(e,c,a,b)});return c},invoke:function(b){var c=$A(arguments).slice(1);return this.map(function(a){return a[b].apply(a,c)})},max:function(c,d){c=c||Prototype.K;var e;this.each(function(a,b){a=c.call(d,a,b);if(e==null||a>=e)e=a});return e},min:function(c,d){c=c||Prototype.K;var e;this.each(function(a,b){a=c.call(d,a,b);if(e==null||a<e)e=a});return e},partition:function(c,d){c=c||Prototype.K;var e=[],falses=[];this.each(function(a,b){(c.call(d,a,b)?e:falses).push(a)});return[e,falses]},pluck:function(b){var c=[];this.each(function(a){c.push(a[b])});return c},reject:function(c,d){var e=[];this.each(function(a,b){if(!c.call(d,a,b))e.push(a)});return e},sortBy:function(e,f){return this.map(function(a,b){return{value:a,criteria:e.call(f,a,b)}}).sort(function(c,d){var a=c.criteria,b=d.criteria;return a<b?-1:a>b?1:0}).pluck('value')},toArray:function(){return this.map()},zip:function(){var c=Prototype.K,args=$A(arguments);if(Object.isFunction(args.last()))c=args.pop();var d=[this].concat(args).map($A);return this.map(function(a,b){return c(d.pluck(b))})},size:function(){return this.toArray().length},inspect:function(){return'#<Enumerable:'+this.toArray().inspect()+'>'}};Object.extend(Enumerable,{map:Enumerable.collect,find:Enumerable.detect,select:Enumerable.findAll,filter:Enumerable.findAll,member:Enumerable.include,entries:Enumerable.toArray,every:Enumerable.all,some:Enumerable.any});function $A(a){if(!a)return[];if(a.toArray)return a.toArray();var b=a.length||0,results=new Array(b);while(b--)results[b]=a[b];return results}if(Prototype.Browser.WebKit){$A=function(a){if(!a)return[];if(!(typeof a==='function'&&typeof a.length==='number'&&typeof a.item==='function')&&a.toArray)return a.toArray();var b=a.length||0,results=new Array(b);while(b--)results[b]=a[b];return results}}Array.from=$A;Object.extend(Array.prototype,Enumerable);if(!Array.prototype._reverse)Array.prototype._reverse=Array.prototype.reverse;Object.extend(Array.prototype,{_each:function(a){for(var i=0,length=this.length;i<length;i++)a(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(a){return a!=null})},flatten:function(){return this.inject([],function(a,b){return a.concat(Object.isArray(b)?b.flatten():[b])})},without:function(){var b=$A(arguments);return this.select(function(a){return!b.include(a)})},reverse:function(a){return(a!==false?this:this.toArray())._reverse()},reduce:function(){return this.length>1?this:this[0]},uniq:function(d){return this.inject([],function(a,b,c){if(0==c||(d?a.last()!=b:!a.include(b)))a.push(b);return a})},intersect:function(c){return this.uniq().findAll(function(b){return c.detect(function(a){return b===a})})},clone:function(){return[].concat(this)},size:function(){return this.length},inspect:function(){return'['+this.map(Object.inspect).join(', ')+']'},toJSON:function(){var c=[];this.each(function(a){var b=Object.toJSON(a);if(!Object.isUndefined(b))c.push(b)});return'['+c.join(', ')+']'}});if(Object.isFunction(Array.prototype.forEach))Array.prototype._each=Array.prototype.forEach;if(!Array.prototype.indexOf)Array.prototype.indexOf=function(a,i){i||(i=0);var b=this.length;if(i<0)i=b+i;for(;i<b;i++)if(this[i]===a)return i;return-1};if(!Array.prototype.lastIndexOf)Array.prototype.lastIndexOf=function(a,i){i=isNaN(i)?this.length:(i<0?this.length+i:i)+1;var n=this.slice(0,i).reverse().indexOf(a);return(n<0)?n:i-n-1};Array.prototype.toArray=Array.prototype.clone;function $w(a){if(!Object.isString(a))return[];a=a.strip();return a?a.split(/\s+/):[]}if(Prototype.Browser.Opera){Array.prototype.concat=function(){var a=[];for(var i=0,length=this.length;i<length;i++)a.push(this[i]);for(var i=0,length=arguments.length;i<length;i++){if(Object.isArray(arguments[i])){for(var j=0,arrayLength=arguments[i].length;j<arrayLength;j++)a.push(arguments[i][j])}else{a.push(arguments[i])}}return a}}Object.extend(Number.prototype,{toColorPart:function(){return this.toPaddedString(2,16)},succ:function(){return this+1},times:function(a,b){$R(0,this,true).each(a,b);return this},toPaddedString:function(a,b){var c=this.toString(b||10);return'0'.times(a-c.length)+c},toJSON:function(){return isFinite(this)?this.toString():'null'}});$w('abs round ceil floor').each(function(a){Number.prototype[a]=Math[a].methodize()});function $H(a){return new Hash(a)};var Hash=Class.create(Enumerable,(function(){function toQueryPair(a,b){if(Object.isUndefined(b))return a;return a+'='+encodeURIComponent(String.interpret(b))}return{initialize:function(a){this._object=Object.isHash(a)?a.toObject():Object.clone(a)},_each:function(a){for(var b in this._object){var c=this._object[b],pair=[b,c];pair.key=b;pair.value=c;a(pair)}},set:function(a,b){return this._object[a]=b},get:function(a){if(this._object[a]!==Object.prototype[a])return this._object[a]},unset:function(a){var b=this._object[a];delete this._object[a];return b},toObject:function(){return Object.clone(this._object)},keys:function(){return this.pluck('key')},values:function(){return this.pluck('value')},index:function(b){var c=this.detect(function(a){return a.value===b});return c&&c.key},merge:function(a){return this.clone().update(a)},update:function(c){return new Hash(c).inject(this,function(a,b){a.set(b.key,b.value);return a})},toQueryString:function(){return this.inject([],function(a,b){var c=encodeURIComponent(b.key),values=b.value;if(values&&typeof values=='object'){if(Object.isArray(values))return a.concat(values.map(toQueryPair.curry(c)))}else a.push(toQueryPair(c,values));return a}).join('&')},inspect:function(){return'#<Hash:{'+this.map(function(a){return a.map(Object.inspect).join(': ')}).join(', ')+'}>'},toJSON:function(){return Object.toJSON(this.toObject())},clone:function(){return new Hash(this)}}})());Hash.prototype.toTemplateReplacements=Hash.prototype.toObject;Hash.from=$H;var ObjectRange=Class.create(Enumerable,{initialize:function(a,b,c){this.start=a;this.end=b;this.exclusive=c},_each:function(a){var b=this.start;while(this.include(b)){a(b);b=b.succ()}},include:function(a){if(a<this.start)return false;if(this.exclusive)return a<this.end;return a<=this.end}});var $R=function(a,b,c){return new ObjectRange(a,b,c)};var Ajax={getTransport:function(){return Try.these(function(){return new XMLHttpRequest()},function(){return new ActiveXObject('Msxml2.XMLHTTP')},function(){return new ActiveXObject('Microsoft.XMLHTTP')})||false},activeRequestCount:0};Ajax.Responders={responders:[],_each:function(a){this.responders._each(a)},register:function(a){if(!this.include(a))this.responders.push(a)},unregister:function(a){this.responders=this.responders.without(a)},dispatch:function(b,c,d,f){this.each(function(a){if(Object.isFunction(a[b])){try{a[b].apply(a,[c,d,f])}catch(e){}}})}};Object.extend(Ajax.Responders,Enumerable);Ajax.Responders.register({onCreate:function(){Ajax.activeRequestCount++},onComplete:function(){Ajax.activeRequestCount--}});Ajax.Base=Class.create({initialize:function(a){this.options={method:'post',asynchronous:true,contentType:'application/x-www-form-urlencoded',encoding:'UTF-8',parameters:'',evalJSON:true,evalJS:true};Object.extend(this.options,a||{});this.options.method=this.options.method.toLowerCase();if(Object.isString(this.options.parameters))this.options.parameters=this.options.parameters.toQueryParams();else if(Object.isHash(this.options.parameters))this.options.parameters=this.options.parameters.toObject()}});Ajax.Request=Class.create(Ajax.Base,{_complete:false,initialize:function($super,a,b){$super(b);this.transport=Ajax.getTransport();this.request(a)},request:function(a){this.url=a;this.method=this.options.method;var b=Object.clone(this.options.parameters);if(!['get','post'].include(this.method)){b['_method']=this.method;this.method='post'}this.parameters=b;if(b=Object.toQueryString(b)){if(this.method=='get')this.url+=(this.url.include('?')?'&':'?')+b;else if(/Konqueror|Safari|KHTML/.test(navigator.userAgent))b+='&_='}try{var c=new Ajax.Response(this);if(this.options.onCreate)this.options.onCreate(c);Ajax.Responders.dispatch('onCreate',this,c);this.transport.open(this.method.toUpperCase(),this.url,this.options.asynchronous);if(this.options.asynchronous)this.respondToReadyState.bind(this).defer(1);this.transport.onreadystatechange=this.onStateChange.bind(this);this.setRequestHeaders();this.body=this.method=='post'?(this.options.postBody||b):null;this.transport.send(this.body);if(!this.options.asynchronous&&this.transport.overrideMimeType)this.onStateChange()}catch(e){this.dispatchException(e)}},onStateChange:function(){var a=this.transport.readyState;if(a>1&&!((a==4)&&this._complete))this.respondToReadyState(this.transport.readyState)},setRequestHeaders:function(){var b={'X-Requested-With':'XMLHttpRequest','X-Prototype-Version':Prototype.Version,'Accept':'text/javascript, text/html, application/xml, text/xml, */*'};if(this.method=='post'){b['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)b['Connection']='close'}if(typeof this.options.requestHeaders=='object'){var c=this.options.requestHeaders;if(Object.isFunction(c.push))for(var i=0,length=c.length;i<length;i+=2)b[c[i]]=c[i+1];else $H(c).each(function(a){b[a.key]=a.value})}for(var d in b)this.transport.setRequestHeader(d,b[d])},success:function(){var a=this.getStatus();return!a||(a>=200&&a<300)},getStatus:function(){try{return this.transport.status||0}catch(e){return 0}},respondToReadyState:function(a){var b=Ajax.Request.Events[a],response=new Ajax.Response(this);if(b=='Complete'){try{this._complete=true;(this.options['on'+response.status]||this.options['on'+(this.success()?'Success':'Failure')]||Prototype.emptyFunction)(response,response.headerJSON)}catch(e){this.dispatchException(e)}var c=response.getHeader('Content-type');if(this.options.evalJS=='force'||(this.options.evalJS&&this.isSameOrigin()&&c&&c.match(/^\s*(text|application)\/(x-)?(java|ecma)script(;.*)?\s*$/i)))this.evalResponse()}try{(this.options['on'+b]||Prototype.emptyFunction)(response,response.headerJSON);Ajax.Responders.dispatch('on'+b,this,response,response.headerJSON)}catch(e){this.dispatchException(e)}if(b=='Complete'){this.transport.onreadystatechange=Prototype.emptyFunction}},isSameOrigin:function(){var m=this.url.match(/^\s*https?:\/\/[^\/]*/);return!m||(m[0]=='#{protocol}//#{domain}#{port}'.interpolate({protocol:location.protocol,domain:document.domain,port:location.port?':'+location.port:''}))},getHeader:function(a){try{return this.transport.getResponseHeader(a)||null}catch(e){return null}},evalResponse:function(){try{return eval((this.transport.responseText||'').unfilterJSON())}catch(e){this.dispatchException(e)}},dispatchException:function(a){(this.options.onException||Prototype.emptyFunction)(this,a);Ajax.Responders.dispatch('onException',this,a)}});Ajax.Request.Events=['Uninitialized','Loading','Loaded','Interactive','Complete'];Ajax.Response=Class.create({initialize:function(a){this.request=a;var b=this.transport=a.transport,readyState=this.readyState=b.readyState;if((readyState>2&&!Prototype.Browser.IE)||readyState==4){this.status=this.getStatus();this.statusText=this.getStatusText();this.responseText=String.interpret(b.responseText);this.headerJSON=this._getHeaderJSON()}if(readyState==4){var c=b.responseXML;this.responseXML=Object.isUndefined(c)?null:c;this.responseJSON=this._getResponseJSON()}},status:0,statusText:'',getStatus:Ajax.Request.prototype.getStatus,getStatusText:function(){try{return this.transport.statusText||''}catch(e){return''}},getHeader:Ajax.Request.prototype.getHeader,getAllHeaders:function(){try{return this.getAllResponseHeaders()}catch(e){return null}},getResponseHeader:function(a){return this.transport.getResponseHeader(a)},getAllResponseHeaders:function(){return this.transport.getAllResponseHeaders()},_getHeaderJSON:function(){var a=this.getHeader('X-JSON');if(!a)return null;a=decodeURIComponent(escape(a));try{return a.evalJSON(this.request.options.sanitizeJSON||!this.request.isSameOrigin())}catch(e){this.request.dispatchException(e)}},_getResponseJSON:function(){var a=this.request.options;if(!a.evalJSON||(a.evalJSON!='force'&&!(this.getHeader('Content-type')||'').include('application/json'))||this.responseText.blank())return null;try{return this.responseText.evalJSON(a.sanitizeJSON||!this.request.isSameOrigin())}catch(e){this.request.dispatchException(e)}}});Ajax.Updater=Class.create(Ajax.Request,{initialize:function($super,c,d,e){this.container={success:(c.success||c),failure:(c.failure||(c.success?null:c))};e=Object.clone(e);var f=e.onComplete;e.onComplete=(function(a,b){this.updateContent(a.responseText);if(Object.isFunction(f))f(a,b)}).bind(this);$super(d,e)},updateContent:function(a){var b=this.container[this.success()?'success':'failure'],options=this.options;if(!options.evalScripts)a=a.stripScripts();if(b=$(b)){if(options.insertion){if(Object.isString(options.insertion)){var c={};c[options.insertion]=a;b.insert(c)}else options.insertion(b,a)}else b.update(a)}}});Ajax.PeriodicalUpdater=Class.create(Ajax.Base,{initialize:function($super,a,b,c){$super(c);this.onComplete=this.options.onComplete;this.frequency=(this.options.frequency||2);this.decay=(this.options.decay||1);this.updater={};this.container=a;this.url=b;this.start()},start:function(){this.options.onComplete=this.updateComplete.bind(this);this.onTimerEvent()},stop:function(){this.updater.options.onComplete=undefined;clearTimeout(this.timer);(this.onComplete||Prototype.emptyFunction).apply(this,arguments)},updateComplete:function(a){if(this.options.decay){this.decay=(a.responseText==this.lastText?this.decay*this.options.decay:1);this.lastText=a.responseText}this.timer=this.onTimerEvent.bind(this).delay(this.decay*this.frequency)},onTimerEvent:function(){this.updater=new Ajax.Updater(this.container,this.url,this.options)}});function $(a){if(arguments.length>1){for(var i=0,elements=[],length=arguments.length;i<length;i++)elements.push($(arguments[i]));return elements}if(Object.isString(a))a=document.getElementById(a);return Element.extend(a)}if(Prototype.BrowserFeatures.XPath){document._getElementsByXPath=function(a,b){var c=[];var d=document.evaluate(a,$(b)||document,null,XPathResult.ORDERED_NODE_SNAPSHOT_TYPE,null);for(var i=0,length=d.snapshotLength;i<length;i++)c.push(Element.extend(d.snapshotItem(i)));return c}}if(!window.Node)var Node={};if(!Node.ELEMENT_NODE){Object.extend(Node,{ELEMENT_NODE:1,ATTRIBUTE_NODE:2,TEXT_NODE:3,CDATA_SECTION_NODE:4,ENTITY_REFERENCE_NODE:5,ENTITY_NODE:6,PROCESSING_INSTRUCTION_NODE:7,COMMENT_NODE:8,DOCUMENT_NODE:9,DOCUMENT_TYPE_NODE:10,DOCUMENT_FRAGMENT_NODE:11,NOTATION_NODE:12})}(function(){var d=this.Element;this.Element=function(a,b){b=b||{};a=a.toLowerCase();var c=Element.cache;if(Prototype.Browser.IE&&b.name){a='<'+a+' name="'+b.name+'">';delete b.name;return Element.writeAttribute(document.createElement(a),b)}if(!c[a])c[a]=Element.extend(document.createElement(a));return Element.writeAttribute(c[a].cloneNode(false),b)};Object.extend(this.Element,d||{});if(d)this.Element.prototype=d.prototype}).call(window);Element.cache={};Element.Methods={visible:function(a){return $(a).style.display!='none'},toggle:function(a){a=$(a);Element[Element.visible(a)?'hide':'show'](a);return a},hide:function(a){a=$(a);a.style.display='none';return a},show:function(a){a=$(a);a.style.display='';return a},remove:function(a){a=$(a);a.parentNode.removeChild(a);return a},update:function(a,b){a=$(a);if(b&&b.toElement)b=b.toElement();if(Object.isElement(b))return a.update().insert(b);b=Object.toHTML(b);a.innerHTML=b.stripScripts();b.evalScripts.bind(b).defer();return a},replace:function(a,b){a=$(a);if(b&&b.toElement)b=b.toElement();else if(!Object.isElement(b)){b=Object.toHTML(b);var c=a.ownerDocument.createRange();c.selectNode(a);b.evalScripts.bind(b).defer();b=c.createContextualFragment(b.stripScripts())}a.parentNode.replaceChild(b,a);return a},insert:function(a,b){a=$(a);if(Object.isString(b)||Object.isNumber(b)||Object.isElement(b)||(b&&(b.toElement||b.toHTML)))b={bottom:b};var c,insert,tagName,childNodes;for(var d in b){c=b[d];d=d.toLowerCase();insert=Element._insertionTranslations[d];if(c&&c.toElement)c=c.toElement();if(Object.isElement(c)){insert(a,c);continue}c=Object.toHTML(c);tagName=((d=='before'||d=='after')?a.parentNode:a).tagName.toUpperCase();childNodes=Element._getContentFromAnonymousElement(tagName,c.stripScripts());if(d=='top'||d=='after')childNodes.reverse();childNodes.each(insert.curry(a));c.evalScripts.bind(c).defer()}return a},wrap:function(a,b,c){a=$(a);if(Object.isElement(b))$(b).writeAttribute(c||{});else if(Object.isString(b))b=new Element(b,c);else b=new Element('div',b);if(a.parentNode)a.parentNode.replaceChild(b,a);b.appendChild(a);return b},inspect:function(d){d=$(d);var e='<'+d.tagName.toLowerCase();$H({'id':'id','className':'class'}).each(function(a){var b=a.first(),attribute=a.last();var c=(d[b]||'').toString();if(c)e+=' '+attribute+'='+c.inspect(true)});return e+'>'},recursivelyCollect:function(a,b){a=$(a);var c=[];while(a=a[b])if(a.nodeType==1)c.push(Element.extend(a));return c},ancestors:function(a){return $(a).recursivelyCollect('parentNode')},descendants:function(a){return $(a).select("*")},firstDescendant:function(a){a=$(a).firstChild;while(a&&a.nodeType!=1)a=a.nextSibling;return $(a)},immediateDescendants:function(a){if(!(a=$(a).firstChild))return[];while(a&&a.nodeType!=1)a=a.nextSibling;if(a)return[a].concat($(a).nextSiblings());return[]},previousSiblings:function(a){return $(a).recursivelyCollect('previousSibling')},nextSiblings:function(a){return $(a).recursivelyCollect('nextSibling')},siblings:function(a){a=$(a);return a.previousSiblings().reverse().concat(a.nextSiblings())},match:function(a,b){if(Object.isString(b))b=new Selector(b);return b.match($(a))},up:function(a,b,c){a=$(a);if(arguments.length==1)return $(a.parentNode);var d=a.ancestors();return Object.isNumber(b)?d[b]:Selector.findElement(d,b,c)},down:function(a,b,c){a=$(a);if(arguments.length==1)return a.firstDescendant();return Object.isNumber(b)?a.descendants()[b]:Element.select(a,b)[c||0]},previous:function(a,b,c){a=$(a);if(arguments.length==1)return $(Selector.handlers.previousElementSibling(a));var d=a.previousSiblings();return Object.isNumber(b)?d[b]:Selector.findElement(d,b,c)},next:function(a,b,c){a=$(a);if(arguments.length==1)return $(Selector.handlers.nextElementSibling(a));var d=a.nextSiblings();return Object.isNumber(b)?d[b]:Selector.findElement(d,b,c)},select:function(){var a=$A(arguments),element=$(a.shift());return Selector.findChildElements(element,a)},adjacent:function(){var a=$A(arguments),element=$(a.shift());return Selector.findChildElements(element.parentNode,a).without(element)},identify:function(a){a=$(a);var b=a.readAttribute('id'),self=arguments.callee;if(b)return b;do{b='anonymous_element_'+self.counter++}while($(b));a.writeAttribute('id',b);return b},readAttribute:function(a,b){a=$(a);if(Prototype.Browser.IE){var t=Element._attributeTranslations.read;if(t.values[b])return t.values[b](a,b);if(t.names[b])b=t.names[b];if(b.include(':')){return(!a.attributes||!a.attributes[b])?null:a.attributes[b].value}}return a.getAttribute(b)},writeAttribute:function(a,b,c){a=$(a);var d={},t=Element._attributeTranslations.write;if(typeof b=='object')d=b;else d[b]=Object.isUndefined(c)?true:c;for(var e in d){b=t.names[e]||e;c=d[e];if(t.values[e])b=t.values[e](a,c);if(c===false||c===null)a.removeAttribute(b);else if(c===true)a.setAttribute(b,b);else a.setAttribute(b,c)}return a},getHeight:function(a){return $(a).getDimensions().height},getWidth:function(a){return $(a).getDimensions().width},classNames:function(a){return new Element.ClassNames(a)},hasClassName:function(a,b){if(!(a=$(a)))return;var c=a.className;return(c.length>0&&(c==b||new RegExp("(^|\\s)"+b+"(\\s|$)").test(c)))},addClassName:function(a,b){if(!(a=$(a)))return;if(!a.hasClassName(b))a.className+=(a.className?' ':'')+b;return a},removeClassName:function(a,b){if(!(a=$(a)))return;a.className=a.className.replace(new RegExp("(^|\\s+)"+b+"(\\s+|$)"),' ').strip();return a},toggleClassName:function(a,b){if(!(a=$(a)))return;return a[a.hasClassName(b)?'removeClassName':'addClassName'](b)},cleanWhitespace:function(a){a=$(a);var b=a.firstChild;while(b){var c=b.nextSibling;if(b.nodeType==3&&!/\S/.test(b.nodeValue))a.removeChild(b);b=c}return a},empty:function(a){return $(a).innerHTML.blank()},descendantOf:function(a,b){a=$(a),b=$(b);if(a.compareDocumentPosition)return(a.compareDocumentPosition(b)&8)===8;if(b.contains)return b.contains(a)&&b!==a;while(a=a.parentNode)if(a==b)return true;return false},scrollTo:function(a){a=$(a);var b=a.cumulativeOffset();window.scrollTo(b[0],b[1]);return a},getStyle:function(a,b){a=$(a);b=b=='float'?'cssFloat':b.camelize();var c=a.style[b];if(!c||c=='auto'){var d=document.defaultView.getComputedStyle(a,null);c=d?d[b]:null}if(b=='opacity')return c?parseFloat(c):1.0;return c=='auto'?null:c},getOpacity:function(a){return $(a).getStyle('opacity')},setStyle:function(a,b){a=$(a);var c=a.style,match;if(Object.isString(b)){a.style.cssText+=';'+b;return b.include('opacity')?a.setOpacity(b.match(/opacity:\s*(\d?\.?\d*)/)[1]):a}for(var d in b)if(d=='opacity')a.setOpacity(b[d]);else c[(d=='float'||d=='cssFloat')?(Object.isUndefined(c.styleFloat)?'cssFloat':'styleFloat'):d]=b[d];return a},setOpacity:function(a,b){a=$(a);a.style.opacity=(b==1||b==='')?'':(b<0.00001)?0:b;return a},getDimensions:function(a){a=$(a);var b=a.getStyle('display');if(b!='none'&&b!=null)return{width:a.offsetWidth,height:a.offsetHeight};var c=a.style;var d=c.visibility;var e=c.position;var f=c.display;c.visibility='hidden';c.position='absolute';c.display='block';var g=a.clientWidth;var h=a.clientHeight;c.display=f;c.position=e;c.visibility=d;return{width:g,height:h}},makePositioned:function(a){a=$(a);var b=Element.getStyle(a,'position');if(b=='static'||!b){a._madePositioned=true;a.style.position='relative';if(Prototype.Browser.Opera){a.style.top=0;a.style.left=0}}return a},undoPositioned:function(a){a=$(a);if(a._madePositioned){a._madePositioned=undefined;a.style.position=a.style.top=a.style.left=a.style.bottom=a.style.right=''}return a},makeClipping:function(a){a=$(a);if(a._overflow)return a;a._overflow=Element.getStyle(a,'overflow')||'auto';if(a._overflow!=='hidden')a.style.overflow='hidden';return a},undoClipping:function(a){a=$(a);if(!a._overflow)return a;a.style.overflow=a._overflow=='auto'?'':a._overflow;a._overflow=null;return a},cumulativeOffset:function(a){var b=0,valueL=0;do{b+=a.offsetTop||0;valueL+=a.offsetLeft||0;a=a.offsetParent}while(a);return Element._returnOffset(valueL,b)},positionedOffset:function(a){var b=0,valueL=0;do{b+=a.offsetTop||0;valueL+=a.offsetLeft||0;a=a.offsetParent;if(a){if(a.tagName.toUpperCase()=='BODY')break;var p=Element.getStyle(a,'position');if(p!=='static')break}}while(a);return Element._returnOffset(valueL,b)},absolutize:function(a){a=$(a);if(a.getStyle('position')=='absolute')return a;var b=a.positionedOffset();var c=b[1];var d=b[0];var e=a.clientWidth;var f=a.clientHeight;a._originalLeft=d-parseFloat(a.style.left||0);a._originalTop=c-parseFloat(a.style.top||0);a._originalWidth=a.style.width;a._originalHeight=a.style.height;a.style.position='absolute';a.style.top=c+'px';a.style.left=d+'px';a.style.width=e+'px';a.style.height=f+'px';return a},relativize:function(a){a=$(a);if(a.getStyle('position')=='relative')return a;a.style.position='relative';var b=parseFloat(a.style.top||0)-(a._originalTop||0);var c=parseFloat(a.style.left||0)-(a._originalLeft||0);a.style.top=b+'px';a.style.left=c+'px';a.style.height=a._originalHeight;a.style.width=a._originalWidth;return a},cumulativeScrollOffset:function(a){var b=0,valueL=0;do{b+=a.scrollTop||0;valueL+=a.scrollLeft||0;a=a.parentNode}while(a);return Element._returnOffset(valueL,b)},getOffsetParent:function(a){if(a.offsetParent)return $(a.offsetParent);if(a==document.body)return $(a);while((a=a.parentNode)&&a!=document.body)if(Element.getStyle(a,'position')!='static')return $(a);return $(document.body)},viewportOffset:function(a){var b=0,valueL=0;var c=a;do{b+=c.offsetTop||0;valueL+=c.offsetLeft||0;if(c.offsetParent==document.body&&Element.getStyle(c,'position')=='absolute')break}while(c=c.offsetParent);c=a;do{if(!Prototype.Browser.Opera||(c.tagName&&(c.tagName.toUpperCase()=='BODY'))){b-=c.scrollTop||0;valueL-=c.scrollLeft||0}}while(c=c.parentNode);return Element._returnOffset(valueL,b)},clonePosition:function(a,b){var c=Object.extend({setLeft:true,setTop:true,setWidth:true,setHeight:true,offsetTop:0,offsetLeft:0},arguments[2]||{});b=$(b);var p=b.viewportOffset();a=$(a);var d=[0,0];var e=null;if(Element.getStyle(a,'position')=='absolute'){e=a.getOffsetParent();d=e.viewportOffset()}if(e==document.body){d[0]-=document.body.offsetLeft;d[1]-=document.body.offsetTop}if(c.setLeft)a.style.left=(p[0]-d[0]+c.offsetLeft)+'px';if(c.setTop)a.style.top=(p[1]-d[1]+c.offsetTop)+'px';if(c.setWidth)a.style.width=b.offsetWidth+'px';if(c.setHeight)a.style.height=b.offsetHeight+'px';return a}};Element.Methods.identify.counter=1;Object.extend(Element.Methods,{getElementsBySelector:Element.Methods.select,childElements:Element.Methods.immediateDescendants});Element._attributeTranslations={write:{names:{className:'class',htmlFor:'for'},values:{}}};if(Prototype.Browser.Opera){Element.Methods.getStyle=Element.Methods.getStyle.wrap(function(d,e,f){switch(f){case'left':case'top':case'right':case'bottom':if(d(e,'position')==='static')return null;case'height':case'width':if(!Element.visible(e))return null;var g=parseInt(d(e,f),10);if(g!==e['offset'+f.capitalize()])return g+'px';var h;if(f==='height'){h=['border-top-width','padding-top','padding-bottom','border-bottom-width']}else{h=['border-left-width','padding-left','padding-right','border-right-width']}return h.inject(g,function(a,b){var c=d(e,b);return c===null?a:a-parseInt(c,10)})+'px';default:return d(e,f)}});Element.Methods.readAttribute=Element.Methods.readAttribute.wrap(function(a,b,c){if(c==='title')return b.title;return a(b,c)})}else if(Prototype.Browser.IE){Element.Methods.getOffsetParent=Element.Methods.getOffsetParent.wrap(function(a,b){b=$(b);try{b.offsetParent}catch(e){return $(document.body)}var c=b.getStyle('position');if(c!=='static')return a(b);b.setStyle({position:'relative'});var d=a(b);b.setStyle({position:c});return d});$w('positionedOffset viewportOffset').each(function(g){Element.Methods[g]=Element.Methods[g].wrap(function(a,b){b=$(b);try{b.offsetParent}catch(e){return Element._returnOffset(0,0)}var c=b.getStyle('position');if(c!=='static')return a(b);var d=b.getOffsetParent();if(d&&d.getStyle('position')==='fixed')d.setStyle({zoom:1});b.setStyle({position:'relative'});var f=a(b);b.setStyle({position:c});return f})});Element.Methods.cumulativeOffset=Element.Methods.cumulativeOffset.wrap(function(a,b){try{b.offsetParent}catch(e){return Element._returnOffset(0,0)}return a(b)});Element.Methods.getStyle=function(a,b){a=$(a);b=(b=='float'||b=='cssFloat')?'styleFloat':b.camelize();var c=a.style[b];if(!c&&a.currentStyle)c=a.currentStyle[b];if(b=='opacity'){if(c=(a.getStyle('filter')||'').match(/alpha\(opacity=(.*)\)/))if(c[1])return parseFloat(c[1])/100;return 1.0}if(c=='auto'){if((b=='width'||b=='height')&&(a.getStyle('display')!='none'))return a['offset'+b.capitalize()]+'px';return null}return c};Element.Methods.setOpacity=function(b,c){function stripAlpha(a){return a.replace(/alpha\([^\)]*\)/gi,'')}b=$(b);var d=b.currentStyle;if((d&&!d.hasLayout)||(!d&&b.style.zoom=='normal'))b.style.zoom=1;var e=b.getStyle('filter'),style=b.style;if(c==1||c===''){(e=stripAlpha(e))?style.filter=e:style.removeAttribute('filter');return b}else if(c<0.00001)c=0;style.filter=stripAlpha(e)+'alpha(opacity='+(c*100)+')';return b};Element._attributeTranslations={read:{names:{'class':'className','for':'htmlFor'},values:{_getAttr:function(a,b){return a.getAttribute(b,2)},_getAttrNode:function(a,b){var c=a.getAttributeNode(b);return c?c.value:""},_getEv:function(a,b){b=a.getAttribute(b);return b?b.toString().slice(23,-2):null},_flag:function(a,b){return $(a).hasAttribute(b)?b:null},style:function(a){return a.style.cssText.toLowerCase()},title:function(a){return a.title}}}};Element._attributeTranslations.write={names:Object.extend({cellpadding:'cellPadding',cellspacing:'cellSpacing'},Element._attributeTranslations.read.names),values:{checked:function(a,b){a.checked=!!b},style:function(a,b){a.style.cssText=b?b:''}}};Element._attributeTranslations.has={};$w('colSpan rowSpan vAlign dateTime accessKey tabIndex '+'encType maxLength readOnly longDesc frameBorder').each(function(a){Element._attributeTranslations.write.names[a.toLowerCase()]=a;Element._attributeTranslations.has[a.toLowerCase()]=a});(function(v){Object.extend(v,{href:v._getAttr,src:v._getAttr,type:v._getAttr,action:v._getAttrNode,disabled:v._flag,checked:v._flag,readonly:v._flag,multiple:v._flag,onload:v._getEv,onunload:v._getEv,onclick:v._getEv,ondblclick:v._getEv,onmousedown:v._getEv,onmouseup:v._getEv,onmouseover:v._getEv,onmousemove:v._getEv,onmouseout:v._getEv,onfocus:v._getEv,onblur:v._getEv,onkeypress:v._getEv,onkeydown:v._getEv,onkeyup:v._getEv,onsubmit:v._getEv,onreset:v._getEv,onselect:v._getEv,onchange:v._getEv})})(Element._attributeTranslations.read.values)}else if(Prototype.Browser.Gecko&&/rv:1\.8\.0/.test(navigator.userAgent)){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1)?0.999999:(b==='')?'':(b<0.00001)?0:b;return a}}else if(Prototype.Browser.WebKit){Element.Methods.setOpacity=function(a,b){a=$(a);a.style.opacity=(b==1||b==='')?'':(b<0.00001)?0:b;if(b==1)if(a.tagName.toUpperCase()=='IMG'&&a.width){a.width++;a.width--}else try{var n=document.createTextNode(' ');a.appendChild(n);a.removeChild(n)}catch(e){}return a};Element.Methods.cumulativeOffset=function(a){var b=0,valueL=0;do{b+=a.offsetTop||0;valueL+=a.offsetLeft||0;if(a.offsetParent==document.body)if(Element.getStyle(a,'position')=='absolute')break;a=a.offsetParent}while(a);return Element._returnOffset(valueL,b)}}if(Prototype.Browser.IE||Prototype.Browser.Opera){Element.Methods.update=function(b,c){b=$(b);if(c&&c.toElement)c=c.toElement();if(Object.isElement(c))return b.update().insert(c);c=Object.toHTML(c);var d=b.tagName.toUpperCase();if(d in Element._insertionTranslations.tags){$A(b.childNodes).each(function(a){b.removeChild(a)});Element._getContentFromAnonymousElement(d,c.stripScripts()).each(function(a){b.appendChild(a)})}else b.innerHTML=c.stripScripts();c.evalScripts.bind(c).defer();return b}}if('outerHTML'in document.createElement('div')){Element.Methods.replace=function(b,c){b=$(b);if(c&&c.toElement)c=c.toElement();if(Object.isElement(c)){b.parentNode.replaceChild(c,b);return b}c=Object.toHTML(c);var d=b.parentNode,tagName=d.tagName.toUpperCase();if(Element._insertionTranslations.tags[tagName]){var e=b.next();var f=Element._getContentFromAnonymousElement(tagName,c.stripScripts());d.removeChild(b);if(e)f.each(function(a){d.insertBefore(a,e)});else f.each(function(a){d.appendChild(a)})}else b.outerHTML=c.stripScripts();c.evalScripts.bind(c).defer();return b}}Element._returnOffset=function(l,t){var a=[l,t];a.left=l;a.top=t;return a};Element._getContentFromAnonymousElement=function(a,b){var c=new Element('div'),t=Element._insertionTranslations.tags[a];if(t){c.innerHTML=t[0]+b+t[1];t[2].times(function(){c=c.firstChild})}else c.innerHTML=b;return $A(c.childNodes)};Element._insertionTranslations={before:function(a,b){a.parentNode.insertBefore(b,a)},top:function(a,b){a.insertBefore(b,a.firstChild)},bottom:function(a,b){a.appendChild(b)},after:function(a,b){a.parentNode.insertBefore(b,a.nextSibling)},tags:{TABLE:['<table>','</table>',1],TBODY:['<table><tbody>','</tbody></table>',2],TR:['<table><tbody><tr>','</tr></tbody></table>',3],TD:['<table><tbody><tr><td>','</td></tr></tbody></table>',4],SELECT:['<select>','</select>',1]}};(function(){Object.extend(this.tags,{THEAD:this.tags.TBODY,TFOOT:this.tags.TBODY,TH:this.tags.TD})}).call(Element._insertionTranslations);Element.Methods.Simulated={hasAttribute:function(a,b){b=Element._attributeTranslations.has[b]||b;var c=$(a).getAttributeNode(b);return!!(c&&c.specified)}};Element.Methods.ByTag={};Object.extend(Element,Element.Methods);if(!Prototype.BrowserFeatures.ElementExtensions&&document.createElement('div')['__proto__']){window.HTMLElement={};window.HTMLElement.prototype=document.createElement('div')['__proto__'];Prototype.BrowserFeatures.ElementExtensions=true}Element.extend=(function(){if(Prototype.BrowserFeatures.SpecificElementExtensions)return Prototype.K;var c={},ByTag=Element.Methods.ByTag;var d=Object.extend(function(a){if(!a||a._extendedByPrototype||a.nodeType!=1||a==window)return a;var b=Object.clone(c),tagName=a.tagName.toUpperCase(),property,value;if(ByTag[tagName])Object.extend(b,ByTag[tagName]);for(property in b){value=b[property];if(Object.isFunction(value)&&!(property in a))a[property]=value.methodize()}a._extendedByPrototype=Prototype.emptyFunction;return a},{refresh:function(){if(!Prototype.BrowserFeatures.ElementExtensions){Object.extend(c,Element.Methods);Object.extend(c,Element.Methods.Simulated)}}});d.refresh();return d})();Element.hasAttribute=function(a,b){if(a.hasAttribute)return a.hasAttribute(b);return Element.Methods.Simulated.hasAttribute(a,b)};Element.addMethods=function(f){var F=Prototype.BrowserFeatures,T=Element.Methods.ByTag;if(!f){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 g=f;f=arguments[1]}if(!g)Object.extend(Element.Methods,f||{});else{if(Object.isArray(g))g.each(extend);else extend(g)}function extend(a){a=a.toUpperCase();if(!Element.Methods.ByTag[a])Element.Methods.ByTag[a]={};Object.extend(Element.Methods.ByTag[a],f)}function copy(a,b,c){c=c||false;for(var d in a){var e=a[d];if(!Object.isFunction(e))continue;if(!c||!(d in b))b[d]=e.methodize()}}function findDOMClass(a){var b;var c={"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(c[a])b='HTML'+c[a]+'Element';if(window[b])return window[b];b='HTML'+a+'Element';if(window[b])return window[b];b='HTML'+a.capitalize()+'Element';if(window[b])return window[b];window[b]={};window[b].prototype=document.createElement(a)['__proto__'];return window[b]}if(F.ElementExtensions){copy(Element.Methods,HTMLElement.prototype);copy(Element.Methods.Simulated,HTMLElement.prototype,true)}if(F.SpecificElementExtensions){for(var h in Element.Methods.ByTag){var i=findDOMClass(h);if(Object.isUndefined(i))continue;copy(T[h],i.prototype)}}Object.extend(Element,Element.Methods);delete Element.ByTag;if(Element.extend.refresh)Element.extend.refresh();Element.cache={}};document.viewport={getDimensions:function(){var a={},B=Prototype.Browser;$w('width height').each(function(d){var D=d.capitalize();if(B.WebKit&&!document.evaluate){a[d]=self['inner'+D]}else if(B.Opera&&parseFloat(window.opera.version())<9.5){a[d]=document.body['client'+D]}else{a[d]=document.documentElement['client'+D]}});return a},getWidth:function(){return this.getDimensions().width},getHeight:function(){return this.getDimensions().height},getScrollOffsets:function(){return Element._returnOffset(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft,window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop)}};var Selector=Class.create({initialize:function(a){this.expression=a.strip();if(this.shouldUseSelectorsAPI()){this.mode='selectorsAPI'}else if(this.shouldUseXPath()){this.mode='xpath';this.compileXPathMatcher()}else{this.mode="normal";this.compileMatcher()}},shouldUseXPath:function(){if(!Prototype.BrowserFeatures.XPath)return false;var e=this.expression;if(Prototype.Browser.WebKit&&(e.include("-of-type")||e.include(":empty")))return false;if((/(\[[\w-]*?:|:checked)/).test(e))return false;return true},shouldUseSelectorsAPI:function(){if(!Prototype.BrowserFeatures.SelectorsAPI)return false;if(!Selector._div)Selector._div=new Element('div');try{Selector._div.querySelector(this.expression)}catch(e){return false}return true},compileMatcher:function(){var e=this.expression,ps=Selector.patterns,h=Selector.handlers,c=Selector.criteria,le,p,m;if(Selector._cache[e]){this.matcher=Selector._cache[e];return}this.matcher=["this.matcher = function(root) {","var r = root, h = Selector.handlers, c = false, n;"];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in ps){p=ps[i];if(m=e.match(p)){this.matcher.push(Object.isFunction(c[i])?c[i](m):new Template(c[i]).evaluate(m));e=e.replace(m[0],'');break}}}this.matcher.push("return h.unique(n);\n}");eval(this.matcher.join('\n'));Selector._cache[this.expression]=this.matcher},compileXPathMatcher:function(){var e=this.expression,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(Object.isFunction(x[i])?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(a){a=a||document;var e=this.expression,results;switch(this.mode){case'selectorsAPI':if(a!==document){var b=a.id,id=$(a).identify();e="#"+id+" "+e}results=$A(a.querySelectorAll(e)).map(Element.extend);a.id=b;return results;case'xpath':return document._getElementsByXPath(this.xpath,a);default:return this.matcher(a)}},match:function(a){this.tokens=[];var e=this.expression,ps=Selector.patterns,as=Selector.assertions;var b,p,m;while(e&&b!==e&&(/\S/).test(e)){b=e;for(var i in ps){p=ps[i];if(m=e.match(p)){if(as[i]){this.tokens.push([i,Object.clone(m)]);e=e.replace(m[0],'')}else{return this.findElements(document).include(a)}}}}var c=true,name,matches;for(var i=0,token;token=this.tokens[i];i++){name=token[0],matches=token[1];if(!Selector.assertions[name](a,matches)){c=false;break}}return c},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:function(m){m[1]=m[1].toLowerCase();return new Template("[@#{1}]").evaluate(m)},attr:function(m){m[1]=m[1].toLowerCase();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(Object.isFunction(h))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)]",'checked':"[@checked]",'disabled':"[(@disabled) and (@type!='hidden')]",'enabled':"[not(@disabled) and (@type!='hidden')]",'not':function(m){var e=m[6],p=Selector.patterns,x=Selector.xpath,le,v;var a=[];while(e&&le!=e&&(/\S/).test(e)){le=e;for(var i in p){if(m=e.match(p[i])){v=Object.isFunction(x[i])?x[i](m):new Template(x[i]).evaluate(m);a.push("("+v.substring(1,v.length-1)+")");e=e.replace(m[0],'');break}}}return"[not("+a.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(c,m){var d,formula=m[6],predicate;if(formula=='even')formula='2n+0';if(formula=='odd')formula='2n+1';if(d=formula.match(/^(\d+)$/))return'['+c+"= "+d[1]+']';if(d=formula.match(/^(-?\d*)?n(([+-])(\d+))?/)){if(d[1]=="-")d[1]=-1;var a=d[1]?Number(d[1]):1;var b=d[2]?Number(d[2]):0;predicate="[((#{fragment} - #{b}) mod #{a} = 0) and "+"((#{fragment} - #{b}) div #{a} >= 0)]";return new Template(predicate).evaluate({fragment:c,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); c = false;',attr:function(m){m[3]=(m[5]||m[6]);return new Template('n = h.attr(n, r, "#{1}", "#{3}", "#{2}", c); 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]+:)?[\w]+)\]/,attr:/\[((?:[\w-]*:)?[\w-]+)\s*(?:([!^$*~|]?=)\s*((['"])([^\4]*?)\4|([^'"][^\]]*?)))?\]/},assertions:{tagName:function(a,b){return b[1].toUpperCase()==a.tagName.toUpperCase()},className:function(a,b){return Element.hasClassName(a,b[1])},id:function(a,b){return a.id===b[1]},attrPresence:function(a,b){return Element.hasAttribute(a,b[1])},attr:function(a,b){var c=Element.readAttribute(a,b[1]);return c&&Selector.operators[b[2]](c,b[5]||b[6])}},handlers:{concat:function(a,b){for(var i=0,node;node=b[i];i++)a.push(node);return a},mark:function(a){var b=Prototype.emptyFunction;for(var i=0,node;node=a[i];i++)node._countedByPrototype=b;return a},unmark:function(a){for(var i=0,node;node=a[i];i++)node._countedByPrototype=undefined;return a},index:function(a,b,c){a._countedByPrototype=Prototype.emptyFunction;if(b){for(var d=a.childNodes,i=d.length-1,j=1;i>=0;i--){var e=d[i];if(e.nodeType==1&&(!c||e._countedByPrototype))e.nodeIndex=j++}}else{for(var i=0,j=1,d=a.childNodes;e=d[i];i++)if(e.nodeType==1&&(!c||e._countedByPrototype))e.nodeIndex=j++}},unique:function(a){if(a.length==0)return a;var b=[],n;for(var i=0,l=a.length;i<l;i++)if(!(n=a[i])._countedByPrototype){n._countedByPrototype=Prototype.emptyFunction;b.push(Element.extend(n))}return Selector.handlers.unmark(b)},descendant:function(a){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++)h.concat(results,node.getElementsByTagName('*'));return results},child:function(a){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++){for(var j=0,child;child=node.childNodes[j];j++)if(child.nodeType==1&&child.tagName!='!')results.push(child)}return results},adjacent:function(a){for(var i=0,results=[],node;node=a[i];i++){var b=this.nextElementSibling(node);if(b)results.push(b)}return results},laterSibling:function(a){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++)h.concat(results,Element.nextSiblings(node));return results},nextElementSibling:function(a){while(a=a.nextSibling)if(a.nodeType==1)return a;return null},previousElementSibling:function(a){while(a=a.previousSibling)if(a.nodeType==1)return a;return null},tagName:function(a,b,c,d){var e=c.toUpperCase();var f=[],h=Selector.handlers;if(a){if(d){if(d=="descendant"){for(var i=0,node;node=a[i];i++)h.concat(f,node.getElementsByTagName(c));return f}else a=this[d](a);if(c=="*")return a}for(var i=0,node;node=a[i];i++)if(node.tagName.toUpperCase()===e)f.push(node);return f}else return b.getElementsByTagName(c)},id:function(a,b,c,d){var e=$(c),h=Selector.handlers;if(!e)return[];if(!a&&b==document)return[e];if(a){if(d){if(d=='child'){for(var i=0,node;node=a[i];i++)if(e.parentNode==node)return[e]}else if(d=='descendant'){for(var i=0,node;node=a[i];i++)if(Element.descendantOf(e,node))return[e]}else if(d=='adjacent'){for(var i=0,node;node=a[i];i++)if(Selector.handlers.previousElementSibling(e)==node)return[e]}else a=h[d](a)}for(var i=0,node;node=a[i];i++)if(node==e)return[e];return[]}return(e&&Element.descendantOf(e,b))?[e]:[]},className:function(a,b,c,d){if(a&&d)a=this[d](a);return Selector.handlers.byClassName(a,b,c)},byClassName:function(a,b,c){if(!a)a=Selector.handlers.descendant([b]);var d=' '+c+' ';for(var i=0,results=[],node,nodeClassName;node=a[i];i++){nodeClassName=node.className;if(nodeClassName.length==0)continue;if(nodeClassName==c||(' '+nodeClassName+' ').include(d))results.push(node)}return results},attrPresence:function(a,b,c,d){if(!a)a=b.getElementsByTagName("*");if(a&&d)a=this[d](a);var e=[];for(var i=0,node;node=a[i];i++)if(Element.hasAttribute(node,c))e.push(node);return e},attr:function(a,b,c,d,e,f){if(!a)a=b.getElementsByTagName("*");if(a&&f)a=this[f](a);var g=Selector.operators[e],results=[];for(var i=0,node;node=a[i];i++){var h=Element.readAttribute(node,c);if(h===null)continue;if(g(h,d))results.push(node)}return results},pseudo:function(a,b,c,d,e){if(a&&e)a=this[e](a);if(!a)a=d.getElementsByTagName("*");return Selector.pseudos[b](a,c,d)}},pseudos:{'first-child':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++){if(Selector.handlers.previousElementSibling(node))continue;results.push(node)}return results},'last-child':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++){if(Selector.handlers.nextElementSibling(node))continue;results.push(node)}return results},'only-child':function(a,b,c){var h=Selector.handlers;for(var i=0,results=[],node;node=a[i];i++)if(!h.previousElementSibling(node)&&!h.nextElementSibling(node))results.push(node);return results},'nth-child':function(a,b,c){return Selector.pseudos.nth(a,b,c)},'nth-last-child':function(a,b,c){return Selector.pseudos.nth(a,b,c,true)},'nth-of-type':function(a,b,c){return Selector.pseudos.nth(a,b,c,false,true)},'nth-last-of-type':function(a,b,c){return Selector.pseudos.nth(a,b,c,true,true)},'first-of-type':function(a,b,c){return Selector.pseudos.nth(a,"1",c,false,true)},'last-of-type':function(a,b,c){return Selector.pseudos.nth(a,"1",c,true,true)},'only-of-type':function(a,b,c){var p=Selector.pseudos;return p['last-of-type'](p['first-of-type'](a,b,c),b,c)},getIndices:function(a,b,d){if(a==0)return b>0?[b]:[];return $R(1,d).inject([],function(c,i){if(0==(i-b)%a&&(i-b)/a>=0)c.push(i);return c})},nth:function(c,d,e,f,g){if(c.length==0)return[];if(d=='even')d='2n+0';if(d=='odd')d='2n+1';var h=Selector.handlers,results=[],indexed=[],m;h.mark(c);for(var i=0,node;node=c[i];i++){if(!node.parentNode._countedByPrototype){h.index(node.parentNode,f,g);indexed.push(node.parentNode)}}if(d.match(/^\d+$/)){d=Number(d);for(var i=0,node;node=c[i];i++)if(node.nodeIndex==d)results.push(node)}else if(m=d.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 k=Selector.pseudos.getIndices(a,b,c.length);for(var i=0,node,l=k.length;node=c[i];i++){for(var j=0;j<l;j++)if(node.nodeIndex==k[j])results.push(node)}}h.unmark(c);h.unmark(indexed);return results},'empty':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++){if(node.tagName=='!'||node.firstChild)continue;results.push(node)}return results},'not':function(a,b,c){var h=Selector.handlers,selectorType,m;var d=new Selector(b).findElements(c);h.mark(d);for(var i=0,results=[],node;node=a[i];i++)if(!node._countedByPrototype)results.push(node);h.unmark(d);return results},'enabled':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++)if(!node.disabled&&(!node.type||node.type!=='hidden'))results.push(node);return results},'disabled':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++)if(node.disabled)results.push(node);return results},'checked':function(a,b,c){for(var i=0,results=[],node;node=a[i];i++)if(node.checked)results.push(node);return results}},operators:{'=':function(a,v){return a==v},'!=':function(a,v){return a!=v},'^=':function(a,v){return a==v||a&&a.startsWith(v)},'$=':function(a,v){return a==v||a&&a.endsWith(v)},'*=':function(a,v){return a==v||a&&a.include(v)},'$=':function(a,v){return a.endsWith(v)},'*=':function(a,v){return a.include(v)},'~=':function(a,v){return(' '+a+' ').include(' '+v+' ')},'|=':function(a,v){return('-'+(a||"").toUpperCase()+'-').include('-'+(v||"").toUpperCase()+'-')}},split:function(a){var b=[];a.scan(/(([\w#:.~>+()\s-]+|\*|\[.*?\])+)\s*(,|$)/,function(m){b.push(m[1].strip())});return b},matchElements:function(a,b){var c=$$(b),h=Selector.handlers;h.mark(c);for(var i=0,results=[],element;element=a[i];i++)if(element._countedByPrototype)results.push(element);h.unmark(c);return results},findElement:function(a,b,c){if(Object.isNumber(b)){c=b;b=false}return Selector.matchElements(a,b||'*')[c||0]},findChildElements:function(a,b){b=Selector.split(b.join(','));var c=[],h=Selector.handlers;for(var i=0,l=b.length,selector;i<l;i++){selector=new Selector(b[i].strip());h.concat(c,selector.findElements(a))}return(l>1)?h.unique(c):c}});if(Prototype.Browser.IE){Object.extend(Selector.handlers,{concat:function(a,b){for(var i=0,node;node=b[i];i++)if(node.tagName!=="!")a.push(node);return a},unmark:function(a){for(var i=0,node;node=a[i];i++)node.removeAttribute('_countedByPrototype');return a}})}function $$(){return Selector.findChildElements(document,$A(arguments))}var Form={reset:function(a){$(a).reset();return a},serializeElements:function(c,d){if(typeof d!='object')d={hash:!!d};else if(Object.isUndefined(d.hash))d.hash=true;var e,value,submitted=false,submit=d.submit;var f=c.inject({},function(a,b){if(!b.disabled&&b.name){e=b.name;value=$(b).getValue();if(value!=null&&b.type!='file'&&(b.type!='submit'||(!submitted&&submit!==false&&(!submit||e==submit)&&(submitted=true)))){if(e in a){if(!Object.isArray(a[e]))a[e]=[a[e]];a[e].push(value)}else a[e]=value}}return a});return d.hash?f:Object.toQueryString(f)}};Form.Methods={serialize:function(a,b){return Form.serializeElements(Form.getElements(a),b)},getElements:function(c){return $A($(c).getElementsByTagName('*')).inject([],function(a,b){if(Form.Element.Serializers[b.tagName.toLowerCase()])a.push(Element.extend(b));return a})},getInputs:function(a,b,c){a=$(a);var d=a.getElementsByTagName('input');if(!b&&!c)return $A(d).map(Element.extend);for(var i=0,matchingInputs=[],length=d.length;i<length;i++){var e=d[i];if((b&&e.type!=b)||(c&&e.name!=c))continue;matchingInputs.push(Element.extend(e))}return matchingInputs},disable:function(a){a=$(a);Form.getElements(a).invoke('disable');return a},enable:function(a){a=$(a);Form.getElements(a).invoke('enable');return a},findFirstElement:function(b){var c=$(b).getElements().findAll(function(a){return'hidden'!=a.type&&!a.disabled});var d=c.findAll(function(a){return a.hasAttribute('tabIndex')&&a.tabIndex>=0}).sortBy(function(a){return a.tabIndex}).first();return d?d:c.find(function(a){return['input','select','textarea'].include(a.tagName.toLowerCase())})},focusFirstElement:function(a){a=$(a);a.findFirstElement().activate();return a},request:function(a,b){a=$(a),b=Object.clone(b||{});var c=b.parameters,action=a.readAttribute('action')||'';if(action.blank())action=window.location.href;b.parameters=a.serialize(true);if(c){if(Object.isString(c))c=c.toQueryParams();Object.extend(b.parameters,c)}if(a.hasAttribute('method')&&!b.method)b.method=a.method;return new Ajax.Request(action,b)}};Form.Element={focus:function(a){$(a).focus();return a},select:function(a){$(a).select();return a}};Form.Element.Methods={serialize:function(a){a=$(a);if(!a.disabled&&a.name){var b=a.getValue();if(b!=undefined){var c={};c[a.name]=b;return Object.toQueryString(c)}}return''},getValue:function(a){a=$(a);var b=a.tagName.toLowerCase();return Form.Element.Serializers[b](a)},setValue:function(a,b){a=$(a);var c=a.tagName.toLowerCase();Form.Element.Serializers[c](a,b);return a},clear:function(a){$(a).value='';return a},present:function(a){return $(a).value!=''},activate:function(a){a=$(a);try{a.focus();if(a.select&&(a.tagName.toLowerCase()!='input'||!['button','reset','submit'].include(a.type)))a.select()}catch(e){}return a},disable:function(a){a=$(a);a.disabled=true;return a},enable:function(a){a=$(a);a.disabled=false;return a}};var Field=Form.Element;var $F=Form.Element.Methods.getValue;Form.Element.Serializers={input:function(a,b){switch(a.type.toLowerCase()){case'checkbox':case'radio':return Form.Element.Serializers.inputSelector(a,b);default:return Form.Element.Serializers.textarea(a,b)}},inputSelector:function(a,b){if(Object.isUndefined(b))return a.checked?a.value:null;else a.checked=!!b},textarea:function(a,b){if(Object.isUndefined(b))return a.value;else a.value=b},select:function(a,b){if(Object.isUndefined(b))return this[a.type=='select-one'?'selectOne':'selectMany'](a);else{var c,currentValue,single=!Object.isArray(b);for(var i=0,length=a.length;i<length;i++){c=a.options[i];currentValue=this.optionValue(c);if(single){if(currentValue==b){c.selected=true;return}}else c.selected=b.include(currentValue)}}},selectOne:function(a){var b=a.selectedIndex;return b>=0?this.optionValue(a.options[b]):null},selectMany:function(a){var b,length=a.length;if(!length)return null;for(var i=0,b=[];i<length;i++){var c=a.options[i];if(c.selected)b.push(this.optionValue(c))}return b},optionValue:function(a){return Element.extend(a).hasAttribute('value')?a.value:a.text}};Abstract.TimedObserver=Class.create(PeriodicalExecuter,{initialize:function($super,a,b,c){$super(c,b);this.element=$(a);this.lastValue=this.getValue()},execute:function(){var a=this.getValue();if(Object.isString(this.lastValue)&&Object.isString(a)?this.lastValue!=a:String(this.lastValue)!=String(a)){this.callback(this.element,a);this.lastValue=a}}});Form.Element.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.Observer=Class.create(Abstract.TimedObserver,{getValue:function(){return Form.serialize(this.element)}});Abstract.EventObserver=Class.create({initialize:function(a,b){this.element=$(a);this.callback=b;this.lastValue=this.getValue();if(this.element.tagName.toLowerCase()=='form')this.registerFormCallbacks();else this.registerCallback(this.element)},onElementEvent:function(){var a=this.getValue();if(this.lastValue!=a){this.callback(this.element,a);this.lastValue=a}},registerFormCallbacks:function(){Form.getElements(this.element).each(this.registerCallback,this)},registerCallback:function(a){if(a.type){switch(a.type.toLowerCase()){case'checkbox':case'radio':Event.observe(a,'click',this.onElementEvent.bind(this));break;default:Event.observe(a,'change',this.onElementEvent.bind(this));break}}}});Form.Element.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.Element.getValue(this.element)}});Form.EventObserver=Class.create(Abstract.EventObserver,{getValue:function(){return Form.serialize(this.element)}});if(!window.Event)var Event={};Object.extend(Event,{KEY_BACKSPACE:8,KEY_TAB:9,KEY_RETURN:13,KEY_ESC:27,KEY_LEFT:37,KEY_UP:38,KEY_RIGHT:39,KEY_DOWN:40,KEY_DELETE:46,KEY_HOME:36,KEY_END:35,KEY_PAGEUP:33,KEY_PAGEDOWN:34,KEY_INSERT:45,cache:{},relatedTarget:function(a){var b;switch(a.type){case'mouseover':b=a.fromElement;break;case'mouseout':b=a.toElement;break;default:return null}return Element.extend(b)}});Event.Methods=(function(){var e;if(Prototype.Browser.IE){var f={0:1,1:4,2:2};e=function(a,b){return a.button==f[b]}}else if(Prototype.Browser.WebKit){e=function(a,b){switch(b){case 0:return a.which==1&&!a.metaKey;case 1:return a.which==1&&a.metaKey;default:return false}}}else{e=function(a,b){return a.which?(a.which===b+1):(a.button===b)}}return{isLeftClick:function(a){return e(a,0)},isMiddleClick:function(a){return e(a,1)},isRightClick:function(a){return e(a,2)},element:function(a){a=Event.extend(a);var b=a.target,type=a.type,currentTarget=a.currentTarget;if(currentTarget&&currentTarget.tagName){if(type==='load'||type==='error'||(type==='click'&&currentTarget.tagName.toLowerCase()==='input'&&currentTarget.type==='radio'))b=currentTarget}if(b.nodeType==Node.TEXT_NODE)b=b.parentNode;return Element.extend(b)},findElement:function(a,b){var c=Event.element(a);if(!b)return c;var d=[c].concat(c.ancestors());return Selector.findElement(d,b,0)},pointer:function(a){var b=document.documentElement,body=document.body||{scrollLeft:0,scrollTop:0};return{x:a.pageX||(a.clientX+(b.scrollLeft||body.scrollLeft)-(b.clientLeft||0)),y:a.pageY||(a.clientY+(b.scrollTop||body.scrollTop)-(b.clientTop||0))}},pointerX:function(a){return Event.pointer(a).x},pointerY:function(a){return Event.pointer(a).y},stop:function(a){Event.extend(a);a.preventDefault();a.stopPropagation();a.stopped=true}}})();Event.extend=(function(){var c=Object.keys(Event.Methods).inject({},function(m,a){m[a]=Event.Methods[a].methodize();return m});if(Prototype.Browser.IE){Object.extend(c,{stopPropagation:function(){this.cancelBubble=true},preventDefault:function(){this.returnValue=false},inspect:function(){return"[object Event]"}});return function(a){if(!a)return false;if(a._extendedByPrototype)return a;a._extendedByPrototype=Prototype.emptyFunction;var b=Event.pointer(a);Object.extend(a,{target:a.srcElement,relatedTarget:Event.relatedTarget(a),pageX:b.x,pageY:b.y});return Object.extend(a,c)}}else{Event.prototype=Event.prototype||document.createEvent("HTMLEvents")['__proto__'];Object.extend(Event.prototype,c);return Prototype.K}})();Object.extend(Event,(function(){var h=Event.cache;function getEventID(a){if(a._prototypeEventID)return a._prototypeEventID[0];arguments.callee.id=arguments.callee.id||1;return a._prototypeEventID=[++arguments.callee.id]}function getDOMEventName(a){if(a&&a.include(':'))return"dataavailable";return a}function getCacheForID(a){return h[a]=h[a]||{}}function getWrappersForEventName(a,b){var c=getCacheForID(a);return c[b]=c[b]||[]}function createWrapper(b,d,e){var f=getEventID(b);var c=getWrappersForEventName(f,d);if(c.pluck("handler").include(e))return false;var g=function(a){if(!Event||!Event.extend||(a.eventName&&a.eventName!=d))return false;Event.extend(a);e.call(b,a)};g.handler=e;c.push(g);return g}function findWrapper(b,d,e){var c=getWrappersForEventName(b,d);return c.find(function(a){return a.handler==e})}function destroyWrapper(a,b,d){var c=getCacheForID(a);if(!c[b])return false;c[b]=c[b].without(findWrapper(a,b,d))}function destroyCache(){for(var a in h)for(var b in h[a])h[a][b]=null}if(window.attachEvent){window.attachEvent("onunload",destroyCache)}if(Prototype.Browser.WebKit){window.addEventListener('unload',Prototype.emptyFunction,false)}return{observe:function(a,b,c){a=$(a);var d=getDOMEventName(b);var e=createWrapper(a,b,c);if(!e)return a;if(a.addEventListener){a.addEventListener(d,e,false)}else{a.attachEvent("on"+d,e)}return a},stopObserving:function(b,c,d){b=$(b);var e=getEventID(b),name=getDOMEventName(c);if(!d&&c){getWrappersForEventName(e,c).each(function(a){b.stopObserving(c,a.handler)});return b}else if(!c){Object.keys(getCacheForID(e)).each(function(a){b.stopObserving(a)});return b}var f=findWrapper(e,c,d);if(!f)return b;if(b.removeEventListener){b.removeEventListener(name,f,false)}else{b.detachEvent("on"+name,f)}destroyWrapper(e,c,d);return b},fire:function(a,b,c){a=$(a);if(a==document&&document.createEvent&&!a.dispatchEvent)a=document.documentElement;var d;if(document.createEvent){d=document.createEvent("HTMLEvents");d.initEvent("dataavailable",true,true)}else{d=document.createEventObject();d.eventType="ondataavailable"}d.eventName=b;d.memo=c||{};if(document.createEvent){a.dispatchEvent(d)}else{a.fireEvent(d.eventType,d)}return Event.extend(d)}}})());Object.extend(Event,Event.Methods);Element.addMethods({fire:Event.fire,observe:Event.observe,stopObserving:Event.stopObserving});Object.extend(document,{fire:Element.Methods.fire.methodize(),observe:Element.Methods.observe.methodize(),stopObserving:Element.Methods.stopObserving.methodize(),loaded:false});(function(){var a;function fireContentLoadedEvent(){if(document.loaded)return;if(a)window.clearInterval(a);document.fire("dom:loaded");document.loaded=true}if(document.addEventListener){if(Prototype.Browser.WebKit){a=window.setInterval(function(){if(/loaded|complete/.test(document.readyState))fireContentLoadedEvent()},0);Event.observe(window,"load",fireContentLoadedEvent)}else{document.addEventListener("DOMContentLoaded",fireContentLoadedEvent,false)}}else{document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>");$("__onDOMContentLoaded").onreadystatechange=function(){if(this.readyState=="complete"){this.onreadystatechange=null;fireContentLoadedEvent()}}}})();Hash.toQueryString=Object.toQueryString;var Toggle={display:Element.toggle};Element.Methods.childOf=Element.Methods.descendantOf;var Insertion={Before:function(a,b){return Element.insert(a,{before:b})},Top:function(a,b){return Element.insert(a,{top:b})},Bottom:function(a,b){return Element.insert(a,{bottom:b})},After:function(a,b){return Element.insert(a,{after:b})}};var $continue=new Error('"throw $continue" is deprecated, use "return" instead');var Position={includeScrollOffsets:false,prepare:function(){this.deltaX=window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0;this.deltaY=window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0},within:function(a,x,y){if(this.includeScrollOffsets)return this.withinIncludingScrolloffsets(a,x,y);this.xcomp=x;this.ycomp=y;this.offset=Element.cumulativeOffset(a);return(y>=this.offset[1]&&y<this.offset[1]+a.offsetHeight&&x>=this.offset[0]&&x<this.offset[0]+a.offsetWidth)},withinIncludingScrolloffsets:function(a,x,y){var b=Element.cumulativeScrollOffset(a);this.xcomp=x+b[0]-this.deltaX;this.ycomp=y+b[1]-this.deltaY;this.offset=Element.cumulativeOffset(a);return(this.ycomp>=this.offset[1]&&this.ycomp<this.offset[1]+a.offsetHeight&&this.xcomp>=this.offset[0]&&this.xcomp<this.offset[0]+a.offsetWidth)},overlap:function(a,b){if(!a)return 0;if(a=='vertical')return((this.offset[1]+b.offsetHeight)-this.ycomp)/b.offsetHeight;if(a=='horizontal')return((this.offset[0]+b.offsetWidth)-this.xcomp)/b.offsetWidth},cumulativeOffset:Element.Methods.cumulativeOffset,positionedOffset:Element.Methods.positionedOffset,absolutize:function(a){Position.prepare();return Element.absolutize(a)},relativize:function(a){Position.prepare();return Element.relativize(a)},realOffset:Element.Methods.cumulativeScrollOffset,offsetParent:Element.Methods.getOffsetParent,page:Element.Methods.viewportOffset,clone:function(a,b,c){c=c||{};return Element.clonePosition(b,a,c)}};if(!document.getElementsByClassName)document.getElementsByClassName=function(f){function iter(a){return a.blank()?null:"[contains(concat(' ', @class, ' '), ' "+a+" ')]"}f.getElementsByClassName=Prototype.BrowserFeatures.XPath?function(a,b){b=b.toString().strip();var c=/\s/.test(b)?$w(b).map(iter).join(''):iter(b);return c?document._getElementsByXPath('.//*'+c,a):[]}:function(b,c){c=c.toString().strip();var d=[],classNames=(/\s/.test(c)?$w(c):null);if(!classNames&&!c)return d;var e=$(b).getElementsByTagName('*');c=' '+c+' ';for(var i=0,child,cn;child=e[i];i++){if(child.className&&(cn=' '+child.className+' ')&&(cn.include(c)||(classNames&&classNames.all(function(a){return!a.toString().blank()&&cn.include(' '+a+' ')}))))d.push(Element.extend(child))}return d};return function(a,b){return $(b||document.body).getElementsByClassName(a)}}(Element.Methods);Element.ClassNames=Class.create();Element.ClassNames.prototype={initialize:function(a){this.element=$(a)},_each:function(b){this.element.className.split(/\s+/).select(function(a){return a.length>0})._each(b)},set:function(a){this.element.className=a},add:function(a){if(this.include(a))return;this.set($A(this).concat(a).join(' '))},remove:function(a){if(!this.include(a))return;this.set($A(this).without(a).join(' '))},toString:function(){return $A(this).join(' ')}};Object.extend(Element.ClassNames.prototype,Enumerable);Element.addMethods();


var Scriptaculous={Version:'1.8.1',require:function(a){document.write('<script type="text/javascript" src="'+a+'"><\/script>')},REQUIRED_PROTOTYPE:'1.6.0',load:function(){function convertVersionString(a){var r=a.split('.');return parseInt(r[0])*100000+parseInt(r[1])*1000+parseInt(r[2])}if((typeof Prototype=='undefined')||(typeof Element=='undefined')||(typeof Element.Methods=='undefined')||(convertVersionString(Prototype.Version)<convertVersionString(Scriptaculous.REQUIRED_PROTOTYPE)))throw("script.aculo.us requires the Prototype JavaScript framework >= "+Scriptaculous.REQUIRED_PROTOTYPE);var d=/(proto|scripta)culous[a-z0-9._-]*\.js(\?.*)?$/;$A(document.getElementsByTagName("script")).findAll(function(s){return(s.src&&s.src.match(d))}).each(function(s){var b=s.src.replace(d,'');var c=(s.src.match(/\?.*load=([a-z,]*)/)||['',''])[1];c.split(',').without('').each(function(a){Scriptaculous.require(b+a+'.js')})})}};

//builder.js

var Builder={NODEMAP:{AREA:'map',CAPTION:'table',COL:'table',COLGROUP:'table',LEGEND:'fieldset',OPTGROUP:'select',OPTION:'select',PARAM:'object',TBODY:'table',TD:'table',TFOOT:'table',TH:'table',THEAD:'table',TR:'table'},node:function(a){a=a.toUpperCase();var b=this.NODEMAP[a]||'div';var c=document.createElement(b);try{c.innerHTML="<"+a+"></"+a+">"}catch(e){}var d=c.firstChild||null;if(d&&(d.tagName.toUpperCase()!=a))d=d.getElementsByTagName(a)[0];if(!d)d=document.createElement(a);if(!d)return;if(arguments[1])if(this._isStringOrNumber(arguments[1])||(arguments[1]instanceof Array)||arguments[1].tagName){this._children(d,arguments[1])}else{var f=this._attributes(arguments[1]);if(f.length){try{c.innerHTML="<"+a+" "+f+"></"+a+">"}catch(e){}d=c.firstChild||null;if(!d){d=document.createElement(a);for(attr in arguments[1])d[attr=='class'?'className':attr]=arguments[1][attr]}if(d.tagName.toUpperCase()!=a)d=c.getElementsByTagName(a)[0]}}if(arguments[2])this._children(d,arguments[2]);return d},_text:function(a){return document.createTextNode(a)},ATTR_MAP:{'className':'class','htmlFor':'for'},_attributes:function(a){var b=[];for(attribute in a)b.push((attribute in this.ATTR_MAP?this.ATTR_MAP[attribute]:attribute)+'="'+a[attribute].toString().escapeHTML().gsub(/"/,'&quot;')+'"');return b.join(" ")},_children:function(a,b){if(b.tagName){a.appendChild(b);return}if(typeof b=='object'){b.flatten().each(function(e){if(typeof e=='object')a.appendChild(e);else if(Builder._isStringOrNumber(e))a.appendChild(Builder._text(e))})}else if(Builder._isStringOrNumber(b))a.appendChild(Builder._text(b))},_isStringOrNumber:function(a){return(typeof a=='string'||typeof a=='number')},build:function(a){var b=this.node('div');$(b).update(a.strip());return b.down()},dump:function(b){if(typeof b!='object'&&typeof b!='function')b=window;var c=("A ABBR ACRONYM ADDRESS APPLET AREA B BASE BASEFONT BDO BIG BLOCKQUOTE BODY "+"BR BUTTON CAPTION CENTER CITE CODE COL COLGROUP DD DEL DFN DIR DIV DL DT EM FIELDSET "+"FONT FORM FRAME FRAMESET H1 H2 H3 H4 H5 H6 HEAD HR HTML I IFRAME IMG INPUT INS ISINDEX "+"KBD LABEL LEGEND LI LINK MAP MENU META NOFRAMES NOSCRIPT OBJECT OL OPTGROUP OPTION P "+"PARAM PRE Q S SAMP SCRIPT SELECT SMALL SPAN STRIKE STRONG STYLE SUB SUP TABLE TBODY TD "+"TEXTAREA TFOOT TH THEAD TITLE TR TT U UL VAR").split(/\s+/);c.each(function(a){b[a]=function(){return Builder.node.apply(Builder,[a].concat($A(arguments)))}})}};

//effects.js

String.prototype.parseColor=function(){var a='#';if(this.slice(0,4)=='rgb('){var b=this.slice(4,this.length-1).split(',');var i=0;do{a+=parseInt(b[i]).toColorPart()}while(++i<3)}else{if(this.slice(0,1)=='#'){if(this.length==4)for(var i=1;i<4;i++)a+=(this.charAt(i)+this.charAt(i)).toLowerCase();if(this.length==7)a=this.toLowerCase()}}return(a.length==7?a:(arguments[0]||this))};Element.collectTextNodes=function(b){return $A($(b).childNodes).collect(function(a){return(a.nodeType==3?a.nodeValue:(a.hasChildNodes()?Element.collectTextNodes(a):''))}).flatten().join('')};Element.collectTextNodesIgnoreClass=function(b,c){return $A($(b).childNodes).collect(function(a){return(a.nodeType==3?a.nodeValue:((a.hasChildNodes()&&!Element.hasClassName(a,c))?Element.collectTextNodesIgnoreClass(a,c):''))}).flatten().join('')};Element.setContentZoom=function(a,b){a=$(a);a.setStyle({fontSize:(b/100)+'em'});if(Prototype.Browser.WebKit)window.scrollBy(0,0);return a};Element.getInlineOpacity=function(a){return $(a).style.opacity||''};Element.forceRerendering=function(a){try{a=$(a);var n=document.createTextNode(' ');a.appendChild(n);a.removeChild(n)}catch(e){}};var Effect={_elementDoesNotExistError:{name:'ElementDoesNotExistError',message:'The specified DOM element does not exist, but is required for this effect to operate'},Transitions:{linear:Prototype.K,sinoidal:function(a){return(-Math.cos(a*Math.PI)/2)+0.5},reverse:function(a){return 1-a},flicker:function(a){var a=((-Math.cos(a*Math.PI)/4)+0.75)+Math.random()/4;return a>1?1:a},wobble:function(a){return(-Math.cos(a*Math.PI*(9*a))/2)+0.5},pulse:function(a,b){b=b||5;return(((a%(1/b))*b).round()==0?((a*b*2)-(a*b*2).floor()):1-((a*b*2)-(a*b*2).floor()))},spring:function(a){return 1-(Math.cos(a*4.5*Math.PI)*Math.exp(-a*6))},none:function(a){return 0},full:function(a){return 1}},DefaultOptions:{duration:1.0,fps:100,sync:false,from:0.0,to:1.0,delay:0.0,queue:'parallel'},tagifyText:function(c){var d='position:relative';if(Prototype.Browser.IE)d+=';zoom:1';c=$(c);$A(c.childNodes).each(function(b){if(b.nodeType==3){b.nodeValue.toArray().each(function(a){c.insertBefore(new Element('span',{style:d}).update(a==' '?String.fromCharCode(160):a),b)});Element.remove(b)}})},multiple:function(c,d){var e;if(((typeof c=='object')||Object.isFunction(c))&&(c.length))e=c;else e=$(c).childNodes;var f=Object.extend({speed:0.1,delay:0.0},arguments[2]||{});var g=f.delay;$A(e).each(function(a,b){new d(a,Object.extend(f,{delay:b*f.speed+g}))})},PAIRS:{'slide':['SlideDown','SlideUp'],'blind':['BlindDown','BlindUp'],'appear':['Appear','Fade']},toggle:function(a,b){a=$(a);b=(b||'appear').toLowerCase();var c=Object.extend({queue:{position:'end',scope:(a.id||'global'),limit:1}},arguments[2]||{});Effect[a.visible()?Effect.PAIRS[b][1]:Effect.PAIRS[b][0]](a,c)}};Effect.DefaultOptions.transition=Effect.Transitions.sinoidal;Effect.ScopedQueue=Class.create(Enumerable,{initialize:function(){this.effects=[];this.interval=null},_each:function(a){this.effects._each(a)},add:function(a){var b=new Date().getTime();var c=Object.isString(a.options.queue)?a.options.queue:a.options.queue.position;switch(c){case'front':this.effects.findAll(function(e){return e.state=='idle'}).each(function(e){e.startOn+=a.finishOn;e.finishOn+=a.finishOn});break;case'with-last':b=this.effects.pluck('startOn').max()||b;break;case'end':b=this.effects.pluck('finishOn').max()||b;break}a.startOn+=b;a.finishOn+=b;if(!a.options.queue.limit||(this.effects.length<a.options.queue.limit))this.effects.push(a);if(!this.interval)this.interval=setInterval(this.loop.bind(this),15)},remove:function(a){this.effects=this.effects.reject(function(e){return e==a});if(this.effects.length==0){clearInterval(this.interval);this.interval=null}},loop:function(){var a=new Date().getTime();for(var i=0,len=this.effects.length;i<len;i++)this.effects[i]&&this.effects[i].loop(a)}});Effect.Queues={instances:$H(),get:function(a){if(!Object.isString(a))return a;return this.instances.get(a)||this.instances.set(a,new Effect.ScopedQueue())}};Effect.Queue=Effect.Queues.get('global');Effect.Base=Class.create({position:null,start:function(c){function codeForEvent(a,b){return((a[b+'Internal']?'this.options.'+b+'Internal(this);':'')+(a[b]?'this.options.'+b+'(this);':''))}if(c&&c.transition===false)c.transition=Effect.Transitions.linear;this.options=Object.extend(Object.extend({},Effect.DefaultOptions),c||{});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(this.options,'beforeSetup')+(this.setup?'this.setup();':'')+codeForEvent(this.options,'afterSetup')+'};if (this.state=="running"){'+'pos=this.options.transition(pos)*'+this.fromToDelta+'+'+this.options.from+';'+'this.position=pos;'+codeForEvent(this.options,'beforeUpdate')+(this.update?'this.update(pos);':'')+codeForEvent(this.options,'afterUpdate')+'}}');this.event('beforeStart');if(!this.options.sync)Effect.Queues.get(Object.isString(this.options.queue)?'global':this.options.queue.scope).add(this)},loop:function(a){if(a>=this.startOn){if(a>=this.finishOn){this.render(1.0);this.cancel();this.event('beforeFinish');if(this.finish)this.finish();this.event('afterFinish');return}var b=(a-this.startOn)/this.totalTime,frame=(b*this.totalFrames).round();if(frame>this.currentFrame){this.render(b);this.currentFrame=frame}}},cancel:function(){if(!this.options.sync)Effect.Queues.get(Object.isString(this.options.queue)?'global':this.options.queue.scope).remove(this);this.state='finished'},event:function(a){if(this.options[a+'Internal'])this.options[a+'Internal'](this);if(this.options[a])this.options[a](this)},inspect:function(){var a=$H();for(property in this)if(!Object.isFunction(this[property]))a.set(property,this[property]);return'#<Effect:'+a.inspect()+',options:'+$H(this.options).inspect()+'>'}});Effect.Parallel=Class.create(Effect.Base,{initialize:function(a){this.effects=a||[];this.start(arguments[1])},update:function(a){this.effects.invoke('render',a)},finish:function(b){this.effects.each(function(a){a.render(1.0);a.cancel();a.event('beforeFinish');if(a.finish)a.finish(b);a.event('afterFinish')})}});Effect.Tween=Class.create(Effect.Base,{initialize:function(b,c,d){b=Object.isString(b)?$(b):b;var e=$A(arguments),method=e.last(),options=e.length==5?e[3]:null;this.method=Object.isFunction(method)?method.bind(b):Object.isFunction(b[method])?b[method].bind(b):function(a){b[method]=a};this.start(Object.extend({from:c,to:d},options||{}))},update:function(a){this.method(a)}});Effect.Event=Class.create(Effect.Base,{initialize:function(){this.start(Object.extend({duration:0},arguments[0]||{}))},update:Prototype.emptyFunction});Effect.Opacity=Class.create(Effect.Base,{initialize:function(a){this.element=$(a);if(!this.element)throw(Effect._elementDoesNotExistError);if(Prototype.Browser.IE&&(!this.element.currentStyle.hasLayout))this.element.setStyle({zoom:1});var b=Object.extend({from:this.element.getOpacity()||0.0,to:1.0},arguments[1]||{});this.start(b)},update:function(a){this.element.setOpacity(a)}});Effect.Move=Class.create(Effect.Base,{initialize:function(a){this.element=$(a);if(!this.element)throw(Effect._elementDoesNotExistError);var b=Object.extend({x:0,y:0,mode:'relative'},arguments[1]||{});this.start(b)},setup:function(){this.element.makePositioned();this.originalLeft=parseFloat(this.element.getStyle('left')||'0');this.originalTop=parseFloat(this.element.getStyle('top')||'0');if(this.options.mode=='absolute'){this.options.x=this.options.x-this.originalLeft;this.options.y=this.options.y-this.originalTop}},update:function(a){this.element.setStyle({left:(this.options.x*a+this.originalLeft).round()+'px',top:(this.options.y*a+this.originalTop).round()+'px'})}});Effect.MoveBy=function(a,b,c){return new Effect.Move(a,Object.extend({x:c,y:b},arguments[3]||{}))};Effect.Scale=Class.create(Effect.Base,{initialize:function(a,b){this.element=$(a);if(!this.element)throw(Effect._elementDoesNotExistError);var c=Object.extend({scaleX:true,scaleY:true,scaleContent:true,scaleFromCenter:false,scaleMode:'box',scaleFrom:100.0,scaleTo:b},arguments[2]||{});this.start(c)},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 b=this.element.getStyle('font-size')||'100%';['em','px','%','pt'].each(function(a){if(b.indexOf(a)>0){this.fontSize=parseFloat(b);this.fontSizeType=a}}.bind(this));this.factor=(this.options.scaleTo-this.options.scaleFrom)/100;this.dims=null;if(this.options.scaleMode=='box')this.dims=[this.element.offsetHeight,this.element.offsetWidth];if(/^content/.test(this.options.scaleMode))this.dims=[this.element.scrollHeight,this.element.scrollWidth];if(!this.dims)this.dims=[this.options.scaleMode.originalHeight,this.options.scaleMode.originalWidth]},update:function(a){var b=(this.options.scaleFrom/100.0)+(this.factor*a);if(this.options.scaleContent&&this.fontSize)this.element.setStyle({fontSize:this.fontSize*b+this.fontSizeType});this.setDimensions(this.dims[0]*b,this.dims[1]*b)},finish:function(a){if(this.restoreAfterFinish)this.element.setStyle(this.originalStyle)},setDimensions:function(a,b){var d={};if(this.options.scaleX)d.width=b.round()+'px';if(this.options.scaleY)d.height=a.round()+'px';if(this.options.scaleFromCenter){var c=(a-this.dims[0])/2;var e=(b-this.dims[1])/2;if(this.elementPositioning=='absolute'){if(this.options.scaleY)d.top=this.originalTop-c+'px';if(this.options.scaleX)d.left=this.originalLeft-e+'px'}else{if(this.options.scaleY)d.top=-c+'px';if(this.options.scaleX)d.left=-e+'px'}}this.element.setStyle(d)}});Effect.Highlight=Class.create(Effect.Base,{initialize:function(a){this.element=$(a);if(!this.element)throw(Effect._elementDoesNotExistError);var b=Object.extend({startcolor:'#ffff99'},arguments[1]||{});this.start(b)},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(a){this.element.setStyle({backgroundColor:$R(0,2).inject('#',function(m,v,i){return m+((this._base[i]+(this._delta[i]*a)).round().toColorPart())}.bind(this))})},finish:function(){this.element.setStyle(Object.extend(this.oldStyle,{backgroundColor:this.options.restorecolor}))}});Effect.ScrollTo=function(a){var b=arguments[1]||{},scrollOffsets=document.viewport.getScrollOffsets(),elementOffsets=$(a).cumulativeOffset(),max=document.viewport.getScrollOffsets[0]-document.viewport.getHeight();if(b.offset)elementOffsets[1]+=b.offset;return new Effect.Tween(null,scrollOffsets.top,elementOffsets[1]>max?max:elementOffsets[1],b,function(p){scrollTo(scrollOffsets.left,p.round())})};Effect.Fade=function(b){b=$(b);var c=b.getInlineOpacity();var d=Object.extend({from:b.getOpacity()||1.0,to:0.0,afterFinishInternal:function(a){if(a.options.to!=0)return;a.element.hide().setStyle({opacity:c})}},arguments[1]||{});return new Effect.Opacity(b,d)};Effect.Appear=function(b){b=$(b);var c=Object.extend({from:(b.getStyle('display')=='none'?0.0:b.getOpacity()||0.0),to:1.0,afterFinishInternal:function(a){a.element.forceRerendering()},beforeSetup:function(a){a.element.setOpacity(a.options.from).show()}},arguments[1]||{});return new Effect.Opacity(b,c)};Effect.Puff=function(b){b=$(b);var c={opacity:b.getInlineOpacity(),position:b.getStyle('position'),top:b.style.top,left:b.style.left,width:b.style.width,height:b.style.height};return new Effect.Parallel([new Effect.Scale(b,200,{sync:true,scaleFromCenter:true,scaleContent:true,restoreAfterFinish:true}),new Effect.Opacity(b,{sync:true,to:0.0})],Object.extend({duration:1.0,beforeSetupInternal:function(a){Position.absolutize(a.effects[0].element)},afterFinishInternal:function(a){a.effects[0].element.hide().setStyle(c)}},arguments[1]||{}))};Effect.BlindUp=function(b){b=$(b);b.makeClipping();return new Effect.Scale(b,0,Object.extend({scaleContent:false,scaleX:false,restoreAfterFinish:true,afterFinishInternal:function(a){a.element.hide().undoClipping()}},arguments[1]||{}))};Effect.BlindDown=function(b){b=$(b);var c=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:0,scaleMode:{originalHeight:c.height,originalWidth:c.width},restoreAfterFinish:true,afterSetup:function(a){a.element.makeClipping().setStyle({height:'0px'}).show()},afterFinishInternal:function(a){a.element.undoClipping()}},arguments[1]||{}))};Effect.SwitchOff=function(c){c=$(c);var d=c.getInlineOpacity();return new Effect.Appear(c,Object.extend({duration:0.4,from:0,transition:Effect.Transitions.flicker,afterFinishInternal:function(b){new Effect.Scale(b.element,1,{duration:0.3,scaleFromCenter:true,scaleX:false,scaleContent:false,restoreAfterFinish:true,beforeSetup:function(a){a.element.makePositioned().makeClipping()},afterFinishInternal:function(a){a.element.hide().undoClipping().undoPositioned().setStyle({opacity:d})}})}},arguments[1]||{}))};Effect.DropOut=function(b){b=$(b);var c={top:b.getStyle('top'),left:b.getStyle('left'),opacity:b.getInlineOpacity()};return new Effect.Parallel([new Effect.Move(b,{x:0,y:100,sync:true}),new Effect.Opacity(b,{sync:true,to:0.0})],Object.extend({duration:0.5,beforeSetup:function(a){a.effects[0].element.makePositioned()},afterFinishInternal:function(a){a.effects[0].element.hide().undoPositioned().setStyle(c)}},arguments[1]||{}))};Effect.Shake=function(g){g=$(g);var h=Object.extend({distance:20,duration:0.5},arguments[1]||{});var i=parseFloat(h.distance);var j=parseFloat(h.duration)/10.0;var k={top:g.getStyle('top'),left:g.getStyle('left')};return new Effect.Move(g,{x:i,y:0,duration:j,afterFinishInternal:function(f){new Effect.Move(f.element,{x:-i*2,y:0,duration:j*2,afterFinishInternal:function(e){new Effect.Move(e.element,{x:i*2,y:0,duration:j*2,afterFinishInternal:function(d){new Effect.Move(d.element,{x:-i*2,y:0,duration:j*2,afterFinishInternal:function(c){new Effect.Move(c.element,{x:i*2,y:0,duration:j*2,afterFinishInternal:function(b){new Effect.Move(b.element,{x:-i,y:0,duration:j,afterFinishInternal:function(a){a.element.undoPositioned().setStyle(k)}})}})}})}})}})}})};Effect.SlideDown=function(b){b=$(b).cleanWhitespace();var c=b.down().getStyle('bottom');var d=b.getDimensions();return new Effect.Scale(b,100,Object.extend({scaleContent:false,scaleX:false,scaleFrom:window.opera?0:1,scaleMode:{originalHeight:d.height,originalWidth:d.width},restoreAfterFinish:true,afterSetup:function(a){a.element.makePositioned();a.element.down().makePositioned();if(window.opera)a.element.setStyle({top:''});a.element.makeClipping().setStyle({height:'0px'}).show()},afterUpdateInternal:function(a){a.element.down().setStyle({bottom:(a.dims[0]-a.element.clientHeight)+'px'})},afterFinishInternal:function(a){a.element.undoClipping().undoPositioned();a.element.down().undoPositioned().setStyle({bottom:c})}},arguments[1]||{}))};Effect.SlideUp=function(b){b=$(b).cleanWhitespace();var c=b.down().getStyle('bottom');var d=b.getDimensions();return new Effect.Scale(b,window.opera?0:1,Object.extend({scaleContent:false,scaleX:false,scaleMode:'box',scaleFrom:100,scaleMode:{originalHeight:d.height,originalWidth:d.width},restoreAfterFinish:true,afterSetup:function(a){a.element.makePositioned();a.element.down().makePositioned();if(window.opera)a.element.setStyle({top:''});a.element.makeClipping().show()},afterUpdateInternal:function(a){a.element.down().setStyle({bottom:(a.dims[0]-a.element.clientHeight)+'px'})},afterFinishInternal:function(a){a.element.hide().undoClipping().undoPositioned();a.element.down().undoPositioned().setStyle({bottom:c})}},arguments[1]||{}))};Effect.Squish=function(b){return new Effect.Scale(b,window.opera?1:0,{restoreAfterFinish:true,beforeSetup:function(a){a.element.makeClipping()},afterFinishInternal:function(a){a.element.hide().undoClipping()}})};Effect.Grow=function(c){c=$(c);var d=Object.extend({direction:'center',moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.full},arguments[1]||{});var e={top:c.style.top,left:c.style.left,height:c.style.height,width:c.style.width,opacity:c.getInlineOpacity()};var f=c.getDimensions();var g,initialMoveY;var h,moveY;switch(d.direction){case'top-left':g=initialMoveY=h=moveY=0;break;case'top-right':g=f.width;initialMoveY=moveY=0;h=-f.width;break;case'bottom-left':g=h=0;initialMoveY=f.height;moveY=-f.height;break;case'bottom-right':g=f.width;initialMoveY=f.height;h=-f.width;moveY=-f.height;break;case'center':g=f.width/2;initialMoveY=f.height/2;h=-f.width/2;moveY=-f.height/2;break}return new Effect.Move(c,{x:g,y:initialMoveY,duration:0.01,beforeSetup:function(a){a.element.hide().makeClipping().makePositioned()},afterFinishInternal:function(b){new Effect.Parallel([new Effect.Opacity(b.element,{sync:true,to:1.0,from:0.0,transition:d.opacityTransition}),new Effect.Move(b.element,{x:h,y:moveY,sync:true,transition:d.moveTransition}),new Effect.Scale(b.element,100,{scaleMode:{originalHeight:f.height,originalWidth:f.width},sync:true,scaleFrom:window.opera?1:0,transition:d.scaleTransition,restoreAfterFinish:true})],Object.extend({beforeSetup:function(a){a.effects[0].element.setStyle({height:'0px'}).show()},afterFinishInternal:function(a){a.effects[0].element.undoClipping().undoPositioned().setStyle(e)}},d))}})};Effect.Shrink=function(b){b=$(b);var c=Object.extend({direction:'center',moveTransition:Effect.Transitions.sinoidal,scaleTransition:Effect.Transitions.sinoidal,opacityTransition:Effect.Transitions.none},arguments[1]||{});var d={top:b.style.top,left:b.style.left,height:b.style.height,width:b.style.width,opacity:b.getInlineOpacity()};var e=b.getDimensions();var f,moveY;switch(c.direction){case'top-left':f=moveY=0;break;case'top-right':f=e.width;moveY=0;break;case'bottom-left':f=0;moveY=e.height;break;case'bottom-right':f=e.width;moveY=e.height;break;case'center':f=e.width/2;moveY=e.height/2;break}return new Effect.Parallel([new Effect.Opacity(b,{sync:true,to:0.0,from:1.0,transition:c.opacityTransition}),new Effect.Scale(b,window.opera?1:0,{sync:true,transition:c.scaleTransition,restoreAfterFinish:true}),new Effect.Move(b,{x:f,y:moveY,sync:true,transition:c.moveTransition})],Object.extend({beforeStartInternal:function(a){a.effects[0].element.makePositioned().makeClipping()},afterFinishInternal:function(a){a.effects[0].element.hide().undoClipping().undoPositioned().setStyle(d)}},c))};Effect.Pulsate=function(b){b=$(b);var c=arguments[1]||{};var d=b.getInlineOpacity();var e=c.transition||Effect.Transitions.sinoidal;var f=function(a){return e(1-Effect.Transitions.pulse(a,c.pulses))};f.bind(e);return new Effect.Opacity(b,Object.extend(Object.extend({duration:2.0,from:0,afterFinishInternal:function(a){a.element.setStyle({opacity:d})}},c),{transition:f}))};Effect.Fold=function(c){c=$(c);var d={top:c.style.top,left:c.style.left,width:c.style.width,height:c.style.height};c.makeClipping();return new Effect.Scale(c,5,Object.extend({scaleContent:false,scaleX:false,afterFinishInternal:function(b){new Effect.Scale(c,1,{scaleContent:false,scaleY:false,afterFinishInternal:function(a){a.element.hide().undoClipping().setStyle(d)}})}},arguments[1]||{}))};Effect.Morph=Class.create(Effect.Base,{initialize:function(c){this.element=$(c);if(!this.element)throw(Effect._elementDoesNotExistError);var d=Object.extend({style:{}},arguments[1]||{});if(!Object.isString(d.style))this.style=$H(d.style);else{if(d.style.include(':'))this.style=d.style.parseStyle();else{this.element.addClassName(d.style);this.style=$H(this.element.getStyles());this.element.removeClassName(d.style);var e=this.element.getStyles();this.style=this.style.reject(function(a){return a.value==e[a.key]});d.afterFinishInternal=function(b){b.element.addClassName(b.options.style);b.transforms.each(function(a){b.element.style[a.style]=''})}}}this.start(d)},setup:function(){function parseColor(a){if(!a||['rgba(0, 0, 0, 0)','transparent'].include(a))a='#ffffff';a=a.parseColor();return $R(0,2).map(function(i){return parseInt(a.slice(i*2+1,i*2+3),16)})}this.transforms=this.style.map(function(a){var b=a[0],value=a[1],unit=null;if(value.parseColor('#zzzzzz')!='#zzzzzz'){value=value.parseColor();unit='color'}else if(b=='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 c=value.match(/^([\+\-]?[0-9\.]+)(.*)$/);value=parseFloat(c[1]);unit=(c.length==3)?c[2]:null}var d=this.element.getStyle(b);return{style:b.camelize(),originalValue:unit=='color'?parseColor(d):parseFloat(d||0),targetValue:unit=='color'?parseColor(value):value,unit:unit}}.bind(this)).reject(function(a){return((a.originalValue==a.targetValue)||(a.unit!='color'&&(isNaN(a.originalValue)||isNaN(a.targetValue))))})},update:function(a){var b={},transform,i=this.transforms.length;while(i--)b[(transform=this.transforms[i]).style]=transform.unit=='color'?'#'+(Math.round(transform.originalValue[0]+(transform.targetValue[0]-transform.originalValue[0])*a)).toColorPart()+(Math.round(transform.originalValue[1]+(transform.targetValue[1]-transform.originalValue[1])*a)).toColorPart()+(Math.round(transform.originalValue[2]+(transform.targetValue[2]-transform.originalValue[2])*a)).toColorPart():(transform.originalValue+(transform.targetValue-transform.originalValue)*a).toFixed(3)+(transform.unit===null?'':transform.unit);this.element.setStyle(b,true)}});Effect.Transform=Class.create({initialize:function(a){this.tracks=[];this.options=arguments[1]||{};this.addTracks(a)},addTracks:function(c){c.each(function(a){a=$H(a);var b=a.values().first();this.tracks.push($H({ids:a.keys().first(),effect:Effect.Morph,options:{style:b}}))}.bind(this));return this},play:function(){return new Effect.Parallel(this.tracks.map(function(a){var b=a.get('ids'),effect=a.get('effect'),options=a.get('options');var c=[$(b)||$$(b)].flatten();return c.map(function(e){return new effect(e,Object.extend({sync:true},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.__parseStyleElement=document.createElement('div');String.prototype.parseStyle=function(){var b,styleRules=$H();if(Prototype.Browser.WebKit)b=new Element('div',{style:this}).style;else{String.__parseStyleElement.innerHTML='<div style="'+this+'"></div>';b=String.__parseStyleElement.childNodes[0].style}Element.CSS_PROPERTIES.each(function(a){if(b[a])styleRules.set(a,b[a])});if(Prototype.Browser.IE&&this.include('opacity'))styleRules.set('opacity',this.match(/opacity:\s*((?:0|1)?(?:\.\d*)?)/)[1]);return styleRules};if(document.defaultView&&document.defaultView.getComputedStyle){Element.getStyles=function(c){var d=document.defaultView.getComputedStyle($(c),null);return Element.CSS_PROPERTIES.inject({},function(a,b){a[b]=d[b];return a})}}else{Element.getStyles=function(c){c=$(c);var d=c.currentStyle,styles;styles=Element.CSS_PROPERTIES.inject({},function(a,b){a[b]=d[b];return a});if(!styles.opacity)styles.opacity=c.getOpacity();return styles}}Effect.Methods={morph:function(a,b){a=$(a);new Effect.Morph(a,Object.extend({style:b},arguments[2]||{}));return a},visualEffect:function(a,b,c){a=$(a);var s=b.dasherize().camelize(),klass=s.charAt(0).toUpperCase()+s.substring(1);new Effect[klass](a,c);return a},highlight:function(a,b){a=$(a);new Effect.Highlight(a,b);return a}};$w('fade appear grow shrink fold blindUp blindDown slideUp slideDown '+'pulsate shake puff squish switchOff dropOut').each(function(c){Effect.Methods[c]=function(a,b){a=$(a);Effect[c.charAt(0).toUpperCase()+c.substring(1)](a,b);return a}});$w('getInlineOpacity forceRerendering setContentZoom collectTextNodes collectTextNodesIgnoreClass getStyles').each(function(f){Effect.Methods[f]=Element[f]});Element.addMethods(Effect.Methods);

//dragdrop.js

if(Object.isUndefined(Effect))throw("dragdrop.js requires including script.aculo.us' effects.js library");var Droppables={drops:[],remove:function(a){this.drops=this.drops.reject(function(d){return d.element==$(a)})},add:function(a){a=$(a);var b=Object.extend({greedy:true,hoverclass:null,tree:false},arguments[1]||{});if(b.containment){b._containers=[];var d=b.containment;if(Object.isArray(d)){d.each(function(c){b._containers.push($(c))})}else{b._containers.push($(d))}}if(b.accept)b.accept=[b.accept].flatten();Element.makePositioned(a);b.element=a;this.drops.push(b)},findDeepestChild:function(a){deepest=a[0];for(i=1;i<a.length;++i)if(Element.isParent(a[i].element,deepest.element))deepest=a[i];return deepest},isContained:function(a,b){var d;if(b.tree){d=a.treeNode}else{d=a.parentNode}return b._containers.detect(function(c){return d==c})},isAffected:function(a,b,c){return((c.element!=b)&&((!c._containers)||this.isContained(b,c))&&((!c.accept)||(Element.classNames(b).detect(function(v){return c.accept.include(v)})))&&Position.within(c.element,a[0],a[1]))},deactivate:function(a){if(a.hoverclass)Element.removeClassName(a.element,a.hoverclass);this.last_active=null},activate:function(a){if(a.hoverclass)Element.addClassName(a.element,a.hoverclass);this.last_active=a},show:function(b,c){if(!this.drops.length)return;var d,affected=[];this.drops.each(function(a){if(Droppables.isAffected(b,c,a))affected.push(a)});if(affected.length>0)d=Droppables.findDeepestChild(affected);if(this.last_active&&this.last_active!=d)this.deactivate(this.last_active);if(d){Position.within(d.element,b[0],b[1]);if(d.onHover)d.onHover(c,d.element,Position.overlap(d.overlap,d.element));if(d!=this.last_active)Droppables.activate(d)}},fire:function(a,b){if(!this.last_active)return;Position.prepare();if(this.isAffected([Event.pointerX(a),Event.pointerY(a)],b,this.last_active))if(this.last_active.onDrop){this.last_active.onDrop(b,this.last_active.element,a);return true}},reset:function(){if(this.last_active)this.deactivate(this.last_active)}};var Draggables={drags:[],observers:[],register:function(a){if(this.drags.length==0){this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.updateDrag.bindAsEventListener(this);this.eventKeypress=this.keyPress.bindAsEventListener(this);Event.observe(document,"mouseup",this.eventMouseUp);Event.observe(document,"mousemove",this.eventMouseMove);Event.observe(document,"keypress",this.eventKeypress)}this.drags.push(a)},unregister:function(a){this.drags=this.drags.reject(function(d){return d==a});if(this.drags.length==0){Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);Event.stopObserving(document,"keypress",this.eventKeypress)}},activate:function(a){if(a.options.delay){this._timeout=setTimeout(function(){Draggables._timeout=null;window.focus();Draggables.activeDraggable=a}.bind(this),a.options.delay)}else{window.focus();this.activeDraggable=a}},deactivate:function(){this.activeDraggable=null},updateDrag:function(a){if(!this.activeDraggable)return;var b=[Event.pointerX(a),Event.pointerY(a)];if(this._lastPointer&&(this._lastPointer.inspect()==b.inspect()))return;this._lastPointer=b;this.activeDraggable.updateDrag(a,b)},endDrag:function(a){if(this._timeout){clearTimeout(this._timeout);this._timeout=null}if(!this.activeDraggable)return;this._lastPointer=null;this.activeDraggable.endDrag(a);this.activeDraggable=null},keyPress:function(a){if(this.activeDraggable)this.activeDraggable.keyPress(a)},addObserver:function(a){this.observers.push(a);this._cacheObserverCallbacks()},removeObserver:function(a){this.observers=this.observers.reject(function(o){return o.element==a});this._cacheObserverCallbacks()},notify:function(a,b,c){if(this[a+'Count']>0)this.observers.each(function(o){if(o[a])o[a](a,b,c)});if(b.options[a])b.options[a](b,c)},_cacheObserverCallbacks:function(){['onStart','onEnd','onDrag'].each(function(a){Draggables[a+'Count']=Draggables.observers.select(function(o){return o[a]}).length})}};var Draggable=Class.create({initialize:function(e){var f={handle:false,reverteffect:function(a,b,c){var d=Math.sqrt(Math.abs(b^2)+Math.abs(c^2))*0.02;new Effect.Move(a,{x:-c,y:-b,duration:d,queue:{scope:'_draggable',position:'end'}})},endeffect:function(a){var b=Object.isNumber(a._opacity)?a._opacity:1.0;new Effect.Opacity(a,{duration:0.2,from:0.7,to:b,queue:{scope:'_draggable',position:'end'},afterFinish:function(){Draggable._dragging[a]=false}})},zindex:1000,revert:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,snap:false,delay:0};if(!arguments[1]||Object.isUndefined(arguments[1].endeffect))Object.extend(f,{starteffect:function(a){a._opacity=Element.getOpacity(a);Draggable._dragging[a]=true;new Effect.Opacity(a,{duration:0.2,from:a._opacity,to:0.7})}});var g=Object.extend(f,arguments[1]||{});this.element=$(e);if(g.handle&&Object.isString(g.handle))this.handle=this.element.down('.'+g.handle,0);if(!this.handle)this.handle=$(g.handle);if(!this.handle)this.handle=this.element;if(g.scroll&&!g.scroll.scrollTo&&!g.scroll.outerHTML){g.scroll=$(g.scroll);this._isScrollChild=Element.childOf(this.element,g.scroll)}Element.makePositioned(this.element);this.options=g;this.dragging=false;this.eventMouseDown=this.initDrag.bindAsEventListener(this);Event.observe(this.handle,"mousedown",this.eventMouseDown);Draggables.register(this)},destroy:function(){Event.stopObserving(this.handle,"mousedown",this.eventMouseDown);Draggables.unregister(this)},currentDelta:function(){return([parseInt(Element.getStyle(this.element,'left')||'0'),parseInt(Element.getStyle(this.element,'top')||'0')])},initDrag:function(a){if(!Object.isUndefined(Draggable._dragging[this.element])&&Draggable._dragging[this.element])return;if(Event.isLeftClick(a)){var b=Event.element(a);if((tag_name=b.tagName.toUpperCase())&&(tag_name=='INPUT'||tag_name=='SELECT'||tag_name=='OPTION'||tag_name=='BUTTON'||tag_name=='TEXTAREA'))return;var c=[Event.pointerX(a),Event.pointerY(a)];var d=Position.cumulativeOffset(this.element);this.offset=[0,1].map(function(i){return(c[i]-d[i])});Draggables.activate(this);Event.stop(a)}},startDrag:function(a){this.dragging=true;if(!this.delta)this.delta=this.currentDelta();if(this.options.zindex){this.originalZ=parseInt(Element.getStyle(this.element,'z-index')||0);this.element.style.zIndex=this.options.zindex}if(this.options.ghosting){this._clone=this.element.cloneNode(true);this._originallyAbsolute=(this.element.getStyle('position')=='absolute');if(!this._originallyAbsolute)Position.absolutize(this.element);this.element.parentNode.insertBefore(this._clone,this.element)}if(this.options.scroll){if(this.options.scroll==window){var b=this._getWindowScroll(this.options.scroll);this.originalScrollLeft=b.left;this.originalScrollTop=b.top}else{this.originalScrollLeft=this.options.scroll.scrollLeft;this.originalScrollTop=this.options.scroll.scrollTop}}Draggables.notify('onStart',this,a);if(this.options.starteffect)this.options.starteffect(this.element)},updateDrag:function(a,b){if(!this.dragging)this.startDrag(a);if(!this.options.quiet){Position.prepare();Droppables.show(b,this.element)}Draggables.notify('onDrag',this,a);this.draw(b);if(this.options.change)this.options.change(this);if(this.options.scroll){this.stopScrolling();var p;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){p=[left,top,left+width,top+height]}}else{p=Position.page(this.options.scroll);p[0]+=this.options.scroll.scrollLeft+Position.deltaX;p[1]+=this.options.scroll.scrollTop+Position.deltaY;p.push(p[0]+this.options.scroll.offsetWidth);p.push(p[1]+this.options.scroll.offsetHeight)}var c=[0,0];if(b[0]<(p[0]+this.options.scrollSensitivity))c[0]=b[0]-(p[0]+this.options.scrollSensitivity);if(b[1]<(p[1]+this.options.scrollSensitivity))c[1]=b[1]-(p[1]+this.options.scrollSensitivity);if(b[0]>(p[2]-this.options.scrollSensitivity))c[0]=b[0]-(p[2]-this.options.scrollSensitivity);if(b[1]>(p[3]-this.options.scrollSensitivity))c[1]=b[1]-(p[3]-this.options.scrollSensitivity);this.startScrolling(c)}if(Prototype.Browser.WebKit)window.scrollBy(0,0);Event.stop(a)},finishDrag:function(a,b){this.dragging=false;if(this.options.quiet){Position.prepare();var c=[Event.pointerX(a),Event.pointerY(a)];Droppables.show(c,this.element)}if(this.options.ghosting){if(!this._originallyAbsolute)Position.relativize(this.element);delete this._originallyAbsolute;Element.remove(this._clone);this._clone=null}var e=false;if(b){e=Droppables.fire(a,this.element);if(!e)e=false}if(e&&this.options.onDropped)this.options.onDropped(this.element);Draggables.notify('onEnd',this,a);var f=this.options.revert;if(f&&Object.isFunction(f))f=f(this.element);var d=this.currentDelta();if(f&&this.options.reverteffect){if(e==0||f!='failure')this.options.reverteffect(this.element,d[1]-this.delta[1],d[0]-this.delta[0])}else{this.delta=d}if(this.options.zindex)this.element.style.zIndex=this.originalZ;if(this.options.endeffect)this.options.endeffect(this.element);Draggables.deactivate(this);Droppables.reset()},keyPress:function(a){if(a.keyCode!=Event.KEY_ESC)return;this.finishDrag(a,false);Event.stop(a)},endDrag:function(a){if(!this.dragging)return;this.stopScrolling();this.finishDrag(a,true);Event.stop(a)},draw:function(a){var b=Position.cumulativeOffset(this.element);if(this.options.ghosting){var r=Position.realOffset(this.element);b[0]+=r[0]-Position.deltaX;b[1]+=r[1]-Position.deltaY}var d=this.currentDelta();b[0]-=d[0];b[1]-=d[1];if(this.options.scroll&&(this.options.scroll!=window&&this._isScrollChild)){b[0]-=this.options.scroll.scrollLeft-this.originalScrollLeft;b[1]-=this.options.scroll.scrollTop-this.originalScrollTop}var p=[0,1].map(function(i){return(a[i]-b[i]-this.offset[i])}.bind(this));if(this.options.snap){if(Object.isFunction(this.options.snap)){p=this.options.snap(p[0],p[1],this)}else{if(Object.isArray(this.options.snap)){p=p.map(function(v,i){return(v/this.options.snap[i]).round()*this.options.snap[i]}.bind(this))}else{p=p.map(function(v){return(v/this.options.snap).round()*this.options.snap}.bind(this))}}}var c=this.element.style;if((!this.options.constraint)||(this.options.constraint=='horizontal'))c.left=p[0]+"px";if((!this.options.constraint)||(this.options.constraint=='vertical'))c.top=p[1]+"px";if(c.visibility=="hidden")c.visibility=""},stopScrolling:function(){if(this.scrollInterval){clearInterval(this.scrollInterval);this.scrollInterval=null;Draggables._lastScrollPointer=null}},startScrolling:function(a){if(!(a[0]||a[1]))return;this.scrollSpeed=[a[0]*this.options.scrollSpeed,a[1]*this.options.scrollSpeed];this.lastScrolled=new Date();this.scrollInterval=setInterval(this.scroll.bind(this),10)},scroll:function(){var a=new Date();var b=a-this.lastScrolled;this.lastScrolled=a;if(this.options.scroll==window){with(this._getWindowScroll(this.options.scroll)){if(this.scrollSpeed[0]||this.scrollSpeed[1]){var d=b/1000;this.options.scroll.scrollTo(left+d*this.scrollSpeed[0],top+d*this.scrollSpeed[1])}}}else{this.options.scroll.scrollLeft+=this.scrollSpeed[0]*b/1000;this.options.scroll.scrollTop+=this.scrollSpeed[1]*b/1000}Position.prepare();Droppables.show(Draggables._lastPointer,this.element);Draggables.notify('onDrag',this);if(this._isScrollChild){Draggables._lastScrollPointer=Draggables._lastScrollPointer||$A(Draggables._lastPointer);Draggables._lastScrollPointer[0]+=this.scrollSpeed[0]*b/1000;Draggables._lastScrollPointer[1]+=this.scrollSpeed[1]*b/1000;if(Draggables._lastScrollPointer[0]<0)Draggables._lastScrollPointer[0]=0;if(Draggables._lastScrollPointer[1]<0)Draggables._lastScrollPointer[1]=0;this.draw(Draggables._lastScrollPointer)}if(this.options.change)this.options.change(this)},_getWindowScroll:function(w){var T,L,W,H;with(w.document){if(w.document.documentElement&&documentElement.scrollTop){T=documentElement.scrollTop;L=documentElement.scrollLeft}else if(w.document.body){T=body.scrollTop;L=body.scrollLeft}if(w.innerWidth){W=w.innerWidth;H=w.innerHeight}else if(w.document.documentElement&&documentElement.clientWidth){W=documentElement.clientWidth;H=documentElement.clientHeight}else{W=body.offsetWidth;H=body.offsetHeight}}return{top:T,left:L,width:W,height:H}}});Draggable._dragging={};var SortableObserver=Class.create({initialize:function(a,b){this.element=$(a);this.observer=b;this.lastValue=Sortable.serialize(this.element)},onStart:function(){this.lastValue=Sortable.serialize(this.element)},onEnd:function(){Sortable.unmark();if(this.lastValue!=Sortable.serialize(this.element))this.observer(this.element)}});var Sortable={SERIALIZE_RULE:/^[^_\-](?:[A-Za-z0-9\-\_]*)[_](.*)$/,sortables:{},_findRootElement:function(a){while(a.tagName.toUpperCase()!="BODY"){if(a.id&&Sortable.sortables[a.id])return a;a=a.parentNode}},options:function(a){a=Sortable._findRootElement($(a));if(!a)return;return Sortable.sortables[a.id]},destroy:function(a){var s=Sortable.options(a);if(s){Draggables.removeObserver(s.element);s.droppables.each(function(d){Droppables.remove(d)});s.draggables.invoke('destroy');delete Sortable.sortables[s.element.id]}},create:function(b){b=$(b);var c=Object.extend({element:b,tag:'li',dropOnEmpty:false,tree:false,treeTag:'ul',overlap:'vertical',constraint:'vertical',containment:b,handle:false,only:false,delay:0,hoverclass:null,ghosting:false,quiet:false,scroll:false,scrollSensitivity:20,scrollSpeed:15,format:this.SERIALIZE_RULE,elements:false,handles:false,onChange:Prototype.emptyFunction,onUpdate:Prototype.emptyFunction},arguments[1]||{});this.destroy(b);var d={revert:true,quiet:c.quiet,scroll:c.scroll,scrollSpeed:c.scrollSpeed,scrollSensitivity:c.scrollSensitivity,delay:c.delay,ghosting:c.ghosting,constraint:c.constraint,handle:c.handle};if(c.starteffect)d.starteffect=c.starteffect;if(c.reverteffect)d.reverteffect=c.reverteffect;else if(c.ghosting)d.reverteffect=function(a){a.style.top=0;a.style.left=0};if(c.endeffect)d.endeffect=c.endeffect;if(c.zindex)d.zindex=c.zindex;var f={overlap:c.overlap,containment:c.containment,tree:c.tree,hoverclass:c.hoverclass,onHover:Sortable.onHover};var g={onHover:Sortable.onEmptyHover,overlap:c.overlap,containment:c.containment,hoverclass:c.hoverclass};Element.cleanWhitespace(b);c.draggables=[];c.droppables=[];if(c.dropOnEmpty||c.tree){Droppables.add(b,g);c.droppables.push(b)}(c.elements||this.findElements(b,c)||[]).each(function(e,i){var a=c.handles?$(c.handles[i]):(c.handle?$(e).select('.'+c.handle)[0]:e);c.draggables.push(new Draggable(e,Object.extend(d,{handle:a})));Droppables.add(e,f);if(c.tree)e.treeNode=b;c.droppables.push(e)});if(c.tree){(Sortable.findTreeElements(b,c)||[]).each(function(e){Droppables.add(e,g);e.treeNode=b;c.droppables.push(e)})}this.sortables[b.id]=c;Draggables.addObserver(new SortableObserver(b,c.onUpdate))},findElements:function(a,b){return Element.findChildren(a,b.only,b.tree?true:false,b.tag)},findTreeElements:function(a,b){return Element.findChildren(a,b.only,b.tree?true:false,b.treeTag)},onHover:function(a,b,c){if(Element.isParent(b,a))return;if(c>.33&&c<.66&&Sortable.options(b).tree){return}else if(c>0.5){Sortable.mark(b,'before');if(b.previousSibling!=a){var d=a.parentNode;a.style.visibility="hidden";b.parentNode.insertBefore(a,b);if(b.parentNode!=d)Sortable.options(d).onChange(a);Sortable.options(b.parentNode).onChange(a)}}else{Sortable.mark(b,'after');var e=b.nextSibling||null;if(e!=a){var d=a.parentNode;a.style.visibility="hidden";b.parentNode.insertBefore(a,e);if(b.parentNode!=d)Sortable.options(d).onChange(a);Sortable.options(b.parentNode).onChange(a)}}},onEmptyHover:function(a,b,c){var d=a.parentNode;var e=Sortable.options(b);if(!Element.isParent(b,a)){var f;var g=Sortable.findElements(b,{tag:e.tag,only:e.only});var h=null;if(g){var i=Element.offsetSize(b,e.overlap)*(1.0-c);for(f=0;f<g.length;f+=1){if(i-Element.offsetSize(g[f],e.overlap)>=0){i-=Element.offsetSize(g[f],e.overlap)}else if(i-(Element.offsetSize(g[f],e.overlap)/2)>=0){h=f+1<g.length?g[f+1]:null;break}else{h=g[f];break}}}b.insertBefore(a,h);Sortable.options(d).onChange(a);e.onChange(a)}},unmark:function(){if(Sortable._marker)Sortable._marker.hide()},mark:function(a,b){var c=Sortable.options(a.parentNode);if(c&&!c.ghosting)return;if(!Sortable._marker){Sortable._marker=($('dropmarker')||Element.extend(document.createElement('DIV'))).hide().addClassName('dropmarker').setStyle({position:'absolute'});document.getElementsByTagName("body").item(0).appendChild(Sortable._marker)}var d=Position.cumulativeOffset(a);Sortable._marker.setStyle({left:d[0]+'px',top:d[1]+'px'});if(b=='after')if(c.overlap=='horizontal')Sortable._marker.setStyle({left:(d[0]+a.clientWidth)+'px'});else Sortable._marker.setStyle({top:(d[1]+a.clientHeight)+'px'});Sortable._marker.show()},_tree:function(a,b,c){var d=Sortable.findElements(a,b)||[];for(var i=0;i<d.length;++i){var e=d[i].id.match(b.format);if(!e)continue;var f={id:encodeURIComponent(e?e[1]:null),element:a,parent:c,children:[],position:c.children.length,container:$(d[i]).down(b.treeTag)};if(f.container)this._tree(f.container,b,f);c.children.push(f)}return c},tree:function(a){a=$(a);var b=this.options(a);var c=Object.extend({tag:b.tag,treeTag:b.treeTag,only:b.only,name:a.id,format:b.format},arguments[1]||{});var d={id:null,parent:null,children:[],container:a,position:0};return Sortable._tree(a,c,d)},_constructIndex:function(a){var b='';do{if(a.id)b='['+a.position+']'+b}while((a=a.parent)!=null);return b},sequence:function(b){b=$(b);var c=Object.extend(this.options(b),arguments[1]||{});return $(this.findElements(b,c)||[]).map(function(a){return a.id.match(c.format)?a.id.match(c.format)[1]:''})},setSequence:function(b,c){b=$(b);var d=Object.extend(this.options(b),arguments[2]||{});var e={};this.findElements(b,d).each(function(n){if(n.id.match(d.format))e[n.id.match(d.format)[1]]=[n,n.parentNode];n.parentNode.removeChild(n)});c.each(function(a){var n=e[a];if(n){n[1].appendChild(n[0]);delete e[a]}})},serialize:function(b){b=$(b);var c=Object.extend(Sortable.options(b),arguments[1]||{});var d=encodeURIComponent((arguments[1]&&arguments[1].name)?arguments[1].name:b.id);if(c.tree){return Sortable.tree(b,arguments[1]).children.map(function(a){return[d+Sortable._constructIndex(a)+"[id]="+encodeURIComponent(a.id)].concat(a.children.map(arguments.callee))}).flatten().join('&')}else{return Sortable.sequence(b,arguments[1]).map(function(a){return d+"[]="+encodeURIComponent(a)}).join('&')}}};Element.isParent=function(a,b){if(!a.parentNode||a==b)return false;if(a.parentNode==b)return true;return Element.isParent(a.parentNode,b)};Element.findChildren=function(b,c,d,f){if(!b.hasChildNodes())return null;f=f.toUpperCase();if(c)c=[c].flatten();var g=[];$A(b.childNodes).each(function(e){if(e.tagName&&e.tagName.toUpperCase()==f&&(!c||(Element.classNames(e).detect(function(v){return c.include(v)}))))g.push(e);if(d){var a=Element.findChildren(e,c,d,f);if(a)g.push(a)}});return(g.length>0?g.flatten():[])};Element.offsetSize=function(a,b){return a['offset'+((b=='vertical'||b=='height')?'Height':'Width')]};

//controls.js

if(typeof Effect=='undefined')throw("controls.js requires including script.aculo.us' effects.js library");var Autocompleter={};Autocompleter.Base=Class.create({baseInitialize:function(c,d,e){c=$(c);this.element=c;this.update=$(d);this.hasFocus=false;this.changed=false;this.active=false;this.index=0;this.entryCount=0;this.oldElementValue=this.element.value;if(this.setOptions)this.setOptions(e);else this.options=e||{};this.options.paramName=this.options.paramName||this.element.name;this.options.tokens=this.options.tokens||[];this.options.frequency=this.options.frequency||0.4;this.options.minChars=this.options.minChars||1;this.options.onShow=this.options.onShow||function(a,b){if(!b.style.position||b.style.position=='absolute'){b.style.position='absolute';Position.clone(a,b,{setHeight:false,offsetTop:a.offsetHeight})}Effect.Appear(b,{duration:0.15})};this.options.onHide=this.options.onHide||function(a,b){new Effect.Fade(b,{duration:0.15})};if(typeof(this.options.tokens)=='string')this.options.tokens=new Array(this.options.tokens);if(!this.options.tokens.include('\n'))this.options.tokens.push('\n');this.observer=null;this.element.setAttribute('autocomplete','off');Element.hide(this.update);Event.observe(this.element,'blur',this.onBlur.bindAsEventListener(this));Event.observe(this.element,'keydown',this.onKeyPress.bindAsEventListener(this))},show:function(){if(Element.getStyle(this.update,'display')=='none')this.options.onShow(this.element,this.update);if(!this.iefix&&(Prototype.Browser.IE)&&(Element.getStyle(this.update,'position')=='absolute')){new Insertion.After(this.update,'<iframe id="'+this.update.id+'_iefix" '+'style="display:none;position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);" '+'src="javascript:false;" frameborder="0" scrolling="no"></iframe>');this.iefix=$(this.update.id+'_iefix')}if(this.iefix)setTimeout(this.fixIEOverlapping.bind(this),50)},fixIEOverlapping:function(){Position.clone(this.update,this.iefix,{setTop:(!this.update.style.height)});this.iefix.style.zIndex=1;this.update.style.zIndex=2;Element.show(this.iefix)},hide:function(){this.stopIndicator();if(Element.getStyle(this.update,'display')!='none')this.options.onHide(this.element,this.update);if(this.iefix)Element.hide(this.iefix)},startIndicator:function(){if(this.options.indicator)Element.show(this.options.indicator)},stopIndicator:function(){if(this.options.indicator)Element.hide(this.options.indicator)},onKeyPress:function(a){if(this.active)switch(a.keyCode){case Event.KEY_TAB:case Event.KEY_RETURN:this.selectEntry();Event.stop(a);case Event.KEY_ESC:this.hide();this.active=false;Event.stop(a);return;case Event.KEY_LEFT:case Event.KEY_RIGHT:return;case Event.KEY_UP:this.markPrevious();this.render();Event.stop(a);return;case Event.KEY_DOWN:this.markNext();this.render();Event.stop(a);return}else if(a.keyCode==Event.KEY_TAB||a.keyCode==Event.KEY_RETURN||(Prototype.Browser.WebKit>0&&a.keyCode==0))return;this.changed=true;this.hasFocus=true;if(this.observer)clearTimeout(this.observer);this.observer=setTimeout(this.onObserverEvent.bind(this),this.options.frequency*1000)},activate:function(){this.changed=false;this.hasFocus=true;this.getUpdatedChoices()},onHover:function(a){var b=Event.findElement(a,'LI');if(this.index!=b.autocompleteIndex){this.index=b.autocompleteIndex;this.render()}Event.stop(a)},onClick:function(a){var b=Event.findElement(a,'LI');this.index=b.autocompleteIndex;this.selectEntry();this.hide()},onBlur:function(a){setTimeout(this.hide.bind(this),250);this.hasFocus=false;this.active=false},render:function(){if(this.entryCount>0){for(var i=0;i<this.entryCount;i++)this.index==i?Element.addClassName(this.getEntry(i),"selected"):Element.removeClassName(this.getEntry(i),"selected");if(this.hasFocus){this.show();this.active=true}}else{this.active=false;this.hide()}},markPrevious:function(){if(this.index>0)this.index--;else this.index=this.entryCount-1;this.getEntry(this.index).scrollIntoView(true)},markNext:function(){if(this.index<this.entryCount-1)this.index++;else this.index=0;this.getEntry(this.index).scrollIntoView(false)},getEntry:function(a){return this.update.firstChild.childNodes[a]},getCurrentEntry:function(){return this.getEntry(this.index)},selectEntry:function(){this.active=false;this.updateElement(this.getCurrentEntry())},updateElement:function(a){if(this.options.updateElement){this.options.updateElement(a);return}var b='';if(this.options.select){var c=$(a).select('.'+this.options.select)||[];if(c.length>0)b=Element.collectTextNodes(c[0],this.options.select)}else b=Element.collectTextNodesIgnoreClass(a,'informal');var d=this.getTokenBounds();if(d[0]!=-1){var e=this.element.value.substr(0,d[0]);var f=this.element.value.substr(d[0]).match(/^\s+/);if(f)e+=f[0];this.element.value=e+b+this.element.value.substr(d[1])}else{this.element.value=b}this.oldElementValue=this.element.value;this.element.focus();if(this.options.afterUpdateElement)this.options.afterUpdateElement(this.element,a)},updateChoices:function(a){if(!this.changed&&this.hasFocus){this.update.innerHTML=a;Element.cleanWhitespace(this.update);Element.cleanWhitespace(this.update.down());if(this.update.firstChild&&this.update.down().childNodes){this.entryCount=this.update.down().childNodes.length;for(var i=0;i<this.entryCount;i++){var b=this.getEntry(i);b.autocompleteIndex=i;this.addObservers(b)}}else{this.entryCount=0}this.stopIndicator();this.index=0;if(this.entryCount==1&&this.options.autoSelect){this.selectEntry();this.hide()}else{this.render()}}},addObservers:function(a){Event.observe(a,"mouseover",this.onHover.bindAsEventListener(this));Event.observe(a,"click",this.onClick.bindAsEventListener(this))},onObserverEvent:function(){this.changed=false;this.tokenBounds=null;if(this.getToken().length>=this.options.minChars){this.getUpdatedChoices()}else{this.active=false;this.hide()}this.oldElementValue=this.element.value},getToken:function(){var a=this.getTokenBounds();return this.element.value.substring(a[0],a[1]).strip()},getTokenBounds:function(){if(null!=this.tokenBounds)return this.tokenBounds;var a=this.element.value;if(a.strip().empty())return[-1,0];var b=arguments.callee.getFirstDifferencePos(a,this.oldElementValue);var c=(b==this.oldElementValue.length?1:0);var d=-1,nextTokenPos=a.length;var e;for(var f=0,l=this.options.tokens.length;f<l;++f){e=a.lastIndexOf(this.options.tokens[f],b+c-1);if(e>d)d=e;e=a.indexOf(this.options.tokens[f],b+c);if(-1!=e&&e<nextTokenPos)nextTokenPos=e}return(this.tokenBounds=[d+1,nextTokenPos])}});Autocompleter.Base.prototype.getTokenBounds.getFirstDifferencePos=function(a,b){var c=Math.min(a.length,b.length);for(var d=0;d<c;++d)if(a[d]!=b[d])return d;return c};Ajax.Autocompleter=Class.create(Autocompleter.Base,{initialize:function(a,b,c,d){this.baseInitialize(a,b,d);this.options.asynchronous=true;this.options.onComplete=this.onComplete.bind(this);this.options.defaultParams=this.options.parameters||null;this.url=c},getUpdatedChoices:function(){this.startIndicator();var a=encodeURIComponent(this.options.paramName)+'='+encodeURIComponent(this.getToken());this.options.parameters=this.options.callback?this.options.callback(this.element,a):a;if(this.options.defaultParams)this.options.parameters+='&'+this.options.defaultParams;new Ajax.Request(this.url,this.options)},onComplete:function(a){this.updateChoices(a.responseText)}});Autocompleter.Local=Class.create(Autocompleter.Base,{initialize:function(a,b,c,d){this.baseInitialize(a,b,d);this.options.array=c},getUpdatedChoices:function(){this.updateChoices(this.options.selector(this))},setOptions:function(h){this.options=Object.extend({choices:10,partialSearch:true,partialChars:2,ignoreCase:true,fullSearch:false,selector:function(a){var b=[];var c=[];var d=a.getToken();var e=0;for(var i=0;i<a.options.array.length&&b.length<a.options.choices;i++){var f=a.options.array[i];var g=a.options.ignoreCase?f.toLowerCase().indexOf(d.toLowerCase()):f.indexOf(d);while(g!=-1){if(g==0&&f.length!=d.length){b.push("<li><strong>"+f.substr(0,d.length)+"</strong>"+f.substr(d.length)+"</li>");break}else if(d.length>=a.options.partialChars&&a.options.partialSearch&&g!=-1){if(a.options.fullSearch||/\s/.test(f.substr(g-1,1))){c.push("<li>"+f.substr(0,g)+"<strong>"+f.substr(g,d.length)+"</strong>"+f.substr(g+d.length)+"</li>");break}}g=a.options.ignoreCase?f.toLowerCase().indexOf(d.toLowerCase(),g+1):f.indexOf(d,g+1)}}if(c.length)b=b.concat(c.slice(0,a.options.choices-b.length));return"<ul>"+b.join('')+"</ul>"}},h||{})}});Field.scrollFreeActivate=function(a){setTimeout(function(){Field.activate(a)},1)};Ajax.InPlaceEditor=Class.create({initialize:function(a,b,c){this.url=b;this.element=a=$(a);this.prepareOptions();this._controls={};arguments.callee.dealWithDeprecatedOptions(c);Object.extend(this.options,c||{});if(!this.options.formId&&this.element.id){this.options.formId=this.element.id+'-inplaceeditor';if($(this.options.formId))this.options.formId=''}if(this.options.externalControl)this.options.externalControl=$(this.options.externalControl);if(!this.options.externalControl)this.options.externalControlOnly=false;this._originalBackground=this.element.getStyle('background-color')||'transparent';this.element.title=this.options.clickToEditText;this._boundCancelHandler=this.handleFormCancellation.bind(this);this._boundComplete=(this.options.onComplete||Prototype.emptyFunction).bind(this);this._boundFailureHandler=this.handleAJAXFailure.bind(this);this._boundSubmitHandler=this.handleFormSubmission.bind(this);this._boundWrapperHandler=this.wrapUp.bind(this);this.registerListeners()},checkForEscapeOrReturn:function(e){if(!this._editing||e.ctrlKey||e.altKey||e.shiftKey)return;if(Event.KEY_ESC==e.keyCode)this.handleFormCancellation(e);else if(Event.KEY_RETURN==e.keyCode)this.handleFormSubmission(e)},createControl:function(a,b,c){var d=this.options[a+'Control'];var e=this.options[a+'Text'];if('button'==d){var f=document.createElement('input');f.type='submit';f.value=e;f.className='editor_'+a+'_button';if('cancel'==a)f.onclick=this._boundCancelHandler;this._form.appendChild(f);this._controls[a]=f}else if('link'==d){var g=document.createElement('a');g.href='#';g.appendChild(document.createTextNode(e));g.onclick='cancel'==a?this._boundCancelHandler:this._boundSubmitHandler;g.className='editor_'+a+'_link';if(c)g.className+=' '+c;this._form.appendChild(g);this._controls[a]=g}},createEditField:function(){var a=(this.options.loadTextURL?this.options.loadingText:this.getText());var b;if(1>=this.options.rows&&!/\r|\n/.test(this.getText())){b=document.createElement('input');b.type='text';var c=this.options.size||this.options.cols||0;if(0<c)b.size=c}else{b=document.createElement('textarea');b.rows=(1>=this.options.rows?this.options.autoRows:this.options.rows);b.cols=this.options.cols||40}b.name=this.options.paramName;b.value=a;b.className='editor_field';if(this.options.submitOnBlur)b.onblur=this._boundSubmitHandler;this._controls.editor=b;if(this.options.loadTextURL)this.loadExternalText();this._form.appendChild(this._controls.editor)},createForm:function(){var d=this;function addText(a,b){var c=d.options['text'+a+'Controls'];if(!c||b===false)return;d._form.appendChild(document.createTextNode(c))};this._form=$(document.createElement('form'));this._form.id=this.options.formId;this._form.addClassName(this.options.formClassName);this._form.onsubmit=this._boundSubmitHandler;this.createEditField();if('textarea'==this._controls.editor.tagName.toLowerCase())this._form.appendChild(document.createElement('br'));if(this.options.onFormCustomization)this.options.onFormCustomization(this,this._form);addText('Before',this.options.okControl||this.options.cancelControl);this.createControl('ok',this._boundSubmitHandler);addText('Between',this.options.okControl&&this.options.cancelControl);this.createControl('cancel',this._boundCancelHandler,'editor_cancel');addText('After',this.options.okControl||this.options.cancelControl)},destroy:function(){if(this._oldInnerHTML)this.element.innerHTML=this._oldInnerHTML;this.leaveEditMode();this.unregisterListeners()},enterEditMode:function(e){if(this._saving||this._editing)return;this._editing=true;this.triggerCallback('onEnterEditMode');if(this.options.externalControl)this.options.externalControl.hide();this.element.hide();this.createForm();this.element.parentNode.insertBefore(this._form,this.element);if(!this.options.loadTextURL)this.postProcessEditField();if(e)Event.stop(e)},enterHover:function(e){if(this.options.hoverClassName)this.element.addClassName(this.options.hoverClassName);if(this._saving)return;this.triggerCallback('onEnterHover')},getText:function(){return this.element.innerHTML},handleAJAXFailure:function(a){this.triggerCallback('onFailure',a);if(this._oldInnerHTML){this.element.innerHTML=this._oldInnerHTML;this._oldInnerHTML=null}},handleFormCancellation:function(e){this.wrapUp();if(e)Event.stop(e)},handleFormSubmission:function(e){var a=this._form;var b=$F(this._controls.editor);this.prepareSubmission();var c=this.options.callback(a,b)||'';if(Object.isString(c))c=c.toQueryParams();c.editorId=this.element.id;if(this.options.htmlResponse){var d=Object.extend({evalScripts:true},this.options.ajaxOptions);Object.extend(d,{parameters:c,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Updater({success:this.element},this.url,d)}else{var d=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(d,{parameters:c,onComplete:this._boundWrapperHandler,onFailure:this._boundFailureHandler});new Ajax.Request(this.url,d)}if(e)Event.stop(e)},leaveEditMode:function(){this.element.removeClassName(this.options.savingClassName);this.removeForm();this.leaveHover();this.element.style.backgroundColor=this._originalBackground;this.element.show();if(this.options.externalControl)this.options.externalControl.show();this._saving=false;this._editing=false;this._oldInnerHTML=null;this.triggerCallback('onLeaveEditMode')},leaveHover:function(e){if(this.options.hoverClassName)this.element.removeClassName(this.options.hoverClassName);if(this._saving)return;this.triggerCallback('onLeaveHover')},loadExternalText:function(){this._form.addClassName(this.options.loadingClassName);this._controls.editor.disabled=true;var c=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(c,{parameters:'editorId='+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(a){this._form.removeClassName(this.options.loadingClassName);var b=a.responseText;if(this.options.stripLoadedTextTags)b=b.stripTags();this._controls.editor.value=b;this._controls.editor.disabled=false;this.postProcessEditField()}.bind(this),onFailure:this._boundFailureHandler});new Ajax.Request(this.options.loadTextURL,c)},postProcessEditField:function(){var a=this.options.fieldPostCreation;if(a)$(this._controls.editor)['focus'==a?'focus':'activate']()},prepareOptions:function(){this.options=Object.clone(Ajax.InPlaceEditor.DefaultOptions);Object.extend(this.options,Ajax.InPlaceEditor.DefaultCallbacks);[this._extraDefaultOptions].flatten().compact().each(function(a){Object.extend(this.options,a)}.bind(this))},prepareSubmission:function(){this._saving=true;this.removeForm();this.leaveHover();this.showSaving()},registerListeners:function(){this._listeners={};var b;$H(Ajax.InPlaceEditor.Listeners).each(function(a){b=this[a.value].bind(this);this._listeners[a.key]=b;if(!this.options.externalControlOnly)this.element.observe(a.key,b);if(this.options.externalControl)this.options.externalControl.observe(a.key,b)}.bind(this))},removeForm:function(){if(!this._form)return;this._form.remove();this._form=null;this._controls={}},showSaving:function(){this._oldInnerHTML=this.element.innerHTML;this.element.innerHTML=this.options.savingText;this.element.addClassName(this.options.savingClassName);this.element.style.backgroundColor=this._originalBackground;this.element.show()},triggerCallback:function(a,b){if('function'==typeof this.options[a]){this.options[a](this,b)}},unregisterListeners:function(){$H(this._listeners).each(function(a){if(!this.options.externalControlOnly)this.element.stopObserving(a.key,a.value);if(this.options.externalControl)this.options.externalControl.stopObserving(a.key,a.value)}.bind(this))},wrapUp:function(a){this.leaveEditMode();this._boundComplete(a,this.element)}});Object.extend(Ajax.InPlaceEditor.prototype,{dispose:Ajax.InPlaceEditor.prototype.destroy});Ajax.InPlaceCollectionEditor=Class.create(Ajax.InPlaceEditor,{initialize:function($super,b,c,d){this._extraDefaultOptions=Ajax.InPlaceCollectionEditor.DefaultOptions;$super(b,c,d)},createEditField:function(){var a=document.createElement('select');a.name=this.options.paramName;a.size=1;this._controls.editor=a;this._collection=this.options.collection||[];if(this.options.loadCollectionURL)this.loadCollection();else this.checkForExternalText();this._form.appendChild(this._controls.editor)},loadCollection:function(){this._form.addClassName(this.options.loadingClassName);this.showLoadingText(this.options.loadingCollectionText);var c=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(c,{parameters:'editorId='+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(a){var b=a.responseText.strip();if(!/^\[.*\]$/.test(b))throw('Server returned an invalid collection representation.');this._collection=eval(b);this.checkForExternalText()}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadCollectionURL,c)},showLoadingText:function(a){this._controls.editor.disabled=true;var b=this._controls.editor.firstChild;if(!b){b=document.createElement('option');b.value='';this._controls.editor.appendChild(b);b.selected=true}b.update((a||'').stripScripts().stripTags())},checkForExternalText:function(){this._text=this.getText();if(this.options.loadTextURL)this.loadExternalText();else this.buildOptionList()},loadExternalText:function(){this.showLoadingText(this.options.loadingText);var b=Object.extend({method:'get'},this.options.ajaxOptions);Object.extend(b,{parameters:'editorId='+encodeURIComponent(this.element.id),onComplete:Prototype.emptyFunction,onSuccess:function(a){this._text=a.responseText.strip();this.buildOptionList()}.bind(this),onFailure:this.onFailure});new Ajax.Request(this.options.loadTextURL,b)},buildOptionList:function(){this._form.removeClassName(this.options.loadingClassName);this._collection=this._collection.map(function(a){return 2===a.length?a:[a,a].flatten()});var c=('value'in this.options)?this.options.value:this._text;var d=this._collection.any(function(a){return a[0]==c}.bind(this));this._controls.editor.update('');var e;this._collection.each(function(a,b){e=document.createElement('option');e.value=a[0];e.selected=d?a[0]==c:0==b;e.appendChild(document.createTextNode(a[1]));this._controls.editor.appendChild(e)}.bind(this));this._controls.editor.disabled=false;Field.scrollFreeActivate(this._controls.editor)}});Ajax.InPlaceEditor.prototype.initialize.dealWithDeprecatedOptions=function(c){if(!c)return;function fallback(a,b){if(a in c||b===undefined)return;c[a]=b};fallback('cancelControl',(c.cancelLink?'link':(c.cancelButton?'button':c.cancelLink==c.cancelButton==false?false:undefined)));fallback('okControl',(c.okLink?'link':(c.okButton?'button':c.okLink==c.okButton==false?false:undefined)));fallback('highlightColor',c.highlightcolor);fallback('highlightEndColor',c.highlightendcolor)};Object.extend(Ajax.InPlaceEditor,{DefaultOptions:{ajaxOptions:{},autoRows:3,cancelControl:'link',cancelText:'cancel',clickToEditText:'Click to edit',externalControl:null,externalControlOnly:false,fieldPostCreation:'activate',formClassName:'inplaceeditor-form',formId:null,highlightColor:'#ffff99',highlightEndColor:'#ffffff',hoverClassName:'',htmlResponse:true,loadingClassName:'inplaceeditor-loading',loadingText:'Loading...',okControl:'button',okText:'ok',paramName:'value',rows:1,savingClassName:'inplaceeditor-saving',savingText:'Saving...',size:0,stripLoadedTextTags:false,submitOnBlur:false,textAfterControls:'',textBeforeControls:'',textBetweenControls:''},DefaultCallbacks:{callback:function(a){return Form.serialize(a)},onComplete:function(a,b){new Effect.Highlight(b,{startcolor:this.options.highlightColor,keepBackgroundImage:true})},onEnterEditMode:null,onEnterHover:function(a){a.element.style.backgroundColor=a.options.highlightColor;if(a._effect)a._effect.cancel()},onFailure:function(a,b){alert('Error communication with the server: '+a.responseText.stripTags())},onFormCustomization:null,onLeaveEditMode:null,onLeaveHover:function(a){a._effect=new Effect.Highlight(a.element,{startcolor:a.options.highlightColor,endcolor:a.options.highlightEndColor,restorecolor:a._originalBackground,keepBackgroundImage:true})}},Listeners:{click:'enterEditMode',keydown:'checkForEscapeOrReturn',mouseover:'enterHover',mouseout:'leaveHover'}});Ajax.InPlaceCollectionEditor.DefaultOptions={loadingCollectionText:'Loading options...'};Form.Element.DelayedObserver=Class.create({initialize:function(a,b,c){this.delay=b||0.5;this.element=$(a);this.callback=c;this.timer=null;this.lastValue=$F(this.element);Event.observe(this.element,'keyup',this.delayedListener.bindAsEventListener(this))},delayedListener:function(a){if(this.lastValue==$F(this.element))return;if(this.timer)clearTimeout(this.timer);this.timer=setTimeout(this.onTimerEvent.bind(this),this.delay*1000);this.lastValue=$F(this.element)},onTimerEvent:function(){this.timer=null;this.callback(this.element,$F(this.element))}});

//slider.js

if(!Control)var Control={};Control.Slider=Class.create({initialize:function(a,b,c){var d=this;if(Object.isArray(a)){this.handles=a.collect(function(e){return $(e)})}else{this.handles=[$(a)]}this.track=$(b);this.options=c||{};this.axis=this.options.axis||'horizontal';this.increment=this.options.increment||1;this.step=parseInt(this.options.step||'1');this.range=this.options.range||$R(0,1);this.value=0;this.values=this.handles.map(function(){return 0});this.spans=this.options.spans?this.options.spans.map(function(s){return $(s)}):false;this.options.startSpan=$(this.options.startSpan||null);this.options.endSpan=$(this.options.endSpan||null);this.restricted=this.options.restricted||false;this.maximum=this.options.maximum||this.range.end;this.minimum=this.options.minimum||this.range.start;this.alignX=parseInt(this.options.alignX||'0');this.alignY=parseInt(this.options.alignY||'0');this.trackLength=this.maximumOffset()-this.minimumOffset();this.handleLength=this.isVertical()?(this.handles[0].offsetHeight!=0?this.handles[0].offsetHeight:this.handles[0].style.height.replace(/px$/,"")):(this.handles[0].offsetWidth!=0?this.handles[0].offsetWidth:this.handles[0].style.width.replace(/px$/,""));this.active=false;this.dragging=false;this.disabled=false;if(this.options.disabled)this.setDisabled();this.allowedValues=this.options.values?this.options.values.sortBy(Prototype.K):false;if(this.allowedValues){this.minimum=this.allowedValues.min();this.maximum=this.allowedValues.max()}this.eventMouseDown=this.startDrag.bindAsEventListener(this);this.eventMouseUp=this.endDrag.bindAsEventListener(this);this.eventMouseMove=this.update.bindAsEventListener(this);this.handles.each(function(h,i){i=d.handles.length-1-i;d.setValue(parseFloat((Object.isArray(d.options.sliderValue)?d.options.sliderValue[i]:d.options.sliderValue)||d.range.start),i);h.makePositioned().observe("mousedown",d.eventMouseDown)});this.track.observe("mousedown",this.eventMouseDown);document.observe("mouseup",this.eventMouseUp);document.observe("mousemove",this.eventMouseMove);this.initialized=true},dispose:function(){var a=this;Event.stopObserving(this.track,"mousedown",this.eventMouseDown);Event.stopObserving(document,"mouseup",this.eventMouseUp);Event.stopObserving(document,"mousemove",this.eventMouseMove);this.handles.each(function(h){Event.stopObserving(h,"mousedown",a.eventMouseDown)})},setDisabled:function(){this.disabled=true},setEnabled:function(){this.disabled=false},getNearestValue:function(b){if(this.allowedValues){if(b>=this.allowedValues.max())return(this.allowedValues.max());if(b<=this.allowedValues.min())return(this.allowedValues.min());var c=Math.abs(this.allowedValues[0]-b);var d=this.allowedValues[0];this.allowedValues.each(function(v){var a=Math.abs(v-b);if(a<=c){d=v;c=a}});return d}if(b>this.range.end)return this.range.end;if(b<this.range.start)return this.range.start;return b},setValue:function(a,b){if(!this.active){this.activeHandleIdx=b||0;this.activeHandle=this.handles[this.activeHandleIdx];this.updateStyles()}b=b||this.activeHandleIdx||0;if(this.initialized&&this.restricted){if((b>0)&&(a<this.values[b-1]))a=this.values[b-1];if((b<(this.handles.length-1))&&(a>this.values[b+1]))a=this.values[b+1]}a=this.getNearestValue(a);this.values[b]=a;this.value=this.values[0];this.handles[b].style[this.isVertical()?'top':'left']=this.translateToPx(a);this.drawSpans();if(!this.dragging||!this.event)this.updateFinished()},setValueBy:function(a,b){this.setValue(this.values[b||this.activeHandleIdx||0]+a,b||this.activeHandleIdx||0)},translateToPx:function(a){return Math.round(((this.trackLength-this.handleLength)/(this.range.end-this.range.start))*(a-this.range.start))+"px"},translateToValue:function(a){return((a/(this.trackLength-this.handleLength)*(this.range.end-this.range.start))+this.range.start)},getRange:function(a){var v=this.values.sortBy(Prototype.K);a=a||0;return $R(v[a],v[a+1])},minimumOffset:function(){return(this.isVertical()?this.alignY:this.alignX)},maximumOffset:function(){return(this.isVertical()?(this.track.offsetHeight!=0?this.track.offsetHeight:this.track.style.height.replace(/px$/,""))-this.alignY:(this.track.offsetWidth!=0?this.track.offsetWidth:this.track.style.width.replace(/px$/,""))-this.alignX)},isVertical:function(){return(this.axis=='vertical')},drawSpans:function(){var a=this;if(this.spans)$R(0,this.spans.length-1).each(function(r){a.setSpan(a.spans[r],a.getRange(r))});if(this.options.startSpan)this.setSpan(this.options.startSpan,$R(0,this.values.length>1?this.getRange(0).min():this.value));if(this.options.endSpan)this.setSpan(this.options.endSpan,$R(this.values.length>1?this.getRange(this.spans.length-1).max():this.value,this.maximum))},setSpan:function(a,b){if(this.isVertical()){a.style.top=this.translateToPx(b.start);a.style.height=this.translateToPx(b.end-b.start+this.range.start)}else{a.style.left=this.translateToPx(b.start);a.style.width=this.translateToPx(b.end-b.start+this.range.start)}},updateStyles:function(){this.handles.each(function(h){Element.removeClassName(h,'selected')});Element.addClassName(this.activeHandle,'selected')},startDrag:function(a){if(Event.isLeftClick(a)){if(!this.disabled){this.active=true;var b=Event.element(a);var c=[Event.pointerX(a),Event.pointerY(a)];var d=b;if(d==this.track){var e=Position.cumulativeOffset(this.track);this.event=a;this.setValue(this.translateToValue((this.isVertical()?c[1]-e[1]:c[0]-e[0])-(this.handleLength/2)));var e=Position.cumulativeOffset(this.activeHandle);this.offsetX=(c[0]-e[0]);this.offsetY=(c[1]-e[1])}else{while((this.handles.indexOf(b)==-1)&&b.parentNode)b=b.parentNode;if(this.handles.indexOf(b)!=-1){this.activeHandle=b;this.activeHandleIdx=this.handles.indexOf(this.activeHandle);this.updateStyles();var e=Position.cumulativeOffset(this.activeHandle);this.offsetX=(c[0]-e[0]);this.offsetY=(c[1]-e[1])}}}Event.stop(a)}},update:function(a){if(this.active){if(!this.dragging)this.dragging=true;this.draw(a);if(Prototype.Browser.WebKit)window.scrollBy(0,0);Event.stop(a)}},draw:function(a){var b=[Event.pointerX(a),Event.pointerY(a)];var c=Position.cumulativeOffset(this.track);b[0]-=this.offsetX+c[0];b[1]-=this.offsetY+c[1];this.event=a;this.setValue(this.translateToValue(this.isVertical()?b[1]:b[0]));if(this.initialized&&this.options.onSlide)this.options.onSlide(this.values.length>1?this.values:this.value,this)},endDrag:function(a){if(this.active&&this.dragging){this.finishDrag(a,true);Event.stop(a)}this.active=false;this.dragging=false},finishDrag:function(a,b){this.active=false;this.dragging=false;this.updateFinished()},updateFinished:function(){if(this.initialized&&this.options.onChange)this.options.onChange(this.values.length>1?this.values:this.value,this);this.event=null}});

//sound.js

Sound={tracks:{},_enabled:true,template:new Template('<embed style="height:0" id="sound_#{track}_#{id}" src="#{url}" loop="false" autostart="true" hidden="true"/>'),enable:function(){Sound._enabled=true},disable:function(){Sound._enabled=false},play:function(c){if(!Sound._enabled)return;var d=Object.extend({track:'global',url:c,replace:false},arguments[1]||{});if(d.replace&&this.tracks[d.track]){$R(0,this.tracks[d.track].id).each(function(a){var b=$('sound_'+d.track+'_'+a);b.Stop&&b.Stop();b.remove()});this.tracks[d.track]=null}if(!this.tracks[d.track])this.tracks[d.track]={id:0};else this.tracks[d.track].id++;d.id=this.tracks[d.track].id;$$('body')[0].insert(Prototype.Browser.IE?new Element('bgsound',{id:'sound_'+d.track+'_'+d.id,src:d.url,loop:1,autostart:true}):Sound.template.evaluate(d))}};if(Prototype.Browser.Gecko&&navigator.userAgent.indexOf("Win")>0){if(navigator.plugins&&$A(navigator.plugins).detect(function(p){return p.name.indexOf('QuickTime')!=-1}))Sound.template=new Template('<object id="sound_#{track}_#{id}" width="0" height="0" type="audio/mpeg" data="#{url}"/>');else Sound.play=function(){}}

//load additional files

Scriptaculous.load();


if(typeof Prototype == 'undefined'){

    throw 'Unable to load Shadowbox, Prototype framework not found';

}



// create the Shadowbox object first

var Shadowbox = {};



Shadowbox.lib = function(){



    // local style camelizing for speed

    var styleCache = {};

    var camelRe = /(-[a-z])/gi;

    var camelFn = function(m, a){

        return a.charAt(1).toUpperCase();

    };

    var toCamel = function(style){

        var camel;

        if(!(camel = styleCache[style])){

            camel = styleCache[style] = style.replace(camelRe, camelFn);

        }

        return camel;

    };



    return {



        adapter: 'prototype',



        /**

         * Gets the value of the style on the given element.

         *

         * @param   {HTMLElement}   el      The DOM element

         * @param   {String}        style   The name of the style (e.g. margin-top)

         * @return  {mixed}                 The value of the given style

         * @public

         */

        getStyle: function(el, style){

            return Element.getStyle(el, style);

        },



        /**

         * Sets the style on the given element to the given value. May be an

         * object to specify multiple values.

         *

         * @param   {HTMLElement}   el      The DOM element

         * @param   {String/Object} style   The name of the style to set if a

         *                                  string, or an object of name =>

         *                                  value pairs

         * @param   {String}        value   The value to set the given style to

         * @return  void

         * @public

         */

        setStyle: function(el, style, value){

            if(typeof style == 'string'){

                var temp = {};

                temp[toCamel(style)] = value;

                style = temp;

            }

            Element.setStyle(el, style);

        },



        /**

         * Gets a reference to the given element.

         *

         * @param   {String/HTMLElement}    el      The element to fetch

         * @return  {HTMLElement}                   A reference to the element

         * @public

         */

        get: function(el){

            return $(el);

        },



        /**

         * Removes an element from the DOM.

         *

         * @param   {HTMLElement}           el      The element to remove

         * @return  void

         * @public

         */

        remove: function(el){

            Element.remove(el);

        },



        /**

         * Gets the target of the given event. The event object passed will be

         * the same object that is passed to listeners registered with

         * addEvent().

         *

         * @param   {mixed}                 e       The event object

         * @return  {HTMLElement}                   The event's target element

         * @public

         */

        getTarget: function(e){

            return Event.element(e);

        },



        /**

         * Prevents the event's default behavior. The event object passed will

         * be the same object that is passed to listeners registered with

         * addEvent().

         *

         * @param   {mixed}                 e       The event object

         * @return  void

         * @public

         */

        preventDefault: function(e){

            Event.stop(e);

        },



        /**

         * Gets the page X/Y coordinates of the mouse event in an [x, y] array.

         * The page coordinates should be relative to the document, and not the

         * viewport. The event object provided here will be the same object that

         * is passed to listeners registered with addEvent().

         *

         * @param   {mixed}         e       The event object

         * @return  {Array}                 The page X/Y coordinates

         * @public

         * @static

         */

        getPageXY: function(e){

            var p = Event.pointer(e);

            return [p.x, p.y];

        },



        /**

         * Gets the key code of the given event object (keydown). The event

         * object here will be the same object that is passed to listeners

         * registered with addEvent().

         *

         * @param   {mixed}         e       The event object

         * @return  {Number}                The key code of the event

         * @public

         * @static

         */

        keyCode: function(e){

            return e.keyCode;

        },



        /**

         * Adds an event listener to the given element. It is expected that this

         * function will be passed the event as its first argument.

         *

         * @param   {HTMLElement}   el          The DOM element to listen to

         * @param   {String}        name        The name of the event to register

         *                                      (i.e. 'click', 'scroll', etc.)

         * @param   {Function}      handler     The event handler function

         * @return  void

         * @public

         */

        addEvent: function(el, name, handler){

            Event.observe(el, name, handler);

        },



        /**

         * Removes an event listener from the given element.

         *

         * @param   {HTMLElement}   el          The DOM element to stop listening to

         * @param   {String}        name        The name of the event to stop

         *                                      listening for (i.e. 'click')

         * @param   {Function}      handler     The event handler function

         * @return  void

         * @public

         */

        removeEvent: function(el, name, handler){

            Event.stopObserving(el, name, handler);

        },



        /**

         * Appends an HTML fragment to the given element.

         *

         * @param   {HTMLElement}       el      The element to append to

         * @param   {String}            html    The HTML fragment to use

         * @return  void

         * @public

         */

        append: function(el, html){

            Element.insert(el, html);

        }



    };



}();





/**

 * The Shadowbox class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox.js 108 2008-07-11 04:19:01Z mjijackson $

 */



if(typeof Shadowbox == 'undefined'){

    throw 'Unable to load Shadowbox, no base library adapter found';

}



/**

 * The Shadowbox class. Used to display different media on a web page using a

 * Lightbox-like effect.

 *

 * Useful resources:

 *

 * - http://www.alistapart.com/articles/byebyeembed

 * - http://www.w3.org/TR/html401/struct/objects.html

 * - http://www.dyn-web.com/dhtml/iframes/

 * - http://www.apple.com/quicktime/player/specs.html

 * - http://www.apple.com/quicktime/tutorials/embed2.html

 * - http://www.howtocreate.co.uk/wrongWithIE/?chapter=navigator.plugins

 * - http://msdn.microsoft.com/en-us/library/ms532969.aspx

 * - http://support.microsoft.com/kb/316992

 *

 * @class       Shadowbox

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @singleton

 */

(function(){



    /**

     * The current version of Shadowbox.

     *

     * @var         String

     * @private

     */

    var version = '2.0';



    /**

     * Contains the default options for Shadowbox.

     *

     * @var         Object

     * @private

     */

    var options = {



        /**

         * Enable all animations besides fades.

         *

         * @var     Boolean

         */

        animate:            true,



        /**

         * Enable fade animations.

         *

         * @var     Boolean

         */

        animateFade:        true,



        /**

         * Specifies the sequence of the height and width animations. May be

         * 'wh' (width then height), 'hw' (height then width), or 'sync' (both

         * at the same time). Of course this will only work if animate is true.

         *

         * @var     String

         */

        animSequence:       'wh',



        /**

         * The path to flvplayer.swf.

         *

         * @var     String

         */

        flvPlayer:          'flvplayer.swf',



        /**

         * Listen to the overlay for clicks. If the user clicks the overlay,

         * it will trigger Shadowbox.close().

         *

         * @var     Boolean

         */

        modal:              false,



        /**

         * The color to use for the modal overlay (in hex).

         *

         * @var     String

         */

        overlayColor:       '#000',



        /**

         * The opacity to use for the modal overlay.

         *

         * @var     Number

         */

        overlayOpacity:     0.8,



        /**

         * The default background color to use for Flash movies (in hex).

         *

         * @var     String

         */

        flashBgColor:       '#000000',



        /**

         * Automatically play movies.

         *

         * @var     Boolean

         */

        autoplayMovies:     true,



        /**

         * Enable movie controllers on movie players.

         *

         * @var     Boolean

         */

        showMovieControls:  true,



        /**

         * A delay (in seconds) to use for slideshows. If set to anything other

         * than 0, this value determines an interval at which Shadowbox will

         * automatically proceed to the next piece in the gallery.

         *

         * @var     Number

         */

        slideshowDelay:     0,



        /**

         * The duration of the resizing animations (in seconds).

         *

         * @var     Number

         */

        resizeDuration:     0.55,



        /**

         * The duration of the fading animations (in seconds).

         *

         * @var     Number

         */

        fadeDuration:       0.35,



        /**

         * Show the navigation controls.

         *

         * @var     Boolean

         */

        displayNav:         true,



        /**

         * Enable continuous galleries. When this is true, users will be able

         * to skip to the first gallery image from the last using next and vice

         * versa.

         *

         * @var     Boolean

         */

        continuous:         false,



        /**

         * Display the gallery counter.

         *

         * @var     Boolean

         */

        displayCounter:     true,



        /**

         * This option may be either 'default' or 'skip'. The default counter is

         * a simple '1 of 5' message. The skip counter displays a link for each

         * piece in the gallery that enables a user to skip directly to any

         * piece.

         *

         * @var     String

         */

        counterType:        'default',



        /**

         * Limits the number of counter links that will be displayed in a "skip"

         * style counter. If the actual number of gallery elements is greater

         * than this value, the counter will be restrained to the elements

         * immediately preceeding and following the current element.

         *

         * @var     Number

         */

        counterLimit:       10,



        /**

         * The amount of padding to maintain around the viewport edge (in

         * pixels). This only applies when the image is very large and takes up

         * the entire viewport.

         *

         * @var     Number

         */

        viewportPadding:    20,



        /**

         * How to handle content that is too large to display in its entirety

         * (and is resizable). A value of 'resize' will resize the content while

         * preserving aspect ratio and display it at the smaller resolution. If

         * the content is an image, a value of 'drag' will display the image at

         * its original resolution but it will be draggable within Shadowbox. A

         * value of 'none' will display the content at its original resolution

         * but it may be cropped.

         *

         * @var     String

         */

        handleOversize:     'resize',



        /**

         * An exception handling function that will be called whenever

         * Shadowbox should throw an exception. Will be passed the error

         * message as its first argument.

         *

         * @var     Function

         */

        handleException:    null,



        /**

         * The mode to use when handling unsupported media. May be either

         * 'remove' or 'link'. If it is 'remove', the unsupported gallery item

         * will merely be removed from the gallery. If it is the only item in

         * the gallery, the link will simply be followed. If it is 'link', a

         * link will be provided to the appropriate plugin page in place of the

         * gallery element.

         *

         * @var     String

         */

        handleUnsupported:  'link',



        /**

         * The initial height of Shadowbox (in pixels).

         *

         * @var     Number

         */

        initialHeight:      160,



        /**

         * The initial width of Shadowbox (in pixels).

         *

         * @var     Number

         */

        initialWidth:       320,



        /**

         * Enable keyboard control.

         *

         * @var     Boolean

         */

        enableKeys:         true,



        /**

         * A hook function to be fired when Shadowbox opens. The single argument

         * will be the current gallery element.

         *

         * @var     Function

         */

        onOpen:             null,



        /**

         * A hook function to be fired when Shadowbox finishes loading its

         * content. The single argument will be the current gallery element on

         * display.

         *

         * @var     Function

         */

        onFinish:           null,



        /**

         * A hook function to be fired when Shadowbox changes from one gallery

         * element to the next. The single argument will be the current gallery

         * element that is about to be displayed.

         *

         * @var     Function

         */

        onChange:           null,



        /**

         * A hook function that will be fired when Shadowbox closes. The single

         * argument will be the gallery element most recently displayed.

         *

         * @var     Function

         */

        onClose:            null,



        /**

         * Skips calling Shadowbox.setup() in init(). This means that it must

         * be called later manually.

         *

         * @var     Boolean

         */

        skipSetup:          false,



        /**

         * An object containing names of plugins and links to their respective

         * download pages.

         *

         * @var     Object

         */

        errors:         {



            fla:        {

                name:   'Flash',

                url:    'http://www.adobe.com/products/flashplayer/'

            },



            qt:         {

                name:   'QuickTime',

                url:    'http://www.apple.com/quicktime/download/'

            },



            wmp:        {

                name:   'Windows Media Player',

                url:    'http://www.microsoft.com/windows/windowsmedia/'

            },



            f4m:        {

                name:   'Flip4Mac',

                url:    'http://www.flip4mac.com/wmv_download.htm'

            }



        },



        /**

         * A map of players to the file extensions they support. Each member of

         * this object is the name of a player (with one exception), whose value

         * is an array of file extensions that player will "play". The one

         * exception to this rule is the "qtwmp" member, which contains extensions

         * that may be played using either QuickTime or Windows Media Player.

         *

         * - img: Image file extensions

         * - swf: Flash SWF file extensions

         * - flv: Flash video file extensions (will be played by JW FLV player)

         * - qt: Movie file extensions supported by QuickTime

         * - wmp: Movie file extensions supported by Windows Media Player

         * - qtwmp: Movie file extensions supported by both QuickTime and Windows Media Player

         * - iframe: File extensions that will be display in an iframe

         *

         * IMPORTANT: If this object is to be modified, it must be copied in its

         * entirety and tweaked because it is not merged recursively with the

         * default. Also, any modifications must be passed into Shadowbox.init

         * for speed reasons.

         *

         * @var     Object      ext

         */

        ext:     {

            img:        ['png', 'jpg', 'jpeg', 'gif', 'bmp'],

            swf:        ['swf'],

            flv:        ['flv'],

            qt:         ['dv', 'mov', 'moov', 'movie', 'mp4'],

            wmp:        ['asf', 'wm', 'wmv'],

            qtwmp:      ['avi', 'mpg', 'mpeg'],

            iframe:     ['asp', 'aspx', 'cgi', 'cfm', 'htm', 'html', 'pl', 'php',

                        'php3', 'php4', 'php5', 'phtml', 'rb', 'rhtml', 'shtml',

                        'txt', 'vbs']

        }



    };



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;



    /**

     * Stores the default set of options in case a custom set of options is used

     * on a link-by-link basis so we can restore them later.

     *

     * @var         Object

     * @private

     */

    var default_options;



    /**

     * An object containing some regular expressions we'll need later. Compiled

     * up front for speed.

     *

     * @var         Object

     * @private

     */

    var RE = {

        domain:         /:\/\/(.*?)[:\/]/, // domain prefix

        inline:         /#(.+)$/, // inline element id

        rel:            /^(light|shadow)box/i, // rel attribute format

        gallery:        /^(light|shadow)box\[(.*?)\]/i, // rel attribute format for gallery link

        unsupported:    /^unsupported-(\w+)/, // unsupported media type

        param:          /\s*([a-z_]*?)\s*=\s*(.+)\s*/, // rel string parameter

        empty:          /^(?:br|frame|hr|img|input|link|meta|range|spacer|wbr|area|param|col)$/i // elements that don't have children

    };



    /**

     * A cache of options for links that have been set up for use with

     * Shadowbox.

     *

     * @var         Array

     * @private

     */

    var cache = [];



    /**

     * An array containing the gallery objects currently being viewed. In the

     * case of non-gallery items, this will only hold one object.

     *

     * @var         Array

     * @private

     */

    var gallery;



    /**

     * The array index of the current gallery that is currently being viewed.

     *

     * @var         Number

     * @private

     */

    var current;



    /**

     * The current content object.

     *

     * @var         Object

     * @private

     */

    var content;



    /**

     * The id to use for content objects.

     *

     * @var         String

     * @private

     */

    var content_id = 'shadowbox_content';



    /**

     * Holds the current dimensions of Shadowbox as calculated by

     * setDimensions(). Contains the following properties:

     *

     * - height: The total height of #shadowbox

     * - width: The total width of #shadowbox

     * - inner_h: The height of #shadowbox_body

     * - inner_w: The width of #shadowbox_body

     * - top: The top to use for #shadowbox

     * - resize_h: The height to use for resizable content

     * - resize_w: The width to use for resizable content

     * - drag: True if dragging should be enabled (oversized image)

     *

     * @var         Object

     * @private

     */

    var dims;



    /**

     * Keeps track of whether or not Shadowbox has been initialized. We never

     * want to initialize twice.

     *

     * @var         Boolean

     * @private

     */

    var initialized = false;



    /**

     * Keeps track of whether or not Shadowbox is activated.

     *

     * @var         Boolean

     * @private

     */

    var activated = false;



    /**

     * The timeout id for the slideshow transition function.

     *

     * @var         Number

     * @private

     */

    var slide_timer;



    /**

     * Keeps track of the time at which the current slideshow frame was

     * displayed.

     *

     * @var         Number

     * @private

     */

    var slide_start;



    /**

     * The delay on which the next slide will display.

     *

     * @var         Number

     * @private

     */

    var slide_delay = 0;



    /**

     * These parameters for simple browser detection. Adapted from Ext.js.

     *

     * @var         Object

     * @private

     */

    var ua = navigator.userAgent.toLowerCase();

    var client = {

        isStrict:   document.compatMode == 'CSS1Compat',

        isOpera:    ua.indexOf('opera') > -1,

        isIE:       ua.indexOf('msie') > -1,

        isIE7:      ua.indexOf('msie 7') > -1,

        isSafari:   /webkit|khtml/.test(ua),

        isWindows:  ua.indexOf('windows') != -1 || ua.indexOf('win32') != -1,

        isMac:      ua.indexOf('macintosh') != -1 || ua.indexOf('mac os x') != -1,

        isLinux:    ua.indexOf('linux') != -1

    };

    client.isBorderBox = client.isIE && !client.isStrict;

    client.isSafari3 = client.isSafari && !!(document.evaluate);

    client.isGecko = ua.indexOf('gecko') != -1 && !client.isSafari;



    /**

     * You're not sill using IE6 are you?

     *

     * @var         Boolean

     * @private

     */

    var ltIE7 = client.isIE && !client.isIE7;



    /**

     * Contains plugin support information. Each property of this object is a

     * boolean indicating whether that plugin is supported.

     *

     * - fla: Flash player

     * - qt: QuickTime player

     * - wmp: Windows Media player

     * - f4m: Flip4Mac plugin

     *

     * @var         Object

     * @private

     */

    var plugins;



    // detect plugin support

    if(navigator.plugins && navigator.plugins.length){

        var detectPlugin = function(plugin_name){

            var detected = false;

            for (var i = 0, len = navigator.plugins.length; i < len; ++i){

                if(navigator.plugins[i].name.indexOf(plugin_name) > -1){

                    detected = true;

                    break;

                }

            }

            return detected;

        };

        var f4m = detectPlugin('Flip4Mac');

        plugins = {

            fla:    detectPlugin('Shockwave Flash'),

            qt:     detectPlugin('QuickTime'),

            wmp:    !f4m && detectPlugin('Windows Media'), // if it's Flip4Mac, it's not really WMP

            f4m:    f4m

        };

    }else{

        var detectPlugin = function(plugin_name){

            var detected = false;

            try{

                var axo = new ActiveXObject(plugin_name);

                if(axo) detected = true;

            }catch(e){}

            return detected;

        };

        plugins = {

            fla:    detectPlugin('ShockwaveFlash.ShockwaveFlash'),

            qt:     detectPlugin('QuickTime.QuickTime'),

            wmp:    detectPlugin('wmplayer.ocx'),

            f4m:    false

        };

    }



    /**

     * Applies all properties of e to o.

     *

     * @param   Object      o       The original object

     * @param   Object      e       The extension object

     * @return  Object              The original object with all properties

     *                              of the extension object applied

     * @private

     */

    var apply = function(o, e){

        for(var p in e) o[p] = e[p];

        return o;

    };



    /**

     * Determines if the given object is an anchor/area element.

     *

     * @param   mixed       el      The object to check

     * @return  Boolean             True if the object is a link element

     * @private

     */

    var isLink = function(el){

        return el && typeof el.tagName == 'string' && (el.tagName.toUpperCase() == 'A' || el.tagName.toUpperCase() == 'AREA');

    };



    /**

     * Gets the height of the viewport in pixels. Note: This function includes

     * scrollbars in Safari 3.

     *

     * @return  Number          The height of the viewport

     * @public

     * @static

     */

    SL.getViewportHeight = function(){

        var h = window.innerHeight; // Safari

        var mode = document.compatMode;

        if((mode || client.isIE) && !client.isOpera){

            h = client.isStrict ? document.documentElement.clientHeight : document.body.clientHeight;

        }

        return h;

    };



    /**

     * Gets the width of the viewport in pixels. Note: This function includes

     * scrollbars in Safari 3.

     *

     * @return  Number          The width of the viewport

     * @public

     * @static

     */

    SL.getViewportWidth = function(){

        var w = window.innerWidth; // Safari

        var mode = document.compatMode;

        if(mode || client.isIE){

            w = client.isStrict ? document.documentElement.clientWidth : document.body.clientWidth;

        }

        return w;

    };



    /**

     * Creates an HTML string from an object representing HTML elements. Based

     * on Ext.DomHelper's createHtml.

     *

     * @param   Object      obj     The HTML definition object

     * @return  String              An HTML string

     * @public

     * @static

     */

    SL.createHTML = function(obj){

        var html = '<' + obj.tag;

        for(var attr in obj){

            if(attr == 'tag' || attr == 'html' || attr == 'children') continue;

            if(attr == 'cls'){

                html += ' class="' + obj['cls'] + '"';

            }else{

                html += ' ' + attr + '="' + obj[attr] + '"';

            }

        }

        if(RE.empty.test(obj.tag)){

            html += '/>';

        }else{

            html += '>';

            var cn = obj.children;

            if(cn){

                for(var i = 0, len = cn.length; i < len; ++i){

                    html += this.createHTML(cn[i]);

                }

            }

            if(obj.html) html += obj.html;

            html += '</' + obj.tag + '>';

        }

        return html;

    };



    /**

     * Easing function used for animations. Based on a cubic polynomial.

     *

     * @param   Number      x       The state of the animation (% complete)

     * @return  Number              The adjusted easing value

     * @private

     * @static

     */

    var ease = function(x){

        return 1 + Math.pow(x - 1, 3);

    };



    /**

     * Animates any numeric (not color) style of the given element from its

     * current state to the given value. Defaults to using pixel-based

     * measurements.

     *

     * @param   HTMLElement     el      The DOM element to animate

     * @param   String          p       The property to animate (in camelCase)

     * @param   mixed           to      The value to animate to

     * @param   Number          d       The duration of the animation (in

     *                                  seconds)

     * @param   Function        cb      A callback function to call when the

     *                                  animation completes

     * @return  void

     * @private

     * @static

     */

    var animate = function(el, p, to, d, cb){

        var from = parseFloat(SL.getStyle(el, p));

        if(isNaN(from)) from = 0;



        if(from == to){

            if(typeof cb == 'function') cb();

            return; // nothing to animate

        }



        var delta = to - from;

        var op = p == 'opacity';

        var unit = op ? '' : 'px'; // default unit is px

        var fn = function(ease){

            SL.setStyle(el, p, from + ease * delta + unit);

        };



        // cancel the animation here if set in the options

        if(!options.animate && !op || op && !options.animateFade){

            fn(1);

            if(typeof cb == 'function') cb();

            return;

        }



        d *= 1000; // convert to milliseconds

        var begin = new Date().getTime();

        var end = begin + d;



        var timer = setInterval(function(){

            var time = new Date().getTime();

            if(time >= end){ // end of animation

                clearInterval(timer);

                fn(1);

                if(typeof cb == 'function') cb();

            }else{

                fn(ease((time - begin) / d));

            }

        }, 10); // 10 ms interval is minimum on WebKit

    };



    /**

     * A utility function used by the fade functions to clear the opacity

     * style setting of the given element. Required in some cases for IE.

     *

     * @param   HTMLElement     el      The DOM element

     * @return  void

     * @private

     */

    var clearOpacity = function(el){

        var s = el.style;

        if(client.isIE){

            if(typeof s.filter == 'string' && (/alpha/i).test(s.filter)){

                // careful not to overwrite other filters!

                s.filter = s.filter.replace(/[\w\.]*alpha\(.*?\);?/i, '');

            }

        }else{

            s.opacity = '';

            s['-moz-opacity'] = '';

            s['-khtml-opacity'] = '';

        }

    };



    /**

     * Gets the computed height of the given element, including padding and

     * borders.

     *

     * @param   HTMLElement     el  The element

     * @return  Number              The computed height of the element

     * @private

     */

    var getComputedHeight = function(el){

        var h = Math.max(el.offsetHeight, el.clientHeight);

        if(!h){

            h = parseInt(SL.getStyle(el, 'height'), 10) || 0;

            if(!client.isBorderBox){

                h += parseInt(SL.getStyle(el, 'padding-top'), 10)

                    + parseInt(SL.getStyle(el, 'padding-bottom'), 10)

                    + parseInt(SL.getStyle(el, 'border-top-width'), 10)

                    + parseInt(SL.getStyle(el, 'border-bottom-width'), 10);

            }

        }

        return h;

    };



    /**

     * Determines the player needed to display the file at the given URL. If

     * the file type is not supported, the return value will be 'unsupported'.

     * If the file type is not supported but the correct player can be

     * determined, the return value will be 'unsupported-*' where * will be the

     * player abbreviation (e.g. 'qt' = QuickTime).

     *

     * @param   String          url     The url of the file

     * @return  String                  The name of the player to use

     * @private

     */

    var getPlayer = function(url){

        var m = url.match(RE.domain);

        var d = m && document.domain == m[1]; // same domain

        if(url.indexOf('#') > -1 && d) return 'inline';

        var q = url.indexOf('?');

        if(q > -1) url = url.substring(0, q); // strip query string for player detection purposes

        if(RE.img.test(url)) return 'img';

        if(RE.swf.test(url)) return plugins.fla ? 'swf' : 'unsupported-swf';

        if(RE.flv.test(url)) return plugins.fla ? 'flv' : 'unsupported-flv';

        if(RE.qt.test(url)) return plugins.qt ? 'qt' : 'unsupported-qt';

        if(RE.wmp.test(url)){

            if(plugins.wmp) return 'wmp';

            if(plugins.f4m) return 'qt';

            if(client.isMac) return plugins.qt ? 'unsupported-f4m' : 'unsupported-qtf4m';

            return 'unsupported-wmp';

        }else if(RE.qtwmp.test(url)){

            if(plugins.qt) return 'qt';

            if(plugins.wmp) return 'wmp';

            return client.isMac ? 'unsupported-qt' : 'unsupported-qtwmp';

        }else if(!d || RE.iframe.test(url)){

            return 'iframe';

        }

        return 'unsupported'; // same domain, not supported

    };



    /**

     * Handles all clicks on links that have been set up to work with Shadowbox

     * and cancels the default event behavior when appropriate.

     *

     * @param   {Event}         ev          The click event object

     * @return  void

     * @private

     */

    var handleClick = function(ev){

        // get anchor/area element

        var link;

        if(isLink(this)){

            link = this; // jQuery, Prototype, YUI

        }else{

            link = SL.getTarget(ev); // Ext, standalone

            while(!isLink(link) && link.parentNode){

                link = link.parentNode;

            }

        }



        //SL.preventDefault(ev); // good for debugging



        if(link){

            SB.open(link);

            if(gallery.length) SL.preventDefault(ev); // stop event

        }

    };



    /**

     * Toggles the display of the nav control with the given id on and off.

     *

     * @param   String      id      The id of the navigation control

     * @param   Boolean     on      True to toggle on, false to toggle off

     * @return  void

     * @private

     */

    var toggleNav = function(id, on){

        var el = SL.get('shadowbox_nav_' + id);

        if(el) el.style.display = on ? '' : 'none';

    };



    /**

     * Builds the content for the title and information bars.

     *

     * @param   Function    cb      A callback function to execute after the

     *                              bars are built

     * @return  void

     * @private

     */

    var buildBars = function(cb){

        var obj = gallery[current];

        var title_i = SL.get('shadowbox_title_inner');



        // build the title

        title_i.innerHTML = obj.title || '';



        // build the nav

        var nav = SL.get('shadowbox_nav');

        if(nav){

            var c, n, pl, pa, p;



            // need to build the nav?

            if(options.displayNav){

                c = true;

                // next & previous links

                var len = gallery.length;

                if(len > 1){

                    if(options.continuous){

                        n = p = true; // show both

                    }else{

                        n = (len - 1) > current; // not last in gallery, show next

                        p = current > 0; // not first in gallery, show previous

                    }

                }

                // in a slideshow?

                if(options.slideshowDelay > 0 && hasNext()){

                    pa = slide_timer != 'paused';

                    pl = !pa;

                }

            }else{

                c = n = pl = pa = p = false;

            }



            toggleNav('close', c);

            toggleNav('next', n);

            toggleNav('play', pl);

            toggleNav('pause', pa);

            toggleNav('previous', p);

        }



        // build the counter

        var counter = SL.get('shadowbox_counter');

        if(counter){

            var co = '';



            // need to build the counter?

            if(options.displayCounter && gallery.length > 1){

                if(options.counterType == 'skip'){

                    // limit the counter?

                    var i = 0, len = gallery.length, end = len;

                    var limit = parseInt(options.counterLimit);

                    if(limit < len){ // support large galleries

                        var h = Math.round(limit / 2);

                        i = current - h;

                        if(i < 0) i += len;

                        end = current + (limit - h);

                        if(end > len) end -= len;

                    }

                    while(i != end){

                        if(i == len) i = 0;

                        co += '<a onclick="Shadowbox.change(' + i + ');"';

                        if(i == current) co += ' class="shadowbox_counter_current"';

                        co += '>' + (++i) + '</a>';

                    }

                }else{ // default

                    co = (current + 1) + ' ' + SB.LANG.of + ' ' + len;

                }

            }



            counter.innerHTML = co;

        }



        cb();

    };



    /**

     * Hides the title and info bars.

     *

     * @param   Boolean     anim    True to animate the transition

     * @param   Function    cb      A callback function to execute after the

     *                              animation completes

     * @return  void

     * @private

     */

    var hideBars = function(anim, cb){

        var obj = gallery[current];

        var title = SL.get('shadowbox_title');

        var info = SL.get('shadowbox_info');

        var title_i = SL.get('shadowbox_title_inner');

        var info_i = SL.get('shadowbox_info_inner');



        // build bars after they are hidden

        var fn = function(){

            buildBars(cb);

        };



        var title_h = getComputedHeight(title);

        var info_h = getComputedHeight(info) * -1;

        if(anim){

            // animate the transition

            animate(title_i, 'margin-top', title_h, 0.35);

            animate(info_i, 'margin-top', info_h, 0.35, fn);

        }else{

            SL.setStyle(title_i, 'margin-top', title_h + 'px');

            SL.setStyle(info_i, 'margin-top', info_h + 'px');

            fn();

        }

    };



    /**

     * Shows the title and info bars.

     *

     * @param   Function    cb      A callback function to execute after the

     *                              animation completes

     * @return  void

     * @private

     */

    var showBars = function(cb){

        var title_i = SL.get('shadowbox_title_inner');

        var info_i = SL.get('shadowbox_info_inner');

        var t = title_i.innerHTML != ''; // is there a title to display?



        if(t) animate(title_i, 'margin-top', 0, 0.35);

        animate(info_i, 'margin-top', 0, 0.35, cb);

    };



    /**

     * Loads the Shadowbox with the current piece.

     *

     * @return  void

     * @private

     */

    var loadContent = function(){

        var obj = gallery[current];

        if(!obj) return; // invalid



        var changing = false;

        if(content){

            content.remove(); // remove old content first

            changing = true; // changing from some previous content

        }



        // determine player, inline is really just HTML

        var p = obj.player == 'inline' ? 'html' : obj.player;



        // make sure player is loaded

        if(typeof SB[p] != 'function'){

            SB.raise('Unknown player ' + obj.player);

        }

        content = new SB[p](content_id, obj); // instantiate new content object



        listenKeys(false); // disable the keyboard temporarily

        toggleLoading(true);



        hideBars(changing, function(){ // if changing, animate the bars transition

            if(!content) return;



            // if opening, clear #shadowbox display

            if(!changing){

                 SL.get('shadowbox').style.display = '';

            }



            var fn = function(){

                resizeContent(function(){

                    if(!content) return;





                    showBars(function(){

                        if(!content) return;



                        // append content just before hiding the loading layer

                        SL.get('shadowbox_body_inner').innerHTML = SL.createHTML(content.markup(dims));



                        toggleLoading(false, function(){

                            if(!content) return;



                            if(typeof content.onLoad == 'function'){

                                content.onLoad(); // call onLoad callback if present

                            }

                            if(options.onFinish && typeof options.onFinish == 'function'){

                                options.onFinish(gallery[current]); // fire onFinish handler

                            }

                            if(slide_timer != 'paused'){

                                SB.play(); // kick off next slide

                            }

                            listenKeys(true); // re-enable the keyboard

                        });

                    });

                });

            };



            if(typeof content.ready != 'undefined'){ // does the object have a ready property?

                var id = setInterval(function(){ // if so, wait for the object to be ready

                    if(content){

                        if(content.ready){

                            clearInterval(id); // clean up

                            id = null;

                            fn();

                        }

                    }else{ // content has been removed

                        clearInterval(id);

                        id = null;

                    }

                }, 100);

            }else{

                fn();

            }

        });



        // preload neighboring gallery images

        if(gallery.length > 1){

            var next = gallery[current + 1] || gallery[0];

            if(next.player == 'img'){

                var a = new Image();

                a.src = next.content;

            }

            var prev = gallery[current - 1] || gallery[gallery.length - 1];

            if(prev.player == 'img'){

                var b = new Image();

                b.src = prev.content;

            }

        }

    };



    /**

     * Calculates the dimensions for Shadowbox, taking into account the borders

     * and surrounding elements of the shadowbox_body. If the height/width

     * combination is too large for Shadowbox and handleOversize option is set

     * to 'resize', the resized dimensions will be returned (preserving the

     * original aspect ratio). Otherwise, the originally calculated dimensions

     * will be used. Stores all dimensions in the private dims variable.

     *

     * @param   Number      height      The content player height

     * @param   Number      width       The content player width

     * @param   Boolean     resizable   True if the content is able to be

     *                                  resized. Defaults to false.

     * @return  void

     * @private

     */

    var setDimensions = function(height, width, resizable){

        resizable = resizable || false;



        var sb = SL.get('shadowbox_body');

        var h = height = parseInt(height);

        var w = width = parseInt(width);

        var view_h = SL.getViewportHeight();

        var view_w = SL.getViewportWidth();



        // calculate the max width

        var border_w = parseInt(SL.getStyle(sb, 'border-left-width'), 10)

            + parseInt(SL.getStyle(sb, 'border-right-width'), 10);

        var extra_w = border_w + 2 * options.viewportPadding;

        if(w + extra_w >= view_w){

            w = view_w - extra_w;

        }



        // calculate the max height

        var border_h = parseInt(SL.getStyle(sb, 'border-top-width'), 10)

            + parseInt(SL.getStyle(sb, 'border-bottom-width'), 10);

        var bar_h = getComputedHeight(SL.get('shadowbox_title'))

            + getComputedHeight(SL.get('shadowbox_info'));

        var extra_h = border_h + 2 * options.viewportPadding + bar_h;

        if(h + extra_h >= view_h){

            h = view_h - extra_h;

        }



        // handle oversized content

        var drag = false;

        var resize_h = height;

        var resize_w = width;

        var handle = options.handleOversize;

        if(resizable && (handle == 'resize' || handle == 'drag')){

            var change_h = (height - h) / height;

            var change_w = (width - w) / width;

            if(handle == 'resize'){

                if(change_h > change_w){

                    w = Math.round((width / height) * h);

                }else if(change_w > change_h){

                    h = Math.round((height / width) * w);

                }

                // adjust resized height or width accordingly

                resize_w = w;

                resize_h = h;

            }else{

                // drag on oversized images only

                var link = gallery[current];

                if(link) drag = link.player == 'img' && (change_h > 0 || change_w > 0);

            }

        }



        // update dims

        dims = {

            height:     h + border_h + bar_h,

            width:      w + border_w,

            inner_h:    h,

            inner_w:    w,

            top:        (view_h - (h + extra_h)) / 2 + options.viewportPadding,

            resize_h:   resize_h,

            resize_w:   resize_w,

            drag:       drag

        };

    };



    /**

     * Resizes Shadowbox to the given height and width. If the callback

     * parameter is given, the transition will be animated and the callback

     * function will be called when the animation completes. Note: The private

     * content variable must be updated before calling this function.

     *

     * @param   Function    cb      A callback function to execute after the

     *                              content has been resized

     * @return  void

     * @private

     */

    var resizeContent = function(cb){

        if(!content) return; // no content



        // set new dimensions

        setDimensions(content.height, content.width, content.resizable);



        if(cb){

            switch(options.animSequence){

                case 'hw':

                    adjustHeight(dims.inner_h, dims.top, true, function(){

                        adjustWidth(dims.width, true, cb);

                    });

                    break;

                case 'wh':

                    adjustWidth(dims.width, true, function(){

                        adjustHeight(dims.inner_h, dims.top, true, cb);

                    });

                    break;

                case 'sync':

                default:

                    adjustWidth(dims.width, true);

                    adjustHeight(dims.inner_h, dims.top, true, cb);

            }

        }else{ // window resize

            adjustWidth(dims.width, false);

            adjustHeight(dims.inner_h, dims.top, false);

            var c = SL.get(content_id);

            if(c){

                // resize resizable content when in resize mode

                if(content.resizable && options.handleOversize == 'resize'){

                    c.height = dims.resize_h;

                    c.width = dims.resize_w;

                }

                // fix draggable positioning if enlarging viewport

                if(gallery[current].player == 'img' && options.handleOversize == 'drag'){

                    var top = parseInt(SL.getStyle(c, 'top'));

                    if(top + content.height < dims.inner_h){

                        SL.setStyle(c, 'top', dims.inner_h - content.height + 'px');

                    }

                    var left = parseInt(SL.getStyle(c, 'left'));

                    if(left + content.width < dims.inner_w){

                        SL.setStyle(c, 'left', dims.inner_w - content.width + 'px');

                    }

                }

            }

        }

    };



    /**

     * Adjusts the height of #shadowbox_body and centers #shadowbox vertically

     * in the viewport.

     *

     * @param   Number      height      The height to use for #shadowbox_body

     * @param   Number      top         The top to use for #shadowbox

     * @param   Boolean     anim        True to animate the transition

     * @param   Function    cb          A callback to use when the animation

     *                                  completes

     * @return  void

     * @private

     */

    var adjustHeight = function(height, top, anim, cb){

        height = parseInt(height);



        // adjust the height

        var sb = SL.get('shadowbox_body');

        if(anim){

            animate(sb, 'height', height, options.resizeDuration);

        }else{

            SL.setStyle(sb, 'height', height + 'px');

        }



        // adjust the top

        var s = SL.get('shadowbox');

        if(anim){

            animate(s, 'top', top, options.resizeDuration, cb);

        }else{

            SL.setStyle(s, 'top', top + 'px');

            if(typeof cb == 'function') cb();

        }

    };



    /**

     * Adjusts the width of #shadowbox.

     *

     * @param   Number      width       The width to use for #shadowbox

     * @param   Boolean     anim        True to animate the transition

     * @param   Function    cb          A callback to use when the animation

     *                                  completes

     * @return  void

     * @private

     */

    var adjustWidth = function(width, anim, cb){

        width = parseInt(width);



        // adjust the width

        var s = SL.get('shadowbox');

        if(anim){

            animate(s, 'width', width, options.resizeDuration, cb);

        }else{

            SL.setStyle(s, 'width', width + 'px');

            if(typeof cb == 'function') cb();

        }

    };



    /**

     * Sets up a listener on the document for keystrokes.

     *

     * @param   Boolean     on      True to enable the listener, false to turn

     *                              it off

     * @return  void

     * @private

     */

    var listenKeys = function(on){

        if(!options.enableKeys) return;

        SL[(on ? 'add' : 'remove') + 'Event'](document, 'keydown', handleKey);

    };



    /**

     * A listener function that is fired when a key is pressed.

     *

     * @param   mixed       e       The event object

     * @return  void

     * @private

     */

    var handleKey = function(e){

        var code = SL.keyCode(e);



        // attempt to prevent default key action

        SL.preventDefault(e);



        if(code == 81 || code == 88 || code == 27){ // q, x, or esc

            SB.close();

        }else if(code == 37){ // left arrow

            SB.previous();

        }else if(code == 39){ // right arrow

            SB.next();

        }else if(code == 32){ // space bar

            SB[(typeof slide_timer == 'number' ? 'pause' : 'play')]();

        }

    };



    /**

     * Toggles the visibility of the "loading" layer.

     *

     * @param   Boolean     on      True to toggle on, false to toggle off

     * @param   Function    cb      The callback function to call when toggling

     *                              completes

     * @return  void

     * @private

     */

    var toggleLoading = function(on, cb){

        var loading = SL.get('shadowbox_loading');

        if(on){

            loading.style.display = '';

            if(typeof cb == 'function') cb();

        }else{

            var p = gallery[current].player;

            var anim = (p == 'img' || p == 'html'); // fade on images & html

            var fn = function(){

                loading.style.display = 'none';

                clearOpacity(loading);

                if(typeof cb == 'function') cb();

            };

            if(anim){

                animate(loading, 'opacity', 0, options.fadeDuration, fn);

            }else{

                fn();

            }

        }

    };



    /**

     * Sets the top of the container element. This is only necessary in IE6

     * where the container uses absolute positioning instead of fixed.

     *

     * @return  void

     * @private

     */

    var fixTop = function(){

        SL.get('shadowbox_container').style.top = document.documentElement.scrollTop + 'px';

    };



    /**

     * Sets the height of the overlay element to the full viewport height. This

     * is only necessary in IE6 where the container uses absolute positioning

     * instead of fixed, thus restricting the size of the overlay element.

     *

     * @return  void

     * @private

     */

    var fixHeight = function(){

        SL.get('shadowbox_overlay').style.height = SL.getViewportHeight() + 'px';

    };



    /**

     * Determines if there is a next piece to display in the current gallery.

     *

     * @return  bool            True if there is another piece, false otherwise

     * @private

     */

    var hasNext = function(){

        return gallery.length > 1 && (current != gallery.length - 1 || options.continuous);

    };



    /**

     * Toggles the visibility of #shadowbox_container and sets its size (if on

     * IE6). Also toggles the visibility of elements (<select>, <object>, and

     * <embed>) that are troublesome for semi-transparent modal overlays. IE has

     * problems with <select> elements, while Firefox has trouble with

     * <object>s.

     *

     * @param   Function    cb      A callback to call after toggling on, absent

     *                              when toggling off

     * @return  void

     * @private

     */

    var toggleVisible = function(cb){

        var els, v = (cb) ? 'hidden' : 'visible';

        var hide = ['select', 'object', 'embed']; // tags to hide

        for(var i = 0; i < hide.length; ++i){

            els = document.getElementsByTagName(hide[i]);

            for(var j = 0, len = els.length; j < len; ++j){

                els[j].style.visibility = v;

            }

        }



        // resize & show container

        var so = SL.get('shadowbox_overlay');

        var sc = SL.get('shadowbox_container');

        var sb = SL.get('shadowbox');

        if(cb){

            // set overlay color/opacity

            SL.setStyle(so, {

                backgroundColor: options.overlayColor,

                opacity: 0

            });

            if(!options.modal) SL.addEvent(so, 'click', SB.close);

            if(ltIE7){

                // fix container top & overlay height before showing

                fixTop();

                fixHeight();

                SL.addEvent(window, 'scroll', fixTop);

            }



            // fade in animation

            sb.style.display = 'none'; // will be cleared in loadContent()

            sc.style.visibility = 'visible';

            animate(so, 'opacity', parseFloat(options.overlayOpacity), options.fadeDuration, cb);

        }else{

            SL.removeEvent(so, 'click', SB.close);

            if(ltIE7) SL.removeEvent(window, 'scroll', fixTop);



            // fade out effect

            sb.style.display = 'none';

            animate(so, 'opacity', 0, options.fadeDuration, function(){

                sc.style.visibility = 'hidden';

                sb.style.display = '';

                clearOpacity(so);

            });

        }

    };



    /**

     * Initializes the Shadowbox environment. Loads the skin (if necessary),

     * compiles the player matching regular expressions, and sets up the

     * window resize listener.

     *

     * @param   Object      opts    (optional) The default options to use

     * @return  void

     * @public

     * @static

     */

    Shadowbox.init = function(opts){

        // don't initialize twice

        if(initialized) return;



        // make sure language is loaded

        if(typeof SB.LANG == 'undefined'){

            SB.raise('No Shadowbox language loaded');

            return;

        }

        // make sure skin is loaded

        if(typeof SB.SKIN == 'undefined'){

            SB.raise('No Shadowbox skin loaded');

            return;

        }



        // apply custom options

        apply(options, opts || {});



        // add markup

        var markup = SB.SKIN.markup.replace(/\{(\w+)\}/g, function(m, p){

            return SB.LANG[p];

        });

        var bd = document.body || document.documentElement;

        SL.append(bd, markup);



        // several fixes for IE6

        if(ltIE7){

            // give the container absolute positioning

            SL.setStyle(SL.get('shadowbox_container'), 'position', 'absolute');

            // give shadowbox_body "layout"...whatever that is

            SL.get('shadowbox_body').style.zoom = 1;

            // use AlphaImageLoader for transparent PNG support

            var png = SB.SKIN.png_fix;

            if(png && png.constructor == Array){

                for(var i = 0; i < png.length; ++i){

                    var el = SL.get(png[i]);

                    if(el){

                        var match = SL.getStyle(el, 'background-image').match(/url\("(.*\.png)"\)/);

                        if(match){

                            SL.setStyle(el, {

                                backgroundImage: 'none',

                                filter: 'progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled=true,src=' + match[1] + ',sizingMethod=scale);'

                            });

                        }

                    }

                }

            }

        }



        // compile file type regular expressions here for speed

        for(var e in options.ext){

            RE[e] = new RegExp('\.(' + options.ext[e].join('|') + ')\s*$', 'i');

        }



        // set up window resize event handler

        var id;

        SL.addEvent(window, 'resize', function(){

            // use 50 ms event buffering to prevent jerky window resizing

            if(id){

                clearTimeout(id);

                id = null;

            }

            id = setTimeout(function(){

                if(ltIE7) fixHeight();

                resizeContent();

            }, 50);

        });



        if(!options.skipSetup) SB.setup();

        initialized = true;

    };



    /**

     * Dynamically loads the specified skin for use with Shadowbox. If the skin

     * is included already in the page via the appropriate <script> and <link>

     * tags, this function does not need to be called. Otherwise, this function

     * must be called before window.onload.

     *

     * @param   String      skin        The directory where the skin is located

     * @param   String      dir         The directory where the Shadowbox skin

     *                                  files are located

     * @return  void

     * @public

     * @static

     */

    Shadowbox.loadSkin = function(skin, dir){

        if(!(/\/$/.test(dir))) dir += '/';

        skin = dir + skin + '/';



        // Safari 2.0 fails using DOM, use document.write instead

        document.write('<link rel="stylesheet" type="text/css" href="' + skin + 'skin.css">');

        document.write('<scr' + 'ipt type="text/javascript" src="' + skin + 'skin.js"><\/script>');

    };



    /**

     * Dynamically loads the specified language file to be used with Shadowbox.

     * If the language file is included already in the page via the appropriate

     * <script> tag, this function does not need to be called. Otherwise, this

     * function must be called before window.onload.

     *

     * @param   String      lang        The language abbreviation (e.g. en)

     * @param   String      dir         The directory where the Shadowbox

     *                                  language file(s) is located

     * @return  void

     * @public

     * @static

     */

    Shadowbox.loadLanguage = function(lang, dir){

        if(!(/\/$/.test(dir))) dir += '/';



        // Safari 2.0 fails using DOM, use document.write instead

        document.write('<scr' + 'ipt type="text/javascript" src="' + dir + 'shadowbox-' + lang + '.js"><\/script>');

    };



    /**

     * Dynamically loads the specified player(s) to be used with Shadowbox. If

     * the needed player(s) is already included in the page via the appropriate

     * <script> tag(s), this function does not need to be called. Otherwise,

     * this function must be called before window.onload.

     *

     * @param   Array       players     The player(s) to load

     * @param   String      dir         The director where the Shadowbox player

     *                                  file(s) is located

     * @return  void

     * @public

     * @static

     */

    Shadowbox.loadPlayer = function(players, dir){

        if(typeof players == 'string') players = [players];

        if(!(/\/$/.test(dir))) dir += '/';



        for(var i = 0, len = players.length; i < len; ++i){

            // Safari 2.0 fails using DOM, use document.write instead

            document.write('<scr' + 'ipt type="text/javascript" src="' + dir + 'shadowbox-' + players[i] + '.js"><\/script>');

        }

    };



    /**

     * Sets up listeners on the given links that will trigger Shadowbox. If no

     * links are given, this method will set up every anchor element on the page

     * with the appropriate rel attribute. Note: Because AREA elements do not

     * support the rel attribute, they must be explicitly passed to this method.

     *

     * @param   Array       links       An array (or array-like) list of anchor

     *                                  and/or area elements to set up

     * @param   Object      opts        Some options to use for the given links

     * @return  void

     * @public

     * @static

     */

    Shadowbox.setup = function(links, opts){

        // get links if none specified

        if(!links){

            var links = [];

            var a = document.getElementsByTagName('a'), rel;

            for(var i = 0, len = a.length; i < len; ++i){

                rel = a[i].getAttribute('rel');

                if(rel && RE.rel.test(rel)) links[links.length] = a[i];

            }

        }else if(!links.length){

            links = [links]; // one link

        }



        var link;

        for(var i = 0, len = links.length; i < len; ++i){

            link = links[i];

            if(typeof link.shadowboxCacheKey == 'undefined'){

                // assign cache key expando

                // use integer primitive to avoid memory leak in IE

                link.shadowboxCacheKey = cache.length;

                SL.addEvent(link, 'click', handleClick); // add listener

            }

            cache[link.shadowboxCacheKey] = this.buildCacheObj(link, opts);

        }

    };



    /**

     * Builds an object from the original link element data to store in cache.

     * These objects contain (most of) the following keys:

     *

     * - el: the link element

     * - title: the linked file title

     * - player: the player to use for the linked file

     * - content: the linked file's URL

     * - gallery: the gallery the file belongs to (optional)

     * - height: the height of the linked file (only necessary for movies)

     * - width: the width of the linked file (only necessary for movies)

     * - options: custom options to use (optional)

     *

     * @param   HTMLElement     link    The link element to process

     * @return  Object                  An object representing the link

     * @public

     * @static

     */

    Shadowbox.buildCacheObj = function(link, opts){

        var href = link.href; // don't use getAttribute() here

        var o = {

            el:         link,

            title:      link.getAttribute('title'),

            player:     getPlayer(href),

            options:    apply({}, opts || {}), // break the reference

            content:    href

        };



        // remove link-level options from top-level options

        var opt, l_opts = ['player', 'title', 'height', 'width', 'gallery'];

        for(var i = 0, len = l_opts.length; i < len; ++i){

            opt = l_opts[i];

            if(typeof o.options[opt] != 'undefined'){

                o[opt] = o.options[opt];

                delete o.options[opt];

            }

        }



        // HTML options always trump JavaScript options, so do these last

        var rel = link.getAttribute('rel');

        if(rel){

            // extract gallery name from shadowbox[name] format

            var match = rel.match(RE.gallery);

            if(match) o.gallery = escape(match[2]);



            // other parameters

            var params = rel.split(';');

            for(var i = 0, len = params.length; i < len; ++i){

                match = params[i].match(RE.param);

                if(match){

                    if(match[1] == 'options'){

                        eval('apply(o.options, ' + match[2] + ')');

                    }else{

                        o[match[1]] = match[2];

                    }

                }

            }

        }



        return o;

    };



    /**

     * Applies the given set of options to those currently in use. Note: Options

     * will be reset on Shadowbox.open() so this function is only useful after

     * it has already been called (while Shadowbox is open).

     *

     * @param   Object      opts        The options to apply

     * @return  void

     * @public

     * @static

     */

    Shadowbox.applyOptions = function(opts){

        if(opts){

            // use apply here to break references

            default_options = apply({}, options); // store default options

            options = apply(options, opts); // apply options

        }

    };



    /**

     * Reverts Shadowbox' options to the last default set in use before

     * Shadowbox.applyOptions() was called.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.revertOptions = function(){

        if(default_options){

            options = default_options; // revert to default options

            default_options = null; // erase for next time

        }

    };



    /**

     * Opens the given object in Shadowbox. This object may be either an

     * anchor/area element, or an object similar to the one created by

     * Shadowbox.buildCacheObj().

     *

     * @param   mixed       obj         The object or link element that defines

     *                                  what to display

     * @return  void

     * @public

     * @static

     */

    Shadowbox.open = function(obj, opts){

        // revert options

        this.revertOptions();



        // is it a link?

        if(isLink(obj)){

            if(typeof obj.shadowboxCacheKey == 'undefined' || typeof cache[obj.shadowboxCacheKey] == 'undefined'){

                // link element that hasn't been set up before

                // create on-the-fly object

                obj = this.buildCacheObj(obj, opts);

            }else{

                // link element that has been set up before, get from cache

                obj = cache[obj.shadowboxCacheKey];

            }

        }



        // is it already a gallery?

        if(obj.constructor == Array){

            gallery = obj;

            current = 0;

        }else{

            // create a copy so it doesn't get modified later

            var copy = apply({}, obj);



            // is it part of a gallery?

            if(!obj.gallery){ // single item, no gallery

                gallery = [copy];

                current = 0;

            }else{

                current = null; // reset current

                gallery = []; // clear the current gallery

                var ci;

                for(var i = 0, len = cache.length; i < len; ++i){

                    ci = cache[i];

                    if(ci.gallery){

                        if(ci.content == obj.content

                            && ci.gallery == obj.gallery

                            && ci.title == obj.title){ // compare content, gallery, & title

                                current = gallery.length; // key element found

                        }

                        if(ci.gallery == obj.gallery){

                            gallery.push(apply({}, ci));

                        }

                    }

                }

                // if not found in cache, prepend to front of gallery

                if(current == null){

                    gallery.unshift(copy);

                    current = 0;

                }

            }

        }



        obj = gallery[current];



        // apply custom options

        if(obj.options || opts){

            // use apply here to break references

            this.applyOptions(apply(apply({}, obj.options || {}), opts || {}));

        }



        // filter gallery for unsupported elements

        var match, r;

        for(var i = 0, len = gallery.length; i < len; ++i){

            r = false; // remove the element?

            if(gallery[i].player == 'unsupported'){ // don't support this at all

                r = true;

            }else if(match = RE.unsupported.exec(gallery[i].player)){ // handle unsupported elements

                if(options.handleUnsupported == 'link'){

                    gallery[i].player = 'html';

                    // generate a link to the appropriate plugin download page(s)

                    var s, a, oe = options.errors;

                    switch(match[1]){

                        case 'qtwmp':

                            s = 'either';

                            a = [oe.qt.url, oe.qt.name, oe.wmp.url, oe.wmp.name];

                        break;

                        case 'qtf4m':

                            s = 'shared';

                            a = [oe.qt.url, oe.qt.name, oe.f4m.url, oe.f4m.name];

                        break;

                        default:

                            s = 'single';

                            if(match[1] == 'swf' || match[1] == 'flv') match[1] = 'fla';

                            a = [oe[match[1]].url, oe[match[1]].name];

                    }

                    var msg = SB.LANG.errors[s].replace(/\{(\d+)\}/g, function(m, i){

                        return a[i];

                    });

                    gallery[i].content = '<div class="shadowbox_message">' + msg + '</div>';

                }else{

                    r = true;

                }

            }else if(gallery[i].player == 'inline'){ // handle inline elements

                // retrieve the innerHTML of the inline element

                var match = RE.inline.exec(gallery[i].content);

                if(match){

                    var el;

                    if(el = SL.get(match[1])){

                        gallery[i].content = el.innerHTML;

                    }else{

                        SB.raise('Cannot find element with id ' + match[1]);

                    }

                }else{

                    SB.raise('Cannot find element id for inline content');

                }

            }

            if(r){

                gallery.splice(i, 1); // remove the element from the gallery

                if(i < current){

                    --current;

                }else if(i == current){

                    // if current is unsupported, look for supported neighbor

                    current = i > 0 ? current - 1 : i;

                }

                --i; // decrement to account for splice

                len = gallery.length; // gallery.length has changed!

            }

        }



        // anything left?

        if(gallery.length){

            // fire onOpen hook

            if(options.onOpen && typeof options.onOpen == 'function'){

                options.onOpen(obj);

            }



            if(!activated){

                // set initial dimensions & load

                setDimensions(options.initialHeight, options.initialWidth);

                adjustHeight(dims.inner_h, dims.top, false);

                adjustWidth(dims.width, false);

                toggleVisible(loadContent);

            } else {

                loadContent();

            }



            activated = true;

        }

    };



    /**

     * Jumps to the piece in the current gallery with index num.

     *

     * @param   Number      num     The gallery index to view

     * @return  void

     * @public

     * @static

     */

    Shadowbox.change = function(num){

        if(!gallery) return; // no current gallery

        if(!gallery[num]){ // index does not exist

            if(!options.continuous){

                return;

            }else{

                num = num < 0 ? (gallery.length - 1) : 0; // loop

            }

        }



        if(typeof slide_timer == 'number'){

            clearTimeout(slide_timer);

            slide_timer = null;

            slide_delay = slide_start = 0; // reset slideshow variables

        }

        current = num; // update current



        if(options.onChange && typeof options.onChange == 'function'){

            options.onChange(gallery[current]); // fire onChange handler

        }



        loadContent();

    };



    /**

     * Jumps to the next piece in the gallery.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.next = function(){

        this.change(current + 1);

    };



    /**

     * Jumps to the previous piece in the gallery.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.previous = function(){

        this.change(current - 1);

    };



    /**

     * Sets the timer for the next image in the slideshow to be displayed.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.play = function(){

        if(!hasNext()) return;

        if(!slide_delay) slide_delay = options.slideshowDelay * 1000;

        if(slide_delay){

            slide_start = new Date().getTime();

            slide_timer = setTimeout(function(){

                slide_delay = slide_start = 0; // reset slideshow

                SB.next();

            }, slide_delay);



            // change play nav to pause

            toggleNav('play', false);

            toggleNav('pause', true);

        }

    };



    /**

     * Pauses the current slideshow.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.pause = function(){

        if(typeof slide_timer == 'number'){

            var time = new Date().getTime();

            slide_delay = Math.max(0, slide_delay - (time - slide_start));



            // any delay left on current slide? if so, stop the timer

            if(slide_delay){

                clearTimeout(slide_timer);

                slide_timer = 'paused';

            }



            // change pause nav to play

            toggleNav('pause', false);

            toggleNav('play', true);

        }

    };



    /**

     * Deactivates Shadowbox.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.close = function(){

        if(!activated) return; // already closed



        // stop listening for keys

        listenKeys(false);

        // hide

        toggleVisible(false);

        // remove the content

        if(content){

            content.remove();

            content = null;

        }



        // clear slideshow variables

        if(typeof slide_timer == 'number') clearTimeout(slide_timer);

        slide_timer = null;

        slide_delay = 0;



        // fire onClose handler

        if(options.onClose && typeof options.onClose == 'function'){

            options.onClose(gallery[current]);

        }



        activated = false;

    };



    /**

     * Clears Shadowbox' cache and removes listeners and expandos from all

     * cached link elements. May be used to completely reset Shadowbox in case

     * links on a page change.

     *

     * @return  void

     * @public

     * @static

     */

    Shadowbox.clearCache = function(){

        for(var i = 0, len = cache.length; i < len; ++i){

            if(cache[i].el){

                SL.removeEvent(cache[i].el, 'click', handleClick);

                delete cache[i].el.shadowboxCacheKey; // remove expando

            }

        }

        cache = [];

    };



    /**

     * Gets an object that lists which plugins are supported by the client. The

     * keys of this object will be:

     *

     * - fla: Adobe Flash Player

     * - qt: QuickTime Player

     * - wmp: Windows Media Player

     * - f4m: Flip4Mac QuickTime Player

     *

     * @return  Object          The plugins object

     * @public

     * @static

     */

    Shadowbox.getPlugins = function(){

        return plugins;

    };



    /**

     * Gets the current options object in use.

     *

     * @return  Object          The options object

     * @public

     * @static

     */

    Shadowbox.getOptions = function(){

        return options;

    };



    /**

     * Gets the current gallery object.

     *

     * @return  Object          The current gallery item

     * @public

     * @static

     */

    Shadowbox.getCurrent = function(){

        return gallery[current];

    };



    /**

     * Gets the current version number of Shadowbox.

     *

     * @return  String          The current version

     * @public

     * @static

     */

    Shadowbox.getVersion = function(){

        return version;

    };



    /**

     * Returns an object containing information about the current client

     * configuration.

     *

     * @return  Object          The object containing client data

     * @public

     * @static

     */

    Shadowbox.getClient = function(){

        return client;

    };



    /**

     * Returns the current content object in use.

     *

     * @return  Object          The current content object

     * @public

     * @static

     */

    Shadowbox.getContent = function(){

        return content;

    };



    /**

     * Gets the current dimensions of Shadowbox as calculated by

     * setDimensions().

     *

     * @return  Object          The current dimensions of Shadowbox

     * @public

     * @static

     */

    Shadowbox.getDimensions = function(){

        return dims;

    };



    /**

     * Handles all Shadowbox exceptions (errors). Calls the exception

     * handler callback if one is present (see handleException option) or

     * throws a new exception.

     *

     * @param   String      e       The error message

     * @return  void

     * @public

     * @static

     */

    Shadowbox.raise = function(e){

        if(typeof options.handleException == 'function'){

            options.handleException(e);

        }else{

            throw e;

        }

    };



})();









/**

 * The "classic" theme markup for Shadowbox.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: skin.js 108 2008-07-11 04:19:01Z mjijackson $

 */



if(typeof Shadowbox == 'undefined'){

    throw 'Unable to load Shadowbox skin, base library not found.';

}



/**

 * The HTML markup to use for Shadowbox.

 *

 * IMPORTANT: The script depends on most of these elements being present.

 *

 * @property    {Object}    SKIN

 * @public

 * @static

 */

Shadowbox.SKIN = {



    markup:     '<div id="shadowbox_container">' +

                    '<div id="shadowbox_overlay"></div>' +

                    '<div id="shadowbox">' +

                        '<div id="shadowbox_title">' +

                            '<div id="shadowbox_title_inner"></div>' +

                        '</div>' +

                        '<div id="shadowbox_body">' +

                            '<div id="shadowbox_body_inner"></div>' +

                            '<div id="shadowbox_loading">' +

                                '<div id="shadowbox_loading_indicator"></div>' +

                                '<span><a onclick="Shadowbox.close();"><!-- {cancel} --></a></span>' +

                            '</div>' +

                        '</div>' +

                        '<div id="shadowbox_info">' +

                            '<div id="shadowbox_info_inner">' +

                                '<div id="shadowbox_counter"></div>' +

                                '<div id="shadowbox_nav">' +

                                    '<a id="shadowbox_nav_close" title="{close}" onclick="Shadowbox.close()"></a>' +

                                    '<a id="shadowbox_nav_next" title="{next}" onclick="Shadowbox.next()"></a>' +

                                    '<a id="shadowbox_nav_play" title="{play}" onclick="Shadowbox.play()"></a>' +

                                    '<a id="shadowbox_nav_pause" title="{pause}" onclick="Shadowbox.pause()"></a>' +

                                    '<a id="shadowbox_nav_previous" title="{previous}" onclick="Shadowbox.previous()"></a>' +

                                '</div>' +

                                '<div class="shadowbox_clear"></div>' +

                            '</div>' +

                        '</div>' +

                    '</div>' +

                '</div>',



    png_fix:    [

        'shadowbox_nav_close',

        'shadowbox_nav_next',

        'shadowbox_nav_play',

        'shadowbox_nav_pause',

        'shadowbox_nav_previous'

    ]



};







/**

 * The German (Deutsch) language file for Shadowbox.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-de-DE.js 100 2008-06-23 02:31:30Z mjijackson $

 */



if(typeof Shadowbox == 'undefined'){

    throw 'Unable to load Shadowbox language file, base library not found.';

}



/**

 * An object containing all textual messages to be used in Shadowbox. These are

 * provided so they may be translated into different languages. Alternative

 * translations may be found in js/lang/shadowbox-*.js where * is an abbreviation

 * of the language name (see

 * http://www.gnu.org/software/gettext/manual/gettext.html#Language-Codes).

 *

 * @var     {Object}    LANG

 * @public

 * @static

 */

Shadowbox.LANG = {



    code:       'de',



    of:         'von',



    loading:    'ladend',



    cancel:     'Abbrechen',



    next:       'Nächste',



    previous:   'Vorige',



    play:       'Abspielen',



    pause:      'Pause',



    close:      'Schließen',



    errors:     {

        single: 'Um den Inhalt anzeigen zu können muss die Browser-Erweiterung <a href="{0}">{1}</a> installiert werden.',

        shared: 'Um den Inhalt anzeigen zu können müssen die beiden Browser-Erweiterungen <a href="{0}">{1}</a> und <a href="{2}">{3}</a> installiert werden.',

        either: 'Um den Inhalt anzeigen zu können muss eine der beiden Browser-Erweiterungen <a href="{0}">{1}</a> oder <a href="{2}">{3}</a> installiert werden.'

    }



};



/**

 * The Shadowbox Flash video player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-flv.js 99 2008-05-11 16:22:43Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;



    /**

     * Constructor. This class is used to display Flash videos with the JW

     * FLV player.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.flv = function(id, obj){

        this.id = id;

        this.obj = obj;



        // FLV's are resizable

        this.resizable = true;



        // height defaults to 300 pixels

        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;

        if(SB.getOptions().showMovieControls == true){

            this.height += 20; // height of JW FLV player controller

        }



        // width defaults to 300 pixels

        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;

    };



    Shadowbox.flv.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            var obj = this.obj;



            // use resized dimensions

            var h = dims.resize_h;

            var w = dims.resize_w;



            var options = SB.getOptions();

            var autoplay = String(options.autoplayMovies);

            var controls = options.showMovieControls;

            var showicons = String(controls);

            var displayheight = h - (controls ? 20 : 0); // subtract controller height

            var flashvars = [

                'file=' + this.obj.content,

                'height=' + h,

                'width=' + w,

                'autostart=' + autoplay,

                'displayheight=' + displayheight,

                'showicons=' + showicons,

                'backcolor=0x000000',

                'frontcolor=0xCCCCCC',

                'lightcolor=0x557722'

            ];



            return {

                tag:        'object',

                id:         this.id,

                name:       this.id,

                type:       'application/x-shockwave-flash',

                data:       options.flvPlayer,

                children:   [

                    { tag: 'param', name: 'movie', value: options.flvPlayer },

                    { tag: 'param', name: 'flashvars', value: flashvars.join('&amp;') },

                    { tag: 'param', name: 'allowfullscreen', value: 'true' }

                ],

                height:     h, // new height includes controller

                width:      w

            };

        },



        /**

         * Removes this movie from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            var el = SL.get(this.id);

            if(el) SL.remove(el);

        }



    };



})();





/**

 * The Shadowbox HTML player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-html.js 99 2008-05-11 16:22:43Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;



    /**

     * Constructor. This class is used to display inline HTML.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.html = function(id, obj){

        this.id = id;

        this.obj = obj;



        // height defaults to 300

        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;



        // width defaults to 500

        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 500;

    };



    Shadowbox.html.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            return {

                tag:    'div',

                id:     this.id,

                cls:    'html', // give special class to enable scrolling

                html:   this.obj.content

            };

        },



        /**

         * Removes this content from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            var el = SL.get(this.id);

            if(el) SL.remove(el);

        }



    };



})();





/**

 * The Shadowbox iframe player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-iframe.js 108 2008-07-11 04:19:01Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;

    var C = SB.getClient();



    /**

     * Constructor. This class is used to display web pages in an HTML iframe.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.iframe = function(id, obj){

        this.id = id;

        this.obj = obj;



        // height defaults to full viewport height

        this.height = this.obj.height ? parseInt(this.obj.height, 10) : SL.getViewportHeight();



        // width defaults to full viewport width

        this.width = this.obj.width ? parseInt(this.obj.width, 10) : SL.getViewportWidth();

    };



    Shadowbox.iframe.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            var markup = {

                tag:            'iframe',

                id:             this.id,

                name:           this.id,

                height:         '100%',

                width:          '100%',

                frameborder:    '0',

                marginwidth:    '0',

                marginheight:   '0',

                scrolling:      'auto'

            };



            if(C.isIE){

                // prevent brief whiteout while loading iframe source

                markup.allowtransparency = 'true';



                if(!C.isIE7){

                    // prevent "secure content" warning for https on IE6

                    // see http://www.zachleat.com/web/2007/04/24/adventures-in-i-frame-shims-or-how-i-learned-to-love-the-bomb/

                    markup.src = 'javascript:false;document.write("");';

                }

            }



            return markup;

        },



        /**

         * An optional callback function to process after this content has been

         * loaded.

         *

         * @return  void

         * @public

         */

        onLoad: function(){

            var win = (C.isIE) ? SL.get(this.id).contentWindow : window.frames[this.id];

            win.location = this.obj.content; // set the iframe's location

        },



        /**

         * Removes this iframe from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            var el = SL.get(this.id);

            if(el){

                SL.remove(el);

                if(C.isGecko) delete window.frames[this.id]; // needed for Firefox

            }

        }



    };



})();





/**

 * The Shadowbox image player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-img.js 103 2008-06-27 06:19:21Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;

    var C = SB.getClient();



    /**

     * Keeps track of 4 floating values (x, y, start_x, & start_y) that are used

     * in the drag calculations.

     *

     * @property    {Object}        drag

     * @private

     */

    var drag;



    /**

     * Holds the draggable element so we don't have to fetch it every time

     * the mouse moves.

     *

     * @property    {HTMLElement}   draggable

     * @private

     */

    var draggable;



    /**

     * The id to use for the drag layer.

     *

     * @property    {String}        drag_id

     * @private

     */

    var drag_id = 'shadowbox_drag_layer';



    /**

     * Resource used to preload images. It's class-level so that when a new

     * image is requested, the same resource can be reassigned, cancelling

     * the original's callback.

     *

     * @property    {HTMLElement}   preloader

     * @private

     */

    var preloader;



    /**

     * Resets the class drag variable.

     *

     * @return  void

     * @private

     */

    var resetDrag = function(){

        drag = {

            x:          0,

            y:          0,

            start_x:    null,

            start_y:    null

        };

    };



    /**

     * Toggles the drag function on and off.

     *

     * @param   {Boolean}   on      True to toggle on, false to toggle off

     * @param   {Number}    h       The height of the drag layer

     * @param   {Number}    w       The width of the drag layer

     * @return  void

     * @private

     */

    var toggleDrag = function(on, h, w){

        if(on){

            resetDrag();

            // add transparent drag layer to prevent browser dragging of actual image

            var styles = [

                'position:absolute',

                'height:' + h + 'px',

                'width:' + w + 'px',

                'cursor:' + (C.isGecko ? '-moz-grab' : 'move'),

                'background-color:' + (C.isIE ? '#fff;filter:alpha(opacity=0)' : 'transparent')

            ];

            SL.append(SL.get('shadowbox_body_inner'), '<div id="' + drag_id + '" style="' + styles.join(';') + '"></div>');

            SL.addEvent(SL.get(drag_id), 'mousedown', listenDrag);

        }else{

            var d = SL.get(drag_id);

            if(d){

                SL.removeEvent(d, 'mousedown', listenDrag);

                SL.remove(d);

            }

        }

    };



    /**

     * Sets up a drag listener on the document. Called when the mouse button is

     * pressed (mousedown).

     *

     * @param   {mixed}     e       The mousedown event

     * @return  void

     * @private

     */

    var listenDrag = function(e){

        // prevent browser dragging

        SL.preventDefault(e);



        var coords = SL.getPageXY(e);

        drag.start_x = coords[0];

        drag.start_y = coords[1];



        draggable = SL.get('shadowbox_content');

        SL.addEvent(document, 'mousemove', positionDrag);

        SL.addEvent(document, 'mouseup', unlistenDrag);

        if(C.isGecko) SL.setStyle(SL.get(drag_id), 'cursor', '-moz-grabbing');

    };



    /**

     * Removes the drag listener. Called when the mouse button is released

     * (mouseup).

     *

     * @return  void

     * @private

     */

    var unlistenDrag = function(){

        SL.removeEvent(document, 'mousemove', positionDrag);

        SL.removeEvent(document, 'mouseup', unlistenDrag); // clean up

        if(C.isGecko) SL.setStyle(SL.get(drag_id), 'cursor', '-moz-grab');

    };



    /**

     * Positions an oversized image on drag.

     *

     * @param   {mixed}     e       The drag event

     * @return  void

     * @private

     */

    var positionDrag = function(e){

        var content = SB.getContent();

        var dims = SB.getDimensions();

        var coords = SL.getPageXY(e);



        var move_x = coords[0] - drag.start_x;

        drag.start_x += move_x;

        drag.x = Math.max(Math.min(0, drag.x + move_x), dims.inner_w - content.width); // x boundaries

        SL.setStyle(draggable, 'left', drag.x + 'px');



        var move_y = coords[1] - drag.start_y;

        drag.start_y += move_y;

        drag.y = Math.max(Math.min(0, drag.y + move_y), dims.inner_h - content.height); // y boundaries

        SL.setStyle(draggable, 'top', drag.y + 'px');

    };



    /**

     * Constructor. This class is used to display images.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.img = function(id, obj){

        this.id = id;

        this.obj = obj;



        // images are resizable

        this.resizable = true;



        // preload the image

        this.ready = false;

        var self = this; // needed inside preloader callback

        preloader = new Image();

        preloader.onload = function(){

            // height defaults to image height

            self.height = self.obj.height ? parseInt(self.obj.height, 10) : preloader.height;



            // width defaults to image width

            self.width = self.obj.width ? parseInt(self.obj.width, 10) : preloader.width;



            // ready to go

            self.ready = true;



            // clean up to prevent memory leak in IE

            preloader.onload = '';

            preloader = null;

        };

        preloader.src = obj.content;

    };



    Shadowbox.img.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            return {

                tag:    'img',

                id:     this.id,

                height: dims.resize_h, // use resized dimensions

                width:  dims.resize_w,

                src:    this.obj.content,

                style:  'position:absolute'

            };

        },



        /**

         * An optional callback function to process after this content has been

         * loaded.

         *

         * @return  void

         * @public

         */

        onLoad: function(){

            var dims = SB.getDimensions();

            if(dims.drag && SB.getOptions().handleOversize == 'drag'){

                // listen for drag

                // in the case of oversized images, the "resized" height and

                // width will actually be the original image height and width

                toggleDrag(true, dims.resize_h, dims.resize_w);

            }

        },



        /**

         * Removes this image from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            var el = SL.get(this.id);

            if(el) SL.remove(el);



            // disable drag layer

            toggleDrag(false);



            // prevent old image requests from loading

            if(preloader){

                preloader.onload = '';

                preloader = null;

            }

        }



    };



})();





/**

 * The Shadowbox QuickTime player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-qt.js 104 2008-06-28 20:09:34Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;

    var C = SB.getClient();



    /**

     * Constructor. This class is used to display QuickTime movies.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.qt = function(id, obj){

        this.id = id;

        this.obj = obj;



        // height defaults to 300 pixels

        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;

        if(SB.getOptions().showMovieControls == true){

            this.height += 16; // height of QuickTime controller

        }



        // width defaults to 300 pixels

        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;

    };



    Shadowbox.qt.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            var options = SB.getOptions();

            var autoplay = String(options.autoplayMovies);

            var controls = String(options.showMovieControls);



            var markup = {

                tag:        'object',

                id:         this.id,

                name:       this.id,

                height:     this.height, // height includes controller

                width:      this.width,

                children:   [

                    { tag: 'param', name: 'src', value: this.obj.content },

                    { tag: 'param', name: 'scale', value: 'aspect' },

                    { tag: 'param', name: 'controller', value: controls },

                    { tag: 'param', name: 'autoplay', value: autoplay }

                ],

                kioskmode:  'true'

            };

            if(C.isIE){

                markup.classid = 'clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B';

                markup.codebase = 'http://www.apple.com/qtactivex/qtplugin.cab#version=6,0,2,0';

            }else{

                markup.type = 'video/quicktime';

                markup.data = this.obj.content;

            }



            return markup;

        },



        /**

         * Removes this movie from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            try{

                document[this.id].Stop(); // stop QT video stream

            }catch(e){}

            var el = SL.get(this.id);

            if(el){

                //el.innerHTML = ''; // stop QT audio stream for movies that have not yet loaded

                SL.remove(el);

            }

        }



    };



})();





/**

 * The Shadowbox SWF movie player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-swf.js 99 2008-05-11 16:22:43Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;



    /**

     * Constructor. This class is used to display SWF movies.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.swf = function(id, obj){

        this.id = id;

        this.obj = obj;



        // SWF's are resizable

        this.resizable = true;



        // height defaults to 300 pixels

        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;



        // width defaults to 300 pixels

        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;

    };



    Shadowbox.swf.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            var bgcolor = SB.getOptions().flashBgColor;

            return {

                tag:        'object',

                id:         this.id,

                name:       this.id,

                type:       'application/x-shockwave-flash',

                data:       this.obj.content,

                children:   [

                    { tag: 'param', name: 'movie', value: this.obj.content },

                    { tag: 'param', name: 'bgcolor', value: bgcolor }

                ],

                height:     dims.resize_h, // use resized dimensions

                width:      dims.resize_w

            };

        },



        /**

         * Removes this SWF from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            var el = SL.get(this.id);

            if(el) SL.remove(el);

        }



    };



})();





/**

 * The Shadowbox Windows Media player class.

 *

 * This file is part of Shadowbox.

 *

 * Shadowbox is an online media viewer application that supports all of the

 * web's most popular media publishing formats. Shadowbox is written entirely

 * in JavaScript and CSS and is highly customizable. Using Shadowbox, website

 * authors can showcase a wide assortment of media in all major browsers without

 * navigating users away from the linking page.

 *

 * Shadowbox is released under version 3.0 of the Creative Commons Attribution-

 * Noncommercial-Share Alike license. This means that it is absolutely free

 * for personal, noncommercial use provided that you 1) make attribution to the

 * author and 2) release any derivative work under the same or a similar

 * license.

 *

 * If you wish to use Shadowbox for commercial purposes, licensing information

 * can be found at http://mjijackson.com/shadowbox/.

 *

 * @author      Michael J. I. Jackson <mjijackson@gmail.com>

 * @copyright   2007-2008 Michael J. I. Jackson

 * @license     http://creativecommons.org/licenses/by-nc-sa/3.0/

 * @version     SVN: $Id: shadowbox-wmp.js 99 2008-05-11 16:22:43Z mjijackson $

 */



(function(){



    // shorthand

    var SB = Shadowbox;

    var SL = SB.lib;

    var C = SB.getClient();



    /**

     * Constructor. This class is used to display Windows Media Player movies.

     *

     * @param   {String}    id      The id to use for this content

     * @param   {Object}    obj     The content object

     * @public

     */

    Shadowbox.wmp = function(id, obj){

        this.id = id;

        this.obj = obj;



        // height defaults to 300 pixels

        this.height = this.obj.height ? parseInt(this.obj.height, 10) : 300;

        if(SB.getOptions().showMovieControls){

            // add height of WMP controller in IE or non-IE respectively

            this.height += (C.isIE ? 70 : 45);

        }



        // width defaults to 300 pixels

        this.width = this.obj.width ? parseInt(this.obj.width, 10) : 300;

    };



    Shadowbox.wmp.prototype = {



        /**

         * Returns an object containing the markup for this content, suitable

         * to pass to Shadowbox.lib.createHTML().

         *

         * @param   {Object}    dims    The current Shadowbox dimensions

         * @return  {Object}            The markup for this content item

         * @public

         */

        markup: function(dims){

            var options = SB.getOptions();

            var autoplay = options.autoplayMovies ? 1 : 0;



            var markup = {

                tag:        'object',

                id:         this.id,

                name:       this.id,

                height:     this.height, // height includes controller

                width:      this.width,

                children:   [

                    { tag: 'param', name: 'autostart', value: autoplay }

                ]

            };

            if(C.isIE){

                var controls = options.showMovieControls ? 'full' : 'none';

                // markup.type = 'application/x-oleobject';

                markup.classid = 'clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6';

                markup.children[markup.children.length] = { tag: 'param', name: 'url', value: this.obj.content };

                markup.children[markup.children.length] = { tag: 'param', name: 'uimode', value: controls };

            }else{

                var controls = options.showMovieControls ? 1 : 0;

                markup.type = 'video/x-ms-wmv';

                markup.data = this.obj.content;

                markup.children[markup.children.length] = { tag: 'param', name: 'showcontrols', value: controls };

            }



            return markup;

        },



        /**

         * Removes this movie from the document.

         *

         * @return  void

         * @public

         */

        remove: function(){

            if(C.isIE){

                try{

                    window[this.id].controls.stop(); // stop the movie

                    window[this.id].URL = 'non-existent.wmv'; // force player refresh

                    window[this.id] = function(){}; // remove from window object

                }catch(e){}

            }

            var el = SL.get(this.id);

            if(el){

                setTimeout(function(){ // using setTimeout prevents browser crashes with WMP

                    SL.remove(el);

                }, 10);

            }

        }



    };



})();







/**

 * @class tkid

 * @version 0.3.1

 * @author biophonc

 *

 * licenced under: http://creativecommons.org/licenses/by-sa/3.0/

 */

var tkid={};





/**

 * static methods

 */

tkid.Helper={

	/**

	 * checks if Scriptaculous is loaded.

	 * @return bool

	 */

	ready: function() {

		return (typeof Scriptaculous=='object') ? true : false;

	},



	/**

	 * checks if the givin value is negative

	 * @param int number

	 * @return bool

	 */

	isNegative: function(number) {

		return (number < 0) ? true : false;

	},



	/**

	 * checks if the givin value is an int

	 * @param mixed number

	 * @return bool

	 */

	isInteger: function(number) {

		return (number.toString().search(/^-?[0-9]+$/) === 0);

	},



	/**

	 * converts a negative int to a positive value

	 * @param int number

	 * @return int

	 */

	negativeToPositive: function(number) {

		return (this.isNegative(number)) ? number*(-1) : number;

	},





	/**

	 * square a quantity

	 * @param int number

	 * @return {}

	 */

	toSquare: function(number) {

		return number*number;

	},



	/**

	 *

	 * @return {}

	 */

	isFF2: function() {

		var reFF2 = /Firefox\/2/i;

		return reFF2.match(navigator.userAgent);

	},



	/**

	 *

	 * @return {}

	 */

	isFF3: function() {

		var reFF3 = /Firefox\/3/i;

		return reFF3.match(navigator.userAgent);

	},



	/**

	 *

	 * @return {}

	 */

	isIE6: function() {

		var reIE6 = /MSIE 6/i;

		return reIE6.match(navigator.userAgent);

	},



	/**

	 *

	 * @return {}

	 */

	isIE7: function() {

		var reIE7 = /MSIE 7/i;

		return reIE7.match(navigator.userAgent);

	},



	isIE: function() {

		return (tkid.Helper.isIE6() || tkid.Helper.isIE7());

	}

};







/**

 * @class Carousel

 * @version 0.2

 */

tkid.Carousel = Class.create(tkid, {



	// add description here

	params:

	{

		axis: false, 				// x or y

		autoPlay: true,			//

		autoPlayDelay: 20000, 		// time in MS

		cssWrapper: false,			// if null => abort

		cssButtonBack: "SC-back",	// s.o.

		cssButtonNext: "SC-next",	// s.o.

		cssActive: false,			// @deprecated

		highlightActive: false,		// default: false

		seamless: true,				// @todo: add this feature (a real carousel and or a faked one)

		widthView: 0,				// width of the visible area

		widthItem: 0,				// only if item is not full size

		mode: 'default',			// [default, center]

		amountItems: 0,				// amount of items - regadkless of what type

		id: false,					// id of carousel

		duration: 0.3,

		transition: Effect.Transitions.sinoidal // @see: http://wiki.github.com/madrobby/scriptaculous/effect-transitions

	},



	/**

	 *

	 * @param {} id

	 * @return {Boolean}

	 */

	initialize: function(id) {



		// run only when all components are loaded

		if(!tkid.Helper.ready()) {

			return false;

		}



		// update params/prefs

		if(typeof arguments != 'undefined') {

			if(arguments.length==2 && typeof arguments[1] == 'object') {

				Object.extend(this.params, arguments[1]);

			}

		}



		if($(id)=='null') {

			return false;

		}



		// set element ID

		this.id = id;



		// fetch all ListItems

		this._ul = $(this.id).down('UL');

		this._listItems = this._ul.childElements();

		if(this._listItems.length===0) {

			throw new Error("no items available");

		}



		// set/get amount of items

		this.params.amountItems = this._listItems.length;



		// calculate the width of all existent items

		this._realWidth = 0;

		for(_itemCount=0;this._listItems.length>_itemCount;_itemCount++) {

			this._realWidth += this._listItems[_itemCount].getWidth();

		}



		// get+set width of wrapper

		this.params.widthView = this._ul.up('div').getWidth();



		// iterate over item list, to fetch the items which are not full size

		for(i=0;this._listItems.length>i;i++) {

			if(this._listItems[i].getWidth() != this.params.widthView) {

				this.params.widthItem = this._listItems.first().getWidth();

			}

		}



		// create "current view" dom storrage

		$$('body')[0].insert(new Element('span', { id: "storrage-"+this.id, title: this.params.amountItems, 'class': '' }));



		// create storrage container for width's of all items

		this._storrage={};

		this._storrage[this.id] = []; // new Array();



		// fill up storrage

		for(_itemCount=0;this._listItems.length>_itemCount;_itemCount++) {

			this._storrage[this.id].push(

				{

					width:this._listItems[_itemCount].getWidth()

				}

			);



		}



		// clone objects/elements

		this._clone();



		// create ItemCollection for later use

		this._buildStorrage();



		// set initial position

		this._switchMode();



		// make eventListner available to all members

		this.buttonEventBack = this._scroll.bindAsEventListener(this);

		this.buttonEventNext = this._scroll.bindAsEventListener(this);



		// add Events to buttons

		this._buttonEvent($(this.id).down("."+this.params.cssButtonBack).down("IMG"), 'back');

		this._buttonEvent($(this.id).down("."+this.params.cssButtonNext).down("IMG"), 'next');



		if(this.params.autoPlay) {

			this._autoPlay();

		}

	},



	/**

	 * gets called only once on init

	 */

	_buildStorrage: function() {



		// create storrage container

		this._storrageCnt = {};

		this._storrageCnt[this.id] = []; // new Array();



		// get/set internal used "constants"

		_allE = this._ul.childElements();

		_min = this._listItems.length;

		_max = this._listItems.length*2;



		// create basic itemcollection

		for(_i=0;_allE.length>_i;_i++) {

			_width = _allE[_i].getWidth();

			this._storrageCnt[this.id][_i] = {

				width: _width,

				isFullWidth: (_width==this.params.widthView) ? true : false,

				isView: ((_i>=_min) && (_i<_max)) ? true : false

			};

		}



		org_length = _allE.length/3;





		// add(calculate) position for each element

		for(_i=0;_allE.length>_i;_i++) {



			// current width

			_width = _allE[_i].getWidth();

			_view = this.params.widthView;

			// previous and next index

			__idxPrev = _i-1;

			__idxNext = _i+1;



				/**

				 * 1: s s s

				 * 2: s s l

				 * 3: s l l

				 * 4: l l l

				 * 5: l l s

				 * 6: l s s

				 * 7: l s l

				 * 8: s l s

				 */

				if(_i===0) {

					// first

					if(this._storrageCnt[this.id][_i].isFullWidth) {

						__position = 0;

					} else {

						__position = (_view/4*1)*-1;

					}



				} else {



					// calculate position, in dependence to the previous and next item

					if((typeof this._storrageCnt[this.id][__idxNext] != 'undefined') && (typeof this._storrageCnt[this.id][__idxPrev] != 'undefined')) {



						if(!this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& !this._storrageCnt[this.id][_i].isFullWidth

						&& !this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position<=0) ? (_view/4*1) : __position+(_view/4*2);

						}



						if(!this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& !this._storrageCnt[this.id][_i].isFullWidth

						&& this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position<=0) ? (_view/4*1) : __position+(_view/4*2);

						}



						if(!this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& this._storrageCnt[this.id][_i].isFullWidth

						&& this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position+(_view/4*3));

						}



						if(this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& this._storrageCnt[this.id][_i].isFullWidth

						&& this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position+_view);

						}



						if(this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& this._storrageCnt[this.id][_i].isFullWidth

						&& !this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position+(_view));

						}



						if(this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& !this._storrageCnt[this.id][_i].isFullWidth

						&& !this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position+(_view/4*3));

						}



						if(this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& !this._storrageCnt[this.id][_i].isFullWidth

						&& this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position+(_view/4*3));

						}



						if(!this._storrageCnt[this.id][__idxPrev].isFullWidth

						&& this._storrageCnt[this.id][_i].isFullWidth

						&& !this._storrageCnt[this.id][__idxNext].isFullWidth)

						{

							__position = (__position+(_view/4*3));

						}

					}



				}

			// add the position to the earlier created itemColletion

			Object.extend(this._storrageCnt[this.id][_i], {

				position: __position

			});



		}

		//console.dir(this._storrageCnt[this.id]);

	},



	_switchMode: function() {

		switch(this.params.mode) {

			case 'center':

				// position is centered

				if(this.params.axis == 'x') {

					// is full width

					if(this._storrage[this.id][0].width==this.params.widthView) {

						position = parseInt(this._realWidth-this.params.widthView+this._storrage[this.id][0].width, 10)*-1;

						this._ul.setStyle("left: "+position+"px");

					} else { // is *not* full width

						position = parseInt(this._realWidth-(this.params.widthView/4*1), 10)*-1;

						this._ul.setStyle("left: "+position+"px");

					}

				}

			break;

			default: // default mode is "default" (left)

				// position is left

				this._ul.setStyle("left: 0px");

			break;

		}

	},



	/**

	 *

	 * @param {} obj

	 * @param {} times

	 * @param {} position

	 */

	_clone: function(/*obj, times, position*/) {

		// clone my clone to a cyclone.....

		_clone =  this._ul.select('li');



		for(i=0;2>i;i++) {

			for(var item in _clone) {

				if(typeof _clone[item] == 'object') {

					var _myClone = _clone[item].cloneNode(true);

					var _cyClone = this._ul.insert({'bottom':_myClone});

				}

			}

		}

		delete _clone;

	},



	/**

	 *

	 * @return {}

	 * @version 0.2

	 */

	_currentPosition: function() {

		return (this.params.axis == 'x') ? parseInt(this._ul.positionedOffset()[0], 10) : parseInt(this._ul.positionedOffset()[1], 10);

	},



	/**

	 *

	 * @param {} element

	 * @return {}

	 */

	_getDirection: function(element) {



		if(Prototype.Browser.IE) {

			res = element.srcElement.up().className.endsWith('next');

		} else if(Prototype.Browser.WebKit || Prototype.Browser.Opera) {

			res = element.srcElement.up().getAttribute('class').endsWith('next');

		} else if(Prototype.Browser.Gecko) {

			res = element.rangeParent.className.endsWith('next');

		}



		return (res) ? 'next' : 'back';

	},



	/**

	 *

	 * @param {} obj

	 */

	_scroll: function(obj) {



		// if the "obj" is a string, _scroll gets called from the autoplay

		if(typeof obj == "string") {

			direction = obj;

		} else {

			direction = this._getDirection(obj);

		}



		// direction dependend values

		_dimensions = (this.params.axis == 'x') ? parseInt(this.params.widthItem, 10) : parseInt(this.params.widthHeight, 10);



		// defaults

		_scrollFx={};

		_scrollTo=0;



		// get current index from dom storrage

		___storrage = parseInt($('storrage-'+this.id).getAttribute('title'), 10);



		// override position and index in title if cond matches

		_revert = false;



		_startFrom = ___storrage;



		// set index level for previous, current and next position

		_idxPrev = (___storrage-1);

		_idxCurr = (___storrage);

		_idxNext = (___storrage+1);



		_min = this._listItems.length;

		_max = this._listItems.length*2;



		if(direction=='next') {

			_scrollTo = this._storrageCnt[this.id][_idxNext].position*-1;



			if(!this._storrageCnt[this.id][_idxNext].isView) {

				_startFrom = _min;

				_revert = true;

			} else {

				_startFrom = _idxNext;

			}



			_scrollFx.morph = {

				element: this._ul,

				options: {

					style: 'left: '+_scrollTo+'px',

					duration: this.params.duration,

					transition: this.params.transition,

					queue: 'end'

				}

			};

		} else {

			_scrollTo = this._storrageCnt[this.id][_idxPrev].position*-1;



			if(!this._storrageCnt[this.id][_idxPrev].isView) {

				_startFrom = _max;

				_revert = true;

			} else {

				_startFrom = _idxPrev;

			}

			_scrollFx.morph = {

				element: this._ul,

				options: {

					style: 'left: '+_scrollTo+'px',

					duration: this.params.duration,

					transition: this.params.transition,

					queue: 'end'

				}

			};

		}



		// save data to storrage

		$('storrage-'+this.id).title = _startFrom;





		new Effect.Morph(_scrollFx.morph.element, _scrollFx.morph.options);





		// if we've reached the position of the defined index, jump back/forward to it's clone

		if(_revert) {

			if(direction=='next') {

				$('storrage-'+this.id).title = _min;

				_goto = this._storrageCnt[this.id][_min].position;

			} else {

				$('storrage-'+this.id).title = _max-1;

				_goto = this._storrageCnt[this.id][_max-1].position;

			}

			new Effect.Morph(this._ul, {

					style: "left: -"+_goto+"px; color: red",

					duration: 0,

					queue: 'end'

			});

		}





	},



	/**

	 *

	 * @param {} element

	 * @param {} direction

	 */

	_buttonEvent: function(element, direction) {

		if(typeof element == 'object') {

			switch(direction) {

				case 'back':

					x = Event.observe(element, "click", this.buttonEventBack);

					break;

				case 'next':

					x = Event.observe(element, "click", this.buttonEventNext);

					break;

				default:

					throw new Error(element+" has no direction.");

					break;

			}

		} else {

			throw new Error("element is no object.");

		}

	},



	/**

	 * recursive timer!

	 */

	_autoPlayWrapper: function() {

		this._scroll('next');

		this._autoPlay();

	},



	/**

	 *

	 */

	_autoPlay: function() {

		btn = $(this.id).down("."+this.params.cssButtonNext).down("IMG");

		setTimeout(this._autoPlayWrapper.bind(this), this.params.autoPlayDelay);

	}



});





/**

 * @class Feed

 * @version 0.1

 */

tkid.Feed = Class.create(tkid, {



	params:

	{

		duration: 0.3,

		transition: Effect.Transitions.sinoidal // @see: http://wiki.github.com/madrobby/scriptaculous/effect-transitions

	},



	initialize: function(id) {

		// run only when all components are loaded

		if(!tkid.Helper.ready()) {

			return false;

		}

		if($(id)=='null') {

			return false;

		}



		// set element ID

		this.id = id;

		this.map = $(id).select('.b90feedmap')[0];

		this.areas = this.map.descendants();

		this._ul = $(this.id).select('.b90feeds_list')[0];

		this._height = this._ul.getHeight();

		this._heightView = $(this.id).select('.b90feeds_wrapper').first().getHeight();



		// make eventListner available to all members

		this.buttonEventBack = this._scroll.bindAsEventListener(this);

		this.buttonEventNext = this._scroll.bindAsEventListener(this);



		// add Events to buttons

		this._buttonEvent(this.areas[0], 'back');

		this._buttonEvent(this.areas[1], 'next');



		return false;

	},



	_scroll: function(element) {





		if(Prototype.Browser.IE) {

			//res = element.srcElement.up().className.endsWith('next');

			res = element.target.className;

		} else if(Prototype.Browser.WebKit || Prototype.Browser.Opera) {

			//res = element.srcElement.up().getAttribute('class').endsWith('next');

			res = element.currentTarget.className;

		} else if(Prototype.Browser.Gecko) {

			res = element.currentTarget.className;

		}



		// this._height

		_currPosition = parseInt(this._ul.positionedOffset()[1]);

		var _scrollFx = {};





		if(res=="back") {

			_newPos = _currPosition+(this._heightView/4*3);

			_scrollFx.morph = {

				element: this._ul,

				options: {

					style: 'top: '+_newPos+'px',

					duration: this.params.duration,

					transition: this.params.transition

				}

			};

			if(_currPosition*-1 < (this._heightView/4*1)) {

				_scrollFx.morph.options = {style: "top: 0px" };

			}

		} else {

			_newPos = _currPosition-(this._heightView/4*3);

			_scrollFx.morph = {

				element: this._ul,

				options: {

					style: 'top: '+_newPos+'px',

					duration: this.params.duration,

					transition: this.params.transition

				}

			};

			if(_currPosition*-1 > (this._height-(this._heightView/4*6))) {

				_scrollFx.morph.options = {style: "top: -"+(this._height-(this._heightView/4*1))+"px" };

			}

		}



		new Effect.Morph(_scrollFx.morph.element, _scrollFx.morph.options);

	},



	_buttonEvent: function(element, direction) {

		if(typeof element == 'object') {

			switch(direction) {

				case 'back':

					x = Event.observe(element, "click", this.buttonEventBack);

					break;

				case 'next':

					x = Event.observe(element, "click", this.buttonEventNext);

					break;

				default:

					throw new Error(element+" has no direction.");

					break;

			}

		} else {

			throw new Error("element is no object.");

		}

	}

});



/**

 * @class Tab

 * @version 0.1

 */

tkid.Tab = Class.create(tkid, {

	params:

	{

		axis: null, 			// x or y

		cssWrapper: null 		//

	},

	initialize: function(id) {

		// run only when all components are loaded

		if(!tkid.Helper.ready() || typeof className == null) {

			return false;

		}



		return false;

	}

});



/**

 * @class Clearer

 * @description Fetches the title attribute and inserts it into the value from an input field.

 *

 * tested on: FF3, Opera 9, Safari3, IE6

 *

 * @version 0.2

 * @example new tkid.Clearer('className');

 */



tkid.Clearer = Class.create(tkid, {

	params:

	{

		elementAttrib: 'title', 	// the title value gets inserted as value

		cssTrigger: null,			// the class name, by which the element gets triggered

		toggle: true				// if toggle is true and no changes are made to the input, the title value gets inserted again.

									// otherwise it will be left blank and the event gets removed. This is usefull, if

									// you have a formular and don't want to double check the value for emptyness and a special value.

									// @todo: add an onsubmit handler to clear the values which are equal to it's title attribute

	},



	/**

	 * constructor

	 * @param {} className

	 * @return {Boolean}

	 */

	initialize: function(className) {

		// run only when all components are loaded

		if(!tkid.Helper.ready() || typeof className == null) {

			return false;

		}



		// copy className to member

		this.params.cssTrigger = className;



		// make eventListner available to all members

		this.eventFieldFocus = this.toggleValue.bindAsEventListener(this);

		this.eventFieldBlur = this.toggleValue.bindAsEventListener(this);

		this.eventFieldLoad = this.toggleValue.bindAsEventListener(this);



		// iterate  through docuemnt and assign event, if condition matches

		$$("."+this.params.cssTrigger).each(

			function(element) {

				this.addEvent(element);

			}.bind(this)

		);

	},



	/**

	 * attaches events to element

	 * @param {} element

	 */

	addEvent: function(element) {

		this.initElement(element);

		Event.observe(element, "focus", this.eventFieldFocus);

		Event.observe(element, "blur", this.eventFieldBlur);

	},



	/**

	 * preset an elements value

	 * @param {} element

	 */

	initElement: function(element) {

		if(typeof element.title == "string") {

			element.setValue(element.getAttribute(this.params.elementAttrib));

		}

	},



	/**

	 * switches/toggles the attributes of an element

	 * @param {} element

	 */

	toggleValue: function(element) {



		if(Prototype.Browser.IE) {

			res = element.target;

		} else if(Prototype.Browser.WebKit || Prototype.Browser.Opera) {

			res = element.currentTarget;

		} else if(Prototype.Browser.Gecko) {

			res = element.currentTarget;

		}



		// active element

		if(element.type == 'focus') {

			if(res.title == res.getValue()) {

				res.setValue('');

			}

		// release of focus

		} else {

			if(res.getValue() == "") {

				res.setValue(res.getAttribute(this.params.elementAttrib));

			}

		}

	}

});





tkid.Gal = Class.create(tkid, {



	/**

	 * constructor

	 * @param {} id

	 */

	initialize: function(id) {

		if(typeof $(id)!='object') {

			return false;

		}



		this.id = id;

		this.items = $(this.id).down('UL').childElements();



		// hide all items

		this.items.each(function(e){

			e.hide();

		});



		// make first visible

		this.items.first().show();



		// pager button one back

		$$('.b90gal_pager')[0].insert(new Element('a', {href:'javascript:tkid.Gal.go(\''+this.id+'-back\');', 'class': 'b90gal_pager_back'}).update('&lt;'));



		// create pager

		for(i=0; this.items.length>i; i++) {

			num = i+1;

			if(i===0) {

				e = new Element('a', {href:'javascript:tkid.Gal.go(\''+this.id+'-'+i+'\');', id: this.id+'-'+i, 'class': 'b90gal_pager_active'}).update(num);

			} else {

				e = new Element('a', {href:'javascript:tkid.Gal.go(\''+this.id+'-'+i+'\');', id: this.id+'-'+i}).update(num);

			}

			$$('.b90gal_pager')[0].insert(e);



			// get content from container

			content = (Prototype.Browser.IE) ? this.items[i].down('.b90gal_content').innerHTML : this.items[i].down('.b90gal_content').textContent;



			// remove all whitespaces:

			cleanContent = content.replace(/  |\t|\n/g, "");



			// if content exceeds a givin length - add "more" button

			if(cleanContent.length > 500) {

				a = new Element('a', {href:'javascript:tkid.Gal.more(\''+this.id+'-'+i+'\');', 'class': 'b90gal_more'}).update('mehr');

				$(this.items[i]).insert(a);

			}

		}



		// pager button one next

		$$('.b90gal_pager')[0].insert(new Element('a', {href:'javascript:tkid.Gal.go(\''+this.id+'-next\');', 'class': 'b90gal_pager_next'}).update('&gt;'));

	}



});



/**

 * singletn like method for tkid.Gal

 * @param {} elm

 */

tkid.Gal.go = function(elm) {



	tmp = elm.split('-');

	id = tmp[0];

	idx = tmp[1];

	pager = false;

	items = $(id).down('UL').childElements();



	if(idx.match('back')) {

		idx = parseInt($(id).down('.b90gal_pager_active').id.split('-')[1])-1;

		if(idx==-1) {

			return;

		}

		pager = true;

	} else if(idx.match('next')) {

		idx = parseInt($(id).down('.b90gal_pager_active').id.split('-')[1])+1;

		if(idx>=items.length) {

			return;

		}

		pager = true;

	}

	elmForPager = $(id).down('.b90gal_pager_active').id.split('-')[0]+"-"+idx;



	var cnt=0;

	items.each(function(e){

		if(cnt == idx && e.style.display == '') {

			return false;

		}

		if(e.style.display == '') {

			e.fade({ duration: 0.3 });

		}

		cnt++;

	});



	$$('.b90gal_pager')[0].childElements().each(

		function(e) {

			e.removeClassName('b90gal_pager_active');

		}

	);

	items[idx].appear({ duration: 0.3 });



	if(pager) {

		$(elmForPager).addClassName('b90gal_pager_active');

	} else {

		$(elm).addClassName('b90gal_pager_active');

	}

};



tkid.Gal.more = function(elm) {

	tmp = elm.split('-');

	id = tmp[0];

	idx = tmp[1];



	items = $(id).down('UL').childElements();

	new Effect.Morph(items[idx], {style: 'height: 1000px'});

	new Effect.Morph(items[idx].down('.b90gal_content'), {style: 'height:490px'});



	// gently removin the "more" button

	items[idx].down('a.b90gal_more').fade();

};





var evaluateSrc = function(src) {

	var imgbase = '/fileadmin/templates/img/feedread/';

	var imgsrc='';

	if(src.match('facebook'))

	{

		imgsrc = 'facebook-trans.png';

	}

	if(src.match('flickr'))

	{

		imgsrc = 'flickr-trans.png';

	}

	if(src.match('myspace'))

	{

		imgsrc = 'my_space-trans.png';

	}

	if(src.match('facebook'))

	{

		imgsrc = 'facebook-trans.png';

	}

	if(src.match('studivz'))

	{

		imgsrc = 'studi_vz-trans.png';

	}

	if(src.match('twitter'))

	{

		imgsrc = 'twitter-trans.png';

	}

	if(src.match('wordpress'))

	{

		imgsrc = 'wordpress-trans.png';

	}

	if(src.match('youtube'))

	{

		imgsrc = 'you_tube-trans.png';

	}

	if(imgsrc.length==0)

	{

		imgsrc = 'blog-trans.png';

	}

	return imgbase+imgsrc;

};



function loadGrnFeedbox ()

{

//	new Ajax.Request('http://' + window.location.host + '/feedshow.php?name=wgpbox2', {
	new Ajax.Request('http://gruene-berlin.de/site/index.php?id=4337&type=334&feed_id=8467&no_cache=1', {

		method: 'get',

		onSuccess: function(transport) {

			list = $('anyFeed2').down('ul.b90feeds_list');

			for(i=0;i<transport.responseJSON.count;i++)

			{

				ftitle = new Element('p').update( transport.responseJSON.value.items[i].title );

				fimgsrc = evaluateSrc(transport.responseJSON.value.items[i].link);

				fimg = new Element('img', {src:fimgsrc});



				// @todo loop aborts on .author.name

				//flink = new Element('a', {href: transport.responseJSON.value.items[i].link}).update( fimg ).insert(' ' +transport.responseJSON.value.items[i].author.name);

				if (transport.responseJSON.value.items[i].author) {

					fauthorname = transport.responseJSON.value.items[i].author.name;

				} else {

					if(fimgsrc.match('twitter')) {

						fauthorname = 'Twitter';

					} else {

						fauthorname = 'Artikel';

					}

				}

				flink = new Element('a', {href: transport.responseJSON.value.items[i].link}).update( fimg ).insert(' ' + fauthorname);



				list.insert(

					new Element('li').update(

						ftitle

					).insert(flink)

				);

				delete ftitle;

				delete flink;

			}

			try {

				new tkid.Feed("anyFeed2");

			} catch(err) {}



		}

	});

}
