(function(a){function n(a,b){var a=a.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]"),m=RegExp("[\\?&]"+a+"=([^&#]*)").exec(b);return m==null?"":m[1]}var b,o;a.fn.mytyLightbox=function(d){function z(){e=="mytyArea"||e=="iframe"||(b.find(".pp_hoverContainer,.pp_details").fadeOut(d.animationSpeed),b.find("#pp_full_res object,#pp_full_res embed").css("visibility","hidden"));a(".pp_loaderIcon").show();v()}function m(b){b=="previous"?(arrayPosition--,j--):(arrayPosition++,j++);l||(l=!0);z();a("a.pp_expand,a.pp_contract").fadeOut(d.animationSpeed, function(){a(this).removeClass("pp_contract").addClass("pp_expand")})}function w(){b.find("object,embed").css("visibility","hidden");a("a.pp_close").css("display","none");e=="mytyArea"?a("#mytyLightboxOverlay,div.pp_pic_holder,div.ppt").hide().remove():(a("div.pp_pic_holder,div.ppt").fadeOut(d.animationSpeed),a("#mytyLightboxOverlay,div.pp_pic_holder,div.ppt").remove());a.browser.msie&&a.browser.version==6&&a("select").css("visibility","visible");d.callback();l=!0;a("html").css("overflow","")}function E(){j== setCount?(b.find("a.pp_next").css("visibility","hidden"),b.find("a.pp_arrow_next").addClass("disabled").unbind("click")):(b.find("a.pp_next").css("visibility","visible"),b.find("a.pp_arrow_next.disabled").removeClass("disabled").bind("click",function(){m("next");return!1}));j==1?(b.find("a.pp_previous").css("visibility","hidden"),b.find("a.pp_arrow_previous").addClass("disabled").unbind("click")):(b.find("a.pp_previous").css("visibility","visible"),b.find("a.pp_arrow_previous.disabled").removeClass("disabled").bind("click", function(){m("previous");return!1}));b.find("p.currentTextHolder").text(j+d.counter_separator_label+setCount);c=isSet?a(k[arrayPosition]):c;A();c.find("img").attr("alt")&&d.showTitle?(hasTitle=!0,o.html(unescape(c.find("img").attr("alt")))):hasTitle=!1}function B(b,c){hasBeenResized=!1;C(b,c);imageWidth=b;imageHeight=c;windowHeight=a(window).height();windowWidth=a(window).width();if((s>windowWidth||p>windowHeight)&&l&&d.allowresize&&!F){for(notFitting=hasBeenResized=!0;notFitting;)s>windowWidth?(imageWidth= windowWidth-200,imageHeight=c/b*imageWidth):p>windowHeight?(imageHeight=windowHeight-200,imageWidth=b/c*imageHeight):notFitting=!1,p=imageHeight,s=imageWidth;C(imageWidth,imageHeight)}return{width:imageWidth,height:imageHeight,containerHeight:p,containerWidth:s,contentHeight:q,contentWidth:x,resized:hasBeenResized}}function C(a,c){b.find(".pp_details").width(a);e=="mytyArea"?(q==0&&(q=c,p=q+b.find(".ppt").height()+b.find(".pp_top").height()+b.find(".pp_bottom").height()),x=a):(q=c+b.find(".pp_details").height()+ parseFloat(b.find(".pp_details").css("marginTop"))+parseFloat(b.find(".pp_details").css("marginBottom")),x=a,p=q+b.find(".ppt").height()+b.find(".pp_top").height()+b.find(".pp_bottom").height());s=a+d.padding}function A(){e=c.attr("href").match(/youtube\.com\/watch/i)?"youtube":c.attr("href").indexOf(".mov")!=-1?"quicktime":c.attr("href").indexOf(".swf")!=-1?"flash":c.attr("rel").indexOf("mytyLightboxIframe")!=-1||c.attr("href").indexOf("iframe")!=-1?"iframe":c.attr("rel").indexOf("mytyArea")!=-1? "mytyArea":"image"}function y(){if(b&&b.size()!=0)a.browser.opera?(windowHeight=window.innerHeight,windowWidth=window.innerWidth):(windowHeight=a(window).height(),windowWidth=a(window).width()),l&&($pHeight=b.height(),$pWidth=b.width(),$tHeight=o.height(),projectedTop=windowHeight/2+r.scrollTop-$pHeight/2,projectedTop<0&&(projectedTop=0+$tHeight),b.css({top:projectedTop,left:windowWidth/2+r.scrollLeft-$pWidth/2}),o.css({top:projectedTop-$tHeight,left:windowWidth/2+r.scrollLeft-$pWidth/2+d.padding/ 2}))}function v(){E();var h=c.attr("class");if(e=="image"){imgPreloader=new Image;nextImage=new Image;if(isSet&&j>setCount)nextImage.src=a(k[arrayPosition+1]).attr("href");prevImage=new Image;if(isSet&&k[arrayPosition-1])prevImage.src=a(k[arrayPosition-1]).attr("href");pp_typeMarkup='<img id="fullResImage" src="" />';b.find("#pp_full_res")[0].innerHTML=pp_typeMarkup;b.find(".pp_content").css("overflow","hidden");b.find("#fullResImage").attr("src",c.attr("href"));imgPreloader.onload=function(){var a= B(imgPreloader.width,imgPreloader.height);imgPreloader.width=a.width;imgPreloader.height=a.height;showimage(imgPreloader.width,imgPreloader.height,a.containerWidth,a.containerHeight,a.contentHeight,a.contentWidth,a.resized)};imgPreloader.src=c.attr("href")}else{movie_width=parseFloat(n("width",c.attr("href")))?n("width",c.attr("href")):"800";movie_height=parseFloat(n("height",c.attr("href")))?n("height",c.attr("href")):"580";movie_width.indexOf("%")!=-1||movie_height.indexOf("%")!=-1?(movie_height= a(window).height()*parseFloat(movie_height)/100-100,movie_width=a(window).width()*parseFloat(movie_width)/100-100,parsentBased=!0):(movie_height=parseFloat(movie_height),movie_width=parseFloat(movie_width));e=="quicktime"&&(movie_height+=13);if(h.indexOf("mytyLightbox-d-")!=-1){var f=h.substring(h.indexOf("mytyLightbox-d-"));f.indexOf(" ")!=-1&&(f=f.substring(0,f.indexOf(" ")));f=f.replace("mytyLightbox-d-","").split("x");correctSizes={width:f[0],height:f[1],containerHeight:f[1],containerWidth:800, contentHeight:f[1],contentWidth:f[0],resized:!1}}else correctSizes=B(movie_width,movie_height);pp_typeMarkup=!1;e=="youtube"?pp_typeMarkup='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="'+correctSizes.width+'" height="'+correctSizes.height+'"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://www.youtube.com/v/'+n("v",c.attr("href"))+'" /><embed src="http://www.youtube.com/v/'+n("v",c.attr("href"))+ '" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="'+correctSizes.width+'" height="'+correctSizes.height+'"></embed></object>':e=="quicktime"?pp_typeMarkup='<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" height="'+correctSizes.height+'" width="'+correctSizes.width+'"><param name="src" value="'+c.attr("href")+'"><param name="autoplay" value="true"><param name="type" value="video/quicktime"><embed src="'+ c.attr("href")+'" height="'+correctSizes.height+'" width="'+correctSizes.width+'" autoplay="true" type="video/quicktime" pluginspage="http://www.apple.com/quicktime/download/"></embed></object>':e=="flash"?(flash_vars=c.attr("href"),flash_vars=flash_vars.substring(c.attr("href").indexOf("flashvars")+10,c.attr("href").length),filename=c.attr("href"),filename=filename.substring(0,filename.indexOf("?")),pp_typeMarkup='<div id="mytyLightBoxFlashContent" class="mytyLBContent">mytyFlash</div>'):e=="iframe"? (movie_url=c.attr("href"),movie_url.indexOf("iframe")!=-1&&(movie_url=movie_url.substr(0,movie_url.indexOf("iframe")-1)),pp_typeMarkup='<div class="mytyLBContent mytyLBStandard"><div id="fashiondetail"><div class="article-detail-headline"><h1 class="detailH1">'+c.attr("title")+'</h1></div><div class="'+h+'"><iframe id="mytyLightBoxIFrame" src ="'+movie_url+'" width="'+correctSizes.width+'" height="'+correctSizes.height+'" frameborder="0" scrolling="no"></iframe></div></div></div>'):e=="mytyArea"&& a("#mytyLightBoxAjaxContent").length!==1&&(pp_typeMarkup='<div id="mytyLightBoxAjaxContent" class="mytyLBContent">mytyArea</div>');if(pp_typeMarkup!=!1)b.find("#pp_full_res")[0].innerHTML=pp_typeMarkup;if(e=="mytyArea"){var g=c.attr("href");document.location.protocol=="https:"&&(g=g.replace("http:","https:"));g=g.replace(/shop_art_id/gi,"loadByMytyLightBox/1/shop_art_id");h=g.indexOf("#");h>0&&(g=g.substr(0,h));h=t.length;f=!1;if(h>20)u=[],t=[],h=0;else if(h>0)for(i=0;i<h;i++)if(g==t[i]){u[i]!=""&& (f=u[i]);break}typeof pageTracker!="undefined"&&pageTracker._trackPageview(g);f!==!1?(a("#mytyLightBoxAjaxContent").html(f),showimage(correctSizes.width,correctSizes.height,correctSizes.containerWidth,correctSizes.containerHeight,correctSizes.contentHeight,correctSizes.contentWidth,correctSizes.resized),d.openCallback()):a("#mytyLightBoxAjaxContent").load(g,function(){t.push(g);u.push(a("#mytyLightBoxAjaxContent").html());showimage(correctSizes.width,correctSizes.height,correctSizes.containerWidth, correctSizes.containerHeight,correctSizes.contentHeight,correctSizes.contentWidth,correctSizes.resized);d.openCallback()})}else e=="flash"&&swfobject.embedSWF(filename+"?"+flash_vars,"mytyLightBoxFlashContent",correctSizes.width,correctSizes.height,"9.0.0","",{debug:!1},{allowScriptAccess:"always",allowfullscreen:!0,wmode:"transparent",scale:"noScale",menu:!1,movie:filename},{});e!=="mytyArea"&&showimage(correctSizes.width,correctSizes.height,correctSizes.containerWidth,correctSizes.containerHeight, correctSizes.contentHeight,correctSizes.contentWidth,correctSizes.resized)}}function D(){if(self.pageYOffset)scrollTop=self.pageYOffset,scrollLeft=self.pageXOffset;else if(document.documentElement&&document.documentElement.scrollTop)scrollTop=document.documentElement.scrollTop,scrollLeft=document.documentElement.scrollLeft;else if(document.body)scrollTop=document.body.scrollTop,scrollLeft=document.body.scrollLeft;return{scrollTop:scrollTop,scrollLeft:scrollLeft}}function G(){toInject="";toInject+= '<div id="mytyLightboxOverlay" class="mytyOverlay"></div>';pp_typeMarkup=e=="image"?'<img id="fullResImage" src="" />':"";toInject+='<div class="pp_pic_holder"><div class="pp_top"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div> <div class="pp_content"><a href="#" class="pp_expand" title="Expand the image">Expand</a><div class="pp_loaderIcon"></div><div class="pp_hoverContainer"><a class="pp_next" href="#">next</a><a class="pp_previous" href="#">previous</a></div><div id="pp_full_res">'+ pp_typeMarkup+'</div><div class="pp_details clearfix"><div class="pp_nav"><a href="#" class="pp_arrow_previous">Previous</a><p class="currentTextHolder">0'+d.counter_separator_label+'0</p><a href="#" class="pp_arrow_next">Next</a></div></div></div><div class="pp_bottom"><div class="pp_left"></div><div class="pp_middle"></div><div class="pp_right"></div></div><a class="pp_close mytyLBClose" href="#"></a></div>';toInject+='<div class="ppt"></div>';a("body").append(toInject);b=a(".pp_pic_holder");o= a(".ppt");a("#mytyLightboxOverlay").css("height",a(document).height()).bind("click",function(){w()});b.css({opacity:0}).addClass(d.theme);a("a.pp_close").bind("click",function(){w();return!1});a("a.pp_expand").bind("click",function(){$this=a(this);$this.hasClass("pp_expand")?($this.removeClass("pp_expand").addClass("pp_contract"),l=!1):($this.removeClass("pp_contract").addClass("pp_expand"),l=!0);z();b.find(".pp_hoverContainer, #pp_full_res, .pp_details").fadeOut(d.animationSpeed,function(){v()}); return!1});b.find(".pp_previous, .pp_arrow_previous").bind("click",function(){m("previous");return!1});b.find(".pp_next, .pp_arrow_next").bind("click",function(){m("next");return!1});b.find(".pp_hoverContainer").css({"margin-left":d.padding/2});isSet||(e=="mytyArea"||e=="iframe"?b.find(".pp_hoverContainer,.pp_arrow_previous,.pp_arrow_next").hide():b.find(".pp_hoverContainer,.pp_nav").hide());a.browser.msie&&a.browser.version==6&&(a("body").addClass("ie6"),a("select").css("visibility","hidden"));a("#mytyLightboxOverlay").show(); b.css("opacity",0).fadeIn(d.animationSpeed,function(){b.attr("style","left:"+b.css("left")+";top:"+b.css("top")+";")});v()}var l=!0,F=!1,k=[],j=0,q=0,x=0,p=0,s=0,e="image",u=[],t=[],c,r=D();a(window).scroll(function(){r=D();y()});a(window).resize(function(){y();a("#mytyLightboxOverlay").css({height:a(document).height(),width:a(window).width()})});a(document).keypress(function(a){switch(a.keyCode){case 27:w()}});d=jQuery.extend({animationSpeed:"normal",padding:40,opacity:0.8,showTitle:!0,allowresize:!1, counter_separator_label:"/",theme:"light_rounded",contentHeight:!1,contentWidth:!1,callback:function(){},openCallback:function(){}},d);if(a.browser.msie&&a.browser.version==6)d.theme="light_square";a(this).each(function(){k[k.length]=this;a(this).unbind("click");a(this).bind("click",function(){c=a(this);a(".pp_loaderIcon").show();theRel=c.attr("rel");galleryRegExp=/\[(?:[^\]]*)\]/;theGallery=galleryRegExp.exec(theRel);isSet=!1;setCount=0;A();for(i=0;i<k.length;i++)a(k[i]).attr("rel").indexOf(theGallery)!= -1&&(setCount++,setCount>1&&(isSet=!0),a(k[i]).attr("href")==c.attr("href")&&(j=setCount,arrayPosition=i));G();b.find("p.currentTextHolder").text(j+d.counter_separator_label+setCount);y();a("#pp_full_res").hide();return!1})});showimage=function(c,f,g,k,j,m,l){a(".pp_loaderIcon").hide();if(d.contentHeight!=!1)j=d.contentHeight;a.browser.opera?(windowHeight=window.innerHeight,windowWidth=window.innerWidth):(windowHeight=a(window).height(),windowWidth=a(window).width());b.find(".pp_content").animate({height:j}, d.animationSpeed);projectedTop=d.contentHeight!=!1?r.scrollTop+(windowHeight/2-d.contentHeight/2):r.scrollTop+(windowHeight/2-k/2);projectedTop<0&&(projectedTop=0+b.find(".ppt").height());b.animate({top:projectedTop,left:windowWidth/2-g/2,width:g},d.animationSpeed,function(){b.width(g);e!="mytyArea"?b.find(".pp_hoverContainer,#fullResImage").height(f).width(c):b.find("#fullResImage").height(f).width(c);b.find("#pp_full_res,.pp_details").fadeIn(d.animationSpeed,function(){a(this).find("object,embed").css("visibility", "visible")});isSet&&e=="image"?b.find(".pp_hoverContainer").fadeIn(d.animationSpeed):e!="mytyArea"?(b.find(".pp_details").fadeIn(d.animationSpeed),a(".pp_hoverContainer").hide()):b.find(".pp_hoverContainer").hide();d.showTitle&&hasTitle&&(o.css({top:b.offset().top-22,left:b.offset().left+d.padding/2,display:"none"}),o.fadeIn(d.animationSpeed));l&&a("a.pp_expand,a.pp_contract").fadeIn(d.animationSpeed);a("a.pp_close").fadeIn(d.animationSpeed)})}}})(jQuery);
