jQuery('document').ready(function() {
	
	//Tab Container Function
	jQuery('.tab-container').each(function() {
		jQuery(this).prepend('<ul class="tab-nav"><li class="tab-1"><a href="/" class="tab" name="tab-1" title="You May Also Like"></a></li><li class="tab-2"><a href="/" class="tab" name="tab-2" title="Complete The Fashion Look"></a></li></ul>');
		jQuery(this).find('.tab-content').hide();
		if(!jQuery('.tab-content-1', this).length){jQuery('.tab-nav .tab-1', this).remove()}
		if(!jQuery('.tab-content-2', this).length){jQuery('.tab-nav .tab-2', this).remove()}
		jQuery(this).find('.tab').click(function() {
			jQuery(this).parent().parent().find('.active').removeClass('active');
			jQuery(this).addClass('active');
			var tab = jQuery(this).attr('name').substr(4);
			jQuery(this).parent().parent().parent().find('.tab-content').hide();
			jQuery(this).parent().parent().parent().find('.tab-content-'+tab).show();
			return false;
		});	
		jQuery(this).find('.tab-nav .tab:first').trigger('click');
	});		
	
	//Promotional Code Function
	
	jQuery('.discount-message').each(function() {
		jQuery(this).prepend('<p>Enter a <a href="/" class="show-discount pink">promotional code</a> here.</p>');
		jQuery(this).find('.discount-form').hide();
		jQuery(this).find('.show-discount').click(function() {
			jQuery(this).parent().parent().find('.discount-form').show();
			return false;
		});	
	});	
	
	//opens window in new window - for external links
	jQuery("a[rel='external']").attr({'target': '_blank'});
	
	//Nav Show and Hide
	
	
	jQuery('div.col-left.sidebar a.header-part').click(
		function(){
			if(!jQuery(this).hasClass('open')){
			    var chosenOne = jQuery(this);
    			jQuery('div.col-left.sidebar a.header-part').each(function(){
    			    if(chosenOne != jQuery(this)){
        				var ulId = this.id.substr(4, this.id.length);
        				if(jQuery('ul#'+ulId+':visible'))
        				{
        				    jQuery('#ttl-'+ulId).removeClass('open');
        					jQuery('ul#'+ulId).slideUp('slow');
        				}
				    }
    			});
        		var ulId = this.id.substr(4, this.id.length);
        		jQuery(this).addClass('open');
			    jQuery('ul#'+this.id.substr(4, this.id.length)).slideDown('slow');
		    }
		    return false;
		}
	);
	if(jQuery('div.col-left.sidebar a.header-part.startopen').length > 0){
	    jQuery('div.col-left.sidebar a.header-part.startopen').trigger('click');
	} else {
	    jQuery("#ttl-autumn2010").trigger('click');	
	}
	
});


// basic show and hide
