function rand(n){return(Math.floor(Math.random()*n+1));}
jQuery(document).ready(function($){$('.promo_slider img').removeAttr('title');var sliders=$('.promo_slider_wrapper');$.each(sliders,function(){var currentSlider=$(this);var thisSlider=$('.promo_slider',currentSlider);var panels=$('.panel',thisSlider);var panelCount=panels.length;var initialPanel;if(promoslider_options.startOn=='first'){initialPanel=1;}else{initialPanel=rand(panelCount);}
if(currentSlider.hasClass('random'))initialPanel=rand(panelCount);if(currentSlider.hasClass('first'))initialPanel=1;var pauseOnMouseover=currentSlider.hasClass('pause');var sliderInterval;var timeDelay=promoslider_options.timeDelay;if($('.promo_slider_time_delay',thisSlider).html()){timeDelay=$('.promo_slider_time_delay',thisSlider).html();}
var autoAdvance=promoslider_options.autoAdvance;if(thisSlider.hasClass('auto_advance'))autoAdvance=true;if(thisSlider.hasClass('no_auto_advance'))autoAdvance=false;if(panelCount<2)autoAdvance=false;var navOption=promoslider_options.nav_option;if(currentSlider.hasClass('default_nav'))navOption='default';else if(currentSlider.hasClass('fancy_nav'))navOption='fancy';else if(currentSlider.hasClass('links_nav'))navOption='links';else if(currentSlider.hasClass('thumb_nav'))navOption='thumb';else if(currentSlider.hasClass('tabbed_nav'))navOption='tabbed';else navOption=false;panels.hide();$('.panel-'+initialPanel,currentSlider).show().addClass('current');if(panelCount>1&&(navOption=='default'||navOption=='fancy'||navOption=='thumb'||navOption=='tabbed')){var navHTML;if('tabbed'!=navOption){$('.promo_slider_nav').not('.tabbed_ps_nav').show();}
$('.promo_slider_thumb_nav').show();if(navOption=='tabbed'){navHTML='';$.each(panels,function(index,object){var panelTitle=$('.panel-'+(index+1)+' span.panel-title',currentSlider).html();var newSpan=''+panelTitle+'';navHTML=navHTML+newSpan;});$('.slider_selections',currentSlider).html(navHTML);}
if(navOption=='fancy'||navOption=='default'){navHTML='';$.each(panels,function(index,object){panelTitle=$('.panel-'+(index+1)+' span.panel-title',currentSlider).html();newSpan=''+(index+1)+'';if((index+1)!=panelCount){newSpan=newSpan+' | ';}
navHTML=navHTML+newSpan;});$('.slider_selections',currentSlider).html(navHTML);}
var slideNav=$('.slider_selections span',currentSlider);$.each(slideNav,function(index,object){$(object).click(function(){clearInterval(sliderInterval);if(!$(object).hasClass('current'))progress($(object).attr('class'),currentSlider,panelCount);if(autoAdvance)sliderInterval=setInterval(function(){progress('forward',currentSlider,panelCount);},(timeDelay*1000));});});$('.slider_selections span[class='+initialPanel+']',currentSlider).addClass('current');}
$('.move_forward',currentSlider).click(function(){clearInterval(sliderInterval);progress('forward',currentSlider,panelCount);if(autoAdvance)sliderInterval=setInterval(function(){progress('forward',currentSlider,panelCount);},(timeDelay*1000));});$('.move_backward',currentSlider).click(function(){clearInterval(sliderInterval);progress('backward',currentSlider,panelCount);if(autoAdvance)sliderInterval=setInterval(function(){progress('forward',currentSlider,panelCount);},(timeDelay*1000));});if(autoAdvance){sliderInterval=setInterval(function(){progress('forward',currentSlider,panelCount);},(timeDelay*1000));if(pauseOnMouseover){$(thisSlider).mouseover(function(){clearInterval(sliderInterval);});$(thisSlider).mouseout(function(){sliderInterval=setInterval(function(){progress('forward',currentSlider,panelCount);},(timeDelay*1000));});}}});function progress(value,currentSlider,panelCount){var currentValue=$('div.promo_slider > .panel',currentSlider).index($('div.panel.current',currentSlider))+1;var panels=$('.panel',currentSlider);var current=$('.panel.current',currentSlider);panels.stop(true,true);var panelNum;if(value=='forward'){panelNum=current.is(panels.last())?1:currentValue+1;}else if(value=='backward'){panelNum=current.is(panels.first())?panels.length:currentValue-1;}else{panelNum=value;}
var next=$('.panel-'+panelNum,currentSlider);var currentSpan=$('.slider_selections span.current',currentSlider);var newSpan=$('.slider_selections span.'+panelNum,currentSlider);current.removeClass('current');next.addClass('current');currentSpan.removeClass('current');newSpan.addClass('current');next.hide().css({'z-index':1});current.css({'z-index':0});next.fadeIn(1200,'swing',function(){current.hide();});}});