$(function(){homepageBannerManager.load(),homepageRandomAdImageManager.load()});var homepageRandomAdImageManager=function(){return{load:function(){function n(n,t,i,r){var s=!1,o,f;if(homepageRandomAdImageData&&n&&n.length>0&&(s=!0),s){var e=[],h=0,c=0;$.each(n,function(){c=this.weight;for(var t=0;t<c;t++)e[e.length]=n[h];h++});var a=Math.floor(Math.random()*e.length),u=e[a],l="";u.bannerType==0&&(l+="onclick=\"ga('send', 'event', '"+u.category+"', '"+u.action+"', '"+u.label+"', "+u.value+');"'),o="",u.bannerTarget==1&&(o+='target="_blank"'),f="",u.uri&&u.uri!=""&&(f+='<a href="'+u.uri+'" title="'+u.title+'"'+l+" "+o+">"),f+='<img alt="'+u.title+'" src="http://cdn.atgmedia.com/bidspotter-com/website/marketing/banners/images/'+u.image+'" width="'+r+'" height="'+i+'" />',u.uri&&u.uri!=""&&(f+="</a>"),$("#randomAdImage"+t).html(f),ga("send","event",u.category,"impression",u.label,0)}}n(homepageRandomAdImageData.bannerPositionOne,1,208,194),n(homepageRandomAdImageData.bannerPositionTwo,2,208,194),n(homepageRandomAdImageData.bannerPositionThree,3,208,194),n(homepageRandomAdImageData.bannerPositionFour,4,208,194)}}}(),homepageBannerManager=function(){return{currentIndex:0,bannerInterval:null,animationTimer:null,currentlyAnimating:!1,load:function(){var t=!1,n;(homepageBannerData&&homepageBannerData.banners&&homepageBannerData.banners.length>0&&(t=!0),t)&&(this.currentIndex=loadingOrder==RandomLoadOptions.Default||homepageBannerData.banners.length==1?0:this.randomIndex(),n=this,$.each(homepageBannerData.banners,function(t,i){var f="",u,e,r,o,s;i.bannerType==0&&(f+="onclick=\"ga('send', 'event', '"+i.category+"', '"+i.action+"', '"+i.label+"', "+i.value+');"'),u="",i.bannerTarget==1&&(u+='target="_blank"'),t==n.currentIndex&&ga("send","event",i.category,"impression",i.label,0),e=t==n.currentIndex?"banner currentBanner":"banner hide",r='<li id="banner'+t+'" title="'+i.title+'" class="'+e+'">',i.uri&&i.uri!=""&&(r+='<a href="'+i.uri+'" title="'+i.title+'"'+f+" "+u+">"),r+='<span class="mainImage" alt="'+i.title+'" style="background-image: url(http://cdn.atgmedia.com/bidspotter-com/website/marketing/banners/images/'+i.image+')" />',i.uri&&i.uri!=""&&(r+="</a>"),r+="</li>",$("#bannerList").append(r),o=t==n.currentIndex?"dot active":"dot",s='<li id="bannerDot'+t+'" class="'+o+'"></li>',$("#bannerLocation").append(s)}),homepageBannerData.banners.length>1&&(this.startAnimationCountdown(this.currentIndex),$("#bannerLocation, #bannerNav .bannerLeft, #bannerNav .bannerRight").removeClass("hide")))},startAnimationCountdown:function(){var t=homepageBannerData.banners[this.currentIndex].displayFor?homepageBannerData.banners[this.currentIndex].displayFor:homepageBannerData.displayFor;this.animationTimer=setTimeout("homepageBannerManager.animate()",t)},animate:function(n){var t,i;if(this.currentlyAnimating!=!0){if(this.currentlyAnimating=!0,clearTimeout(this.animationTimer),t=0,loadingOrder==RandomLoadOptions.RandomAll&&n==null)t=this.randomIndex();else{i=10;switch(n){case"prev":t=this.currentIndex!=0?this.currentIndex-1:homepageBannerData.banners.length-1;break;case"next":t=this.currentIndex!=homepageBannerData.banners.length-1?this.currentIndex+1:0;break;default:t=this.currentIndex!=homepageBannerData.banners.length-1?this.currentIndex+1:0,i=homepageBannerData.transitionFor}}var r=$("#banner"+this.currentIndex),u=$("#banner"+t),f=$("#bannerDot"+this.currentIndex),e=$("#bannerDot"+t);f.removeClass("active"),e.addClass("active"),r.animate({opacity:0},i,function(){r.addClass("hide"),r.removeClass("currentBanner")}),u.css({opacity:0}).removeClass("hide").addClass("currentBanner").animate({opacity:1},i,function(){homepageBannerManager.currentlyAnimating=!1}),this.currentIndex=t,this.startAnimationCountdown(this.currentIndex)}},randomIndex:function(){return rand=0,homepageBannerData.banners.length>1&&(rand=Math.floor(Math.random()*homepageBannerData.banners.length)),rand}}}()