/**
 * Product Photo Enlargement
 */
(function(){var EnlargeImgFunc=function(photoCon,photoOri){if(!window.zMaskIframe){window.zMaskIframe='<iframe class="zMaskIframe" style="position:absolute;z-index:-1;left:0;top:0;width:330px;height:330px;filter:mask();" frameborder="0"><\/iframe>'}jQuery('.sImg').hide();jQuery('body').append('<div class="enlarge-con"><div class="arrow-left" /><div class="fl"><div class="photo300"><a href="#" target="_blank"><img src="/images/loading_nail.gif" alt="" /></a></div></div><div class="sImg"></div><a href="#" target="_blank" class="prevDetail">Click for Details</a></div>').find('.enlarge-con').hide();var EnlargeImgTimer=null;var loadingImg=new Image();loadingImg.src='/images/loading_nail.gif';var newPhoto=new Image();newPhoto.src='/images/spacer.gif';newPhoto.onload=function(){var cssImg={'width':newPhoto.width+'px','height':newPhoto.height+'px'};if(newPhoto.width>300||newPhoto.height>300){if(newPhoto.width>=newPhoto.height){cssImg.height=parseInt(300*newPhoto.height/newPhoto.width)+'px';cssImg.width=300+'px'}else{cssImg.width=parseInt(300*newPhoto.width/newPhoto.height)+'px';cssImg.height=300+'px'}}if(!+'\v1'&&!window.XMLHttpRequest){jQuery('.enlarge-con .photo300 > a img').replaceWith('<img src="'+newPhoto.src+'" style="width:'+cssImg.width+';height:'+cssImg.height+'" />').show()}else{setTimeout(function(){jQuery('.enlarge-con .photo300 > a img').hide().css(cssImg).attr('src',newPhoto.src).show()},50)}};var imgOverFunc=function(){clearTimeout(EnlargeImgTimer);var qThis=jQuery(this);EnlargeImgTimer=setTimeout(function(){var qPhotoL=qThis.parents(photoCon);if(!qPhotoL.length){qPhotoL=qThis.parent()}if(!qPhotoL.find(photoOri+' img[class!="pia"]:not([src*="/safe_image"]):not([src*="/no_photo"]):not([name*="multiToprank"])').length)return;var photoSRC=qPhotoL.find(photoOri+' img').attr('src');photoSRC='.Photo160'!=photoOri?photoSRC.replace(/\/3f2/,'/2f0').replace(/\/8f4/,'/8f6').replace(/\/5f2/,'/4f0'):photoSRC.replace(/\/2f1/,'/2f0').replace(/\/8f5/,'/8f6').replace(/\/4f2/,'/4f0');if(qPhotoL.find('.sImg').length){jQuery('.enlarge-con').width('370px');jQuery('.enlarge-con .sImg').replaceWith(qPhotoL.find('.sImg').clone());jQuery('.prevDetail').addClass("prevDetailW365");conLeft=conLeft-63}else if(qPhotoL.filter('.pro_show .pro_show_over').length&&qPhotoL.parent().find('.sImg').length){jQuery('.enlarge-con').width('370px');jQuery('.enlarge-con .sImg').replaceWith(qPhotoL.parent().find('.sImg').clone());jQuery('.prevDetail').addClass("prevDetailW365")}else{jQuery('.enlarge-con').width('auto');jQuery('.enlarge-con .sImg').empty();jQuery('.enlarge-con .sImg').attr("style","padding:0");jQuery('.prevDetail').removeClass("prevDetailW365")}var smallImgs=jQuery('.enlarge-con .sImg').find(' img');smallImgs.each(function(){var samllImgObj=new Image();var smallImg=jQuery(this);samllImgObj.src=smallImg.attr('src');var cssSmallImg={'width':samllImgObj.width+'px','height':samllImgObj.height+'px'};if(samllImgObj.width>40||samllImgObj.height>40){if(samllImgObj.width>=samllImgObj.height){cssSmallImg.height=parseInt(40*samllImgObj.height/samllImgObj.width)+'px';cssSmallImg.width=40+'px'}else{cssSmallImg.width=parseInt(40*samllImgObj.width/samllImgObj.height)+'px';cssSmallImg.height=40+'px'}}smallImg.css(cssSmallImg)});var conTop=parseInt(qPhotoL.position().top);var conLeft=parseInt(qPhotoL.position().left);var enLargeWidth=parseInt(jQuery('.enlarge-con').width());var enLargeHeight=parseInt(jQuery('.enlarge-con').height());conLeft='.Photo160'!=photoOri?conLeft+104:conLeft+192;var viewWidth=((document.documentElement&&(document.documentElement.clientWidth+document.documentElement.scrollLeft))||(document.body&&(document.body.clientWidth+document.body.scrollLeft)));var viewTop=((document.documentElement&&(document.documentElement.clientHeight+(document.documentElement.scrollTop+document.body.scrollTop)))||(document.body&&(document.body.clientHeight+document.body.scrollTop)));var bChangeArrow='.image'==photoOri?true:(qPhotoL.position().left-enLargeWidth-28>0&&(conLeft+enLargeWidth)>viewWidth);var photoAlt=qPhotoL.find(photoOri+' img').attr('alt');var photoHref=qPhotoL.find(photoOri+' a').attr('href');var qImg=jQuery('.enlarge-con .photo300 > a img');if(!+'\v1'&&!window.XMLHttpRequest){qImg.hide()}else{qImg.attr({'alt':photoAlt,'src':loadingImg.src}).css({'width':'auto','height':'auto'})}var compareTop=0;var arrowTop='.Photo160'!=photoOri?45:85;if(conTop+enLargeHeight>viewTop){compareTop=conTop+enLargeHeight-viewTop+23;arrowTop-=20;arrowTop=arrowTop+compareTop-20}else if(viewTop-conTop>document.documentElement.clientHeight){compareTop=conTop-(document.documentElement.scrollTop+document.body.scrollTop)-2;if(arrowTop==85){arrowTop=conTop-(document.documentElement.scrollTop+document.body.scrollTop)+arrowTop+50}else{arrowTop=conTop-(document.documentElement.scrollTop+document.body.scrollTop)+arrowTop+20}}var cssArrow={'left':'auto','right':'auto'};cssArrow.top=arrowTop+'px';if(bChangeArrow){conLeft=qPhotoL.position().left-enLargeWidth-28;cssArrow.right='-11px'}else{cssArrow.left='-11px'}jQuery('.enlarge-con').find('.arrow-left,.arrow-right').toggleClass('arrow-left',!bChangeArrow).toggleClass('arrow-right',bChangeArrow).css(cssArrow).end().find('a').attr({'href':photoHref,'title':photoAlt}).end().css({'left':conLeft+'px','top':conTop-compareTop+'px'}).show().find('.sImg').show();newPhoto.src = "#";newPhoto.src=photoSRC},100)};var conOverFunc=function(){clearTimeout(EnlargeImgTimer)};var conOutFunc=imgOutFunc=function(){clearTimeout(EnlargeImgTimer);EnlargeImgTimer=setTimeout(function(){jQuery('.enlarge-con').hide()},100)};var smallImgOver=function(){clearTimeout(EnlargeImgTimer);var target=jQuery(this);EnlargeImgTimer=setTimeout(function(){var qSimg=jQuery('.enlarge-con .sImg');qSimg.find('div').removeClass('on');qSimg.find('div').find('div').removeClass();target.parent().addClass('on');var smallSRC=target.find(' img').attr('src');var smallAlt=target.find(' img').attr('alt');var photoHref=jQuery('enlarge-con .photo300 >  a').attr('href');smallSRC=smallSRC.replace(/\/2f1/,'/2f0').replace(/\/8f5/,'/8f6').replace(/\/4f2/,'/4f0');var originImgs=jQuery('.enlarge-con').find('.photo300 img');var originImg=new Image();originImg.src=smallSRC;var cssOriginImg={'width':originImg.width+'px','height':originImg.height+'px'};if(originImg.width>300||originImg.height>300){if(originImg.width>=originImg.height){cssOriginImg.height=parseInt(300*originImg.height/originImg.width)+'px';cssOriginImg.width=300+'px'}else{cssOriginImg.width=parseInt(300*originImg.width/originImg.height)+'px';cssOriginImg.height=300+'px'}}jQuery('.enlarge-con .photo300 > a img').css(cssOriginImg).attr('src',smallSRC).attr('alt',smallAlt);var conLeft=parseInt(jQuery('.enlarge-con').position().left);var conTop=parseInt(jQuery('.enlarge-con').position().top);jQuery('.enlarge-con .photo300').find('a').attr({'href':photoHref,'title':smallAlt}).end().css({'left':conLeft+'px','top':conTop+'px'}).show();newPhoto.src=smallSRC},100)};if(!+'\v1'&&!window.XMLHttpRequest){jQuery('.enlarge-con').append(window.zMaskIframe);jQuery('.enlarge-con .photo300').css('background','#fff url(/images/loading_nail.gif) no-repeat center');try{document.execCommand('BackgroundImageCache',false,true)}catch(e){}}jQuery(photoOri+' img[class!="pia"]:not([src*="/safe_image"]):not([src*="/no_photo"]):not([name*="multiToprank"])').hover(imgOverFunc,imgOutFunc);jQuery('.enlarge-icon').hover(imgOverFunc,imgOutFunc);jQuery('.enlarge-con').hover(conOverFunc,conOutFunc);jQuery('.enlarge-con #small_0').live("mouseover",smallImgOver);jQuery('.enlarge-con #small_1').live("mouseover",smallImgOver);jQuery('.enlarge-con #small_2').live("mouseover",smallImgOver);jQuery('.enlarge-con #small_3').live("mouseover",smallImgOver);jQuery('.enlarge-con #small_4').live("mouseover",smallImgOver);jQuery('.enlarge-con #small_5').live("mouseover",smallImgOver)};if(jQuery('.PhotoL').length&&jQuery('.Photo100').length){EnlargeImgFunc('.PhotoL','.Photo100')}else{if(jQuery('.item').length&&jQuery('.Photo160').length){EnlargeImgFunc('.item','.Photo160')}else{if(jQuery('.pro_show').length&&jQuery('.image').length){EnlargeImgFunc('.pro_show','.image')}}}})();
