$(function(){
	/* New window (add class "blank") */
    $('a.blank').click(function(){
        window.open(this.href);
        return false;
    });

	// Hide characters on Recipes page (should probably rework this so it only hides if Flash is enabled…)
	if (!$("body").hasClass("recipes, fourohfour")){
		$("div#character-snap, div#character-crackle").hide()		
	}
	
	// Print-friendly stuff
	$("div#panel-print").append('<p><a href="#" id="button-print">Print <img src="assets/images/print/button_print.gif" border="0" alt="" width="15" height="14"/></a></p><p><small><a href="#" id="button-switch">Switch to print without images</a></small></p>')

	$("a#button-switch").toggle(
		function(){
			$("body").addClass("lofi");
			$("img#logo").attr("src", "assets/images/print/logo_bw.gif");
			$("a#button-switch").text("Switch to print with images")
		},
		function(){
			$("body").removeClass("lofi");
			$("img#logo").attr("src", "assets/images/print/logo.gif");
			$("a#button-switch").text("Switch to print without images")
		}
	)
			
	$("a#button-print").click(function(){
	    setPrintEvent(this,$('.container h1').text());
		window.print();
		return false;			
	})

});

function thisMovie( movieName ) { 
    return document.getElementById(movieName);
} 

function setNavCookie(id)
{
	var options = { path: '/', expires: 1 };
	$.cookie('LastNavId', id , options);	
}

function selectNavId(e)
{
    if($.cookie('LastNavId')!=null)
    {   
        var navId = $.cookie('LastNavId');
        $('.active').removeClass('active'); 
        $('#' + navId + ' a').addClass('active');
        return '';
    }
}

function setFilterCookie(season)
{
    var options = { path: '/', expires: 1 };
    $.cookie('Filter', season, options);
}

function deleteCookies()
{
    $.cookie('LastNavId',null);
    $.cookie('Filter',null);
}

function initBackToIPhoneVersionButton()
{
    $('mobile-link').click(function(){ 
        $.cookie('IPhoneOverride',null);
    });
}