jQuery.extend({roundabout_shape:{def:"lazySusan",lazySusan:function(d,b,c){return{x:Math.sin(d+b),y:(Math.sin(d+3*Math.PI/2+b)/8)*c,z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};}}});jQuery.fn.roundabout=function(){var a=(typeof arguments[0]!="object")?{}:arguments[0];a={bearing:(typeof a.bearing=="undefined")?0:jQuery.roundabout_toFloat(a.bearing%360),tilt:(typeof a.tilt=="undefined")?0:jQuery.roundabout_toFloat(a.tilt),minZ:(typeof a.minZ=="undefined")?100:parseInt(a.minZ,10),maxZ:(typeof a.maxZ=="undefined")?400:parseInt(a.maxZ,10),minOpacity:(typeof a.minOpacity=="undefined")?0.4:jQuery.roundabout_toFloat(a.minOpacity),maxOpacity:(typeof a.maxOpacity=="undefined")?1:jQuery.roundabout_toFloat(a.maxOpacity),minScale:(typeof a.minScale=="undefined")?0.4:jQuery.roundabout_toFloat(a.minScale),maxScale:(typeof a.maxScale=="undefined")?1:jQuery.roundabout_toFloat(a.maxScale),duration:(typeof a.duration=="undefined")?600:parseInt(a.duration,10),btnNext:a.btnNext||null,btnPrev:a.btnPrev||null,easing:a.easing||"swing",clickToFocus:(a.clickToFocus!==false),focusBearing:(typeof a.focusBearing=="undefined")?0:jQuery.roundabout_toFloat(a.focusBearing%360),shape:a.shape||"lazySusan",debug:a.debug||false,childSelector:a.childSelector||"li",startingChild:(typeof a.startingChild=="undefined")?null:parseInt(a.startingChild,10),reflect:(typeof a.reflect=="undefined"||a.reflect===false)?false:true};this.each(function(e){var f=jQuery(this);var g=jQuery.roundabout_toFloat(360/f.children(a.childSelector).length);var d=(a.startingChild===null)?a.bearing:a.startingChild*g;f.addClass("roundabout-holder").css("padding",0).css("position","relative").css("z-index",a.minZ);f.data("roundabout",{bearing:d,tilt:a.tilt,minZ:a.minZ,maxZ:a.maxZ,minOpacity:a.minOpacity,maxOpacity:a.maxOpacity,minScale:a.minScale,maxScale:a.maxScale,duration:a.duration,easing:a.easing,clickToFocus:a.clickToFocus,focusBearing:a.focusBearing,animating:0,childInFocus:-1,shape:a.shape,period:g,debug:a.debug,childSelector:a.childSelector,reflect:a.reflect});if(a.clickToFocus===true){f.children(a.childSelector).each(function(h){jQuery(this).click(function(i){var j=(a.reflect===true)?360-(g*h):g*h;j=jQuery.roundabout_toFloat(j);if(!jQuery.roundabout_isInFocus(f,j)){i.preventDefault();if(f.data("roundabout").animating===0){f.roundabout_animateAngleToFocus(j);}return false;}});});}if(a.btnNext){jQuery(a.btnNext).bind("click.roundabout",function(h){h.preventDefault();if(f.data("roundabout").animating===0){f.roundabout_animateToNextChild();}return false;});}if(a.btnPrev){jQuery(a.btnPrev).bind("click.roundabout",function(h){h.preventDefault();if(f.data("roundabout").animating===0){f.roundabout_animateToPreviousChild();}return false;});}});this.roundabout_startChildren();if(typeof arguments[1]==="function"){var c=arguments[1],b=this;setTimeout(function(){c(b);},0);}return this;};jQuery.fn.roundabout_startChildren=function(){this.each(function(b){var c=jQuery(this);var d=c.data("roundabout");var a=c.children(d.childSelector);a.each(function(e){var f=(d.reflect===true)?360-(d.period*e):d.period*e;jQuery(this).addClass("roundabout-moveable-item").css("position","absolute");jQuery(this).data("roundabout",{startWidth:jQuery(this).width(),startHeight:jQuery(this).height(),startFontSize:parseInt(jQuery(this).css("font-size"),10),degrees:f});});c.roundabout_updateChildPositions();});return this;};jQuery.fn.roundabout_setTilt=function(a){this.each(function(d){jQuery(this).data("roundabout").tilt=a;jQuery(this).roundabout_updateChildPositions();});if(typeof arguments[1]==="function"){var c=arguments[1],b=this;setTimeout(function(){c(b);},0);}return this;};jQuery.fn.roundabout_setBearing=function(a){this.each(function(d){jQuery(this).data("roundabout").bearing=jQuery.roundabout_toFloat(a%360,2);jQuery(this).roundabout_updateChildPositions();});if(typeof arguments[1]==="function"){var c=arguments[1],b=this;setTimeout(function(){c(b);},0);}return this;};jQuery.fn.roundabout_adjustBearing=function(c){c=jQuery.roundabout_toFloat(c);if(c!==0){this.each(function(d){jQuery(this).data("roundabout").bearing=jQuery.roundabout_getBearing(jQuery(this))+c;jQuery(this).roundabout_updateChildPositions();});}if(typeof arguments[1]==="function"){var b=arguments[1],a=this;setTimeout(function(){b(a);},0);}return this;};jQuery.fn.roundabout_adjustTilt=function(c){c=jQuery.roundabout_toFloat(c);if(c!==0){this.each(function(d){jQuery(this).data("roundabout").tilt=jQuery.roundabout_toFloat(jQuery(this).roundabout_get("tilt")+c);jQuery(this).roundabout_updateChildPositions();});}if(typeof arguments[1]==="function"){var b=arguments[1],a=this;setTimeout(function(){b(a);},0);}return this;};jQuery.fn.roundabout_animateToBearing=function(b){b=jQuery.roundabout_toFloat(b);var c=new Date();var d=(typeof arguments[1]=="undefined")?null:arguments[1];var a=(typeof arguments[2]=="undefined")?null:arguments[2];var e=(typeof arguments[3]!=="object")?null:arguments[3];this.each(function(j){var k=jQuery(this),m=k.data("roundabout"),n,l,f;var g=(d===null)?m.duration:d;var h=(a!==null)?a:m.easing||"swing";if(e===null){e={timerStart:c,start:jQuery.roundabout_getBearing(k),totalTime:g};}n=c-e.timerStart;if(n<g){m.animating=1;if(typeof jQuery.easing.def=="string"){l=jQuery.easing[h]||jQuery.easing[jQuery.easing.def];f=l(null,n,e.start,b-e.start,e.totalTime);}else{f=jQuery.easing[h]((n/e.totalTime),n,e.start,b-e.start,e.totalTime);}k.roundabout_setBearing(f,function(){k.roundabout_animateToBearing(b,g,h,e);});}else{b=(b<0)?b+360:b%360;m.animating=0;k.roundabout_setBearing(b);}});return this;};jQuery.fn.roundabout_animateToDelta=function(c){var a=arguments[1],b=arguments[2];this.each(function(d){c=jQuery.roundabout_getBearing(jQuery(this))+jQuery.roundabout_toFloat(c);jQuery(this).roundabout_animateToBearing(c,a,b);});return this;};jQuery.fn.roundabout_animateToChild=function(a){var b=arguments[1],c=arguments[2];this.each(function(d){var e=jQuery(this),f=e.data("roundabout");if(f.childInFocus!==a&&f.animating===0){var g=jQuery(e.children(f.childSelector)[a]);e.roundabout_animateAngleToFocus(g.data("roundabout").degrees,b,c);}});return this;};jQuery.fn.roundabout_animateToNearbyChild=function(a,c){var b=a[0],d=a[1];this.each(function(k){var m=jQuery(this).data("roundabout");var h=jQuery.roundabout_toFloat(360-jQuery.roundabout_getBearing(jQuery(this)));var n=m.period,g=0,f;var e=m.reflect;var l=jQuery(this).children(m.childSelector).length;h=(e===true)?h%360:h;if(m.animating===0){if((e===false&&c==="next")||(e===true&&c!=="next")){h=(h===0)?360:h;while(true&&g<l){f={lower:jQuery.roundabout_toFloat(n*g),upper:jQuery.roundabout_toFloat(n*(g+1))};f.upper=(g==l-1)?360:f.upper;if(h<=f.upper&&h>f.lower){jQuery(this).roundabout_animateToDelta(h-f.lower,b,d);break;}g++;}}else{while(true){f={lower:jQuery.roundabout_toFloat(n*g),upper:jQuery.roundabout_toFloat(n*(g+1))};f.upper=(g==l-1)?360:f.upper;if(h>=f.lower&&h<f.upper){jQuery(this).roundabout_animateToDelta(h-f.upper,b,d);break;}g++;}}}});return this;};jQuery.fn.roundabout_animateToNextChild=function(){return this.roundabout_animateToNearbyChild(arguments,"next");};jQuery.fn.roundabout_animateToPreviousChild=function(){return this.roundabout_animateToNearbyChild(arguments,"previous");};jQuery.fn.roundabout_animateAngleToFocus=function(b){var a=arguments[1],c=arguments[2];this.each(function(d){var e=jQuery.roundabout_getBearing(jQuery(this))-b;e=(Math.abs(360-e)<Math.abs(0-e))?360-e:0-e;e=(e>180)?-(360-e):e;if(e!==0){jQuery(this).roundabout_animateToDelta(e,a,c);}});return this;};jQuery.fn.roundabout_updateChildPositions=function(){this.each(function(a){var b=jQuery(this),c=b.data("roundabout");var e=-1;var d={bearing:jQuery.roundabout_getBearing(b),tilt:c.tilt,stage:{width:Math.floor(b.width()*0.9),height:Math.floor(b.height()*0.9)},animating:c.animating,inFocus:c.childInFocus,focusBearingRad:jQuery.roundabout_degToRad(c.focusBearing),shape:jQuery.roundabout_shape[c.shape]||jQuery.roundabout_shape[jQuery.roundabout_shape.def]};d.midStage={width:d.stage.width/2,height:d.stage.height/2};d.nudge={width:d.midStage.width+d.stage.width*0.05,height:d.midStage.height+d.stage.height*0.05};d.zValues={min:c.minZ,max:c.maxZ,diff:c.maxZ-c.minZ};d.opacity={min:c.minOpacity,max:c.maxOpacity,diff:c.maxOpacity-c.minOpacity};d.scale={min:c.minScale,max:c.maxScale,diff:c.maxScale-c.minScale};b.children(c.childSelector).each(function(f){if(jQuery.roundabout_updateChildPosition(jQuery(this),b,d,f)&&d.animating===0){e=f;jQuery(this).addClass("roundabout-in-focus");}else{jQuery(this).removeClass("roundabout-in-focus");}});if(e!==d.inFocus){jQuery.roundabout_triggerEvent(b,d.inFocus,"blur");if(e!==-1){jQuery.roundabout_triggerEvent(b,e,"focus");}c.childInFocus=e;}});return this;};jQuery.roundabout_getBearing=function(a){return jQuery.roundabout_toFloat(a.data("roundabout").bearing)%360;};jQuery.roundabout_degToRad=function(a){return(a%360)*Math.PI/180;};jQuery.roundabout_isInFocus=function(a,b){return(jQuery.roundabout_getBearing(a)%360===(b%360));};jQuery.roundabout_triggerEvent=function(b,c,a){return(c<0)?this:jQuery(b.children(b.data("roundabout").childSelector)[c]).trigger(a);};jQuery.roundabout_toFloat=function(a){a=Math.round(parseFloat(a)*1000)/1000;return parseFloat(a.toFixed(2));};jQuery.roundabout_updateChildPosition=function(c,a,d,b){var e=jQuery(c),g=e.data("roundabout"),f=[];var i=jQuery.roundabout_degToRad((360-e.data("roundabout").degrees)+d.bearing);while(i<0){i=i+Math.PI*2;}while(i>Math.PI*2){i=i-Math.PI*2;}var h=d.shape(i,d.focusBearingRad,d.tilt);h.scale=(h.scale>1)?1:h.scale;h.adjustedScale=(d.scale.min+(d.scale.diff*h.scale)).toFixed(4);h.width=(h.adjustedScale*g.startWidth).toFixed(4);h.height=(h.adjustedScale*g.startHeight).toFixed(4);e.css("left",((h.x*d.midStage.width+d.nudge.width)-h.width/2).toFixed(1)+"px").css("top",((h.y*d.midStage.height+d.nudge.height)-h.height/2).toFixed(1)+"px").css("width",h.width+"px").css("height",h.height+"px").css("opacity",(d.opacity.min+(d.opacity.diff*h.scale)).toFixed(2)).css("z-index",Math.round(d.zValues.min+(d.zValues.diff*h.z))).css("font-size",(h.adjustedScale*g.startFontSize).toFixed(2)+"px").attr("current-scale",h.adjustedScale);if(a.data("roundabout").debug===true){f.push('<div style="font-weight: normal; font-size: 10px; padding: 2px; width: '+e.css("width")+'; background-color: #ffc;">');f.push('<strong style="font-size: 12px; white-space: nowrap;">Child '+b+"</strong><br />");f.push("<strong>left:</strong> "+e.css("left")+"<br /><strong>top:</strong> "+e.css("top")+"<br />");f.push("<strong>width:</strong> "+e.css("width")+"<br /><strong>opacity:</strong> "+e.css("opacity")+"<br />");f.push("<strong>z-index:</strong> "+e.css("z-index")+"<br /><strong>font-size:</strong> "+e.css("font-size")+"<br />");f.push("<strong>scale:</strong> "+e.attr("current-scale"));f.push("</div>");e.html(f.join(""));}return jQuery.roundabout_isInFocus(a,e.data("roundabout").degrees);};jQuery.extend(jQuery.roundabout_shape,{theJuggler:function(d,b,c){return{x:Math.sin(d+b),y:Math.tan(Math.exp(Math.log(d))+b)/(c-1),z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},figure8:function(d,b,c){return{x:Math.sin(d*2+b),y:(Math.sin(d+Math.PI/2+b)/8)*c,z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},waterWheel:function(d,b,c){return{x:(Math.sin(d+Math.PI/2+b)/8)*c,y:Math.sin(d+b)/(Math.PI/2),z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},square:function(d,b,c){var g,f,e;if(d<=Math.PI/2){g=(2/Math.PI)*d;f=-(2/Math.PI)*d+1;e=-(1/Math.PI)*d+1;}else{if(d>Math.PI/2&&d<=Math.PI){g=-(2/Math.PI)*d+2;f=-(2/Math.PI)*d+1;e=-(1/Math.PI)*d+1;}else{if(d>Math.PI&&d<=(3*Math.PI)/2){g=-(2/Math.PI)*d+2;f=(2/Math.PI)*d-3;e=(1/Math.PI)*d-1;}else{g=(2/Math.PI)*d-4;f=(2/Math.PI)*d-3;e=(1/Math.PI)*d-1;}}}return{x:g,y:f*c,z:e,scale:e};},conveyorBeltLeft:function(d,b,c){return{x:-Math.cos(d+b),y:(Math.cos(d+3*Math.PI/2+b)/8)*c,z:(Math.sin(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},conveyorBeltRight:function(d,b,c){return{x:Math.cos(d+b),y:(Math.cos(d+3*Math.PI/2+b)/8)*c,z:(Math.sin(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},goodbyeCruelWorld:function(d,b,c){return{x:Math.sin(d+b),y:(Math.tan(d+3*Math.PI/2+b)/8)*(c+0.5),z:(Math.sin(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},diagonalRingLeft:function(d,b,c){return{x:Math.sin(d+b),y:-Math.cos(d+Math.tan(Math.cos(b)))/(c+1.5),z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},diagonalRingRight:function(d,b,c){return{x:Math.sin(d+b),y:Math.cos(d+Math.tan(Math.cos(b)))/(c+1.5),z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},rollerCoaster:function(d,b,c){return{x:Math.sin(d+b),y:Math.sin((2+c)*d),z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};},tearDrop:function(d,b,c){return{x:Math.sin(d+b),y:-Math.sin(d/2+c)+0.35,z:(Math.cos(d+b)+1)/2,scale:(Math.sin(d+Math.PI/2+b)/2)+0.5};}});jQuery.fn.extend({everyTime:function(a,b,c,d){return this.each(function(){jQuery.timer.add(this,a,b,c,d);});},oneTime:function(a,b,c){return this.each(function(){jQuery.timer.add(this,a,b,c,1);});},stopTime:function(a,b){return this.each(function(){jQuery.timer.remove(this,a,b);});}});jQuery.extend({timer:{global:[],guid:1,dataKey:"jQuery.timer",regex:/^([0-9]+(?:\.[0-9]*)?)\s*(.*s)?$/,powers:{ms:1,cs:10,ds:100,s:1000,das:10000,hs:100000,ks:1000000},timeParse:function(c){if(c==undefined||c==null){return null;}var a=this.regex.exec(jQuery.trim(c.toString()));if(a[2]){var b=parseFloat(a[1]);var d=this.powers[a[2]]||1;return b*d;}else{return c;}},add:function(d,b,c,f,h){var a=0;if(jQuery.isFunction(c)){if(!h){h=f;}f=c;c=b;}b=jQuery.timer.timeParse(b);if(typeof b!="number"||isNaN(b)||b<0){return;}if(typeof h!="number"||isNaN(h)||h<0){h=0;}h=h||0;var g=jQuery.data(d,this.dataKey)||jQuery.data(d,this.dataKey,{});if(!g[c]){g[c]={};}f.timerID=f.timerID||this.guid++;var e=function(){if((++a>h&&h!==0)||f.call(d,a)===false){jQuery.timer.remove(d,c,f);}};e.timerID=f.timerID;if(!g[c][f.timerID]){g[c][f.timerID]=window.setInterval(e,b);}this.global.push(d);},remove:function(c,b,d){var e=jQuery.data(c,this.dataKey),a;if(e){if(!b){for(b in e){this.remove(c,b,d);}}else{if(e[b]){if(d){if(d.timerID){window.clearInterval(e[b][d.timerID]);delete e[b][d.timerID];}}else{for(var d in e[b]){window.clearInterval(e[b][d]);delete e[b][d];}}for(a in e[b]){break;}if(!a){a=null;delete e[b];}}}for(a in e){break;}if(!a){jQuery.removeData(c,this.dataKey);}}}}});jQuery(window).bind("unload",function(){jQuery.each(jQuery.timer.global,function(a,b){jQuery.timer.remove(b);});});
