var AudioPlayer = function () {
	var instances = [];
	var activePlayerID;
	var playerURL = "";
	var defaultOptions = {};
	var currentVolume = -1;
	
	function getPlayer(playerID) {
		return document.all ? window[playerID] : document[playerID];
	}
	
	return {
		setup: function (url, options) {
	        if(url) {
	        	playerURL = url;
	        }
	        defaultOptions = options;
	    },

		getPlayer: function (playerID) {
			return getPlayer(playerID);
		},
	    
	    embed: function (elementID, options) {
			var instanceOptions = {};
	        var key;
	        var so;
			var bgcolor;
			var wmode;
			
			var flashParams = {};
			var flashVars = {};
			var flashAttributes = {};
	
	        // Merge default options and instance options
			for (key in defaultOptions) {
	            instanceOptions[key] = defaultOptions[key];
	        }
	        for (key in options) {
	            instanceOptions[key] = options[key];
	        }
	        
			if (instanceOptions.transparentpagebg == "yes") {
				flashParams.bgcolor = "#FFFFFF";
				flashParams.wmode = "transparent";
			} else {
				if (instanceOptions.pagebg) {
					flashParams.bgcolor = "#" + instanceOptions.pagebg;
				}
				flashParams.wmode = "opaque";
			}
			
			flashParams.menu = "false";
			
	        for (key in instanceOptions) {
				if (key == "pagebg" || key == "width" || key == "transparentpagebg") {
					continue;
				}
	            flashVars[key] = instanceOptions[key];
	        }
			
			flashAttributes.name = elementID;
			flashAttributes.style = "outline: none";
			
			flashVars.playerID = elementID;
			
			swfobject.embedSWF(playerURL, elementID, instanceOptions.width.toString(), "24", "9", false, flashVars, flashParams, flashAttributes);
			
			
			instances.push(elementID);
	    },
		
		syncVolumes: function (playerID, volume) {	
			currentVolume = volume;
			for (var i = 0; i < instances.length; i++) {
				if (instances[i] != playerID) {
					getPlayer(instances[i]).setVolume(currentVolume);
				}
			}
		},
		
		activate: function (playerID) {
			if (activePlayerID && activePlayerID != playerID) {
				getPlayer(activePlayerID).close();
			}
			
			activePlayerID = playerID;
		},
		
		load: function (playerID, soundFile, titles, artists) {
			getPlayer(playerID).load(soundFile, titles, artists);
		},
		
		close: function (playerID) {
			getPlayer(playerID).close();
			if (playerID == activePlayerID) {
				activePlayerID = null;
			}
		},
		
		open: function (playerID) {
			getPlayer(playerID).open();
		},
		
		getVolume: function (playerID) {
			return currentVolume;
		}
		
	}
	
}();

/*
 * jQuery Cycle Plugin (with Transition Definitions)
 * Examples and documentation at: http://jquery.malsup.com/cycle/
 * Copyright (c) 2007-2009 M. Alsup
 * Version: 2.73 (04-NOV-2009)
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 * Requires: jQuery v1.2.6 or later
 *
 * Originally based on the work of:
 *	1) Matt Oakes
 *	2) Torsten Baldes (http://medienfreunde.com/lab/innerfade/)
 *	3) Benjamin Sterling (http://www.benjaminsterling.com/experiments/jqShuffle/)
 */
(function(i){var l="2.73";if(i.support==undefined){i.support={opacity:!(i.browser.msie)}}function a(q){if(i.fn.cycle.debug){f(q)}}function f(){if(window.console&&window.console.log){window.console.log("[cycle] "+Array.prototype.join.call(arguments," "))}}i.fn.cycle=function(r,q){var s={s:this.selector,c:this.context};if(this.length===0&&r!="stop"){if(!i.isReady&&s.s){f("DOM not ready, queuing slideshow");i(function(){i(s.s,s.c).cycle(r,q)});return this}f("terminating; zero elements found by selector"+(i.isReady?"":" (DOM not ready)"));return this}return this.each(function(){var w=m(this,r,q);if(w===false){return}if(this.cycleTimeout){clearTimeout(this.cycleTimeout)}this.cycleTimeout=this.cyclePause=0;var x=i(this);var y=w.slideExpr?i(w.slideExpr,this):x.children();var u=y.get();if(u.length<2){f("terminating; too few slides: "+u.length);return}var t=k(x,y,u,w,s);if(t===false){return}var v=t.continuous?10:h(t.currSlide,t.nextSlide,t,!t.rev);if(v){v+=(t.delay||0);if(v<10){v=10}a("first timeout: "+v);this.cycleTimeout=setTimeout(function(){e(u,t,0,!t.rev)},v)}})};function m(q,t,r){if(q.cycleStop==undefined){q.cycleStop=0}if(t===undefined||t===null){t={}}if(t.constructor==String){switch(t){case"stop":q.cycleStop++;if(q.cycleTimeout){clearTimeout(q.cycleTimeout)}q.cycleTimeout=0;i(q).removeData("cycle.opts");return false;case"pause":q.cyclePause=1;return false;case"resume":q.cyclePause=0;if(r===true){t=i(q).data("cycle.opts");if(!t){f("options not found, can not resume");return false}if(q.cycleTimeout){clearTimeout(q.cycleTimeout);q.cycleTimeout=0}e(t.elements,t,1,1)}return false;case"prev":case"next":var u=i(q).data("cycle.opts");if(!u){f('options not found, "prev/next" ignored');return false}i.fn.cycle[t](u);return false;default:t={fx:t}}return t}else{if(t.constructor==Number){var s=t;t=i(q).data("cycle.opts");if(!t){f("options not found, can not advance slide");return false}if(s<0||s>=t.elements.length){f("invalid slide index: "+s);return false}t.nextSlide=s;if(q.cycleTimeout){clearTimeout(q.cycleTimeout);q.cycleTimeout=0}if(typeof r=="string"){t.oneTimeFx=r}e(t.elements,t,1,s>=t.currSlide);return false}}return t}function b(q,r){if(!i.support.opacity&&r.cleartype&&q.style.filter){try{q.style.removeAttribute("filter")}catch(s){}}}function k(y,J,u,t,E){var C=i.extend({},i.fn.cycle.defaults,t||{},i.metadata?y.metadata():i.meta?y.data():{});if(C.autostop){C.countdown=C.autostopCount||u.length}var r=y[0];y.data("cycle.opts",C);C.$cont=y;C.stopCount=r.cycleStop;C.elements=u;C.before=C.before?[C.before]:[];C.after=C.after?[C.after]:[];C.after.unshift(function(){C.busy=0});if(!i.support.opacity&&C.cleartype){C.after.push(function(){b(this,C)})}if(C.continuous){C.after.push(function(){e(u,C,0,!C.rev)})}n(C);if(!i.support.opacity&&C.cleartype&&!C.cleartypeNoBg){g(J)}if(y.css("position")=="static"){y.css("position","relative")}if(C.width){y.width(C.width)}if(C.height&&C.height!="auto"){y.height(C.height)}if(C.startingSlide){C.startingSlide=parseInt(C.startingSlide)}if(C.random){C.randomMap=[];for(var H=0;H<u.length;H++){C.randomMap.push(H)}C.randomMap.sort(function(L,w){return Math.random()-0.5});C.randomIndex=0;C.startingSlide=C.randomMap[0]}else{if(C.startingSlide>=u.length){C.startingSlide=0}}C.currSlide=C.startingSlide=C.startingSlide||0;var x=C.startingSlide;J.css({position:"absolute",top:0,left:0}).hide().each(function(w){var L=x?w>=x?u.length-(w-x):x-w:u.length-w;i(this).css("z-index",L)});i(u[x]).css("opacity",1).show();b(u[x],C);if(C.fit&&C.width){J.width(C.width)}if(C.fit&&C.height&&C.height!="auto"){J.height(C.height)}var D=C.containerResize&&!y.innerHeight();if(D){var v=0,B=0;for(var F=0;F<u.length;F++){var q=i(u[F]),K=q[0],A=q.outerWidth(),I=q.outerHeight();if(!A){A=K.offsetWidth}if(!I){I=K.offsetHeight}v=A>v?A:v;B=I>B?I:B}if(v>0&&B>0){y.css({width:v+"px",height:B+"px"})}}if(C.pause){y.hover(function(){this.cyclePause++},function(){this.cyclePause--})}if(c(C)===false){return false}var s=false;t.requeueAttempts=t.requeueAttempts||0;J.each(function(){var N=i(this);this.cycleH=(C.fit&&C.height)?C.height:N.height();this.cycleW=(C.fit&&C.width)?C.width:N.width();if(N.is("img")){var L=(i.browser.msie&&this.cycleW==28&&this.cycleH==30&&!this.complete);var O=(i.browser.mozilla&&this.cycleW==34&&this.cycleH==19&&!this.complete);var M=(i.browser.opera&&((this.cycleW==42&&this.cycleH==19)||(this.cycleW==37&&this.cycleH==17))&&!this.complete);var w=(this.cycleH==0&&this.cycleW==0&&!this.complete);if(L||O||M||w){if(E.s&&C.requeueOnImageNotLoaded&&++t.requeueAttempts<100){f(t.requeueAttempts," - img slide not loaded, requeuing slideshow: ",this.src,this.cycleW,this.cycleH);setTimeout(function(){i(E.s,E.c).cycle(t)},C.requeueTimeout);s=true;return false}else{f("could not determine size of image: "+this.src,this.cycleW,this.cycleH)}}}return true});if(s){return false}C.cssBefore=C.cssBefore||{};C.animIn=C.animIn||{};C.animOut=C.animOut||{};J.not(":eq("+x+")").css(C.cssBefore);if(C.cssFirst){i(J[x]).css(C.cssFirst)}if(C.timeout){C.timeout=parseInt(C.timeout);if(C.speed.constructor==String){C.speed=i.fx.speeds[C.speed]||parseInt(C.speed)}if(!C.sync){C.speed=C.speed/2}while((C.timeout-C.speed)<250){C.timeout+=C.speed}}if(C.easing){C.easeIn=C.easeOut=C.easing}if(!C.speedIn){C.speedIn=C.speed}if(!C.speedOut){C.speedOut=C.speed}C.slideCount=u.length;C.currSlide=C.lastSlide=x;if(C.random){C.nextSlide=C.currSlide;if(++C.randomIndex==u.length){C.randomIndex=0}C.nextSlide=C.randomMap[C.randomIndex]}else{C.nextSlide=C.startingSlide>=(u.length-1)?0:C.startingSlide+1}if(!C.multiFx){var G=i.fn.cycle.transitions[C.fx];if(i.isFunction(G)){G(y,J,C)}else{if(C.fx!="custom"&&!C.multiFx){f("unknown transition: "+C.fx,"; slideshow terminating");return false}}}var z=J[x];if(C.before.length){C.before[0].apply(z,[z,z,C,true])}if(C.after.length>1){C.after[1].apply(z,[z,z,C,true])}if(C.next){i(C.next).bind(C.prevNextEvent,function(){return o(C,C.rev?-1:1)})}if(C.prev){i(C.prev).bind(C.prevNextEvent,function(){return o(C,C.rev?1:-1)})}if(C.pager){d(u,C)}j(C,u);return C}function n(q){q.original={before:[],after:[]};q.original.cssBefore=i.extend({},q.cssBefore);q.original.cssAfter=i.extend({},q.cssAfter);q.original.animIn=i.extend({},q.animIn);q.original.animOut=i.extend({},q.animOut);i.each(q.before,function(){q.original.before.push(this)});i.each(q.after,function(){q.original.after.push(this)})}function c(w){var u,s,r=i.fn.cycle.transitions;if(w.fx.indexOf(",")>0){w.multiFx=true;w.fxs=w.fx.replace(/\s*/g,"").split(",");for(u=0;u<w.fxs.length;u++){var v=w.fxs[u];s=r[v];if(!s||!r.hasOwnProperty(v)||!i.isFunction(s)){f("discarding unknown transition: ",v);w.fxs.splice(u,1);u--}}if(!w.fxs.length){f("No valid transitions named; slideshow terminating.");return false}}else{if(w.fx=="all"){w.multiFx=true;w.fxs=[];for(p in r){s=r[p];if(r.hasOwnProperty(p)&&i.isFunction(s)){w.fxs.push(p)}}}}if(w.multiFx&&w.randomizeEffects){var t=Math.floor(Math.random()*20)+30;for(u=0;u<t;u++){var q=Math.floor(Math.random()*w.fxs.length);w.fxs.push(w.fxs.splice(q,1)[0])}a("randomized fx sequence: ",w.fxs)}return true}function j(r,q){r.addSlide=function(u,v){var t=i(u),w=t[0];if(!r.autostopCount){r.countdown++}q[v?"unshift":"push"](w);if(r.els){r.els[v?"unshift":"push"](w)}r.slideCount=q.length;t.css("position","absolute");t[v?"prependTo":"appendTo"](r.$cont);if(v){r.currSlide++;r.nextSlide++}if(!i.support.opacity&&r.cleartype&&!r.cleartypeNoBg){g(t)}if(r.fit&&r.width){t.width(r.width)}if(r.fit&&r.height&&r.height!="auto"){$slides.height(r.height)}w.cycleH=(r.fit&&r.height)?r.height:t.height();w.cycleW=(r.fit&&r.width)?r.width:t.width();t.css(r.cssBefore);if(r.pager){i.fn.cycle.createPagerAnchor(q.length-1,w,i(r.pager),q,r)}if(i.isFunction(r.onAddSlide)){r.onAddSlide(t)}else{t.hide()}}}i.fn.cycle.resetState=function(r,q){q=q||r.fx;r.before=[];r.after=[];r.cssBefore=i.extend({},r.original.cssBefore);r.cssAfter=i.extend({},r.original.cssAfter);r.animIn=i.extend({},r.original.animIn);r.animOut=i.extend({},r.original.animOut);r.fxFn=null;i.each(r.original.before,function(){r.before.push(this)});i.each(r.original.after,function(){r.after.push(this)});var s=i.fn.cycle.transitions[q];if(i.isFunction(s)){s(r.$cont,i(r.elements),r)}};function e(x,q,w,y){if(w&&q.busy&&q.manualTrump){i(x).stop(true,true);q.busy=false}if(q.busy){return}var u=q.$cont[0],A=x[q.currSlide],z=x[q.nextSlide];if(u.cycleStop!=q.stopCount||u.cycleTimeout===0&&!w){return}if(!w&&!u.cyclePause&&((q.autostop&&(--q.countdown<=0))||(q.nowrap&&!q.random&&q.nextSlide<q.currSlide))){if(q.end){q.end(q)}return}if(w||!u.cyclePause){var v=q.fx;A.cycleH=A.cycleH||i(A).height();A.cycleW=A.cycleW||i(A).width();z.cycleH=z.cycleH||i(z).height();z.cycleW=z.cycleW||i(z).width();if(q.multiFx){if(q.lastFx==undefined||++q.lastFx>=q.fxs.length){q.lastFx=0}v=q.fxs[q.lastFx];q.currFx=v}if(q.oneTimeFx){v=q.oneTimeFx;q.oneTimeFx=null}i.fn.cycle.resetState(q,v);if(q.before.length){i.each(q.before,function(B,C){if(u.cycleStop!=q.stopCount){return}C.apply(z,[A,z,q,y])})}var s=function(){i.each(q.after,function(B,C){if(u.cycleStop!=q.stopCount){return}C.apply(z,[A,z,q,y])})};if(q.nextSlide!=q.currSlide){q.busy=1;if(q.fxFn){q.fxFn(A,z,q,s,y)}else{if(i.isFunction(i.fn.cycle[q.fx])){i.fn.cycle[q.fx](A,z,q,s)}else{i.fn.cycle.custom(A,z,q,s,w&&q.fastOnEvent)}}}q.lastSlide=q.currSlide;if(q.random){q.currSlide=q.nextSlide;if(++q.randomIndex==x.length){q.randomIndex=0}q.nextSlide=q.randomMap[q.randomIndex]}else{var t=(q.nextSlide+1)==x.length;q.nextSlide=t?0:q.nextSlide+1;q.currSlide=t?x.length-1:q.nextSlide-1}if(q.pager){i.fn.cycle.updateActivePagerLink(q.pager,q.currSlide)}}var r=0;if(q.timeout&&!q.continuous){r=h(A,z,q,y)}else{if(q.continuous&&u.cyclePause){r=10}}if(r>0){u.cycleTimeout=setTimeout(function(){e(x,q,0,!q.rev)},r)}}i.fn.cycle.updateActivePagerLink=function(q,r){i(q).each(function(){i(this).find("a").removeClass("activeSlide").filter("a:eq("+r+")").addClass("activeSlide")})};function h(v,s,u,r){if(u.timeoutFn){var q=u.timeoutFn(v,s,u,r);while((q-u.speed)<250){q+=u.speed}a("calculated timeout: "+q+"; speed: "+u.speed);if(q!==false){return q}}return u.timeout}i.fn.cycle.next=function(q){o(q,q.rev?-1:1)};i.fn.cycle.prev=function(q){o(q,q.rev?1:-1)};function o(r,u){var q=r.elements;var t=r.$cont[0],s=t.cycleTimeout;if(s){clearTimeout(s);t.cycleTimeout=0}if(r.random&&u<0){r.randomIndex--;if(--r.randomIndex==-2){r.randomIndex=q.length-2}else{if(r.randomIndex==-1){r.randomIndex=q.length-1}}r.nextSlide=r.randomMap[r.randomIndex]}else{if(r.random){if(++r.randomIndex==q.length){r.randomIndex=0}r.nextSlide=r.randomMap[r.randomIndex]}else{r.nextSlide=r.currSlide+u;if(r.nextSlide<0){if(r.nowrap){return false}r.nextSlide=q.length-1}else{if(r.nextSlide>=q.length){if(r.nowrap){return false}r.nextSlide=0}}}}if(i.isFunction(r.prevNextClick)){r.prevNextClick(u>0,r.nextSlide,q[r.nextSlide])}e(q,r,1,u>=0);return false}function d(r,s){var q=i(s.pager);i.each(r,function(t,u){i.fn.cycle.createPagerAnchor(t,u,q,r,s)});i.fn.cycle.updateActivePagerLink(s.pager,s.startingSlide)}i.fn.cycle.createPagerAnchor=function(u,v,s,t,w){var r;if(i.isFunction(w.pagerAnchorBuilder)){r=w.pagerAnchorBuilder(u,v)}else{r='<a href="#">'+(u+1)+"</a>"}if(!r){return}var x=i(r);if(x.parents("body").length===0){var q=[];if(s.length>1){s.each(function(){var y=x.clone(true);i(this).append(y);q.push(y[0])});x=i(q)}else{x.appendTo(s)}}x.bind(w.pagerEvent,function(A){A.preventDefault();w.nextSlide=u;var z=w.$cont[0],y=z.cycleTimeout;if(y){clearTimeout(y);z.cycleTimeout=0}if(i.isFunction(w.pagerClick)){w.pagerClick(w.nextSlide,t[w.nextSlide])}e(t,w,1,w.currSlide<u);return false});if(w.pagerEvent!="click"){x.click(function(){return false})}if(w.pauseOnPagerHover){x.hover(function(){w.$cont[0].cyclePause++},function(){w.$cont[0].cyclePause--})}};i.fn.cycle.hopsFromLast=function(t,s){var r,q=t.lastSlide,u=t.currSlide;if(s){r=u>q?u-q:t.slideCount-q}else{r=u<q?q-u:q+t.slideCount-u}return r};function g(s){function r(t){t=parseInt(t).toString(16);return t.length<2?"0"+t:t}function q(w){for(;w&&w.nodeName.toLowerCase()!="html";w=w.parentNode){var t=i.css(w,"background-color");if(t.indexOf("rgb")>=0){var u=t.match(/\d+/g);return"#"+r(u[0])+r(u[1])+r(u[2])}if(t&&t!="transparent"){return t}}return"#ffffff"}s.each(function(){i(this).css("background-color",q(this))})}i.fn.cycle.commonReset=function(v,t,u,r,s,q){i(u.elements).not(v).hide();u.cssBefore.opacity=1;u.cssBefore.display="block";if(r!==false&&t.cycleW>0){u.cssBefore.width=t.cycleW}if(s!==false&&t.cycleH>0){u.cssBefore.height=t.cycleH}u.cssAfter=u.cssAfter||{};u.cssAfter.display="none";i(v).css("zIndex",u.slideCount+(q===true?1:0));i(t).css("zIndex",u.slideCount+(q===true?0:1))};i.fn.cycle.custom=function(B,v,q,s,r){var A=i(B),w=i(v);var t=q.speedIn,z=q.speedOut,u=q.easeIn,y=q.easeOut;w.css(q.cssBefore);if(r){if(typeof r=="number"){t=z=r}else{t=z=1}u=y=null}var x=function(){w.animate(q.animIn,t,u,s)};A.animate(q.animOut,z,y,function(){if(q.cssAfter){A.css(q.cssAfter)}if(!q.sync){x()}});if(q.sync){x()}};i.fn.cycle.transitions={fade:function(r,s,q){s.not(":eq("+q.currSlide+")").css("opacity",0);q.before.push(function(v,t,u){i.fn.cycle.commonReset(v,t,u);u.cssBefore.opacity=0});q.animIn={opacity:1};q.animOut={opacity:0};q.cssBefore={top:0,left:0}}};i.fn.cycle.ver=function(){return l};i.fn.cycle.defaults={fx:"fade",timeout:4000,timeoutFn:null,continuous:0,speed:1000,speedIn:null,speedOut:null,next:null,prev:null,prevNextClick:null,prevNextEvent:"click",pager:null,pagerClick:null,pagerEvent:"click",pagerAnchorBuilder:null,before:null,after:null,end:null,easing:null,easeIn:null,easeOut:null,shuffle:null,animIn:null,animOut:null,cssBefore:null,cssAfter:null,fxFn:null,height:"auto",startingSlide:0,sync:1,random:0,fit:0,containerResize:1,pause:0,pauseOnPagerHover:0,autostop:0,autostopCount:0,delay:0,slideExpr:null,cleartype:!i.support.opacity,cleartypeNoBg:false,nowrap:0,fastOnEvent:0,randomizeEffects:1,rev:0,manualTrump:true,requeueOnImageNotLoaded:true,requeueTimeout:250}})(jQuery);
/*
 * jQuery Cycle Plugin Transition Definitions
 * This script is a plugin for the jQuery Cycle Plugin
 * Examples and documentation at: http://malsup.com/jquery/cycle/
 * Copyright (c) 2007-2008 M. Alsup
 * Version:	 2.72
 * Dual licensed under the MIT and GPL licenses:
 * http://www.opensource.org/licenses/mit-license.php
 * http://www.gnu.org/licenses/gpl.html
 */
(function(a){a.fn.cycle.transitions.none=function(c,d,b){b.fxFn=function(g,e,f,h){a(e).show();a(g).hide();h()}};a.fn.cycle.transitions.scrollUp=function(d,e,c){d.css("overflow","hidden");c.before.push(a.fn.cycle.commonReset);var b=d.height();c.cssBefore={top:b,left:0};c.cssFirst={top:0};c.animIn={top:0};c.animOut={top:-b}};a.fn.cycle.transitions.scrollDown=function(d,e,c){d.css("overflow","hidden");c.before.push(a.fn.cycle.commonReset);var b=d.height();c.cssFirst={top:0};c.cssBefore={top:-b,left:0};c.animIn={top:0};c.animOut={top:b}};a.fn.cycle.transitions.scrollLeft=function(d,e,c){d.css("overflow","hidden");c.before.push(a.fn.cycle.commonReset);var b=d.width();c.cssFirst={left:0};c.cssBefore={left:b,top:0};c.animIn={left:0};c.animOut={left:0-b}};a.fn.cycle.transitions.scrollRight=function(d,e,c){d.css("overflow","hidden");c.before.push(a.fn.cycle.commonReset);var b=d.width();c.cssFirst={left:0};c.cssBefore={left:-b,top:0};c.animIn={left:0};c.animOut={left:b}};a.fn.cycle.transitions.scrollHorz=function(c,d,b){c.css("overflow","hidden").width();b.before.push(function(h,f,g,e){a.fn.cycle.commonReset(h,f,g);g.cssBefore.left=e?(f.cycleW-1):(1-f.cycleW);g.animOut.left=e?-h.cycleW:h.cycleW});b.cssFirst={left:0};b.cssBefore={top:0};b.animIn={left:0};b.animOut={top:0}};a.fn.cycle.transitions.scrollVert=function(c,d,b){c.css("overflow","hidden");b.before.push(function(h,f,g,e){a.fn.cycle.commonReset(h,f,g);g.cssBefore.top=e?(1-f.cycleH):(f.cycleH-1);g.animOut.top=e?h.cycleH:-h.cycleH});b.cssFirst={top:0};b.cssBefore={left:0};b.animIn={top:0};b.animOut={left:0}};a.fn.cycle.transitions.slideX=function(c,d,b){b.before.push(function(g,e,f){a(f.elements).not(g).hide();a.fn.cycle.commonReset(g,e,f,false,true);f.animIn.width=e.cycleW});b.cssBefore={left:0,top:0,width:0};b.animIn={width:"show"};b.animOut={width:0}};a.fn.cycle.transitions.slideY=function(c,d,b){b.before.push(function(g,e,f){a(f.elements).not(g).hide();a.fn.cycle.commonReset(g,e,f,true,false);f.animIn.height=e.cycleH});b.cssBefore={left:0,top:0,height:0};b.animIn={height:"show"};b.animOut={height:0}};a.fn.cycle.transitions.shuffle=function(e,f,d){var c,b=e.css("overflow","visible").width();f.css({left:0,top:0});d.before.push(function(i,g,h){a.fn.cycle.commonReset(i,g,h,true,true,true)});if(!d.speedAdjusted){d.speed=d.speed/2;d.speedAdjusted=true}d.random=0;d.shuffle=d.shuffle||{left:-b,top:15};d.els=[];for(c=0;c<f.length;c++){d.els.push(f[c])}for(c=0;c<d.currSlide;c++){d.els.push(d.els.shift())}d.fxFn=function(m,j,l,g,i){var h=i?a(m):a(j);a(j).css(l.cssBefore);var k=l.slideCount;h.animate(l.shuffle,l.speedIn,l.easeIn,function(){var o=a.fn.cycle.hopsFromLast(l,i);for(var q=0;q<o;q++){i?l.els.push(l.els.shift()):l.els.unshift(l.els.pop())}if(i){for(var r=0,n=l.els.length;r<n;r++){a(l.els[r]).css("z-index",n-r+k)}}else{var s=a(m).css("z-index");h.css("z-index",parseInt(s)+1+k)}h.animate({left:0,top:0},l.speedOut,l.easeOut,function(){a(i?this:m).hide();if(g){g()}})})};d.cssBefore={display:"block",opacity:1,top:0,left:0}};a.fn.cycle.transitions.turnUp=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,true,false);f.cssBefore.top=e.cycleH;f.animIn.height=e.cycleH});b.cssFirst={top:0};b.cssBefore={left:0,height:0};b.animIn={top:0};b.animOut={height:0}};a.fn.cycle.transitions.turnDown=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,true,false);f.animIn.height=e.cycleH;f.animOut.top=g.cycleH});b.cssFirst={top:0};b.cssBefore={left:0,top:0,height:0};b.animOut={height:0}};a.fn.cycle.transitions.turnLeft=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,false,true);f.cssBefore.left=e.cycleW;f.animIn.width=e.cycleW});b.cssBefore={top:0,width:0};b.animIn={left:0};b.animOut={width:0}};a.fn.cycle.transitions.turnRight=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,false,true);f.animIn.width=e.cycleW;f.animOut.left=g.cycleW});b.cssBefore={top:0,left:0,width:0};b.animIn={left:0};b.animOut={width:0}};a.fn.cycle.transitions.zoom=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,false,false,true);f.cssBefore.top=e.cycleH/2;f.cssBefore.left=e.cycleW/2;f.animIn={top:0,left:0,width:e.cycleW,height:e.cycleH};f.animOut={width:0,height:0,top:g.cycleH/2,left:g.cycleW/2}});b.cssFirst={top:0,left:0};b.cssBefore={width:0,height:0}};a.fn.cycle.transitions.fadeZoom=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,false,false);f.cssBefore.left=e.cycleW/2;f.cssBefore.top=e.cycleH/2;f.animIn={top:0,left:0,width:e.cycleW,height:e.cycleH}});b.cssBefore={width:0,height:0};b.animOut={opacity:0}};a.fn.cycle.transitions.blindX=function(d,e,c){var b=d.css("overflow","hidden").width();c.before.push(function(h,f,g){a.fn.cycle.commonReset(h,f,g);g.animIn.width=f.cycleW;g.animOut.left=h.cycleW});c.cssBefore={left:b,top:0};c.animIn={left:0};c.animOut={left:b}};a.fn.cycle.transitions.blindY=function(d,e,c){var b=d.css("overflow","hidden").height();c.before.push(function(h,f,g){a.fn.cycle.commonReset(h,f,g);g.animIn.height=f.cycleH;g.animOut.top=h.cycleH});c.cssBefore={top:b,left:0};c.animIn={top:0};c.animOut={top:b}};a.fn.cycle.transitions.blindZ=function(e,f,d){var c=e.css("overflow","hidden").height();var b=e.width();d.before.push(function(i,g,h){a.fn.cycle.commonReset(i,g,h);h.animIn.height=g.cycleH;h.animOut.top=i.cycleH});d.cssBefore={top:c,left:b};d.animIn={top:0,left:0};d.animOut={top:c,left:b}};a.fn.cycle.transitions.growX=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,false,true);f.cssBefore.left=this.cycleW/2;f.animIn={left:0,width:this.cycleW};f.animOut={left:0}});b.cssBefore={width:0,top:0}};a.fn.cycle.transitions.growY=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,true,false);f.cssBefore.top=this.cycleH/2;f.animIn={top:0,height:this.cycleH};f.animOut={top:0}});b.cssBefore={height:0,left:0}};a.fn.cycle.transitions.curtainX=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,false,true,true);f.cssBefore.left=e.cycleW/2;f.animIn={left:0,width:this.cycleW};f.animOut={left:g.cycleW/2,width:0}});b.cssBefore={top:0,width:0}};a.fn.cycle.transitions.curtainY=function(c,d,b){b.before.push(function(g,e,f){a.fn.cycle.commonReset(g,e,f,true,false,true);f.cssBefore.top=e.cycleH/2;f.animIn={top:0,height:e.cycleH};f.animOut={top:g.cycleH/2,height:0}});b.cssBefore={left:0,height:0}};a.fn.cycle.transitions.cover=function(f,g,e){var i=e.direction||"left";var b=f.css("overflow","hidden").width();var c=f.height();e.before.push(function(j,d,h){a.fn.cycle.commonReset(j,d,h);if(i=="right"){h.cssBefore.left=-b}else{if(i=="up"){h.cssBefore.top=c}else{if(i=="down"){h.cssBefore.top=-c}else{h.cssBefore.left=b}}}});e.animIn={left:0,top:0};e.animOut={opacity:1};e.cssBefore={top:0,left:0}};a.fn.cycle.transitions.uncover=function(f,g,e){var i=e.direction||"left";var b=f.css("overflow","hidden").width();var c=f.height();e.before.push(function(j,d,h){a.fn.cycle.commonReset(j,d,h,true,true,true);if(i=="right"){h.animOut.left=b}else{if(i=="up"){h.animOut.top=-c}else{if(i=="down"){h.animOut.top=c}else{h.animOut.left=-b}}}});e.animIn={left:0,top:0};e.animOut={opacity:1};e.cssBefore={top:0,left:0}};a.fn.cycle.transitions.toss=function(e,f,d){var b=e.css("overflow","visible").width();var c=e.height();d.before.push(function(i,g,h){a.fn.cycle.commonReset(i,g,h,true,true,true);if(!h.animOut.left&&!h.animOut.top){h.animOut={left:b*2,top:-c/2,opacity:0}}else{h.animOut.opacity=0}});d.cssBefore={left:0,top:0};d.animIn={left:0}};a.fn.cycle.transitions.wipe=function(s,m,e){var q=s.css("overflow","hidden").width();var j=s.height();e.cssBefore=e.cssBefore||{};var g;if(e.clip){if(/l2r/.test(e.clip)){g="rect(0px 0px "+j+"px 0px)"}else{if(/r2l/.test(e.clip)){g="rect(0px "+q+"px "+j+"px "+q+"px)"}else{if(/t2b/.test(e.clip)){g="rect(0px "+q+"px 0px 0px)"}else{if(/b2t/.test(e.clip)){g="rect("+j+"px "+q+"px "+j+"px 0px)"}else{if(/zoom/.test(e.clip)){var o=parseInt(j/2);var f=parseInt(q/2);g="rect("+o+"px "+f+"px "+o+"px "+f+"px)"}}}}}}e.cssBefore.clip=e.cssBefore.clip||g||"rect(0px 0px 0px 0px)";var k=e.cssBefore.clip.match(/(\d+)/g);var u=parseInt(k[0]),c=parseInt(k[1]),n=parseInt(k[2]),i=parseInt(k[3]);e.before.push(function(w,h,t){if(w==h){return}var d=a(w),b=a(h);a.fn.cycle.commonReset(w,h,t,true,true,false);t.cssAfter.display="block";var r=1,l=parseInt((t.speedIn/13))-1;(function v(){var y=u?u-parseInt(r*(u/l)):0;var z=i?i-parseInt(r*(i/l)):0;var A=n<j?n+parseInt(r*((j-n)/l||1)):j;var x=c<q?c+parseInt(r*((q-c)/l||1)):q;b.css({clip:"rect("+y+"px "+x+"px "+A+"px "+z+"px)"});(r++<=l)?setTimeout(v,13):d.css("display","none")})()});e.cssBefore={display:"block",opacity:1,top:0,left:0};e.animIn={left:0};e.animOut={left:0}}})(jQuery);
(function(window, document) {

    Date.prototype.format = function(format) { var returnStr = ''; var replace = Date.replaceChars; for (var i = 0; i < format.length; i++) { var curChar = format.charAt(i); if (replace[curChar]) { returnStr += replace[curChar].call(this); } else { returnStr += curChar; } } return returnStr; }; Date.replaceChars = { shortMonths: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], longMonths: ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'], shortDays: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], longDays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], d: function() { return (this.getDate() < 10 ? '0' : '') + this.getDate(); }, D: function() { return Date.replaceChars.shortDays[this.getDay()]; }, j: function() { return this.getDate(); }, l: function() { return Date.replaceChars.longDays[this.getDay()]; }, N: function() { return this.getDay() + 1; }, S: function() { return (this.getDate() % 10 == 1 && this.getDate() != 11 ? 'st' : (this.getDate() % 10 == 2 && this.getDate() != 12 ? 'nd' : (this.getDate() % 10 == 3 && this.getDate() != 13 ? 'rd' : 'th'))); }, w: function() { return this.getDay(); }, z: function() { return "Not Yet Supported"; }, W: function() { return "Not Yet Supported"; }, F: function() { return Date.replaceChars.longMonths[this.getMonth()]; }, m: function() { return (this.getMonth() < 9 ? '0' : '') + (this.getMonth() + 1); }, M: function() { return Date.replaceChars.shortMonths[this.getMonth()]; }, n: function() { return this.getMonth() + 1; }, t: function() { return "Not Yet Supported"; }, L: function() { return "Not Yet Supported"; }, o: function() { return "Not Supported"; }, Y: function() { return this.getFullYear(); }, y: function() { return ('' + this.getFullYear()).substr(2); }, a: function() { return this.getHours() < 12 ? 'am' : 'pm'; }, A: function() { return this.getHours() < 12 ? 'AM' : 'PM'; }, B: function() { return "Not Yet Supported"; }, g: function() { return this.getHours() % 12 || 12; }, G: function() { return this.getHours(); }, h: function() { return ((this.getHours() % 12 || 12) < 10 ? '0' : '') + (this.getHours() % 12 || 12); }, H: function() { return (this.getHours() < 10 ? '0' : '') + this.getHours(); }, i: function() { return (this.getMinutes() < 10 ? '0' : '') + this.getMinutes(); }, s: function() { return (this.getSeconds() < 10 ? '0' : '') + this.getSeconds(); }, e: function() { return "Not Yet Supported"; }, I: function() { return "Not Supported"; }, O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; }, T: function() { var m = this.getMonth(); this.setMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setMonth(m); return result; }, Z: function() { return -this.getTimezoneOffset() * 60; }, c: function() { return "Not Yet Supported"; }, r: function() { return this.toString(); }, U: function() { return this.getTime() / 1000; } };

    Date.prototype.formatUtc = function(format) {
        var returnStr = '';
        var replace = Date.replaceUtcChars;
        for (var i = 0; i < format.length; i++) {
            var curChar = format.charAt(i);
            if (replace[curChar]) {
                returnStr += replace[curChar].call(this);
            } else {
                returnStr += curChar;
            }
        }
        return returnStr;
    };
    Date.replaceUtcChars = {

        // Day
        d: function() { return (this.getUTCDate() < 10 ? '0' : '') + this.getDate(); },
        D: function() { return Date.replaceChars.shortDays[this.getUTCDay()]; },
        j: function() { return this.getUTCDate(); },
        l: function() { return Date.replaceChars.longDays[this.getUTCDay()]; },
        N: function() { return this.getUTCDay() + 1; },
        S: function() { return (this.getDate() % 10 == 1 && this.getUTCDate() != 11 ? 'st' : (this.getUTCDate() % 10 == 2 && this.getUTCDate() != 12 ? 'nd' : (this.getUTCDate() % 10 == 3 && this.getUTCDate() != 13 ? 'rd' : 'th'))); },
        w: function() { return this.getUTCDay(); },
        z: function() { return "Not Yet Supported"; },
        // Week
        W: function() { return "Not Yet Supported"; },
        // Month
        F: function() { return Date.replaceChars.longMonths[this.getUTCMonth()]; },
        m: function() { return (this.getUTCMonth() < 9 ? '0' : '') + (this.getUTCMonth() + 1); },
        M: function() { return Date.replaceChars.shortMonths[this.getUTCMonth()]; },
        n: function() { return this.getUTCMonth() + 1; },
        t: function() { return "Not Yet Supported"; },
        // Year
        L: function() { return "Not Yet Supported"; },
        o: function() { return "Not Supported"; },
        Y: function() { return this.getUTCFullYear(); },
        y: function() { return ('' + this.getUTCFullYear()).substr(2); },
        // Time
        a: function() { return this.getUTCHours() < 12 ? 'am' : 'pm'; },
        A: function() { return this.getUTCHours() < 12 ? 'AM' : 'PM'; },
        B: function() { return "Not Yet Supported"; },
        g: function() { return this.getUTCHours() % 12 || 12; },
        G: function() { return this.getUTCHours(); },
        h: function() { return ((this.getUTCHours() % 12 || 12) < 10 ? '0' : '') + (this.getUTCHours() % 12 || 12); },
        H: function() { return (this.getUTCHours() < 10 ? '0' : '') + this.getUTCHours(); },
        i: function() { return (this.getUTCMinutes() < 10 ? '0' : '') + this.getUTCMinutes(); },
        s: function() { return (this.getUTCSeconds() < 10 ? '0' : '') + this.getUTCSeconds(); },
        // Timezone
        e: function() { return "Not Yet Supported"; },
        I: function() { return "Not Supported"; },
        O: function() { return (-this.getTimezoneOffset() < 0 ? '-' : '+') + (Math.abs(this.getTimezoneOffset() / 60) < 10 ? '0' : '') + (Math.abs(this.getTimezoneOffset() / 60)) + '00'; },
        T: function() { var m = this.getUTCMonth(); this.setUTCMonth(0); var result = this.toTimeString().replace(/^.+ \(?([^\)]+)\)?$/, '$1'); this.setUTCMonth(m); return result; },
        Z: function() { return -this.getTimezoneOffset() * 60; },
        // Full Date/Time
        c: function() { return "Not Yet Supported"; },
        r: function() { return this.toString(); },
        U: function() { return this.getTime() / 1000; }
    };

    var windowName = window.name;

    /**
    *
    *  Base64 encode / decode
    *  http://www.webtoolkit.info/
    *
    **/

    var Base64 = {

        // private property
        _keyStr: "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

        // public method for encoding
        encode: function(input) {
            var output = "";
            var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
            var i = 0;

            input = Base64._utf8_encode(input);

            while (i < input.length) {

                chr1 = input.charCodeAt(i++);
                chr2 = input.charCodeAt(i++);
                chr3 = input.charCodeAt(i++);

                enc1 = chr1 >> 2;
                enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
                enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
                enc4 = chr3 & 63;

                if (isNaN(chr2)) {
                    enc3 = enc4 = 64;
                } else if (isNaN(chr3)) {
                    enc4 = 64;
                }

                output = output +
			    this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			    this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

            }

            return output;
        },

        // public method for decoding
        decode: function(input) {
            var output = "";
            var chr1, chr2, chr3;
            var enc1, enc2, enc3, enc4;
            var i = 0;

            input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

            while (i < input.length) {

                enc1 = this._keyStr.indexOf(input.charAt(i++));
                enc2 = this._keyStr.indexOf(input.charAt(i++));
                enc3 = this._keyStr.indexOf(input.charAt(i++));
                enc4 = this._keyStr.indexOf(input.charAt(i++));

                chr1 = (enc1 << 2) | (enc2 >> 4);
                chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
                chr3 = ((enc3 & 3) << 6) | enc4;

                output = output + String.fromCharCode(chr1);

                if (enc3 != 64) {
                    output = output + String.fromCharCode(chr2);
                }
                if (enc4 != 64) {
                    output = output + String.fromCharCode(chr3);
                }

            }

            output = Base64._utf8_decode(output);

            return output;

        },

        // private method for UTF-8 encoding
        _utf8_encode: function(string) {
            string = string.replace(/\r\n/g, "\n");
            var utftext = "";

            for (var n = 0; n < string.length; n++) {

                var c = string.charCodeAt(n);

                if (c < 128) {
                    utftext += String.fromCharCode(c);
                }
                else if ((c > 127) && (c < 2048)) {
                    utftext += String.fromCharCode((c >> 6) | 192);
                    utftext += String.fromCharCode((c & 63) | 128);
                }
                else {
                    utftext += String.fromCharCode((c >> 12) | 224);
                    utftext += String.fromCharCode(((c >> 6) & 63) | 128);
                    utftext += String.fromCharCode((c & 63) | 128);
                }

            }

            return utftext;
        },

        // private method for UTF-8 decoding
        _utf8_decode: function(utftext) {
            var string = "";
            var i = 0;
            var c = c1 = c2 = 0;

            while (i < utftext.length) {

                c = utftext.charCodeAt(i);

                if (c < 128) {
                    string += String.fromCharCode(c);
                    i++;
                }
                else if ((c > 191) && (c < 224)) {
                    c2 = utftext.charCodeAt(i + 1);
                    string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
                    i += 2;
                }
                else {
                    c2 = utftext.charCodeAt(i + 1);
                    c3 = utftext.charCodeAt(i + 2);
                    string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
                    i += 3;
                }

            }

            return string;
        }

    };


    var dateHtmlTemplate = new Template('<span class="date-weekday date-weekday-#{ddd}">#{DDD}</span><span class="date-separator date-weekday-month-separator">, </span><span class="date-month date-month-#{M} date-month-#{mmm}">#{MMM} </span><span class="date-day date-day-#{d}">#{d}</span><span class="date-separator date-day-year-separator">, </span><span class="date-year date-year-#{yyyy}">#{yyyy}</span><span class="date-time"> #{h}:#{tmm} #{TT}</span>');
    var dateClassTemplate = new Template("date-year-#{yyyy} date-month-#{m} date-month-#{mmm} date-day-#{d} date-weekday-#{ddd}");
    var isoDateTemplate = new Template("#{yyyy}-#{mm}-#{dd}T#{HH}:#{tmm}:#{ss}Z");
    var getDateForEvaluation = function(date) {
        return {
            d: date.format("j"),
            D: date.format("j"),
            dd: date.format("d"),
            DD: date.format("d"),
            ddd: date.format("D").toLowerCase(),
            DDD: date.format("D"),
            dddd: date.format("l").toLowerCase(),
            DDDD: date.format("l"),
            m: date.format("n"),
            M: date.format("n"),
            mm: date.format("m"),
            MM: date.format("m"),
            mmm: date.format("M").toLowerCase(),
            MMM: date.format("M"),
            mmmmm: date.format("F").toLowerCase(),
            MMMM: date.format("F"),
            yy: date.format("y"),
            yyyy: date.format("Y"),
            h: date.format("g"),
            hh: date.format("h"),
            H: date.format("G"),
            HH: date.format("H"),
            tm: date.format("i"),
            tmm: date.format("i"),
            tt: date.format("a"),
            TT: date.format("A"),
            ss: date.format("s")
        }
    };
    var getUtcDateForEvaluation = function(date) {
        return {
            d: date.formatUtc("j"),
            D: date.formatUtc("j"),
            dd: date.formatUtc("d"),
            DD: date.formatUtc("d"),
            ddd: date.formatUtc("D").toLowerCase(),
            DDD: date.formatUtc("D"),
            dddd: date.formatUtc("l").toLowerCase(),
            DDDD: date.formatUtc("l"),
            m: date.formatUtc("n"),
            M: date.formatUtc("n"),
            mm: date.formatUtc("m"),
            MM: date.formatUtc("m"),
            mmm: date.formatUtc("M").toLowerCase(),
            MMM: date.formatUtc("M"),
            mmmmm: date.formatUtc("F").toLowerCase(),
            MMMM: date.formatUtc("F"),
            yy: date.formatUtc("y"),
            yyyy: date.formatUtc("Y"),
            h: date.formatUtc("g"),
            hh: date.formatUtc("h"),
            H: date.formatUtc("G"),
            HH: date.formatUtc("H"),
            tm: date.formatUtc("i"),
            tmm: date.formatUtc("i"),
            tt: date.formatUtc("a"),
            TT: date.formatUtc("A"),
            ss: date.formatUtc("s")
        }
    };

    var buildFeedListFromGoogleJson = function(id, count, feed) {

        var container = $(id);
        if (container) {
            var p = $(jQuery(container).find("p:last")[0]);

            if (p) {
                p.remove();
            }

            if (feed.entries.length < count) {
                count = feed.entries.length;
            }
            //container.addClassName("hfeed");
            var list = new Element("ul", { className: "hfeed feed-items" }).addClassName("feed-items-" + count);
            for (var i = 0; i < count; i++) {
                var item = new Element("li", { className: "feed-item hentry" });
                item.insert(new Element("a", { href: feed.entries[i].link, className: "feed-item-title entry-title", rel: "bookmark" }).update(feed.entries[i].title.stripScripts())).insert(" ");
                var publishedDate = feed.entries[i].publishedDate;
                if (publishedDate && publishedDate != "") {
                    var date = new Date(publishedDate);

                    var dateInfo = getDateForEvaluation(date);
                    item.insert(new Element("abbr", { title: isoDateTemplate.evaluate(getUtcDateForEvaluation(date)), className: dateClassTemplate.evaluate(dateInfo) }).addClassName("published").addClassName("feed-item-published").update(dateHtmlTemplate.evaluate(dateInfo)));

                    if (container.hasClassName("syndication-feed-preview-content")) {
                        item.insert(new Element("p", { className: "feed-item-preview-content entry-summary" }).update(feed.entries[i].contentSnippet.stripScripts()));
                    } else if (container.hasClassName("syndication-feed-full-content")) {
                        item.insert(new Element("div", { className: "feed-item-full-content entry-content" }).update(feed.entries[i].content.stripScripts()));
                    }
                }
                list.insert(item);
            }
            container.insert(list);
            jQuery(document).trigger("change");

        }
    };

    // lightbox options
    if (window.LightboxOptions) {
        Object.extend(window.LightboxOptions, {
            fileLoadingImage: "//assets.rocketshipcms.com/images/lightbox/loading.gif",
            fileBottomNavCloseImage: "//assets.rocketshipcms.com/images/lightbox/closelabel.gif",

            overlayOpacity: 0.8,   // controls transparency of shadow overlay

            animate: true,         // toggles resizing animations
            resizeSpeed: 9      // controls the speed of the image resizing animations (1=slowest and 10=fastest)

        });
    }


    var rotators = [];

    jQuery(function($) {


        $("a.open-new-window").attr("target", "_blank");

        $("#site-menu li:has(ul)").hover(function(e) { $(this).addClass("hover"); }, function(e) { $(this).removeClass("hover"); }).filter(":has( > ul)").hover(function(e) { $(this).addClass("active"); }, function(e) { $(this).removeClass("active"); });

        $("div[title]").attr("_title", function() { return this.title; }).removeAttr("title");

        $("div.map a").wrap("<p></p>");

        // fix flash stuff

        //$("object").append('<param name="wmode" value="transparent">');
        //$("embed").attr("wmode", "transparent");
        /*$("object,embed").each(function() {
        $(this).filter("object").append('<param name="wmode" value="transparent">');
        $(this).filter("embed").attr("wmode", "transparent");
        var html = $('<div>').append($(this).eq(0).clone()).html();
        alert(html);
        //alert($('<div>').append($(this).eq(0).clone()).html());
        //$(this).replaceWith($('<div>').append($(this).eq(0).clone()).html());
        $(this).before(html).remove();
        });*/
        $("#site-index-menu li li:not(:last-child)").append(",");

        $("p.blog-post-dateline > abbr, p.blog-post-comment-dateline > abbr").each(function() {
            var hdate = this;
            $(hdate).attr("className").split(/\s+/).grep(/^date-.*/i).each(function(item) {
                $(hdate).removeClass(item);
            });
            // this REALLY needs new logic
            var date = new Date($(hdate).attr("title").replace(/-/g, "/").replace(/T/g, " ").replace(/Z/g, " GMT"));
            var dateInfo = getDateForEvaluation(date);
            $(hdate).addClass(dateClassTemplate.evaluate(dateInfo)).html(dateHtmlTemplate.evaluate(dateInfo));
            //$(hdate).addClass("date-year-" + date.getFullYear() + " date-month-" + (date.getMonth() + 1) + " date-month-" + months[date.getMonth()].abbr.toLowerCase() + " date-day-" + date.getDate() + " date-weekday-" + days[date.getDay()].abbr.toLowerCase()).empty().append('<span class="date-weekday date-weekday-' + days[date.getDay()].abbr.toLowerCase() + '">' + days[date.getDay()].name + '</span><span class="date-separator date-weekday-month-separator">, </span><span class="date-month date-month-' + (date.getMonth() + 1) + ' date-month-' + months[date.getMonth()].abbr.toLowerCase() + '">' + months[date.getMonth()].abbr + ' </span><span class="date-day date-day-' + date.getDate() + '">' + date.getDate() + '</span><span class="date-separator date-day-year-separator">, </span><span class="date-year date-year-' + date.getFullYear() + '">' + date.getFullYear() + '</span><span class="date-time"> ' + (date.getHours() % 12 == 0 ? 12 : date.getHours() % 12) + ':' + (date.getMinutes() < 10 ? "0" + date.getMinutes() : date.getMinutes()) + (date.getHours() < 12 ? " AM" : " PM") + '</span>');
        });

        // load weathers
        var weatherTemplate = new Template('<p><a href="#{url}" target="_blank" title="#{title}"><img src="#{icon}" /></a> #{condition}, <span class="temp">#{temp}&#176;</span></p>');
        var extractConditionCode = function(iconUrl) {
            return iconUrl.substr(iconUrl.search(/cond(\d{3})/i) + 4, 3);
        };
        var weathers = $(".weather-search-location").each(function() {
            var base = $(this);
            var search = base.val() || base.attr("title") || base.text();
            /*if(base.parents("a").size() > 0) {
            base.parents("a:first").html("Loading weather for " + search + "...");
            };*/
            jQuery.getJSON("http://pipes.yahoo.com/pipes/pipe.run?_id=1634adfb3ba292c006ac5619c5826375&_render=json&location=" + search + "&_callback=?", function(pipesData) {
                if (!pipesData || pipesData.count == 0 || !pipesData.value || !pipesData.value.items || !pipesData.value.items[0]) return;
                var feed = pipesData.value.items[0].channel;
                if (!feed || !feed.weather) return;
                var observation = feed.weather.ob;
                // extract condition code
                var conditionCode = extractConditionCode(observation["current-condition"].icon);

                var html = weatherTemplate.evaluate({ url: feed.link, title: feed.title || (observation["city-state"].content + " " + observation.country), icon: ("http://assets.rocketshipcms.com/images/site-defaults/weather/24x24/" + conditionCode + ".png"), condition: observation["current-condition"].content, temp: Math.round(observation.temp.content) });
                if (base.is("input:hidden")) {
                    base.after(html).remove()
                } else if (base.parents("p").size() > 0) {
                    base.parents("p:first").replaceWith(html);
                }

                jQuery(document).trigger("changed");
            });
        });
        if (weathers.size() > 0) {
            $("#site-copyright").append(' Weather data provided by <a href="http://weather.weatherbug.com">WeatherBug</a>.');
        }

        $("div.syndication-feed").each(function() {

            var container = $(this);
            var link = $(this).find("a").slice(0);
            var msg = $('<span>Loading feed:</span>').prependTo($(this).find("p:last"));

            var count = 20;
            var classNames = (link.attr("className") || "").split(/\s+/);
            for (var i = 0; i < classNames.length; i++) {
                if (classNames[i].search(/max-items-[0-9]+$/i) >= 0) {
                    count = parseInt(classNames[i].substr(10));
                    //container.addClass(classNames[i])
                    break;
                }
            }
            var isLocalBlog = link.hasClass("site-blog-page");
            jQuery.getJSON((isLocalBlog ? link.attr("href").replace(/\.[\w]+$/i, ".json") : "http://ajax.googleapis.com/ajax/services/feed/load") + "?callback=?", isLocalBlog ? null : {
                "v": "1.0",
                "num": count,
                "q": link.attr("href")
            }, function(data) {
                var status = data.responseStatus || 200;
                if (status < 200 || status >= 300) {
                    msg.text("Could not load feed: ");
                    return;
                }

                buildFeedListFromGoogleJson(container.attr("id"), count, data.feed || data.responseData.feed);
            });



        });

        // auto link in blog comments
        if ($("body").hasClass("site-blog-page")) {
            $("#page-body-content").find("div.blog-post-comment-text").html(function(i, html) {
                return html.replace(/\b(?:(?:https?|ftp|file):\/\/|www\.|ftp\.)(?:\([-A-Z0-9+&@#\/%=~_|$?!:,.]*\)|[-A-Z0-9+&@#\/%=~_|$?!:,.])*(?:\([-A-Z0-9+&#\/%=~_|$?!:,.]*\)|[A-Z0-9+&@#\/%=~_|$])/gim, '<a href="$&" rel="nofollow">$&</a>');
            });
        }

        // forms
        $("form:not(.no-auto-wireup)").submit(function(e) {
            if (this.action && !this.action.empty() && !$(this).is("form[action$=/email_form_submission],form[action*=mailto],.feedback")) {
                if (window != window.parent) {
                    this.target = "_blank";
                }
                return;
            }

            e.preventDefault();

            $(this).filter("form[action*=mailto]").each(function() {
                var email = $(this).find("input[name=toAddress]");
                if (email.length <= 0) email = $('<input type="hidden" name="toAddress" />').prependTo(this);
                email.val(this.action.substr(7));
                this.action = "./email_form_submission";
            });



            // test form action
            if (!this.action && !this.action.empty()) {
                this.action = "./email_form_submission";
            }

            // extract a redirect url
            var redirectUrl = $(this).find("input[name=submitRedirectUrl],input[name=redirectUrl]").val() || null;

            //var buttons = form.select("button");
            var inputs = $(this).find("input,select,textarea,button");
            var originalSubmit = $(this).find("button[type=submit]").blur().html();

            var form = this;
            this.target = "_blank";
            this.method = "POST";
            var response = Form.request(form, {
                onCreate: function() {
                    inputs.attr("disabled", true);
                    $(form).find("button[type=submit]").html("Submitting...");
                },
                onSuccess: function(transport) {
                    $(form).replaceWith($('<div class="feedback-message" />').addClass(form.className).append($("<p />", { html: $(form).find("input[name=submitMessage]").val() || "Your message has been sent!" })));
                    if (redirectUrl && !redirectUrl.empty()) {
                        if (window != window.parent) {
                            // in a frame, pop open window
                            window.open(redirectUrl);
                        } else {
                            window.location.href = redirectUrl;
                        }
                    }
                    $(document).trigger("change");
                },
                onFailure: function(transport) {
                    form.submit();
                },
                onException: function(request, error) {
                    form.submit();
                },
                onComplete: function(request) {
                    $(form).find("button[type=submit]").html(originalSubmit);
                    inputs.removeAttr("disabled");
                }
            });

        });
        
        // group photo galleries by rel
        $("ul.image-set-thumb-gallery a").attr("rel", function(index, rel) {
        	return [rel, $(this).closest("[id]").attr("id") + "-image-set"].compact().without("").join(" ");
        });
        
        // photo gallery fancybox
        $("a").filter(function() {
        	var regex = /\.(jpg|jpeg|png|gif)$/i;
        	return regex.test($(this).attr("href"));
        }).fancybox({
			overlayOpacity:0.7,
			overlayColor: "#000000",
			cyclic:true,
			titlePosition:"over",
			titleFormat: function(title, currentArray, currentIndex, currentOpts) {
		    	return currentArray.length > 1 ? '<span id="fancybox-title-over">' + title + ' (' + (currentIndex + 1) + ' of ' + currentArray.length + ')</span>' : title;
			}
		}).filter(":has(img)").not("ul.image-set-thumb-gallery a").addClass("thumb").append('<span style="display:none;">Expand</span>');
        

    });

    window.document.observe("dom:loaded", function() {

        // seem to be having trouble with load...
        //Event.observe(window, "load",  function() {

        var body = $(document.body) || $(document.documentElement).down("body");

        $$("#site-protected-page-login").invoke("observe", "submit", function(submitEvent) {
            submitEvent.preventDefault();
            var form = this;
            var request = new Ajax.Request(form.action, {

                method: "GET",
                requestHeaders: {
                    "Authorization": "Basic " + Base64.encode($F("site-protected-page-login-username") + ":" + $F("site-protected-page-login-password"))
                },
                onSuccess: function(response) {
                    window.location.reload();
                },
                onFailure: function(response) {
                    if (!form.previous("p")) {
                        form.insert({ before: "<p>Password is incorrect.  Please try again:</p>" });
                    }
                }

            });

        });

        AudioPlayer.setup("http://assets.rocketshipcms.com/behavior/lib/audioplayer/player.swf", {
            initialvolume: 80,
            transparentpagebg: "yes",
            checkpolicy: "yes",
            noinfo: "yes",
            width: "100%",
            animation: "yes",
            bg: "ffffff",
            leftbg: "dfdfdf",
            leftbghover: "dfdfdf",
            lefticon: "717171",
            voltrack: "ffffff",
            volslider: "717171",
            rightbg: "cfcfcf",
            rightbghover: "cfcfcf",
            righticon: "717171",
            righticonhover: "363636",
            border: "e9e9e9",
            loader: "717171",
            tracker: "e9e9e9",
            text: "717171"

        });
        var audioDocInit = function(item) {
            var link = item.down("a");
            //link.hide().next().hide();
            var src = link.href;
            var swf = new Element("div");
            item.insert({ bottom: swf });
            //link.next().insert({after:swf});
            var width = item.offsetWidth - 10 > 290 ? 290 : "100%";
            AudioPlayer.embed(swf.identify(), { soundFile: src, autostart: link.hasClassName("auto-play") ? "yes" : "no" });
            item.addClassName("player");
        };
        $$(".audio-set .mp3").each(audioDocInit);

        // blog comment form
        var blogCommentForm = $("blog-post-comment-new");
        if (blogCommentForm) {
            blogCommentForm.show().observe("submit", function(submitEvent) {
                submitEvent.stop();

                form = this;
                var inputs = form.select("input,select,textarea,button");
                //var buttons = form.select("button");
                var submitButton = form.down("button[type=submit]");
                submitButton.blur();
                var oldButtonText = submitButton.innerHTML;

                var response = form.request({
                    onCreate: function() {
                        form.disable();
                        inputs.invoke("writeAttribute", "disabled", "disabled");
                        submitButton.update("Posting this comment...")
                    },
                    onSuccess: function(response) {
                        /*var temp = new Element("div");
                        temp.update(response.responseText);
                        temp.childElements().invoke("writeAttribute", "title", "");
                        form.up().insert({before:temp.innerHTML});
                        window.document.fire("dom:changed");*/
                        form.reset();
                        form.enable();
                        submitButton.update(oldButtonText);
                        inputs.invoke("writeAttribute", "disabled", null);
                        window.location.reload();
                    },
                    onFailure: function(response) {
                        form.enable();
                        submitButton.update(oldButtonText);
                        inputs.invoke("writeAttribute", "disabled", null);
                    },
                    onComplete: function(response) {

                    }
                });

            });
        }

    });

    // setup live viewport tracking
    document.viewport.dimensions = document.viewport.getDimensions();
    Event.observe(window, "resize", function() {
        this.document.viewport.dimensions = this.document.viewport.getDimensions();
    });

})(window, document);

// setup tracking
(function($) {

    if ((function(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for (var i = 0; i < ca.length; i++) {
            var c = ca[i];
            while (c.charAt(0) == ' ') c = c.substring(1, c.length);
            if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
        }
        return null;
    })("X-Rocketship-AuthChallenged")) return;

    var logView = function(pageGuid, googleAnaltyics) {
        if (googleAnaltyics) {
            var rsPageTracker = googleAnaltyics._getTracker("UA-6128391-1");
            rsPageTracker._setDomainName("none");
            rsPageTracker._trackPageview();
            
            if(pageGuid) {
                var rsPageTracker2 = googleAnaltyics._getTracker("UA-11631005-1");
                rsPageTracker2._setDomainName("none");
                rsPageTracker2._trackPageview("/pages/" + pageGuid);
            }
        }

    };
    
    jQuery(window).load(function() {

            var pageGuid = $("meta[name=id]").attr("content");

            if (window._gat) {
                logView(pageGuid, window._gat);
            } else {
                jQuery.ajaxSetup({ cache: true });
                jQuery.getScript((("https:" == document.location.protocol) ? "https://ssl." : "http://www.") + "google-analytics.com/ga.js", function() {
                    logView.defer(pageGuid, window._gat);
                });
                jQuery.ajaxSetup({ cache: false });
            }
    });

})(jQuery);

// setup rotators
(function($) {

    $.fn.cycle.transitions.scrollVertUp = function($cont, $slides, opts) {
        $cont.css('overflow','hidden');
        opts.before.push(function(curr, next, opts, fwd) {
                $.fn.cycle.commonReset(curr,next,opts);
                opts.cssBefore.top = fwd ? (next.cycleH-1) : (1-next.cycleH);
                opts.animOut.top = fwd ? -curr.cycleH : curr.cycleH;
        });
        opts.cssFirst = { top: 0 };
        opts.cssBefore= { left: 0 };
        opts.animIn   = { top: 0 };
        opts.animOut  = { left: 0 };
    };
    
    var rotators;
    jQuery(window).ready(function() {
        rotators = $("ul.rotator");
    }).load(function() {
        (rotators || $("ul.rotator")).each(function() {
            var rotator = $(this);
            var indexItems = new Array(rotator.children().size());
            //var baseID = $(rotator).parents(".content-item").attr("id");
            var menu, next, previous
            if(rotator.hasClass("rotation-menu") || rotator.hasClass("rotation-menu-nextprev")) {
                menu = $('<ul class="rotator-menu"></ul>');
                previous = $('<li class="previous"><button type="button">Previous</button></li>').appendTo(menu);
                next = $('<li class="next"><button type="button">Next</button></li>').appendTo(menu);
                $('<div class="rotator-nav"></div>').append(menu).insertAfter(rotator);
            }
       
            var startIndex = rotator.children().index(rotator.children(":visible"));
            var transition = "fade";
            var speed = 1000;
            if(rotator.hasClass("rotation-transition-scrollhorizontal")) {
                transition = "scrollHorz";
                speed = 500;
            } else if(rotator.hasClass("rotation-transition-scrollvertical")) {
                transition = "scrollVertUp";
                speed = 500;
            }
            rotator.cycle(Object.extend({
                //fx:"fade",
                fx:transition,
                speed:speed,
                timeout: 10000,
                pause: true,
                startingSlide: startIndex,
                cleartypeNoBg: true
            }, menu && menu.is(":visible") ? Object.extend({
                //fx:"scrollHorz",
                //speed:500,
                next:next,
                prev:previous
            }, rotator.hasClass("rotation-menu") ? {
                pager:menu,
                pagerAnchorBuilder:function(index, slide) {
                    var item = $('<li class="item item-' + (index + 1) + '"><button type="button">' + (index + 1) + '</button></li>');
                    if(index == startIndex) {
                        item.addClass("selected");
                    }
                    indexItems[index] = item;
                    return item;
                },
                pauseOnPagerHover: true,
                before:function(currSlideElement, nextSlideElement, options, forwardFlag) {
                    menu.children().removeClass("selected");
                    var item = indexItems[rotator.children().index(this)];
                    if(item) item.addClass("selected");
                }
            } : {}) : {}));
            
            // need this?
            if(menu && next) {
                next.appendTo(menu);
            }
            
        });
        
    });
})(jQuery);

// fix flash wmode - this seems to be necessary for some iframes
//if (window.parent != window) {
    jQuery(function($) {
        // loop through every embed tag on the site
        var embeds = document.getElementsByTagName('embed');
        for (i = 0; i < embeds.length; i++) {
            embed = embeds[i];
            var new_embed;
            // everything but Firefox & Konqueror
            if (embed.outerHTML) {
                var html = embed.outerHTML;
                // replace an existing wmode parameter
                if (html.match(/wmode\s*=\s*('|")[a-zA-Z]+('|")/i))
                    new_embed = html.replace(/wmode\s*=\s*('|")window('|")/i, "wmode='transparent'");
                // add a new wmode parameter
                else
                    new_embed = html.replace(/<embed\s/i, "<embed wmode='transparent' ");
                // replace the old embed object with the fixed version
                embed.insertAdjacentHTML('beforeBegin', new_embed);
                embed.parentNode.removeChild(embed);
            } else {
                // cloneNode is buggy in some versions of Safari & Opera, but works fine in FF
                new_embed = embed.cloneNode(true);
                if (!new_embed.getAttribute('wmode') || new_embed.getAttribute('wmode').toLowerCase() == 'window')
                    new_embed.setAttribute('wmode', 'transparent');
                embed.parentNode.replaceChild(new_embed, embed);
            }
        }
        // loop through every object tag on the site
        var objects = document.getElementsByTagName('object');
        for (i = 0; i < objects.length; i++) {
            object = objects[i];
            var new_object;
            // object is an IE specific tag so we can use outerHTML here
            if (object.outerHTML) {
                var html = object.outerHTML;
                // replace an existing wmode parameter
                if (html.match(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")[a-zA-Z]+('|")\s*\/?\>/i))
                    new_object = html.replace(/<param\s+name\s*=\s*('|")wmode('|")\s+value\s*=\s*('|")window('|")\s*\/?\>/i, "<param name='wmode' value='transparent' />");
                // add a new wmode parameter
                else
                    new_object = html.replace(/<\/object\>/i, "<param name='wmode' value='transparent' />\n</object>");
                // loop through each of the param tags
                var children = object.childNodes;
                for (j = 0; j < children.length; j++) {
                    if (children[j].getAttribute('name').match(/flashvars/i)) {
                        new_object = html.replace(/<param\s+name\s*=\s*('|")flashvars('|")\s+value\s*=\s*('|")[^'"]*('|")\s*\/?\>/i, "<param name='flashvars' value='" + children[j].getAttribute('value') + "' />");
                    }
                }
                // replace the old embed object with the fixed versiony
                object.insertAdjacentHTML('beforeBegin', new_object);
                object.parentNode.removeChild(object);
            }
        }

    });
//}

