/**
 * Event handlers and functions specific for the 'Switcher' module
 * @author Andres Pagella <andres@minorstudios.com>
 */

 var Switcher;Switcher||(Switcher={});if(!Switcher.run)Switcher.run={};if(!Switcher.loop)Switcher.loop={};var anmtSpeed="medium",trnstSpeed=6500,currentSlide=1,play=true,arrMyContent=[];Switcher.load=function(){$("#switcher .display").html("");if(document.images)for(var a=0;a<arrMyContent.length;a++){_img=new Image(615,315);_img.src=arrMyContent[a][0]}$.getJSON("getSwitcherContent",function(b){for(var c=0;c<b.length;c++)arrMyContent.push(new Array(b[c].imageUrl,b[c].url));Switcher.run.prop3();Switcher.run()})};
 Switcher.loop=function(){setInterval(function(){play&&Switcher.run.next()},trnstSpeed)};Switcher.loop.switchOnOff=function(){if(play){$("#playButton").val("Play");play=false}else{$("#playButton").val("Stop");play=true}};Switcher.run=function(){$(".controls").removeClass("dn");$("#transitionControl").removeClass("dn");Switcher.loop()};
 Switcher.run.next=function(){if(currentSlide<arrMyContent.length)$("#img"+currentSlide).fadeOut(anmtSpeed);else for(var a=0;a<arrMyContent.length;a++)$("#img"+a).fadeIn(anmtSpeed);currentSlide=currentSlide<arrMyContent.length?currentSlide+1:1};Switcher.run.prev=function(){if(currentSlide>1)$("#img"+(currentSlide-1)).fadeIn(anmtSpeed);else for(var a=0;a<arrMyContent.length;a++)$("#img"+a).fadeOut(anmtSpeed);currentSlide=currentSlide>1?currentSlide-1:arrMyContent.length};
 Switcher.run.prop3=function(){$("#switcher .display").html("");for(var a="",b=0;b<arrMyContent.length;b++){a='<div class="image" id="img'+(b+1)+'" style="left: 0px; position: absolute; z-index: '+(10-b)+'">\t<a href="'+arrMyContent[b][1]+'">\t\t<img src="'+arrMyContent[b][0]+'" alt="" />\t</a>';$("#switcher .display").append(a)}};
 $(document).ready(function(){Switcher.load();currentSlide=1;$("#switcher .next").click(function(){Switcher.run.next()});$("#switcher .prev").click(function(){Switcher.run.prev()});$("#switcher .next").mouseover(function(){$(this).attr("src","/atmosphir/r/i/switcher/slideshow_arrow_right_hover.png")});$("#switcher .prev").mouseover(function(){$(this).attr("src","/atmosphir/r/i/switcher/slideshow_arrow_left_hover.png")});$("#switcher .next").mouseout(function(){$(this).attr("src","/atmosphir/r/i/switcher/slideshow_arrow_right.png")});
 $("#switcher .prev").mouseout(function(){$(this).attr("src","/atmosphir/r/i/switcher/slideshow_arrow_left.png")})});