var $j=jQuery.noConflict(),rotatorSettings=[];function changeImage(d){var a="#"+d,c=$j(a+" img.active"),b;if(c.length==0){c=$j(a+" img:last")}if($j(c).next("img").length){b=$j(c).next("img")}else{b=$j(a+" img:first");rotatorSettings[d]["cyclecount"]+=1;debug(a+" completed cycle #"+rotatorSettings[d]["cyclecount"]+" of "+rotatorSettings[d]["cycles"]);if(rotatorSettings[d]["cycles"]>0&&rotatorSettings[d]["cycles"]==rotatorSettings[d]["cyclecount"]){clearInterval(rotatorSettings[d]["intervalid"]);debug(a+" stopped after "+rotatorSettings[d]["cyclecount"]+" cycles");return}}$j(b).addClass("next").fadeTo(rotatorSettings[d]["transition"],1,function(){$j(this).addClass("active")});$j(c).removeClass("next").fadeTo(rotatorSettings[d]["transition"],0,function(){$j(this).removeClass("active")})}jQuery(document).ready(function(h){var j,p=$j("div.simplerotator"),f=p.size(),c,b,m,o,n,e,d,a,l,k,g;for(j=0;j<f;j++){c=$j(p[j]).attr("id");b=$j("#"+c+" img.active").attr("src");debug("#"+c+": src was    "+b);$j("#"+c+" img.active").attr("src","#");debug("#"+c+": src is now "+$j("#"+c+" img.active").attr("src"));$j("#"+c+" img.first").load(function(){m=$j(this).parents("div.simplerotator")[0];o=$j(m).attr("id");debug("#"+o+": running img.load() event");if(rotatorSettings[o]["fullscreen"]){debug("#"+o+": initialising full screen rotator with offsets = T:"+rotatorSettings[o]["topoffset"]+" R:"+rotatorSettings[o]["rightoffset"]+" B:"+rotatorSettings[o]["bottomoffset"]+" L:"+rotatorSettings[o]["leftoffset"]+", losingside = "+rotatorSettings[o]["losingside"]+" and ensurefullscreen = "+rotatorSettings[o]["ensurefullscreen"]);$j("#"+o).css({position:"fixed",left:rotatorSettings[o]["leftoffset"],top:rotatorSettings[o]["topoffset"],"z-index":"-1"});n=$j(this);e=n.width()/n.height();function i(){switch(rotatorSettings[o]["losingside"]){case"bottom":rotatorSettings[o]["bottomoffset"]=0;break;case"right":rotatorSettings[o]["rightoffset"]=0;break}d=$j(window).width()-rotatorSettings[o]["leftoffset"]-rotatorSettings[o]["rightoffset"];a=$j(window).height()-rotatorSettings[o]["topoffset"]-rotatorSettings[o]["bottomoffset"];switch(rotatorSettings[o]["losingside"]){case"bottom":l=d;k=l/e;if(rotatorSettings[o]["ensurefullscreen"]&&k<a){debug("#"+o+": White space detected between the bottom of the image and the bottom of the browser window -> increasing image height (potentially chopping off the right hand side of the image)");k=a;l=k*e}break;case"right":k=a;l=k*e;if(rotatorSettings[o]["ensurefullscreen"]&&l<d){debug("#"+o+": White space detected between the right hand side of the image and the right hand side of the browser window -> increasing image width (potentially chopping off the bottom side of the image)");l=d;k=l/e}break}debug("#"+o+": browser window dimensions: "+$j(window).width()+" x "+$j(window).height());debug("#"+o+": adjusted window dimensions: "+d+" x "+a);debug("#"+o+": imgHeight:"+k+", windowHeight:"+a);$j("#"+o+" img").width(l).height(k)}i();h(window).resize(i)}$j(m).css("height",$j(this).outerHeight(true)).css("width",$j(this).outerWidth(true));$j("#"+o+" img").removeClass("hidden first")});$j("#"+c+" img.active").attr("src",b);debug("#"+c+": src is now "+$j("#"+c+" img.active").attr("src"));if(rotatorSettings[c]["totalnumimages"]==1){return}g=rotatorSettings[c]["startdelay"]-rotatorSettings[c]["interval"];if(g>0){setTimeout("setupRotator('"+c+"')",g);debug("#"+c+": delaying the setup of this rotator for "+g+"ms")}else{setupRotator(c)}}});function setupRotator(a){debug("#"+a+": set up rotator to run every "+rotatorSettings[a]["interval"]+"ms");rotatorSettings[a]["intervalid"]=setInterval("changeImage('"+a+"')",rotatorSettings[a]["interval"]);rotatorSettings[a]["cyclecount"]=0}function debug(a){if(window.console){console.log(a)}};