
$(window).load(function(){var quickViewProducts=new Array();$('a.quickMC').click(function(e){e.preventDefault();lightBox.Loading();$('div.btnFecharLightbox a').bind('click',function(){lightBox.Close();});var productId=$(this).attr('productId');var found=null;for(i=0;i<quickViewProducts.length;i++){if(quickViewProducts[i].d.ProductId==productId)
found=quickViewProducts[i];}
if(found==null){$.ajax({type:"POST",url:"/WebService/SiteMaster.asmx/GetProductQuickView",data:"{'productId':"+productId+"}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(T){bindTemplate(T);quickViewProducts[quickViewProducts.length]=T;}});}
else
bindTemplate(found);});$('p.btnVisualizacaoRapida a, span.btnVisualizacaoRapida a, a.btnVisualizacaoRapida').click(function(e){e.preventDefault();lightBox.Loading();$('div.btnFecharLightbox a').bind('click',function(){lightBox.Close();});var productId=$(this).attr('productId');var relationType=$(this).attr('relationType');if(productId==undefined)
productId=$(this).parent('.btnVisualizacaoRapida').attr('productId');if(relationType==undefined)
relationType=$(this).parent('.btnVisualizacaoRapida').attr('relationType');if(relationType==null)relationType=0;var found=null;for(i=0;i<quickViewProducts.length;i++){if(quickViewProducts[i].d.ProductId==productId)
found=quickViewProducts[i];}
if(found==null){$.ajax({type:"POST",url:"/WebService/SiteMaster.asmx/GetProductQuickView",data:"{'productId':"+productId+", 'relationType':"+relationType+"}",contentType:"application/json; charset=utf-8",dataType:"json",success:function(T){bindTemplate(T);quickViewProducts[quickViewProducts.length]=T;}});}
else
bindTemplate(found);});});function bindTemplate(T){lightBox.SetTemplate('templateLightbox',T);var $de=$('div.descricaoProduto p.de');var $por=$('div.descricaoProduto p.por');var $caracteristicaProduto=$('div.caracteristicaProduto');if(T.d.OldPrice!='R$ 0,00'){$de.html('De: '+T.d.OldPrice);$por.html('Por: '+T.d.Price);}
else{$de.hide();$por.attr('class','de por')
$por.html(T.d.Price);}
if(T.d.BestInstallment==''){$('div.descricaoProduto p.emAte').hide();$('div.descricaoProduto p.semJuros').hide();}
if(T.d.PromotionValue=='')
$('div.descricaoProduto p.avista').hide();for(var i=0;i<5;i++){if(T.d.Avaliation>(i+0.65))
$('#imgAvaliation'+i).attr('src',$('#imgAvaliation'+i).attr('src').replace('-off','-on'));else if(T.d.Avaliation>(i+0.15))
$('#imgAvaliation'+i).attr('src',$('#imgAvaliation'+i).attr('src').replace('-off','-half'));else
break;}
if(T.d.BrandName==null||T.d.BrandName=='')
$('#areaBrand').hide();if(T.d.Chips.length<=0)
$('#areaChips').hide();else{var $urlProductBuy=$('#urlProductBuy');$urlProductBuy.attr("href",$urlProductBuy.attr("href")+"&secondProductId="+$('#selChips').val());$('#selChips').change(function(){$urlProductBuy.attr("href",$urlProductBuy.attr("href").replace(/secondProductId=[0-9]*/,"secondProductId="+$(this).val()));});}
switch(T.d.ButtonStock){case"buttonDetail":$('#divButtonDetail').show();$('#divProductBuyButton').hide();$('#divProductSoldOutButton').hide();break;case"buttonTellMe":$('#divButtonDetail').hide();$('#divProductBuyButton').hide();$('#divProductSoldOutButton').show();break;default:$('#divButtonDetail').show();$('#divProductBuyButton').show();$('#divProductSoldOutButton').hide();break;}
$('#soldOut').hide();if(!T.d.IsPriceInformation){$('#priceInformation').hide();$('#soldOut').show();}
$caracteristicaProduto.find('ul li:first div').each(function(){$(this).attr('class',$(this).attr('class')+'-on');});$('#scrollConteudo div[name]').each(function(){$(this).css("display","none");});var $filstTabContent=$('#scrollConteudo div:first');$filstTabContent.css("display","block");var $scrollableContent=$('#scrollConteudo');$scrollableContent.height(80);$scrollableContent.parents('.jScrollPaneContainer').height(80);$scrollableContent.jScrollPane({scrollbarWidth:14,scrollbarMargin:0,showArrows:true,dragMaxHeight:8});$caracteristicaProduto.find('ul li a').click(function(e){e.preventDefault();var selectedTab=$(this).parents('li:first').attr("name");$caracteristicaProduto.find('ul li div').each(function(){$(this).attr('class',$(this).attr('class').replace('-on',''));});$(this).parents('li').children('div').each(function(){$(this).attr('class',$(this).attr('class')+'-on');});$('#scrollConteudo div[name]').each(function(){if(selectedTab==$(this).attr("name")){$(this).css("display","block");var $scrollableContent=$('#scrollConteudo');var $jScrollPaneContainer=$scrollableContent.parents('.jScrollPaneContainer');if($(this).height()<=80){$scrollableContent.height($(this).height()+20);$jScrollPaneContainer.height($(this).height()+20);$jScrollPaneContainer.find('.jScrollPaneTrack, .jScrollArrowUp, .jScrollArrowDown').css("display","none");try{$scrollableContent[0].scrollTo(0);}
catch(err){}}
else{$scrollableContent.height(80);$jScrollPaneContainer.height(80);$scrollableContent.jScrollPane({scrollbarWidth:14,scrollbarMargin:0,showArrows:true,dragMaxHeight:8});try{$scrollableContent[0].scrollTo(0);}
catch(err){}}}
else
$(this).css("display","none");});});if(T.d.Pictures.length>3){$('#picturesCarrosel').jcarousel({scroll:3,animation:'slow',initCallback:quickViewCarousel_initCallback});}else if(T.d.Pictures.length<=1){$('#areaCarousel').hide();}
var $imgPictureStamp=$('#imgPictureStamp');if(!($imgPictureStamp.attr('src'))||$imgPictureStamp.attr('src').length<=0){$imgPictureStamp.hide();}
$("#picturesCarrosel li").mouseover(function(e){$("#picturesCarrosel li img").removeClass("active");$(this).find('img').addClass("active");var newImg=$("img",this).attr("image");$("#imgPictureZoom").attr("src",newImg);e.preventDefault();});}
function quickViewCarousel_initCallback(carousel){$('div.btnFecharLightbox a').bind('click',function(){$(window).unbind('resize',carousel.funcResize);});$('#boxOverlay').bind('click',function(){$(window).unbind('resize',carousel.funcResize);});}