(function(a){a.anythingSlider=function(c,b){var d=this;d.$el=a(c).addClass("anythingBase").wrap('<div class="anythingSlider"><div class="anythingWindow" /></div>');d.$el.data("AnythingSlider",d);d.init=function(){if(d.$el.closest("ul.anythingBase").attr("id")=="HomeSlider"){autoplay=true}else{autoplay=false}d.options=a.extend({},a.anythingSlider.defaults,b);d.$wrapper=d.$el.parent().closest("div.anythingSlider");d.$window=d.$el.closest("div.anythingWindow");d.$items=d.$el.find("> li").addClass("panel");d.$objects=d.$items.find("object");d.$dimensions=[];d.currentPage=d.options.startPanel;d.timer=null;d.playing=false;d.pages=d.$items.length;d.$objlen=!!d.$objects.length;d.runTimes=a("div.anythingSlider").index(d.$wrapper)+1;if(!a.isFunction(a.easing[d.options.easing])){d.options.easing="swing"}if(d.options.resizeContents){if(d.options.width){d.$wrapper.css("width",d.options.width);d.$items.css("width",d.options.width)}if(d.options.height){d.$wrapper.css("height",d.options.height);d.$items.css("height",d.options.height)}if(d.$objlen){d.$objects.find("embed").andSelf().css({width:"100%",height:"100%"})}}d.$objects.each(function(){if(a(this).find("[src*=youtube]").length){a(this).parent().wrap('<div id="yt-temp"></div>').find("embed[src*=youtube]").attr("src",function(f,g){return g+"&enablejsapi=1&version=3"}).end().find("param[value*=youtube]").attr("value",function(g,f){return f+"&enablejsapi=1&version=3"}).end().detach().appendTo(a("#yt-temp")).unwrap()}});if(d.pages===1){d.options.autoPlay=false;d.options.buildNavigation=false;d.options.buildArrows=false}if(d.options.autoPlay){d.playing=!d.options.startStopped;d.buildAutoPlay()}d.buildNavigation();var e=d.$items.filter(":last").clone().addClass("cloned");d.$items.filter(":first").before(e.attr("id",function(f,g){return(g==="")?"":g+"-cloned"}));e=d.$items.filter(":first").clone().addClass("cloned");d.$items.filter(":last").after(e.attr("id",function(f,g){return(g==="")?"":g+"-cloned"}));d.$items=d.$el.find("> li");d.setDimensions();if(!d.options.resizeContents){a(window).load(function(){d.setDimensions()})}if(d.options.buildArrows){d.buildNextBackButtons()}if(d.options.pauseOnHover){d.$wrapper.hover(function(){d.clearTimer()},function(){d.startStop(d.playing)})}if((d.options.hashTags===true&&!d.gotoHash())||d.options.hashTags===false){d.setCurrentPage(d.options.startPanel,false)}d.$items.find("a").focus(function(){d.$items.find(".focusedLink").removeClass("focusedLink");a(this).addClass("focusedLink");d.$items.each(function(f){if(a(this).find("a.focusedLink").length){d.gotoPage(f);return false}})});a(window).keyup(function(f){if(d.$wrapper.is(".activeSlider")){switch(f.which){case 39:d.goForward();break;case 37:d.goBack();break}}})};d.buildNavigation=function(){d.$nav=a('<ul class="thumbNav" style="display:none" />').appendTo(d.$wrapper);if(d.options.playRtl){d.$wrapper.addClass("rtl")}if(d.options.buildNavigation&&(d.pages>1)){d.$items.each(function(f,g){var e=f+1,h=a("<a href='#'>&nbsp;&nbsp;</a>");if(typeof(d.options.navigationFormatter)=="function"){h.html(d.options.navigationFormatter(e,a(this)))}else{}h.bind("click focusin",function(i){d.gotoPage(e);if(d.options.hashTags){d.setHash("panel"+d.runTimes+"-"+e)}i.preventDefault()});a(d.$nav).append(h);h.wrap("<li />")})}};d.buildNextBackButtons=function(){var e=a('<span class="arrow forward"><a href="#">'+d.options.forwardText+'</a></span><div class="arrow forward FloatRight" style="margin-left: 392px;  width: 80px ! important;" id="opinancount"></div>'),g=a('<span class="arrow back"><a href="#">'+d.options.backText+"</a></span>");if(document.getElementById("opinan1")){var f=document.getElementById("opinan1").innerHTML;a("#opinancount").html(f)}g.click(function(h){d.goBack();h.preventDefault()});e.click(function(h){d.goForward();h.preventDefault()});g.add(e).find("a").bind("focusin focusout",function(){a(this).toggleClass("hover")});d.$wrapper.prepend(e).prepend(g)};d.buildAutoPlay=function(){d.$startStop=a("<a href='#' class='start-stop' style='display:none'></a>").html(d.playing?d.options.stopText:d.options.startText);d.$wrapper.append(d.$startStop);d.$startStop.click(function(f){d.startStop(!d.playing);if(d.playing){if(d.options.playRtl){d.goBack(true)}else{d.goForward(true)}}f.preventDefault()}).bind("focusin focusout",function(){a(this).toggleClass("hover")});d.startStop(d.playing)};d.setDimensions=function(){var g,k,m,f,i,l=0,e=d.$window.width(),j=a(window).width();d.$items.each(function(h){m=a(this).children("*");if(d.options.resizeContents){g=parseInt(d.options.width,10)||e;k=parseInt(d.options.height,10)||d.$window.height();a(this).css({width:g,height:k});if(m.length==1){m.css({width:g,height:k})}}else{g=a(this).width();i=(g>=j)?true:false;if(m.length==1&&i){f=(m.width()>=j)?e:m.width();a(this).css("width",f);m.css("max-width",f);g=f}g=(i)?d.options.width||e:g;a(this).css("width",g);k=a(this).outerHeight();a(this).css("height",k)}d.$dimensions[h]=[g,k,l];l+=g});d.$el.css("width",(l<d.options.maxOverallWidth)?l:d.options.maxOverallWidth)};d.gotoPage=function(g,f){if(d.$el.closest("ul.anythingBase").attr("id")=="HomeSlider"){f=true}else{f=false}if(typeof(g)==="undefined"||g===null){g=d.options.startPage;d.setCurrentPage(d.options.startPage)}if(g>d.pages+1){g=d.pages}if(g<0){g=1}var h=g;if(h>d.pages){h=1}if(document.getElementById("opinan"+h)){var e=document.getElementById("opinan"+h).innerHTML;a("#opinancount").html(e)}if(f!==true){f=false}if(!f||(d.options.stopAtEnd&&g==d.pages)){d.startStop(false)}if(d.checkVideo(d.playing)){return}if(!d.options.resizeContents){d.$wrapper.filter(":not(:animated)").animate({width:d.$dimensions[g][0],height:d.$dimensions[g][1]},{queue:false,duration:d.options.animationTime,easing:d.options.easing})}d.$window.filter(":not(:animated)").animate({scrollLeft:d.$dimensions[g][2]},{queue:false,duration:d.options.animationTime,easing:d.options.easing,complete:function(){d.endAnimation(g)}})};d.endAnimation=function(g){if(g===0){d.$window.scrollLeft(d.$dimensions[d.pages][2]);g=d.pages}else{if(g>d.pages){d.$window.scrollLeft(0);g=1}}d.setCurrentPage(g,false);if(d.$objlen){var e=d.$items.eq(d.currentPage).find("embed[src*=youtube]");try{if(e.length&&a.isFunction(e[0].getPlayerState)&&e[0].getPlayerState()>0){e[0].playVideo()}}catch(f){}}};d.setCurrentPage=function(f,e){if(d.options.buildNavigation){d.$nav.find(".cur").removeClass("cur");d.$nav.find("a").eq(f-1).addClass("cur")}if(!e){d.$wrapper.css({width:d.$dimensions[f][0],height:d.$dimensions[f][1]});d.$wrapper.scrollLeft(0);d.$window.scrollLeft(d.$dimensions[f][2])}d.currentPage=f;if(!d.$wrapper.is(".activeSlider")){a(".activeSlider").removeClass("activeSlider");d.$wrapper.addClass("activeSlider")}};d.goForward=function(e){if(d.$el.closest("ul.anythingBase").attr("id")=="HomeSlider"){e=true}else{e=false}if(e!==true){e=false;d.startStop(false)}d.gotoPage(d.currentPage+1,e);d.startStop(e)};d.goBack=function(e){if(d.$el.closest("ul.anythingBase").attr("id")=="HomeSlider"){e=true}else{e=false}if(e!==true){e=false;d.startStop(false)}d.gotoPage(d.currentPage-1,e);d.startStop(e)};d.gotoHash=function(){var h=window.location.hash.match(/^#?panel(\d+)-(\d+)$/);if(h){var f=parseInt(h[1],10);if(f==d.runTimes){var e=parseInt(h[2],10),g=d.$items.filter(":eq("+e+")");if(g.length!==0){d.setCurrentPage(e,false);return true}}}return false};d.setHash=function(e){if(typeof window.location.hash!=="undefined"){if(window.location.hash!==e){window.location.hash=e}}else{if(location.hash!==e){location.hash=e}}return e};d.clearTimer=function(){if(d.timer){window.clearInterval(d.timer)}};d.startStop=function(e){if(e!==true){e=false}d.playing=e;if(d.options.autoPlay){d.$startStop.toggleClass("playing",e).html(e?d.options.stopText:d.options.startText)}if(e){d.clearTimer();d.timer=window.setInterval(function(){if(!d.checkVideo(e)){if(d.options.playRtl){d.goBack(true)}else{d.goForward(true)}}},d.options.delay)}else{d.clearTimer()}};d.checkVideo=function(g){var f,h,e=false;if(d.$objlen){d.$objects.each(function(){f=a(this).find("embed[src*=youtube]");try{if(f.length&&a.isFunction(f[0].getPlayerState)){h=f[0].getPlayerState();if(g&&h==1&&d.$items.index(f.closest("li"))==d.currentPage&&d.options.resumeOnVideoEnd){e=true}else{if(h>0){f[0].pauseVideo()}}}}catch(i){}})}return e};d.init()};a.anythingSlider.defaults={width:null,height:null,resizeContents:true,startPanel:1,hashTags:true,buildArrows:true,buildNavigation:true,navigationFormatter:null,forwardText:"&raquo;",backText:"&laquo;",autoPlay:true,startStopped:false,pauseOnHover:true,resumeOnVideoEnd:true,stopAtEnd:false,playRtl:false,startText:"Start",stopText:"Stop",delay:3000,animationTime:600,easing:"swing",maxOverallWidth:32766};a.fn.anythingSlider=function(b){if((typeof(b)).match("object|undefined")){return this.each(function(c){(new a.anythingSlider(this,b))})}else{if(/\d/.test(b)&&!isNaN(b)){return this.each(function(c){var e=a(this).data("AnythingSlider");if(e){var d=(typeof(b)=="number")?b:parseInt(a.trim(b),10);if(d<1||d>e.pages){return}e.gotoPage(d)}})}}}})(jQuery);
