jQuery.fn.fadeToggle = function(speed, easing, callback) {
	return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};


$(document).ready(function(){
	
	// remove right margin from every 7th image in press thumbnail grid
	$('#pressGrid a:nth-child(7n)').children('img').css('marginRight','0');
	
	// initialize colorbox for press images
	$('#pressGrid a[rel="image"]').colorbox();
		// special instances for items with PDFs or slideshows
		$("#pressGrid #wJul09").colorbox({iframe:true, innerWidth:850, innerHeight:500});
		$("#pressGrid #jacquesSpr09").colorbox({iframe:true, innerWidth:890, innerHeight:560});
		$("#pressGrid #vogueitalia").colorbox({iframe:true, innerWidth:430, innerHeight:620});
		$("#pressGrid #corduroyshow").colorbox({iframe:true, innerWidth:670, innerHeight:500});
		$("#pressGrid #203040show").colorbox({iframe:true, innerWidth:670, innerHeight:530});
		$("#pressGrid #vevantshow").colorbox({iframe:true, innerWidth:660, innerHeight:435});
	
	// initialize cluetip for press images -- uses title attribute for text
	$('#pressGrid a').cluetip({
    splitTitle: '|'
	});
	
	// initialize tooltip plugin for press images -- uses title attribute
	/* $("#pressGrid a").tooltip({showURL: false});
	*/
	
	// show/hide behavior for the Stockists page
	$('#stockList li').click(function() {
		$(this).addClass('selected').siblings('li').removeClass('selected');
		$('#stockInfo div').hide();
		var whichList = $(this).attr('id');
		$('#stockInfo div.'+whichList).slideDown();
		$('#stockInfo div.online').show();
	});
	
	// place label over the email input
	$("#emailTxt").labelify({
	  text: "label"
	});
	
	// hover effect for the submit button
	$('#submit').hover(function() {
		$(this).addClass('btnHover');
	}, function() {
		$(this).removeClass('btnHover');
	});
	
	// show/hide on the signup form
	$('#joinList a').click(function() {
		$('#joinForm').fadeToggle('fast');
		return false;
	});
	
	// function passed to page on form submit
	var options = { 
      success:	signupConfirm  // post-submit callback 
  }; 

  // bind to the form's submit event 
  $('#joinForm').validate({ 
      submitHandler: function(form) {
      	$(form).ajaxSubmit(options); 
     	} 
  });
  // post-submit callback
	function signupConfirm() {
		$('#signupConfirm').fadeIn();
		return false;
	}
	
	// expanding the press item box
	
	// show more
	$('#pressExpander #showMore').click(function() {
		$("#pressGrid").animate({ 
		        height: "2455px"
		      }, 1500 );
		$(this).hide();
		$('#pressExpander #showLess').show();
		return false;
	});
	
	// show less
	$('#pressExpander #showLess').click(function() {
		$("#pressGrid").animate({ 
		        height: "596px"
		      }, 1500 );
		$(this).hide();
		$('#pressExpander #showMore').show();
	});
	
	$('#pressExpander #showLess').localScroll();
	
	// remove right margin on the last collections item
	$('#content .collItem:last').css('marginRight','0');
	
	// colorbox overlays for collections
	$(".collItem #fw2011campaign").colorbox({iframe:true, innerWidth:1013, innerHeight:720});
	$(".collItem #fw2011lookbook").colorbox({iframe:true, innerWidth:725, innerHeight:570});
	$(".collItem #ss2011lookbook").colorbox({iframe:true, innerWidth:319, innerHeight:700});
	$(".collItem #ss2011").colorbox({iframe:true, innerWidth:849, innerHeight:730});
	$(".collItem #fw2010").colorbox({iframe:true, innerWidth:1000, innerHeight:730});
	$(".collItem #ss2010").colorbox({iframe:true, innerWidth:889, innerHeight:760});
	$(".collItem #fall09").colorbox({iframe:true, innerWidth:940, innerHeight:630});
	$(".collItem #ss09").colorbox({iframe:true, innerWidth:940, innerHeight:630});
	$(".collItem #fall08").colorbox({iframe:true, innerWidth:940, innerHeight:630});
	$(".collItem #s08f07").colorbox({iframe:true, innerWidth:900, innerHeight:530});
	$(".collItem #ss07").colorbox({iframe:true, innerWidth:900, innerHeight:530});
	
	// spring/summer collection overlay on the home page
	$(".home #fw2011campaign").colorbox({iframe:true, innerWidth:1013, innerHeight:720});
	$(".home #homeCollection").colorbox({iframe:true, innerWidth:849, innerHeight:730});
	

});
