var wSwitcherInputBreak=1;var wSwitcherData=new Array();function sSwitcherUpdate(switcher,action){var sD=wSwitcherData[switcher];if(sD['info']['timeout']!=undefined){clearTimeout(sD['info']['timeout']);}$("#"+switcher+" .sActive").animate(sD['info']['out']['properties'],sD['info']['out']['duration'],sD['info']['out']['easing'],function(){var next=sD['info']['current'];if(action=='auto'||action=='next'){next+=1;if(next>=sD['data'].length){next=0;}}else if(action=='prev'){next-=1;if(next<0)next=sD['data'].length-1;}else{next=action;if(sD['data'][next]==undefined)next=0;}$("#"+switcher+" .sLink").attr("href",sD['data'][next]['link']);$("#"+switcher+" .sImage").attr("src",sD['info']['folder']+sD['data'][next]['image']);$("#"+switcher+" .sText").html(sD['data'][next]['text']);wSwitcherData[switcher]['info']['current']=next;$('#'+switcher+' .sControl .number').removeClass('active');$('#'+switcher+' .sControl .number.n'+(next+1)).addClass('active');$("#"+switcher+" .sActive").animate(sD['info']['in']['properties'],sD['info']['in']['duration'],sD['info']['in']['easing'],function(){if(!wSwitcherInputBreak||action=='auto'){wSwitcherData[switcher]['info']['timeout']=setTimeout("sSwitcherUpdate('"+switcher+"', 'auto')",sD['info']['interval']);}});});}$(document).ready(function(){$(".wSwitcher").each(function(){var switcher=$(this).attr('id');$.getJSON('switches.php','switcher='+switcher,function(data){if(data['info']==undefined)return;var preload=new Array();for(var i=0;i<data['data'].length;i++){if(data['data'][i]['image']!=''){preload[i]=new Image();preload[i].src=data['info']['folder']+data['data'][i]['image'];}}var number=$('#'+switcher+' .sControl .number:first'),numberHtml=number.html();number.html('');if(number.length){var i;for(i=data['data'].length;i>0;--i){number.clone().insertAfter(number).addClass('n'+i);$('#'+switcher+' .sControl .number.n'+i).html(numberHtml.replace('XY',i));$('#'+switcher+' .sControl .number.n'+i).click(function(){var r=new RegExp(/ n(\d+)/),m=r.exec($(this).attr("class")),n=parseInt(m[1])-1;sSwitcherUpdate(switcher,n);});}number.remove();}$('#'+switcher+' .sControl .prev').click(function(){sSwitcherUpdate(switcher,'prev');});$('#'+switcher+' .sControl .next').click(function(){sSwitcherUpdate(switcher,'next');});$('#'+switcher+' .sActive').hide();$('#'+switcher).show();wSwitcherData[switcher]=data;wSwitcherData[switcher]['info']['current']=-1;sSwitcherUpdate(switcher,'auto');});});});
