(function($){function MsnShoppingWidget(domNode,options){this._el=$(domNode);this._opts=$.extend($.msnShoppingWidgetDefaults,options);this._init()}MsnShoppingWidget.prototype={_init:function(){var self=this;cached_image=Array(new Image,new Image);cached_image[0].src="http://blstc.msn.com/br/chan/lfs/i/1/buttonCompare_default.gif";cached_image[1].src="http://blstc.msn.com/br/chan/lfs/i/1/buttonCompare_mo.gif";self._buildControl(this._el);if(self._opts.searchTerm==undefined||self._opts.searchTerm==null||self._opts.searchTerm=="")self.mineAndSearch(location.href);else self.search(self._opts.searchTerm)},search:function(query){var self=this,request=self._opts.url+"/Search?method=?&query="+escape(query)+"&maxresults="+self._opts.maxResults+"&sourceChannel="+self._opts.sourceChannel,jsonpCallback=function(foundProducts){self._cachedProducts=foundProducts;self._createProductList(foundProducts);$(".SearchTerm").html(query.toUpperCase());$("#divSearchResults",self._el).scrollTop(0);self._setSortedHeader($(".sortByMatch"));if(foundProducts==null||foundProducts.length==0)self._showNoResultsMessage()};self._startProgress(self);$.jsonp({url:request,success:function(json){jsonpCallback(json);self._endProgress(self)},error:function(){self._cleanupError();self._endProgress(self)}})},mineAndSearch:function(url){var self=this,request=self._opts.url+"/MineAndSearch?method=?&url="+escape(url)+"&hints="+escape(self._opts.hints)+"&maxresults="+self._opts.maxResults+"&sourceChannel="+self._opts.sourceChannel,jsonpCallback=function(foundProducts){if(foundProducts!=null&&foundProducts.length>0){self._cachedProducts=foundProducts;self._createProductList(foundProducts);$(".SearchTerm").html("BING AND DECIDE");$("#divSearchResults",self._el).scrollTop(0);self._setSortedHeader($(".sortByMatch"))}};self._startProgress(self);$.jsonp({url:request,success:function(json){jsonpCallback(json);self._endProgress(self)},error:function(){self._cleanupError();self._endProgress(self)}})},_cleanupError:function(){var self=this;$(".SearchResult",self._el).empty();self._showNoResultsMessage()},_buildControl:function(host){var self=this,footerTitleText="Popular searches on Bing shopping",borderStyle="1px solid #B3C1CC",headerStyle={backgroundColor:"#7992C4",border:borderStyle,height:"68px",marginBottom:"0px",position:"relative",background:"url(http://blstc.msn.com/br/chan/lfs/i/1/search_shopBkg.gif) no-repeat",backgroundPosition:"right center"},contentStyle={border:borderStyle,height:"442px"},searchResultsStyle={height:"395px",overflow:"auto",padding:"8px 0 0 6px"},footerStyle={border:borderStyle,borderTop:"none",height:"80px",overflow:"hidden",backgroundColor:"#EEEFED"},searchLogoStyle={"float":"left",margin:"6px 0 0 6px"},searchButtonStyle={cursor:"pointer","float":"left",marginLeft:"2px",marginTop:"3px"},searchScopeStyle={height:"26px"},searchScopeCurrentStyle={color:"#001852",cursor:"default",fontWeight:"bold"},searchScopeOffStyle={color:"#FFFFFF",cursor:"pointer",fontWeight:"normal"},searchScopeInnerStyle={color:"#FFFFFF","float":"left",fontFamily:"Segoe, Tahoma, sans-serif",fontSize:"12px",padding:"8px 8px 0 8px",textAlign:"center",textDecoration:"none"},searchScopeArrowStyle={background:"transparent url(http://blstc.msn.com/br/chan/lfs/i/1/scope_arrow.png) no-repeat scroll center bottom",display:"block",height:"4px",left:"30px",position:"absolute",top:"22px",width:"7px"},searchScopePipe={background:"transparent url(http://blstc.msn.com/br/chan/lfs/i/1/pipe.png) no-repeat scroll center bottom",display:"block",height:"20px",width:"4px","float":"left"},searchBoxStyle={"float":"left",height:"36px"},searchBoxLeftStyle={background:"transparent url(http://blstc.msn.com/br/chan/lfs/i/1/searchBoxLeft.png) no-repeat scroll left top",clear:"left",marginLeft:"6px",width:"6px"},searchBoxCenterStyle={background:"transparent url(http://blstc.msn.com/br/chan/lfs/i/1/searchBoxCenter.png) repeat-x scroll left top",position:"relative"},searchBoxRightStyle={background:"transparent url(http://blstc.msn.com/br/chan/lfs/i/1/searchBoxRight.png) no-repeat scroll left top",width:"6px"},searchInputAreaStyle={backgroundColor:"#FFFFFF",border:"1px solid #EEEFED",height:"26px",left:"-1px",marginTop:"4px",position:"relative"},searchInputStyle={"float":"left",paddingLeft:"5px"},searchTextBoxStyle={border:"none 0",color:"#000000",display:"block","float":"left",fontFamily:"Tahoma,sans-serif",marginTop:"3px",padding:"2px 1px 0 6px"},shoppingLogoStyle={color:"#000000",width:"100px",height:"100px"},searchTermStyle={color:"#001852",fontFamily:"Tahoma,sans-serif",fontSize:"11px",fontWeight:"bold",padding:"4px 0 0 0px",overflow:"hidden",whitespace:"nowrap",height:"12px"},sortStyle={borderBottom:borderStyle,height:"36px",margin:"0px",overflow:"hidden"},sortByStyle={color:"#999999",fontFamily:"Arial",fontSize:"11px",fontWeight:"bold",textDecoration:"none",textAlign:"left",padding:"2px 0 0 0px",whiteSpace:"nowrap",overflow:"hidden"},footerTitleStyle={color:"#001853",fontFamily:"Tahoma",fontSize:"11px",fontWeight:"bold",height:"20px",lineHeight:"20px",padding:"0 6px"},hoverStyle={display:"none",fontFamily:"Arial,Tahoma,sans-serif",fontSize:"11px",left:"0px",position:"absolute",top:"0px",width:"385px",border:"2px solid #808080",zIndex:999},hoverLeftStyle={backgroundColor:"#FFFFFF","float":"left",height:"165px",width:"130px"},hoverRightStyle={backgroundColor:"#FFFFFF","float":"left",width:"255px"},cashbackCoin={"float":"left",background:"transparent url(http://blstc.msn.com/br/chan/lfs/i/1/coin.png) no-repeat scroll left top"};host=$(host).css("position","relative");var headerDiv=$("<div/>").css(headerStyle).appendTo(host),contentDiv=$("<div/>").css(contentStyle).appendTo(host),footerDiv=$("<div/>").css(footerStyle).appendTo(host),searchBox=$("<div/>").appendTo(headerDiv),searchScope=$("<div/>").css(searchScopeStyle).appendTo(searchBox),bingSearch=function(){var queryterm=$("#searchTextBox").val(),querystring=self._getSearchUrl();if(queryterm!=undefined&&queryterm!=""){querystring+="&q=";querystring+=escape(queryterm)}window.location=querystring};$("<a/>").text("Shopping").css(searchScopeInnerStyle).css(searchScopeCurrentStyle).appendTo($("<div/>").css("float","left").css("tabindex",0).appendTo(searchScope));$("<div/>").css(searchScopePipe).appendTo(searchScope);$("<a/>").text("Web").css(searchScopeInnerStyle).click(bingSearch).css(searchScopeOffStyle).hover(function(){$(this).css("textDecoration","underline")},function(){$(this).css("textDecoration","none")}).appendTo($("<div/>").css("float","left").css("tabindex",1).appendTo(searchScope));$("<div/>").css(searchScopeArrowStyle).appendTo(searchScope);$("<div/>").css(searchBoxStyle).css(searchBoxLeftStyle).appendTo(searchBox);var searchCenter=$("<div/>").css(searchBoxStyle).css(searchBoxCenterStyle).css("width",self._el.width()-75).appendTo(searchBox);$("<div/>").css(searchBoxStyle).css(searchBoxRightStyle).appendTo(searchBox);var searchInputArea=$("<div/>").css(searchInputAreaStyle).css("width",self._el.width()-75).appendTo(searchCenter),searchInput=$("<div/>").css(searchInputStyle).appendTo(searchInputArea),searchTextBox=$('<input type="text" id="searchTextBox" title="Search, Shop, and Save" />').css(searchTextBoxStyle).css("tabindex",2).css("width",self._el.width()-165).keyup(function(event){if(event.keyCode==13)$(".searchButton",searchInput).click()}).appendTo(searchInput);$.updnWatermark.attachAll();$('<img src="http://blstc.msn.com/br/chan/lfs/i/1/bing-logo.gif" />').css(searchLogoStyle).css("tabindex",3).appendTo(searchInput);var searchButton=$('<img src="http://blstc.msn.com/br/chan/lfs/i/1/button-search.png" alt="Search" title="Search" />').addClass("searchButton").css(searchButtonStyle).click(function(){self.search(searchTextBox.focus().val())}).appendTo(searchInput),sortDiv=$("<div/>").css(sortStyle).appendTo(contentDiv);$('<img src="http://blstc.msn.com/br/chan/lfs/i/1/coin.png" />').css(cashbackCoin).appendTo(sortDiv);$("<div>BING AND DECIDE</div>").css(searchTermStyle).addClass("SearchTerm").appendTo(sortDiv);$('<div>sort by: <a class="sortByMatch sortLink">best match</a> | <a class="sortByPrice sortLink">price</a> | <a class="sortByCashback sortLink">cashback</a> | <a class="sortByRating sortLink">rating</a></div>').css(sortByStyle).find("a").css("textDecoration","none").end().appendTo(sortDiv);$(".sortByMatch",sortDiv).css("tabindex",4).click(function(){self._sortProductsList(self._cachedProducts);self._setSortedHeader($(this))});$(".sortByPrice",sortDiv).css("tabindex",5).click(function(){self._sortProductsList(self._cachedProducts,self._sortByPrice);self._setSortedHeader($(this))});$(".sortByCashback",sortDiv).css("tabindex",6).click(function(){self._sortProductsList(self._cachedProducts,self._sortByCashback);self._setSortedHeader($(this))});$(".sortByRating",sortDiv).css("tabindex",7).click(function(){self._sortProductsList(self._cachedProducts,self._sortByUserReview);self._setSortedHeader($(this))});self._setSortedHeader($(".sortByMatch",sortDiv));var searchDiv=$("<div/>").addClass("SearchResult").css(searchResultsStyle).appendTo(contentDiv),progressDiv=$("<div/>").addClass("divProgress").addClass("transparentdiv").appendTo(contentDiv),progressDivImage=$("<div/>").addClass("divProgressImage").appendTo(progressDiv),progressImage=$('<img src="http://blstc.msn.com/br/chan/lfs/i/1/roller.gif" />').appendTo(progressDivImage);$("<div/>").css(footerTitleStyle).text(footerTitleText).appendTo(footerDiv);var popularLinksDiv=$("<div/>").css({fontFamily:"Arial,Tahoma,sans-serif",fontSize:"10px",textAlign:"left",marginTop:"5px",marginLeft:"5px",color:"#07519A"}).appendTo(footerDiv);for(i=0;i<self._opts.popularSearchTerms.length;i++)$("<span/>").text(self._opts.popularSearchTerms[i]).css("cursor","pointer").click(function(){$("#searchTextBox",self._el).val("");$("#searchTextBox",self._el).blur();self.search($(this).text())}).appendTo($("<div/>").appendTo(popularLinksDiv));popularLinksDiv.columnize({columns:3});var hoverProductImageStyle={height:"100px",width:"100px",marginTop:"10px",marginLeft:"15px",marginBottom:"20px"},hoverProductLinkStyle={fontSize:"12px",marginTop:"10px"},hoverDetailsStyle={paddingRight:"10px"},hoverCashbackCoinStyle={background:"transparent url(http://www.bing.com/shopping/static/shopping_coins2.gif) no-repeat scroll 0 -61px",display:"inline-block",height:"16px",marginRight:"5px",marginLeft:"10px",verticalAlign:"middle",width:"27px"},hoverDiv=$("<div/>").addClass("productHover").css(hoverStyle).mouseleave(function(){$(this).fadeOut()}).appendTo(host),hoverLeftDiv=$("<div/>").css(hoverLeftStyle).appendTo(hoverDiv),hoverRightDiv=$("<div/>").addClass("hoverProductDetails").css(hoverRightStyle).appendTo(hoverDiv),hoverDetailsDiv=$("<div/>").css(hoverDetailsStyle).appendTo(hoverRightDiv);$('<img class="hoverProductImg"/>').appendTo($("<div/>").css(hoverProductImageStyle).appendTo(hoverLeftDiv));$('<div class="hoverComparePrices" />').addClass("comparePrices").mouseover(function(){$(this).addClass("comparePricesOver")}).mouseout(function(){$(this).removeClass("comparePricesOver")}).appendTo($("<div/>").appendTo(hoverLeftDiv));$('<a class="hoverProductLink"/>').appendTo($("<div/>").css(hoverProductLinkStyle).appendTo(hoverDetailsDiv));$('<div class="hoverProductDescription"/>').appendTo(hoverDetailsDiv);var priceDiv=$("<div/>").appendTo(hoverDetailsDiv);$('<a class="hoverProductPrice"/>').appendTo(priceDiv);$('<span class="hoverProductStores"/>').appendTo(priceDiv);$('<span class="hoverCashbackCoin" />').css(hoverCashbackCoinStyle).appendTo(priceDiv);$('<span class="hoverCashback" />').addClass("dullText").appendTo(priceDiv);var hoverUserReviews=$("<div/>").addClass("userHoverReviews").appendTo(hoverDetailsDiv);$('<div class="ui-rater-starsOff" style="width: 50px; cursor: pointer;"><div class="ui-rater-starsOn" style="cursor: pointer;"></div></div>').appendTo(hoverUserReviews);$('<a class="hoverReviewsLink">user reviews</a><span class="hoverReviewsNumber"/>').appendTo(hoverUserReviews);var hoverExpertReviews=$("<div/>").addClass("expertHoverReviews").appendTo(hoverDetailsDiv);$('<div class="ui-rater-starsOff" style="width: 50px; cursor: pointer;"><div class="ui-rater-starsOn" style="cursor: pointer;"></div></div>').appendTo(hoverExpertReviews);$('<a class="hoverReviewsLink">expert reviews</a><span class="hoverReviewsNumber"/>').appendTo(hoverExpertReviews)},_setSortedHeader:function(selectedSortHeader){$(".sortByMatch").removeClass("sortBy");$(".sortByPrice").removeClass("sortBy");$(".sortByCashback").removeClass("sortBy");$(".sortByRating").removeClass("sortBy");$(selectedSortHeader).addClass("sortBy")},_sortProductsList:function(products,fn){var self=this;if(products!=null){self._startProgress(self);var sortedProducts=self._copyArray(products);if(fn!=undefined)sortedProducts.sort(fn);self._createProductList(sortedProducts);$(".SearchResult",self._el).scrollTop(0);self._endProgress(self)}},_copyArray:function(input){var newArray=[];for(i=0;i<input.length;i++)newArray[i]=input[i];return newArray},_sortByPrice:function(a,b){var result=0,PriceA,PriceB,PriceRe=/\$([\d,\.]+)$/,matchA=a.Price.match(PriceRe)[1],matchB=b.Price.match(PriceRe)[1];matchA=matchA.replace(",","");matchB=matchB.replace(",","");PriceA=parseInt(matchA);PriceB=parseInt(matchB);if(PriceA>PriceB)result=1;else if(PriceA<PriceB)result=-1;return result},_sortByCashback:function(a,b){var result=0,CashbackA,CashbackB,CashbackRe=/(\d{1,2})%/;CashbackA=a.Cashback!=""?parseInt(a.Cashback.match(CashbackRe)[1]):0;CashbackB=b.Cashback!=""?parseInt(b.Cashback.match(CashbackRe)[1]):0;if(CashbackA>CashbackB)result=-1;else if(CashbackA<CashbackB)result=1;return result},_sortByUserReview:function(a,b){var result=0;if(a.UserReview>b.UserReview)result=-1;else if(a.UserReview<b.UserReview)result=1;if(result==0)if(a.NumUserReviews>b.NumUserReviews)result=-1;else if(a.NumUserReviews<b.NumUserReviews)result=1;return result},_createProductList:function(products){var self=this,RatingRe=/Rating: (\d\.?\d?) out of (\d)/,productContainer=$(".SearchResult",self._el).empty(),productStyle={"float":"left",marginLeft:"8px"},productImageBorderStyle={border:"1px solid #CCCCCC",height:self._searchResultDisplaySize+"px",marginBottom:"4px",width:self._searchResultDisplaySize+"px"},productImageStyle={},separatorStyle={"float":"left",height:"6px"},fontStyle={fontFamily:"Arial",fontSize:"11px"},cashbackCoinStyle={background:"transparent url(http://www.bing.com/shopping/static/shopping_coins2.gif) no-repeat scroll 0 -61px",display:"inline-block",height:"16px",marginRight:"5px",verticalAlign:"middle",width:"27px"},numColumns=Math.floor(productContainer.width()/self._searchResultDisplaySize),productSpacing=self._calculateProductSpacing(productContainer,numColumns,155,products.length);for(var i=0;i<products.length;i++){var product=products[i];product.Cashback=product.Cashback||"";product.UserReview=product.UserReview||"";product.ExpertReview=product.ExpertReview||"";var productDiv=$("<div/>").css(productStyle),productImage=$("<img/>").attr("src",product.ImageUrl).css(productImageStyle).appendTo($("<div/>").css(productImageBorderStyle).appendTo(productDiv));self._addImageScaling(productImage,product,self._searchResultDisplaySize);var productLinkContainer=$("<div/>").css("width",self._searchResultDisplaySize+"px").css("overflow","hidden").appendTo(productDiv),productLink=$("<a/>").attr("href",products[i].ProductUrl).attr("target",self._opts.defaultTarget).html(product.Name).css(fontStyle).css("color","#0000EE").appendTo(productLinkContainer),productPriceDiv=$("<div/>").appendTo(productDiv);$("<a/>").attr("href",products[i].PriceUrl).attr("target",self._opts.defaultTarget).css(fontStyle).css("color","#0000EE").css("text-decoration","none").html(product.Price).appendTo(productPriceDiv);if(product.Cashback!="")$("<div/>").text(product.Cashback).addClass("dullText").css(fontStyle).appendTo(productDiv).prepend($("<span/>").css(cashbackCoinStyle));if(product.UserReview!="")$('<span class="ui-rater"><span class="ui-rater-starsOff" style="width:50px;"><span class="ui-rater-starsOn" style="width:'+10*product.UserReview.match(RatingRe)[1]+'px"></span></span></span>').appendTo($("<div/>").css("clear","both").appendTo(productDiv)).after($("<span/>").html(product.NumUserReviews).addClass("dullText").css(fontStyle).css("float","left"));if(product.ExpertReview!="")$('<span class="ui-rater"><span class="ui-rater-starsOff" style="width:50px;"><span class="ui-rater-starsOn" style="width:'+10*product.ExpertReview.match(RatingRe)[1]+'px"></span></span></span>').appendTo($('<div style="clear:left"/>').appendTo(productDiv)).after($("<span/>").html(product.NumExpertReviews).addClass("dullText").css(fontStyle).css("float","left"));if(i%numColumns==0){productDiv.css("marginLeft","0");if(i!=0)$("<div/>").css(separatorStyle).css("width",numColumns*self._searchResultDisplaySize).appendTo(productContainer)}else productDiv.css("marginLeft",productSpacing);var onHoverOver=function(e){var product=$(this).data("product");if(product!=undefined){var hover=$(".productHover:first"),leftEdge=productContainer.width()-405,topEdge=e.pageY-75>=0?e.pageY-75-hover.parent().offset().top:0,hoverProductImage=$(".hoverProductImg",hover).attr("src",product.ImageUrl);self._addImageScaling(hoverProductImage,product,100);$(".hoverComparePrices",hover).unbind("click").click(function(){window.open(product.PriceUrl,self._opts.defaultTarget)});$(".hoverProductLink",hover).html(product.Name).attr("href",product.ProductUrl).attr("target",self._opts.defaultTarget);self._addProductDescription($(".hoverProductDescription",hover),product);$(".hoverProductPrice",hover).attr("href",product.ProductUrl).attr("target",self._opts.defaultTarget).html(product.Price);$(".hoverProductStores",hover).addClass("dullText").html(product.NumberStores);if(product.Cashback!=""){$(".hoverCashbackCoin",hover).css("display","inline-block");$(".hoverCashback",hover).show();$(".hoverCashback",hover).text(product.Cashback)}else{$(".hoverCashbackCoin",hover).hide();$(".hoverCashback",hover).hide()}if(product.UserReview.match(RatingRe)&&product.UserReview.match(RatingRe).length>0){var hoverReviews=$(".userHoverReviews",hover);hoverReviews.css("display","block");$(".ui-rater-starsOn",hoverReviews).width(product.UserReview.match(RatingRe)[1]*10);$(".hoverReviewsLink",hoverReviews).attr("href",product.UserReviewUrl).attr("target",self._opts.defaultTarget);$(".hoverReviewsNumber",hoverReviews).addClass("dullText").html(product.NumUserReviews)}else $(".userHoverReviews",hover).css("display","none");if(product.ExpertReview.match(RatingRe)&&product.ExpertReview.match(RatingRe).length>0){var hoverReviews=$(".expertHoverReviews",hover);hoverReviews.css("display","block");$(".ui-rater-starsOn",hoverReviews).width(product.ExpertReview.match(RatingRe)[1]*10);$(".hoverReviewsLink",hoverReviews).attr("href",product.ExpertReviewUrl).attr("target",self._opts.defaultTarget);$(".hoverReviewsNumber",hoverReviews).addClass("dullText").html(product.NumExpertReviews)}else $(".expertHoverReviews",hover).css("display","none");var detailsHeight=$(".hoverProductDetails > div").height()<160?165:$(".hoverProductDetails > div").height()+20;$(".hoverProductDetails").height(detailsHeight);hover.css({left:leftEdge+"px",top:topEdge+"px"}).fadeIn()}},onHoverOut=function(){if($("#SearchResultDetail",self._el).is(":visible"))$("#SearchResultDetail",self._el).hide("slide",{direction:"right",easing:"easeOutCirc"},500)},hoverConfig={sensitivity:3,interval:250,over:onHoverOver,timeout:500,out:onHoverOut};productImage.data("product",product).hoverIntent(hoverConfig);productDiv.appendTo(productContainer);productLink.each(function(){var thisLink=$(this);if(thisLink.text().length>13)thisLink.text(thisLink.text().substr(0,12)+"...")});productContainer.scrollTop(0)}},_calculateProductSpacing:function(container,numColumns,productDivHeight,numResults){var self=this,columnWidth=numColumns*self._searchResultDisplaySize,totalWidth=container.width()-columnWidth;if(self._isScrollbarVisible(container,numColumns,productDivHeight,numResults))totalWidth-=self._getScrollbarWidth();var ie=/MSIE/i.test(navigator.userAgent);if(ie){var removalWidth=20;if(document.documentMode=="7")totalWidth-=removalWidth;var isIE6=/msie|MSIE 6/.test(navigator.userAgent),isIE7=/msie|MSIE 7/.test(navigator.userAgent);if(isIE6||isIE7)totalWidth-=removalWidth}return Math.floor(totalWidth/numColumns)},_isScrollbarVisible:function(container,numColumns,productDivHeight,numResults){var visible=false,visibleRows=Math.floor(container.height()/productDivHeight),productRows=Math.ceil(numResults/numColumns);if(productRows>visibleRows)visible=true;return visible},_getScrollbarWidth:function(){var scr=null,inn=null,wNoScroll=0,wScroll=0;scr=document.createElement("div");scr.style.position="absolute";scr.style.top="-1000px";scr.style.left="-1000px";scr.style.width="100px";scr.style.height="50px";scr.style.overflow="hidden";inn=document.createElement("div");inn.style.width="100%";inn.style.height="200px";scr.appendChild(inn);document.body.appendChild(scr);wNoScroll=inn.offsetWidth;scr.style.overflow="auto";wScroll=inn.offsetWidth;document.body.removeChild(document.body.lastChild);return wNoScroll-wScroll},_addImageScaling:function(image,product,preferredSize){var imageHeight=parseInt(product.ImageHeight),imageWidth=parseInt(product.ImageWidth);image.css("margin-left",0);image.css("margin-top",0);if(imageHeight>imageWidth||imageHeight==imageWidth){if(imageHeight>preferredSize){image.attr("height",preferredSize);imageWidth=preferredSize/imageHeight*imageWidth;image.attr("width",imageWidth)}else{image.attr("height",imageHeight);image.attr("width",imageWidth);var topMargin=(preferredSize-imageHeight)/2;image.css("margin-top",topMargin)}var leftMargin=(preferredSize-imageWidth)/2;image.css("margin-left",leftMargin)}else{if(imageWidth>preferredSize){image.attr("width",preferredSize);imageHeight=preferredSize/imageWidth*imageHeight;image.attr("height",imageHeight)}else{image.attr("height",imageHeight);image.attr("width",imageWidth);var leftMargin=(preferredSize-imageWidth)/2;image.css("margin-left",leftMargin)}var topMargin=(preferredSize-imageHeight)/2;image.css("margin-top",topMargin)}},_addProductDescription:function(descriptionElement,product){var self=this,description=product.Description,match=description.match("More...$");if(match=="More..."){description=description.substr(0,description.length-"More...".length);descriptionElement.html(description);$("<a/>").attr("href",product.DescriptionUrl).attr("target",self._opts.defaultTarget).css("text-decoration","none").text("more...").appendTo(descriptionElement)}else descriptionElement.html(description)},_startProgress:function(self){var divSearchResults=$(".SearchResult",self._el),divProgress=$(".divProgress",self._el),divProgressImage=$(".divProgressImage",self._el),pos=divSearchResults.position();divProgress.css({position:"absolute",marginLeft:0,marginTop:0,top:pos.top,left:pos.left,width:divSearchResults.outerWidth(),height:divSearchResults.outerHeight()});divProgressImage.css({position:"absolute",top:divSearchResults.outerHeight()/2-16,left:divSearchResults.outerWidth()/2-16});divProgress.show()},_endProgress:function(self){$(".divProgress",self._el).hide()},_showNoResultsMessage:function(){var searchDiv=$(".SearchResult"),noResultsDiv=$("<div/>").addClass("divNoResultsMessage").appendTo(searchDiv);noResultsDiv.text("No results found")},_getSearchUrl:function(){var self=this,fullUrl=self._opts.webSearchUrl;fullUrl+="&FORM=";fullUrl+=self._opts.sourceChannel;return fullUrl},_el:null,_opts:null,_cachedProducts:null,_searchResultDisplaySize:83};$.fn.msnshoppingwidget=function(options){return this.each(function(){var el=$(this);if(!el.data("msnshoppingwidget"))el.data("msnshoppingwidget",new MsnShoppingWidget(this,options))})};$.msnShoppingWidgetDefaults={searchTerm:null,url:"http://mssas.directapps.com/BingProxyService.svc",maxResults:30,webSearchUrl:"http://www.bing.com/?scope=web&mkt=en-US",defaultTarget:"_self",sourceChannel:"MSNLPW",hints:null,popularSearchTerms:["Desktops","Laptops","PDAs","Digital Cameras","Camcorders","MP3 Players","Cell Phones","Software","Audio/Video","Peripherals","Networking","Storage"]};$.msnshoppingwidget=function(el){return $(el).eq(0).data("msnshoppingwidget")}})(jQuery)