$(document).ready(function(){
	// Make sure IE plays nice with the dropdown menu
	$("#nav li").hover(
		function(){ $(this).addClass("hover"); },
		function(){ $(this).removeClass("hover"); }
	);
	
	$('a.btn_arrow').toggle(
		function(){
			$(this).parent().animate({"marginLeft": "0px"}, "slow", "easeOutCubic");
			$(this).css({backgroundPosition:'-24px 0'});
			return false;
		},function(){
			$(this).parent().animate({"marginLeft": "-160px"}, "slow", "easeInCubic");
			$(this).css({backgroundPosition:'0 0'});
			return false;
		}
	);
	
	$('#slides').innerfade({
		speed:1000,
        timeout:5000,
        type:'sequence',
        containerheight:'272px',
        slide_timer_on:'yes',
        slide_ui_parent:'slides',
        slide_ui_text:null,
       	pause_button_id:null,
       	slide_nav_id:'slide-nav'
	});
	if ($('#slides').length>0)
		$.setOptionsButtonEvent();
	
	// Product Tabs
	$('#product-tabs').tabs({
		event:'mouseover'
	});
	
	// This is to slow down spam on all the forms.
	$('form').append('<input type="hidden" name="secretsquirrel" value="ihatebots" />');
	
	// Show me the Sleep Calculator!
	$('#fl_sleepCalculator').flash({swf:'/flash/SleepCalculator.swf',width:504,height:470,params:{wmode:'transparent'}});
	
	// The Sleep Quiz
	quizAnswers = new Array();
	quizTotal = 0;
	$('#the-quiz p.q a').click(function(){
		$(this).parent().find('a').fadeOut();
		var answer = Number($(this).attr('href'));
		quizAnswers.push(answer);
		quizTotal = quizTotal+answer;
		$(this).parent().next().slideDown();
		if(quizAnswers.length>9)
		{
			$('#result #you strong').text(quizTotal);
			$('#result').fadeIn();
			$('#the-quiz p.q a').click(function(){return false;});
		}
		$(this).unbind('click');
		return false;
	});
});
Cufon.replace('#nav a:not(#nav ul ul a)',{fontFamily:'Moderne',hover:true});
Cufon.replace('h1,.sidebar h3,#product-tabs h2,h2.special',{fontFamily:'Moderne'});
//Cufon.replace('.ui-tabs-nav li',{fontFamily:'Moderne',hover:true});
//Cufon.replace('.visual-box p,.side-bar h3,.side-bar h2,.blocks-holder h2',{fontFamily:'Minion Pro'});
