/* 
Wrangler Javascript
Date Created: 12th July, 2010
Author: Liza Nguyen
*/

$(document).ready(function(){$(function(){var zIndexNumber=900;$('.MainNav *, .MainPanel, .LeftNavPanel').each(function(){$(this).css('zIndex',zIndexNumber);zIndexNumber-=10;});});$('.MainNav > ul > li[class!="active"] > ul').addClass("floatingSubNav").hide();$(".MainNav li:not(.active) ul:not(.floatingSubNav)").hide();$("ul.floatingSubNav").each(function(){var navPos=$(this).parent().find("a:first").width()+14;$(this).css("left",navPos+"px");});$(".MainNav > ul > li").hover(function(){$(this).find("ul.floatingSubNav").css("display","inline-block").find("ul").show();},function(){$(this).find("ul.floatingSubNav").css("display","none").find("ul").hide();});$(".mapLink").click(function(){parent.location="#mapSection"});$(".externalLink").click(function(){window.open($(this).attr('href'));return false});$("input.textbox").each(function(){var defaultValue=$(this).val();$(this).focus(function(){if($(this).val()==defaultValue){$(this).val("")}}).blur(function(){if($(this).val()==""){$(this).val(defaultValue)}})});$(".MainPanel a span").parent().hover(function(){$(this).addClass("hover")},function(){$(this).removeClass("hover")});if(!($.browser.msie)){$("select").sSelect({ddMaxHeight:250})}
$(".jqmWindow").appendTo("body").css("position","absolute").hide();$("#NewsletterSubscribe").css({"top":"17%","left":"50%","margin-left":"-180px"}).jqm({trigger:".openModal",overlay:80,onShow:function(h){h.w.fadeIn(800)},onHide:function(h){h.w.fadeOut(500,function(){if(h.o){h.o.remove()}
$("#SubscribeForm").show();$("#ThankYou").hide()})}});$("#NewsletterSubscribe").jqmAddClose(".closeModal a, .close");$("#btnSend").click(function(){$.ajax({type:"POST",url:$("#ajax-form").attr("action"),data:$("#ajax-form").serialize(),success:function(msg){var response=jQuery.deparam(msg);if(response.success=="true"){$("#SubscribeForm").fadeOut(500);setTimeout('$("#ThankYou").fadeIn(500);',500)}else{if(response.code>0){alert(response.message)}else{alert("Sorry there has been a technical problem processing your subscription. Please send an email to info@wrangler.com.au instead.")}}},error:function(msg){alert("Sorry, there has been a technical issue while sending your request to the server.")}});return false});$("#DOB").datepicker({changeMonth:true,changeYear:true,dateFormat:'dd/mm/yy',yearRange:'1930:2010'});if($(".lookbook div, .collection div").hasClass("mainFeature")){detailFeature();$("#zoomGalleryModal").css({"margin-left":"-393px","top":"10%","left":"50%","z-index":999})}
$(".collection .secondaryFeature .grid li.active a, .collection .secondaryFeature .grid li.active a.hover").each(function(){$(this).find("span").css("cursor","default");$(this).css("cursor","default").click(function(){return false})});$(".collection .secondaryFeature .grid li.active a, .collection .secondaryFeature .grid li.active a.hover").css("cursor","default").click(function(){$(this).find("span").css("cursor","default");return false});if($(".homeModuleWrap").hasClass("homeModuleWrap")&&($(".Slides > .slide").length>1)){$('.Slides').append("<div class='pager'><a href='#prev' title='Previous' class='prev'>Previous</a><a href='#next' title='Next' class='next'>Next</a><div class='counter'></div></div>").cycle(carouselConfig)}
if($(".ContentPanel .Campaign").hasClass("Campaign")){$(".jqmWindow[id*=gallery]").each(function(i){var galleryId=i+1;var maxWidth=962;var slides=".slides";$(this).modalGallery(maxWidth,".zoom"+galleryId,slides,"prev"+galleryId,"next"+galleryId)})}
if($(".ContentPanel .fitGuide").hasClass("fitGuide")){var currentPage=window.location;if($(".Slides > div.slide").length>1){$("#zoomGalleryModal").addModalNav("lrgPrev","lrgNext")}
$("ul.imageNav").prepend("<li><a href='#' title='View larger version of image' class='zoom'>Zoom</a></li>");$("ul.imageNav").append('<li class="like"><iframe src="http://www.facebook.com/plugins/like.php?href='+currentPage+'&layout=button_count&show_faces=true&width=90&action=like&colorscheme=dark&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px; background: none;" allowTransparency="true"></iframe></li>');$('.Slides').cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',slideExpr:'div.slide',prev:'a.prev',next:'a.next',pager:'.invisiblePager',pagerAnchorBuilder:function(idx,slide){return'<div><a href="#">'+slide.getElementsByTagName("a")[0].className+'</a></div>'}});$('.Slides').cycle("pause");$("#zoomGalleryModal").jqm({trigger:".zoom, .Slides .slide a",overlay:80,onShow:function(h){h.w.fadeIn(800,function(){$("#zoomGallery").cycle("resume")})},onHide:function(h){h.w.fadeOut(500,function(){if(h.o){h.o.remove()}
$("#zoomGallery").cycle("pause")})}}).jqmAddClose(".closeModalGallery a");$('#zoomGallery').cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',prev:'a.lrgPrev',next:'a.lrgNext'}).cycle("pause").css("width","768px");$('#zoomGallery img').each(function(){var width=$(this).css("width").toString();var widthInt=width.match(/\d+/);if(widthInt<786){var padding=(786-widthInt)/2;$(this).css("padding","0 "+padding+"px")}});$('.zoom, .Slides .slide a').click(function(){$(".activeSlide").goToSlide("#zoomGallery");return false});$("#zoomGalleryModal").css({"margin-left":"-393px","top":"10%","left":"50%","z-index":999});$(".secondaryFeature .grid li a").each(function(){var imageClass=$(this).attr("class");var imageNumber=imageClass.match(/\d+/);$(this).click(function(){$(".Slides").cycle(imageNumber-1);return false})})}
if($(".press div").hasClass("mainFeature")){pressFeature();$("#zoomGalleryModal").css({"margin-left":"-270px","top":"10%","left":"50%","z-index":999});$("#zoomGallery").css("width","540px")}});var carouselConfig={fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',slideExpr:'div.slide',prev:'a.prev',next:'a.next',after:function(currSlideElement,nextSlideElement,options){var caption=(options.currSlide+1);$('.counter').html(caption+"/"+options.slideCount)}};$.fn.cycle.updateActivePagerLink=function(pager,currSlideIndex){$(pager).find('div').removeClass('activeSlide').filter('div:eq('+currSlideIndex+')').addClass('activeSlide');if($("#ContentPanel .fitGuide").hasClass("fitGuide")){$(".secondaryFeature .grid").find("li").removeClass('active').filter('li:eq('+currSlideIndex+')').addClass('active')}};$.fn.goToSlide=function(gallery){var slideClass=$(this).text();var slideID=(slideClass.match(/\d+$/))-1;$(gallery).cycle(slideID)};$.fn.addModalNav=function(previous,next){$(this).prepend("<a href='#prev' title='Previous' class='"+previous+" modalPrev'>Previous</a><a href='#next' title='Next' class='"+next+" modalNext'>Next</a>")};function detailFeature(){var currentPage=window.location;if($(".Slides > div.slide").length>1){$("ul.imageNav").prepend("<li><a href='#' title='Previous' class='prev'>Previous</a></li><li><a href='#' title='Next' class='next'>Next</a></li><li><a href='#' title='View larger version of image' class='zoom'>Zoom</a></li>");$("#zoomGalleryModal").addModalNav("lrgPrev","lrgNext")}else{$("ul.imageNav").prepend("<li><a href='#' title='View larger version of image' class='zoom'>Zoom</a></li>")}
$("ul.imageNav").append('<li class="like"><iframe src="http://www.facebook.com/plugins/like.php?href='+currentPage+'&layout=button_count&show_faces=true&width=90&action=like&colorscheme=dark&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:90px; height:21px; background: none;" allowTransparency="true"></iframe></li>');$('.Slides').cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',slideExpr:'div.slide',prev:'a.prev',next:'a.next',pager:'.invisiblePager',pagerAnchorBuilder:function(idx,slide){return'<div><a href="#">'+slide.getElementsByTagName("a")[0].className+'</a></div>'}});$("#zoomGalleryModal").jqm({trigger:".zoom, .Slides .slide a",overlay:80,onShow:function(h){h.w.fadeIn(800,function(){$('.Slides').cycle("pause");$("#zoomGallery").cycle("resume")})},onHide:function(h){h.w.fadeOut(500,function(){if(h.o){h.o.remove()}
$('.Slides').cycle('resume');$("#zoomGallery").cycle("pause").css("width","768px")})}}).jqmAddClose(".closeModalGallery a");$('#zoomGallery').cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',prev:'a.lrgPrev',next:'a.lrgNext'}).cycle("pause").css("width","768px");$('#zoomGallery img').each(function(){var width=$(this).css("width").toString();var widthInt=width.match(/\d+/);if(widthInt<786){var padding=(786-widthInt)/2;$(this).css("padding","0 "+padding+"px")}});$('.zoom,.Slides .slide a').click(function(){$(".activeSlide").goToSlide("#zoomGallery");return false})}
$.fn.modalGallery=function(maxWidth,modalTrigger,slideWrapper,prevBtn,nextBtn){var centreMargin="-"+(maxWidth/2)+"px";$(this).css({"margin-left":centreMargin,"top":"10%","left":"50%","z-index":999}).jqm({trigger:modalTrigger,overlay:80,onShow:function(h){h.w.fadeIn(800,function(){$(this).find(slideWrapper).cycle("resume")})},onHide:function(h){h.w.fadeOut(500,function(){if(h.o){h.o.remove()};$(this).find(slideWrapper).cycle("pause")})}});$(this).addModalNav(prevBtn,nextBtn);$(this).find(slideWrapper).cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',prev:"a."+prevBtn,next:"a."+nextBtn}).cycle("pause").css("width",maxWidth+"px");$(this).jqmAddClose(".closeModalGallery");$(modalTrigger).click(function(){window.location="#"});$(this).find("img").each(function(){var width=$(this).css("width").toString();var widthInt=width.match(/\d+/);if(widthInt<maxWidth){var padding=(maxWidth-widthInt)/2;$(this).css("padding","0 "+padding+"px")}})};function pressFeature(){if($(".featuredPress > div.slide").length>1){$('.featuredPress').append("<div class='pager'><a href='#prev' title='Previous' class='prev'>Previous</a><a href='#next' title='Next' class='next'>Next</a><div class='counter'></div></div>").cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',slideExpr:'div.slide',prev:'a.prev',next:'a.next',after:function(currSlideElement,nextSlideElement,options){var caption=(options.currSlide+1);$('.counter').html("<span>"+caption+"</span>"+"/"+options.slideCount)}});$("#zoomGalleryModal").addModalNav("lrgPrev","lrgNext")}
$("#zoomGalleryModal").jqm({trigger:".featuredPress .slide a",overlay:80,onShow:function(h){h.w.fadeIn(800,function(){$('.featuredPress').cycle("pause");$("#zoomGallery").cycle("resume")})},onHide:function(h){h.w.fadeOut(500,function(){if(h.o){h.o.remove()}
$('.featuredPress').cycle('resume');$("#zoomGallery").cycle("pause")})}}).jqmAddClose(".closeModalGallery a");$('#zoomGallery').cycle({fx:'scrollHorz',speed:1000,timeout:5000,easing:'swing',prev:'a.lrgPrev',next:'a.lrgNext'}).cycle("pause");$('#zoomGallery img').each(function(){var width=$(this).css("width").toString();var widthInt=width.match(/\d+/);if(widthInt<540){var padding=(540-widthInt)/2;$(this).css("padding","0 "+padding+"px")}});$('.featuredPress .slide a').click(function(){$(".counter span").goToSlide("#zoomGallery");return false})}
