    $(document).ready(function(){

	$(document).pngFix();

	// Call stylesheet init so that all stylesheet changing functions will work.
	$.stylesheetInit();
	// This code loops through the stylesheets when you click the link with an ID of "toggler" below.
	$('#toggler').bind('click',function(e){
		$.stylesheetToggle();
		return false;
		}
	);
	// When one of the styleswitch links is clicked then switch the stylesheet to the one matching the value of that links rel attribute.
	$('.styleswitch').bind('click',function(e){
		$.stylesheetSwitch(this.getAttribute('rel'));
		return false;
		}
	);

	// -- TOGGLE/fade content ---------// 

	jQuery.fn.fadeToggle = function(s, fn){
        return (this.is(":visible"))
            ? this.fadeOut(s, fn)
            : this.fadeIn(s, fn);
    	};
	
	$("button.toggler").hide(); // get it ready first
	$(".contentTogglerAdvice").hide();

	// Content 1= All Ages (over 25s)
	// Content 2 = Under 25s
		
        var status1text = 'Click here to view info for Under 25 Year Olds';
        var status2text = 'Click here to view info for 25 Year Olds and over';
		
	$(".content1").hide(); // init: hide both to start with (?)
	$(".content2").hide();
		
	var currentStatus = $.cookie('currentStatus');
	
	function displayAppropriateContent() {
	// COOKIE ALREADY EXISTS?
	if(currentStatus > 0) {
		//alert("Cookie already exists as: " +$.cookie('currentStatus'));
		if (currentStatus == "1") {
       			$("button.toggler").text(status1text);
			$(".content2").hide();
			$(".content1").show();
		} else { // currentStatus == "2"
			$("button.toggler").text(status2text);
			$(".content1").hide();
			$(".content2").show();
		}
		$("button.toggler").show();
		$("button#choice1").hide();
		$("button#choice2").hide();
		$("div#ageChoice").hide();
	} else {
		///////////////////////////////////////////////
		// NO COOKIE so hide content and present choice.
		$(".content1").hide();
		$(".content2").hide();
		$("button.toggler").hide();
		if(ageSelectionPage == true) {
			$("#mainContent").append("<div id='ageChoice'><h2>Select your age group</h2><p>To view the information that is relevant to you, please select your age group...</p><button class='toggler' id='choice1'></button> &nbsp; or &nbsp; <button class='toggler' id='choice2'></button></div>");
		}
		$("#ageChoice h2").css("color","#ffffff");
		$("button#choice1").html("I am <b>under</b> 25 years old");
		$("button#choice2").html("I am <b>at least</b> 25 years old ");
		// SET COOKIE DEPENDING ON CHOICE
		$("button#choice1").click(function(){
			setAgeGroupCookie('1');
			currentStatus = 1;
			displayAppropriateContent();
		});
		$("button#choice2").click(function(){
			setAgeGroupCookie('2');
			currentStatus = 2;
			displayAppropriateContent();
		});
	}
	}; // end of displayAppropriateContent function
	displayAppropriateContent(); // init
	
	// TOGGLER CLICK FUNCTION (only called if cookie already exisits / content is being displayed).
        $("button.toggler").click(function(){
		if ($(".content1").is(":visible")) {
			var buttonLabel = status2text;
			$(".content1").hide();
			$(".content2").fadeToggle();
			setAgeGroupCookie('2');
			currentStatus = 2;
		} else {
			var buttonLabel = status1text;
			$(".content2").hide();
			$(".content1").fadeToggle();
			setAgeGroupCookie('1');
			currentStatus = 1;
		}
		$("button.toggler").text(buttonLabel); // all instances
        });

	$("button.toggler").mouseup(function(){
		this.blur(); // remove dotted focus line
	});

	function setAgeGroupCookie(status) {
		if(jQuery.browser.mozilla) {
			//alert("Firefox");
			// expire in 1 day (session doesn't work in FF
			$.cookie('currentStatus', status, {expires: 1});
		} else {
			// normal session cookie
			$.cookie('currentStatus', status);
		}
	}

	// --- TOGGLE/fade end.

	$("#A").hide();
	$("#A").show(); //fixes ie display bug
    });


	// FIX SAFARI 4 FLASH Z-INDEX BUG (need Flash version 10.0.3+)
	var flashVersionSub = $.fn.flash.hasFlash.playerVersion();
	flashVersionSub = flashVersionSub.split(",");
	flashVersionSub = flashVersionSub[2];
	flashVersionSub = flashVersionSub.split("");//get first integer
	flashVersionSub = flashVersionSub[0];
	//alert(flashVersionSub);
	var Safari4FlashVersionBug = false;
	if (flashVersionSub < 3) {
		Safari4FlashVersionBug = true;
	}

	if (($.browser.safari && jQuery.browser.version >= 4 && Safari4FlashVersionBug == true)) {
		$('#Safari4FlashBug').show();
		$('#Safari4FlashBug').flash(
    			{ src: 'null.swf' }, 
    			{ version: '10.0.22.87' }
		);
	}

    /*****************************************************************************
    The sIFR configuration should typically go in `sifr-config.js`, but in order to Keep the config file clean, and to give a quick overview, it's done here instead.
    *****************************************************************************/
    var museo = {
      src: '/sifr3/museo.swf'
      ,ratios: [8, 1.41, 10, 1.33, 14, 1.31, 16, 1.26, 20, 1.27, 24, 1.26, 25, 1.24, 26, 1.25, 35, 1.24, 49, 1.23, 74, 1.22, 75, 1.21, 79, 1.22, 80, 1.21, 81, 1.22, 1.21]
	  ,wmode: 'transparent'
	  ,selectable: true
    };
    // sIFR.useStyleCheck = true;
    if (!($.browser.safari && jQuery.browser.version >= 4 && Safari4FlashVersionBug == true)) {
    		sIFR.activate(museo);	
	}	
	//sIFR.debug.ratios({ src: '/sifr3/museo.swf', selector: 'h1' });

	sIFR.replace(museo, {
      selector: 'h1'
      ,css: [
        '.sIFR-root { background-color: #000000; color: #f31b7a; }'
      ]
    });

