var slideShowBBY={createSlideShow:function(a,c,b,e,f){var d=new ui.slideshow();d.buildNavigation=slideShowBBY.buildNavigation;d.defaultTransition=slideShowBBY.defaultTransition;d.prepareBubbles=slideShowBBY.prepareBubbles;this.initNavButtons(d.init(a,c,b,e,f));$("#roller").css("opacity",0.5);d.progressBar.resume=slideShowBBY.progressBarResume;d.progressBar.reset=slideShowBBY.progressBarReset;d.progressBar.reset(d.getTimeout());return d},buildNavigation:function(){sh=this;this.isIE6=/MSIE 6/i.test(navigator.userAgent);this.isIPad=/iPad/i.test(navigator.userAgent);this.isIPhone=/iPhone/i.test(navigator.userAgent);if(this.isIE6){$("#"+this.divid).addClass("ie6")}$(this.params.navigation).children().each(function(d){$(this).click(function(){var e=$(this).index();sh.pause();sh.flip(e);return false});if(!sh.isIPad&&!sh.isIPhone){$(this).mouseenter(function(){var e=$(this).index();if(sh.curr.currSlide!=$(this).index()){$(sh.params.navigation+" > li").eq(sh.curr.currSlide).children(".tooltip").hide();$(this).find(".tooltip").show()}});$(this).mouseleave(function(){var e=$(this).index();$(this).find(".tooltip").stop(true,true);if(sh.curr.currSlide!=$(this).index()){$(this).find(".tooltip").hide();$(sh.params.navigation+" > li").eq(sh.curr.currSlide).children(".tooltip").show()}})}});$(this.params.navigation+" > li").eq(0).addClass("hover").children(".tooltip").show();var c=($(sh.params.navigation+" > li").eq(0).position()).left-315;$(".tooltip").css("left",c+"px");$("#homepage-slide ul.slides").css("display","block");var b=$(this.params.navigation+" > li").eq(this.curr.currSlide);var a=b.position();$("#"+this.params.progressBar.id).prependTo(b);$("#"+this.params.progressBar.id).css({left:a.left+4,top:a.top+7})},defaultTransition:function(b,a){sh=this;if($.browser.msie){$("#"+b+" ul.slides").css("left",a*-1)}else{$("#"+this.divid+" ul.slides").fadeOut(sh.params.transitionSpeed/2,function(){$("#"+b+" ul.slides").css("left",a*-1);$("#"+sh.divid+" ul.slides").queue(function(){$(this).fadeIn(sh.params.transitionSpeed/2);$(this).dequeue()})})}var d=$(this.params.navigation+" > li").eq(this.curr.currSlide);var c=d.position();$("#"+this.params.progressBar.id).prependTo(d);$("#"+this.params.progressBar.id).css({left:c.left+4,top:c.top+7});if(this.curr.prevSlide!=this.curr.currSlide){$(this.params.navigation+" > li").eq(this.curr.prevSlide).removeClass("hover").children(".tooltip").hide()}$(this.params.navigation+" > li").eq(this.curr.currSlide).addClass("hover").children(".tooltip").show()},prepareBubbles:function(){sh=this;$("#"+this.divid+" .bubble").each(function(b,c){var e=null,a=$(c);a.wrapInner('<div class="bubbleInsert" />');a.wrapInner('<div class="bubbleContent" />');a.prepend('<div class="indicator"></div>');var d=$(this).find("a");d.each(function(f){f=(d.size()>1)?f+1:"";$(this).click(function(){sh.trackEvent(sh.params.trackingPrefix+sh.params.slideDate+"_S"+(a.parent().index()+1)+"_BubbleLink"+f+"_"+a.attr("id"))})});a.mouseenter(function(){var m=($(this).position()).left,j=($(this).position()).top,g=$("#"+sh.divid).width(),l=$("#"+sh.divid).height(),f=$(".bubbleContent",this),k=f.width(),i=f.height(),h=50;$(".bubble").css("z-index","100");a.css("z-index","200");if((m+k+h)>g){f.css("left",(-1*k)+"px")}if((j+i+h)>l-50){f.css("top",(-1*i)+"px")}f.fadeIn("fast");if(a.attr("id")!=null&&a.attr("id").length>0){sh.trackEvent(sh.params.trackingPrefix+sh.params.slideDate+"_S"+(a.parent().index()+1)+"_BubbleHover_"+a.attr("id"))}else{sh.trackEvent(sh.params.trackingPrefix+sh.params.slideDate+"_S"+(a.parent().index()+1)+"_BubbleHover_"+a.parent().attr("id"))}sh.pause()});a.mouseleave(function(){a.css("z-index","160");$(".bubbleContent",this).hide().css("z-index","100")})})},initNavButtons:function(a){if(a.isIE6){$(".indicator").addClass("ie6")}$("#"+a.params.next.id).click(function(){a.next();return false}).andSelf().mouseover(function(){$(this).children("div").addClass("hoverRight")}).andSelf().mouseout(function(){$(this).children("div").removeClass("hoverRight")});$("#"+a.params.previous.id).click(function(){a.prev();return false}).andSelf().mouseover(function(){$(this).children("div").addClass("hoverLeft")}).andSelf().mouseout(function(){$(this).children("div").removeClass("hoverLeft")});$("#"+a.params.pause.id).click(function(){if(a.curr.paused==true){a.resume();return false}else{a.pause();return false}})},progressBarReset:function(b){var a={width:this.rollerWidth,opacity:0.5};this.stop();this.time=b;$(this.divId+" #roller").css("width","0px");$(this.divId+" #roller").animate(a,this.time,"linear")},progressBarResume:function(b){var a={width:this.rollerWidth,opacity:0.5};$(this.divId+" #roller").animate(a,b,"linear")}};var uiBBY={statusMsg:function(a){$("#globalStatusMsg").clearQueue().stop().html("").css("height","auto").hide().html(a).slideDown().animate({opacity:1},5000,function(){$(this).slideUp()})},accessoriesWidget:function(B,c,t,v,p,d,u,g){var z=$(c),C=$(p),F=(B.substr(0,2)).toUpperCase(),m=false,E=null,x=null,l=g?g:false,n=null,s=null,f=null,h=null,q=null;this.showNumProd=t;var i={alsoAddThisOn:{EN:"Also Add This",FR:"Ajoutez aussi ce produit"},alsoAddThisOff:{EN:"Remove",FR:"Retirer"},showMoreOn:{EN:'Show more <img src="/images/common/pictures/sortdescending.gif" width="12" height="10" />',FR:'Montrez-en plus <img src="/images/common/pictures/sortdescending.gif" width="12" height="10" />'},showMoreOff:{EN:'Hide <img src="/images/common/pictures/sortascending.gif" width="12" height="10" />',FR:'Cacher <img src="/images/common/pictures/sortascending.gif" width="12" height="10" />'},accessories:{EN:"more item(s)<br/>selected",FR:"plus d'article(s)<br/>s&eacute;lectionn&eacute;s"}};this.init=function(){var H=this;for(var G=0;G<u.length;G++){$(c+" "+u[G]).each(function(I,J){o($(J))})}$(c+" "+v).each(function(I,J){y(J)});z.find(".removeAll").click(function(){a()});z.find(".tabLink").each(function(I,J){$(J).bind("click",function(){H.showItemsFromTab(I)})});z.find(d).toggle(function(){H.showMoreProd();$(this).html(e("showMoreOff"))},function(){H.hideMoreProd();$(this).html(e("showMoreOn"))});z.find(".ui-tabcontrol-content").each(function(J,K){var I=$(this).find(v);var L=$(K).find(d);(I.length>H.showNumProd)?L.show():L.hide();I.each(function(N,O){var M=$(O);if(N<H.showNumProd){M.css("display","block").addClass("noBottomBorder")}else{if(N>=H.showNumProd){return false}}if((N+1)%H.showNumProd==0){M.addClass("noBorder");M.after('<div class="clear"></div>')}})});this.showItemsFromTab(0)};var o=function(G){$(G).click(function(){var J=$(this).parentsUntil(v).parent(),I=J.find(".prodImageWrap"),H=J.find(".field-title"),K=J.find(".accessoriesWidgetActionBtn"),L=(H.find("a").attr("href")).match(/((m|M|b|B){1}[0-9]{7}|[0-9]{8})/)[0];if(w(L)==null){b(L);K.html(e("alsoAddThisOff"));I.find(".prodStatus").fadeIn();L=null}else{j(L);I.find(".prodStatus").fadeOut();K.html(e("alsoAddThisOn"));L=null}trackEvent.event("event.link",{lid:"AccessoryWidget_prodSelect"})})};var b=function(G){if(!w(G)){basket.GenericUpdateAccessories(G,true);D()}};var j=function(G){if(w(G)>=0){basket.GenericUpdateAccessories(G,false);D()}};var a=function(){var G=z.find(".prodStatus");basket.Accessories=new Array(1);G.each(function(H,I){$(I).css("display","none")});z.find(".accessoriesWidgetActionBtn").each(function(H,I){$(I).html(e("alsoAddThisOn"))});D()};var w=function(I){var G=null;for(var H=0;H<basket.Accessories.length;H++){if(I==basket.Accessories[H]){G=H;break}}return G};var D=function(){if(basket.Accessories.length>1){C.addClass("active").html('<span class="quantity">+'+(basket.Accessories.length-1)+"</span> "+e("accessories")+' <div class="thumbs"></div>');C.append('<div class="clear"></div>');$("#accessoriesBoxStatusBottom").show()}else{C.removeClass("active").html("");$("#accessoriesBoxStatusBottom").hide()}return false};var y=function(H){var G=$(H);$(H).mouseenter(function(){if((!m)&&(E==null)){m=true;E=G;var I=G;k(x,500,function(){if(E==G){I.css({"z-index":"10"}).find(".product").addClass("hover").find(".product-details").css({display:"block"});l&&I.find(".field-title").css("display","block")}})}}).mouseleave(function(){if(E==G){A(x);$(this).css({"z-index":"5"}).find(".product").removeClass("hover").find(".product-details").css({display:"none"});l&&$(this).find(".field-title").css("display","none");m=false;E=null}})};var r=function(H,G){return"http://www.bestbuy.ca/multimedia/products/"+G+"x"+G+"/"+H.substr(0,3)+"/"+H.substr(0,5)+"/"+H+".jpg"};this.showItemsFromTab=function(G){f=z.find(".ui-tabcontrol-content").eq(G);h=f.find(v)};this.showMoreProd=function(G){var H=this;l&&h.removeClass("noBottomBorder");h.each(function(J,K){var I=$(K);if(J>=H.showNumProd){I.css("display","block");((J+1)>=(Math.floor(h.length/H.showNumProd)*H.showNumProd+1))&&I.addClass("noBottomBorder")}if((J+1)%H.showNumProd==0){I.addClass("noBorder");I.after('<div class="clear"></div>')}});trackEvent.event("event.link",{lid:"AccessoryWidget_showMore"})};this.hideMoreProd=function(){var G=this;h.each(function(I,J){var H=$(J);(I<G.showNumProd)&&H.addClass("noBottomBorder");(I>=G.showNumProd)&&H.css("display","none")});trackEvent.event("event.link",{lid:"AccessoryWidget_hideMore"})};var e=function(G){return i[G][F]};var k=function(H,I,G){(function J(){if(I<=0){G();clearInterval(H)}else{I-=30;H=setTimeout(J,30)}})()};var A=function(G){clearInterval(G)};this.init()},Variance:function(j,d,f,i){var j=j?j:"",d=d?d:"",f=f?f:null,i=i?i:30,e=null,g=null,c=0,b=false;var k=function(){h();if(!b&&f!=null){if(c==0){for(var m=0;m<f.length;m++){c+=f[m].weight}}var l=Math.floor(Math.random()*c),n=0;for(var m=0;m<f.length;m++){if(l<(n+f[m].weight)){g=f[m];e=f[m].variance;break}else{n+=f[m].weight}}a();trackEvent.event("event.link",{lid:"GUI_Variance_"+j+"_"+d+"_"+e+"_visitor"})}else{if(f!=null){for(var m=0;m<f.length;m++){if(f[m].variance==e){g=f[m];break}}}else{if(!b){e="unaffected"}}}if(f!=null){trackEvent.event("event.link",{lid:"GUI_Variance_"+j+"_"+d+"_"+e+"_views"})}!(g==null)&&g.init()};this.entry=function(l){trackEvent.event("event.link",{lid:"GUI_Variance_"+j+"_"+d+"_"+e+"_"+l+"_entry"})};this.goal=function(){if(b){trackEvent.event("event.link",{lid:"GUI_Variance_"+j+"_"+d+"_"+e+"_goal"})}};var a=function(){var l=new Date();var m="|";l.setTime(l.getTime()+(i*24*60*60*1000));document.cookie="gui_v_"+j+"_"+d+"="+e+"; expires="+l.toGMTString()+"; path=/"};var h=function(){var l=document.cookie.split(";");for(var m=0;m<l.length;m++){var n=l[m];while(n.charAt(0)==" "){n=n.substring(1,n.length)}if(n.indexOf("gui_v_"+j+"_"+d+"=")==0){e=n.substring((6+j.length+1+d.length+1),n.length);b=true}}};this.clearCookie=function(){var l=new Date();l.setTime(l.getTime()+(-1*24*60*60*1000));document.cookie="gui_v_"+j+"_"+d+"=; expires="+l.toGMTString()+"; path=/"};k()}};var facetFinderWidget=function(b){var f={initRO:{pageSize:1,include:"facets",query:"",cat:"27218"}};b=$.extend(true,f,b);var g={};var a=$(".CaseFinderWidget select#ddBrands"),d=$(".CaseFinderWidget select#ddModels");var e=function(h){var i={};h=$.extend(i,h);a.unbind("change").change(function(){var k=$(this).val();d.find(".val").remove();if(k=="select"){d.val("select").trigger("change").attr("disabled","disabled")}else{var l=g[k];d.find(".val").remove();for(var j in l){d.append($('<option class="val" value="'+j+'">'+j+"</option>").data("count",l[j]))}d.attr("disabled","")}});d.unbind("change").change(function(){var j=$(this).val();if(j=="select"){$(".CaseFinderWidget .lblAvail").text(b.initAvailText);$(".CaseFinderWidget .count").text($(".CaseFinderWidget .count").data("count"))}else{$(".CaseFinderWidget .lblAvail").text(b.searchAvailtext);$(".CaseFinderWidget .count").text($(this).find("[value="+$(this).val()+"]").data("count"))}});if(b.phoneBrand&&a.find("[value~="+unescape(b.phoneBrand)+"]").attr("value")){a.val(a.find("[value~="+unescape(b.phoneBrand)+"]").attr("value")).trigger("change")}if(b.phoneModel&&d.find(":contains("+unescape(b.phoneModel)+")").attr("value")){d.val(d.find(":contains("+unescape(b.phoneModel)+")").attr("value")).trigger("change")}$(".CaseFinderWidget .btnContinue a").click(function(){window.location=h.finderURL+((h.finderURL.search(/\?/)>0)?"&":"?")+((a.val()&&a.val()!="select")?"phoneBrand="+a.val()+"&":"")+((d.val()&&d.val()!="select")?"phoneModel="+d.val():"");return false})};b.initRO.cb=function(h){$(".CaseFinderWidget .count").data("count",h.total);$(".CaseFinderWidget .count").text(h.total);$(h.facets).each(function(i){var k=this;if(k.name!="category"&&(/^For/.test(k.name)||/^Pour/.test(k.name))){var j={};$(k.filters).each(function(){var l=this;j[l.name]=l.count});g[k.name]=j;a.append($('<option class="val" value="'+k.name+'">'+k.name+"</option>"))}});e({finderURL:b.finderURL})};var c=new api2.search(b.initRO)};$(document).ready(function(){$("#glb-top-menu").buildMenu();var b=util.cookie.getCookie("bbyca_mob_optout_ca")||"false",c=util.url.qs("fullsite")||"false";if(/(PlayBook|Android|iPod|iPhone|BlackBerry|iPad)/gi.test(navigator.userAgent)){if(b=="false"&&c=="true"){util.cookie.createCookie("bbyca_mob_optout_ca","true",30)}var a=Math.min(screen.width,screen.height)>599;$("#hdr-back-to-mobile, #ftr-back-to-mobile").addClass(a?"show-tablet-link":"show-mobile-link").show()}});
