var HL = (function(jQuery){
	
	return {
	
		init: function(){
			
		var that = this;
							
		jQuery('.hl_productDetailsContainer ul').hide(1,function(){
			jQuery(this).prev().toggleClass('hl_productDetailsClosed');
		});
		
		jQuery('.hl_productDetailsToggle').live('click',function(){
			jQuery('.hl_productDetailsContainer ul').slideToggle(500,function(){
				jQuery(this).prev().toggleClass('hl_productDetailsClosed');
			});
		});
		
		jQuery('.hl_notifyMeToggle').live('click',function(){
			jQuery('.hl_notifyMe').slideToggle(500);
		});
		
		
		jQuery('.hl_sizePickerToggle').live('click',function(){
			jQuery(this).next().toggle();
		});
		
		jQuery('.hl_sizePicker').bind('mouseleave',function(evt){
			if(jQuery(this).next().css('display')=='block'){
			jQuery('.hl_sizePicker ul').css('display','none');
			}
		});
		
		jQuery('#hl_filmstrip_container.open .hl_filmstripToggle').text('CLOSE SHOP NAVIGATION');
		
		jQuery('#hl_filmstrip_container.open .hl_filmstripToggle').attr('title','CLOSE SHOP NAVIGATION');
		
		jQuery('.hl_filmstripToggle').live('click',function(){
			if(jQuery('#hl_filmstrip_container').css('bottom')!=='19px'){
			jQuery('#hl_filmstrip_container').animate({ bottom: 19 },250,function(){
				jQuery('.hl_filmstripToggle').toggleClass('hl_filmstripOpen');
				jQuery('.hl_filmstripToggle').text('CLOSE SHOP NAVIGATION');
				jQuery('.hl_flimstripToggle').attr('title','CLOSE SHOP NAVIGATION');
			});
			} else {
			jQuery('#hl_filmstrip_container').animate({ bottom: -92 },250,function(){
				jQuery('.hl_filmstripToggle').toggleClass('hl_filmstripOpen');
				jQuery('.hl_filmstripToggle').text('MORE FROM THE SHOP');
				jQuery('.hl_flimstripToggle').attr('title','MORE FROM THE SHOP');
			});	
			} 
		});
		
		jQuery('#hl_filmstrip_container_look .hl_filmstripToggle').live('click',function(){
			if(jQuery('#hl_filmstrip_container_look').css('bottom')!=='19px'){
			jQuery('#hl_filmstrip_container_look').animate({ bottom: 19 },250,function(){
				jQuery('.hl_filmstripToggle').toggleClass('hl_filmstripOpen');
				jQuery('.hl_filmstripToggle').text('MORE FROM THE SHOP');
				jQuery('.hl_flimstripToggle').attr('title','MORE FROM THE SHOP');
				jQuery('.hl_lookProducts').fadeToggle(100);
				jQuery('#hl_shopTheLook').addClass("clickable");
				jQuery('#hl_shopTheLook').bind("click", function(){
					jQuery('#hl_filmstrip_container_look .hl_filmstripToggle').click();
				});
			});
			} else {
			jQuery('#hl_filmstrip_container_look').animate({ bottom: -92 },250,function(){
				jQuery('.hl_filmstripToggle').toggleClass('hl_filmstripOpen');
				jQuery('.hl_filmstripToggle').text('CLOSE SHOP NAVIGATION');
				jQuery('.hl_flimstripToggle').attr('title','CLOSE SHOP NAVIGATION');
				jQuery('.hl_lookProducts').fadeToggle(100);
				jQuery('#hl_shopTheLook').unbind("click");
				jQuery('#hl_shopTheLook').removeClass("clickable");
			});	
			} 
		});
		
		jQuery('#storelocator select.country').bind('change', function(){
						
			if(($(this).val().length > 0) && ($(this).val() != 'US')){
				$('.storelocatorsearch').hide();
				$('.domestic').hide();
			} else {
				$('.storelocatorsearch').show();
				$('.domestic').show();
			}
			
		});
		
		$('.twitter.popup').click(function(event) {
		    var width  = 575,
		        height = 400,
		        left   = ($(window).width()  - width)  / 2,
		        top    = ($(window).height() - height) / 2,
		        url    = this.href,
		        opts   = 'status=1' +
		                 ',width='  + width  +
		                 ',height=' + height +
		                 ',top='    + top    +
		                 ',left='   + left;
		    
		    window.open(url, 'twitter', opts);
		 
		    return false;
		});
		
		$('#hl_share_button').bind('click', function(){
			$('#hl_share_button').toggleClass('open');
			$('.social_dropdown').toggleClass('open');
		});
		
		window.onload = function(){
			var frame = $('.fb_ltr');
		};
		
		if(jQuery('.homepage').length>0){
			jQuery('.homepage .htmlslotcontainer img.mainImage').css('height', (jQuery(window).height()-133));
			jQuery('.homepage .htmlslotcontainer img.mainImage').css('width','auto');
			jQuery(window).bind('resize',function(){
				jQuery('.homepage .htmlslotcontainer img.mainImage').css('height', (jQuery(window).height()-133));
				jQuery('.homepage .htmlslotcontainer img').css('width','auto');
			});
		}
		
		jQuery('.hl_categorymenu ul li.active ul li').fadeIn('fast');
		
		var isiPad = navigator.userAgent.match(/iPad/i) != null;

        if(!isiPad){
				
		jQuery(".hl_topcat").hoverIntent({
			 over: function() { 
			 	if(jQuery(this).find('.hl_subcat:visible').length < 1){
			 		jQuery('.hl_subcat').hide();  
			 		jQuery(this).find('.hl_subcat').fadeIn('fast');
				}
			 }, 
			 timeout: 500,
			 out: function(e) {
				 if(($(this).hasClass('active')==false)){
				 jQuery(this).find('.hl_subcat').fadeOut(50);
				 jQuery('.hl_categorymenu ul li.active ul li').fadeIn('fast');
				 }
			 }
		});
		
        }
		
		}
	
	}
	
})(jQuery);

jQuery(document).ready(function(){
	HL.init();
});
