jQuery.noConflict();
jQuery(document).ready(function($){
	$('input[type=submit]:not(.exclude)').each(function(){
		$(this).replaceWith('<button class="button"><span><span>' + $(this).val() + '</span></span></button>');
	});
	
	$('span.submit-button').click(function(){
		$(this).parents('form').submit();
		$(this).unbind('click');
	});
	
	Cufon.replace('.cufon-text')('#nav li', { hoverables: { li: true }, hover: true })('.sidebar ul li.first')('.page-title h1')('.quote')('h2:not(.product-name)')('.coltitle')('.button')('.pagetitle')('.red')('.black')('.orange')('.subtitle')('.mailcue') ('.phrase')('h3');
	
	$("a[rel^='lightbox']").prettyPhoto({
		showtitle: false,
		deeplinking: false,
		social_tools: false
	});
	
	
	$(".tab_content").hide(); 
	$("ul.tabs li:first").addClass("active").show(); 
	$(".tab_content:first").show(); 
	$("ul.tabs li").click(function() {
		$("ul.tabs li").removeClass("active"); 
		$(this).addClass("active"); 
		$(".tab_content").hide(); 
		var activeTab = $(this).find("a").attr("href");
		$(activeTab).fadeIn(); 
		return false;
	});
	
	$('#product-tabs #tab-1').addClass('active-tab');
	$('#tab-1-link').addClass('active');
	$('#product-tabs #tab-2').hide();
	
	if($('#home-banners').html()){
		$('#home-banners').after('<div id="home-banners-nav"></div><div class="clear"></div>').cycle({
			timeout: 7500,
			pager: '#home-banners-nav'
		});
	}
	
	$('#newsletter-signup').submit(function(e){
		e.preventDefault();
		submitForm();
	});
	
	$('.accordionButton').each(function(){
		$(this).data('oldtext',$(this).html());
	});
	
	$('.accordionButton').click(function(){
		if($(this).hasClass('on')){
			$('.accordionContent').slideUp('normal');
			$(this).removeClass('on').html($(this).data('oldtext'));
		} else {
			$(this).next().slideDown('normal');
			$(this).addClass('on').html('Click here to hide');
		}
	 });
	 
	 $('.accordionContent').hide();
	 
});

function swapTabs(tab){
	jQuery('#product-tabs > div').hide().removeClass('active-tab');
	jQuery('#product-tabs #tab-' + tab).show().addClass('active-tab');
	
	jQuery('#tab-1-link, #tab-2-link').removeClass('active');
	jQuery('#tab-' + tab + '-link').addClass('active');
}

function submitForm(){
	jQuery.post('/newsletter.php',jQuery('#newsletter-signup').serialize(),function(data){
		jQuery('#newsletter-signup #email').val(data);
	});
}
