(function(a){var b=null;a.fn.fadehomepage=function(c){return this.each(function(){a.fadehomepage(this,c);});};a.fadehomepage=function(d,h){var e={speed:"normal",type:"sequence",timeout:10000};if(h){a.extend(e,h);}var f=a(d).children();if(f.length>1){a(d).css("position","relative");var g='<div id="buttonWrapper">';for(var j=0;j<f.length;j++){a(f[j]).css("z-index",String(f.length-j)).css("position","absolute").hide();}if(e.type=="sequence"){b=setTimeout(function(){a.fadehomepage.next(f,e,1,0);},e.timeout);a(f[0]).show();g+='<ul class="buttons">';for(var j=0;j<f.length;j++){g+='<li id="button'+(j+1)+'"><a href="#" title="">'+(j+1)+"</a></li>";}g+="</ul>";}else{if(e.type=="random"){var c=Math.floor(Math.random()*(f.length));b=setTimeout(function(){do{current=Math.floor(Math.random()*(f.length));}while(c==current);a.fadehomepage.next(f,e,current,c);},e.timeout);a(f[c]).show();}else{alert("Type must either be 'sequence' or 'random'");}}g+='<a id="slidesPausePlay"><img class="slidesPause" src="slide/SlidesPl.png" /></a></div>';a(d).before(g);a("li#button1").addClass("active");a("ul.buttons li.active a").css("background-position","-20px 0px").animate({backgroundPosition:"0px 0px"},e.timeout,"linear");a("ul.buttons li").each(function(i){a(this).bind("click",function(){a.fadehomepage.buttonClick(f,e,i);});});a("a#slidesPausePlay").bind("click",function(){a.fadehomepage.togglePlay(f,e);});}};a.fadehomepage.next=function(e,d,c,f){a(e[f]).fadeOut(d.speed);a(e[c]).fadeIn(d.speed);if(d.type=="sequence"){a("ul.buttons li.active a").stop().css("background-position","-20px 0px");a("ul.buttons li").removeClass("active");a("li#button"+(c+1)).addClass("active");if((c+1)<e.length){c=c+1;f=c-1;}else{c=0;f=e.length-1;}}else{if(d.type=="random"){f=c;while(c==f){c=Math.floor(Math.random()*e.length);}}else{alert("Type must either be 'sequence' or 'random'");}}if(a("a#slidesPausePlay img").attr("class")=="slidesPause"){a("ul.buttons li.active a").css("background-position","-20px 0px").animate({backgroundPosition:"0px 0px"},d.timeout,"linear");b=setTimeout((function(){a.fadehomepage.next(e,d,c,f);}),d.timeout);}};a.fadehomepage.buttonClick=function(e,d,c){clearTimeout(b);var f=getCurrentSlideElement(e);a.fadehomepage.next(e,d,c,f);};a.fadehomepage.togglePlay=function(e,d){var f=a("a#slidesPausePlay img");if(f.attr("class")=="slidesPause"){clearTimeout(b);f.removeClass("slidesPause");f.addClass("slidesPlay");a("ul.buttons li.active a").stop().css("background-position","-20px 0px");}else{f.removeClass("slidesPlay");f.addClass("slidesPause");var g;var c=getCurrentSlideElement(e);if(d.type=="sequence"){if((c+1)<e.length){c=c+1;g=c-1;}else{c=0;g=e.length-1;}a("ul.buttons li.active a").css("background-position","-20px 0px").animate({backgroundPosition:"0px 0px"},d.timeout/2,"linear");b=setTimeout(function(){a.fadehomepage.next(e,d,c,g);},d.timeout/2);}else{if(d.type=="random"){g=c;b=setTimeout(function(){do{c=Math.floor(Math.random()*(e.length));}while(g==c);a.fadehomepage.next(e,d,c,g);},d.timeout/2);}else{alert("Type must either be 'sequence' or 'random'");}}}};})(jQuery);function getCurrentSlideElement(a){for(var b=0;b<a.length;b++){if($(a[b]).is(":visible")){return b;}}return 0;}
