jQuery(document).ready(function() {	

	// Closing share boxes if open (mobile)
	if (mobile()) {
		$('body').click(function(){
			$('ul.share.expand').removeClass('expand');
		});
	}

	// Device detection
	if ((navigator.userAgent.indexOf('iPhone') != -1) || (navigator.userAgent.indexOf('iPad') != -1))
		$('html').addClass('mobile');	


	// Language options
	$('#openLangs, #closeLangs').live('click',function (e) {
		$('#langs').toggle();
		e.preventDefault();
		$('html,body').scrollTop($('body').height());
		$('html.mobile div#main-content').touchScroll('update');
	});


	// Body overflow fixing
	var headerHeight = $('#header').height();
	
	// Back to top
	$('.back-to-top').click(function (e) {
		e.preventDefault();
		
		if(mobile()) {
			$('#main-content').touchScroll('setPosition', 0); 
		} else {
			$('html,body').animate({scrollTop: 0}, 500, 'easeOutQuint');
		}
	});


	if($('.mobile').length > 0 ) {
		$(".mobile #wrapper").css("top", headerHeight);
	} else {
		$(".container, .grid, .home-slideshow-holder, .collection-detail, .jeans-strip-outer, .lookbook-container").css("margin-top", headerHeight); 
	}
			
	$(".back").css("top", headerHeight);

	
	jQuery(".grid").delegate(".unit .unit-overlay", "mouseover mouseout", function(e) {
            if (e.type == 'mouseover') {
                    $(".grid .unit .unit-overlay").not(this).dequeue().animate({opacity: "1"}, 0);
                    $(this).parent().children(".plus-hover").css("display", "block");		
            } else {
                    $(".grid .unit .unit-overlay").not(this).dequeue().animate({opacity: "0"}, 0);
                    $(this).parent().children(".plus-hover").css("display", "none");
            }
	});


	jQuery(".sub-menu").delegate("li", "mouseover mouseout", function(e) {
            if (e.type == 'mouseover') {
                    $(".sub-menu li").not(this).dequeue().animate({opacity: "0.3"}, 0);
            } else {
                    $(".sub-menu li").not(this).dequeue().animate({opacity: "1"}, 0);
            }
	});


});

$(".press-clipping-item").live("mouseover mouseout", function(event) {
  if ( event.type == "mouseover" ) {	
	  $(this).find('a').css("text-decoration", "underline");
	$(this).css("cursor", "pointer");
  } else {
	$(this).find('a').css("text-decoration", "none");
	$(this).css("cursor", "default");

  }
});



$("#featured-tabs div").live("mouseover mouseout", function(event) {
  if ( event.type == "mouseover" ) {	
	  $(this).find('a').css("text-decoration", "underline");
	$(this).css("cursor", "pointer");
  } else {
	$(this).find('a').css("text-decoration", "none");
	$(this).css("cursor", "default");

  }
});






$('.press-clipping-item a').live('click',function(e){
	e.preventDefault();
});

$('.press-clipping-item').live('click',function(e){
	e.stopPropagation;
	targetHref = $(this).find('a').attr('href');
	window.open(targetHref);
});




