$(document).ready(function(){


//homepage quotes

$('#haveyoutried').load('mexican-recipes/home-recipes.htm',function(){
      var $quotes = $(this).find('dl');
      var n = $quotes.length;
      var random = Math.floor( Math.random()*n );
      $quotes.hide().eq(random).show();
}); 



//slide show of quotes in subfooter
	$('#que').innerfade({
		animationtype: 'fade',
		speed: 0,
		timeout: 4000,
		containerheight: '30px'
	});



//slide show for homepage
	$('#home-boxes').innerfade({
		animationtype: 'fade',
		speed: 1500,
		timeout: 12000,
		containerheight: '256px'
	});
	
	
//slide show for products / recipes
	$('#slideshow').innerfade({
		animationtype: 'fade',
		speed: 1000,
		timeout: 4000,
		containerheight: '318px'
	});	



//show javascript print link
  	$('#sidebar .print').removeClass('hide');



//show sms link
  	$('#content .recipes-page .sms').show();




//sitemap show / hide functions

	$('.sitemap').hide();

  	$('#sitemap-link').click(function(){
		$('.sitemap').slideToggle();return false;
	});

  	$('#subfooter .sitemap .close a').click(function(){
		$('.sitemap').slideUp('slow');return false;
	});



//form questions

    var questionsValue = ( $("input[name='ctl00$areaMain$questionRadioList']:checked").val() );

    if( ( questionsValue === undefined ) || questionsValue.toLowerCase() != 'yes' ) {

        $('#questions.closed').hide();
    }


	$("#ctl00_areaMain_questionRadioList_0").click(function() {
		$('#questions').slideDown();
	});

	$("#ctl00_areaMain_questionRadioList_1").click(function() {
		$('#questions').slideUp();
	});



//Invite form more-friends

    if( $( "#inviteFormErrorArea" ).text() != "" ) {
        // the Invite Friends form was submitted, and there was an error
    }
    else {
        // the Invite Friends form has no error message to show - display it in its default state

	    $('.inviteformArea').hide();
	    $('.sendInviteVerticalPad').show();
	    $('.addmore').show();
	    $('.morefriends').hide();
    }

  	$('.sendinvite a').click(function(){
		$('.inviteformArea').slideToggle();
        $('.sendInviteVerticalPad').slideToggle();
        return false;
	});

  	$('.addmore').click(function(){
		$('.morefriends').slideToggle();return false;
	});



//Product pages

	$('.product-nutritional').hide();

	$('.nutritional').append(' &gt;');

	$('.nutritional').addClass('link');	

  	$('.nutritional').click(function(){
		$('.product-nutritional').slideToggle();return false;
	});



// show / hide homepage boxes


  	$('#home-boxes ul').show();

 	$('#home-boxes .link1 a').click(function(){
		$('#home-boxes .box1').show();
		$('#home-boxes .box2').hide();
		$('#home-boxes .box3').hide();
		$('#home-boxes .box4').hide();
		$('#home-boxes .box5').hide();return false;
	});

 	$('#home-boxes .link2 a').click(function(){
		$('#home-boxes .box2').show();
		$('#home-boxes .box1').hide();
		$('#home-boxes .box3').hide();
		$('#home-boxes .box4').hide();
		$('#home-boxes .box5').hide();return false;
	});

 	$('#home-boxes .link3 a').click(function(){
		$('#home-boxes .box3').show();
		$('#home-boxes .box2').hide();
		$('#home-boxes .box1').hide();
		$('#home-boxes .box4').hide();
		$('#home-boxes .box5').hide();return false;
	});

 	$('#home-boxes .link4 a').click(function(){
		$('#home-boxes .box4').show();
		$('#home-boxes .box2').hide();
		$('#home-boxes .box3').hide();
		$('#home-boxes .box1').hide();
		$('#home-boxes .box5').hide();return false;
	});

 	$('#home-boxes .link5 a').click(function(){
		$('#home-boxes .box5').show();
		$('#home-boxes .box2').hide();
		$('#home-boxes .box3').hide();
		$('#home-boxes .box4').hide();
		$('#home-boxes .box1').hide();return false;
	});


//Loading videos

	$('#burritos_homevideo .normal a').click(function(){
		$('#burritos-videos .video-player').load('Burritos-normal.html')
		return false;
	});
	
	$('#burritos_homevideo .hq a').click(function(){
		$('#burritos-videos .video-player').load('Burritos-hq.html');
		return false;
	});


	$('#burritos_video .normal a').click(function(){
		$('#watch-videos .video-player').load('Burritos-normal.html')
		return false;
	});
	
	$('#burritos_video .hq a').click(function(){
		$('#watch-videos .video-player').load('Burritos-hq.html');
		return false;
	});
	
		$('#chicken_fajitas .normal a').click(function(){
		$('#watch-videos .video-player').load('crispychicken-normal.html')
		return false;
	});
	
	$('#chicken_fajitas .hq a').click(function(){
		$('#watch-videos .video-player').load('crispychicken-hq.html');
		return false;
	});

  	$('#fajitas .normal a').click(function(){
		$('#watch-videos .video-player').load('fajitas-normal.html')
		return false;
	});
	
	$('#fajitas .hq a').click(function(){
		$('#watch-videos .video-player').load('fajitas-hq.html');
		return false;
	});
	
	$('#tacos .normal a').click(function(){
		$('#watch-videos .video-player').load('tacos-normal.html');
		return false;
	});
	
	$('#tacos .hq a').click(function(){
		$('#watch-videos .video-player').load('tacos-hq.html');
		return false;
	});
	
  	$('#watch-videos .holder').click(function(){
		$('#watch-videos .video-player').load('Burritos-normal.html')
		return false;
	});	

	
	$('#burritos-videos .holder').click(function(){
		$('#burritos-videos .video-player').load('Burritos-normal.html')
		return false;
	});
	
		$('#chillichase_video .hq a').click(function(){
		$('#chillichase .video-player-chillichase .video-player').load('ad-hq.html')
		return false;
	});
		
		$('#chillichase_video .normal a').click(function(){
		$('#chillichase .video-player-chillichase .video-player').load('ad-normal.html')
		return false;
	});

//$('#share-the-fun').wrap('<div style="clear:both" />');
//$('#sitemap-link').append($('</p>'));

});
function init() {

var browser=navigator.appName;
var b_version=navigator.appVersion;
var version=parseFloat(b_version);
if ((browser=="Microsoft Internet Explorer") && (version==4)){

var newdiv = document.createElement('br');
newdiv.setAttribute('id', 'newlayer');
newdiv.setAttribute('clear', 'all');
var p2 = document.getElementById('sitemap-link');
document.getElementById("subfooter").insertBefore(newdiv, p2)
}
}

window.onload = init; 
