$(document).ready(function(){
						   
	// Email to friend
	$("#email_to_friend").click(function(){
		this.href='mailto:?subject='+escape("Thames Water Corporate Responsibility Report 2008/09")+'&body='+escape("Hello. I thought you might be interested in this:\n"+window.location);
		return true;
	})
		
	 //See also Hover
	$("#seealso li").hover (function(){
		$(this).addClass('hover');
	},function(){
		$(this).removeClass('hover');
	});

	//Collapsible Graph
	$(".collapsible").hide();
	$(".collapsible-container a").click(function (event) {
		
		var $item = $('.collapsible', $(event.target).parents('.collapsible-container'));
		
		if ($item.is(':visible')){
			$item.slideUp('normal',function(){
				$(event.target).text('Show graph');
			});
		} else {
			$item.slideDown('normal',function(){
				$(event.target).text('Hide graph');
			});
		};
		return false;
	});
	
	//Style switcher
	styleSwitch();
    $("#tools li.switcher a").click(function() {
		$.cookie('css', $(this).attr('rel'), {expires: 365, path: '/'});
		styleSwitch();
		return false;
    });
	
	function styleSwitch()
	{
		if($.cookie('css')) {
			if($.cookie('css').substring(($.cookie('css').length-8)) == 'main.css') {
				if($('link#style-switch').length) $('link#style-switch').remove();
			} else {
				if($('link#style-switch').length) {
					$('link#style-switch').attr('href', $.cookie('css'));
				} else {
					$('<link id="style-switch" rel="stylesheet" type="text/css" media="screen">').attr('href', $.cookie('css')).insertAfter($('link:last'));
				}
			}
		}
	};
});


$.cookie = function(name, value, options) {
    if (typeof value != 'undefined') { // name and value given, set cookie
        options = options || {};
        if (value === null) {
            value = '';
            options.expires = -1;
        }
        var expires = '';
        if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
            var date;
            if (typeof options.expires == 'number') {
                date = new Date();
                date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
            } else {
                date = options.expires;
            }
            expires = '; expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
        }
        // CAUTION: Needed to parenthesize options.path and options.domain
        // in the following expressions, otherwise they evaluate to undefined
        // in the packed version for some reason...
        var path = options.path ? '; path=' + (options.path) : '';
        var domain = options.domain ? '; domain=' + (options.domain) : '';
        var secure = options.secure ? '; secure' : '';
        document.cookie = [name, '=', encodeURIComponent(value), expires, path, domain, secure].join('');
    } else { // only name given, get cookie
        var cookieValue = null;
        if (document.cookie && document.cookie != '') {
            var cookies = document.cookie.split(';');
            for (var i = 0; i < cookies.length; i++) {
                var cookie = jQuery.trim(cookies[i]);
                // Does this cookie string begin with the name we want?
                if (cookie.substring(0, name.length + 1) == (name + '=')) {
                    cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
                    break;
                }
            }
        }
        return cookieValue;
    }
};

// sIFR Configuration
var albert = {src: '/cr/_swf/albert.swf'};
var jeanna = {src: '/cr/_swf/jeanna.swf'};

sIFR.activate(albert);

sIFR.replace(albert, {
	selector: '#header h1',
	ratios: [8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #ccc; font-size: 18px; }',
	wmode: 'transparent',
	tuneHeight: -8
});

//Home, Responsibilities, CR Videos, Feedback, Build your report, Summary, Performance
sIFR.replace(albert, {
	selector: '#home #header h2, #performance #header h2, #responsibilities #header h2,  #responsibilities #content h2, #responsibilities .pullout_quote, #feedback #header h2,  #feedback #content h2, #feedback .pullout_quote, #videos #header h2, #summary #header h2, #summary #content h2, #summary .pullout_quote, #build-report #header h2, #build-report #content h2, #build-report .pullout_quote, #performance #content h2, #performance .pullout_quote, #site-map #header h2, #site-map #content h2',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #0047b6; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5; letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#responsibilities #header_pullout, #videos #header_pullout, #feedback #header_pullout, #summary #header_pullout, #build-report #header_pullout, #performance #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #0047b6; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});

// Customer service
sIFR.replace(albert, {
	selector: '#customer-service #header h2, #customer-service #content h2, #customer-service .pullout_quote',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #b6006f; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5; letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#customer-service #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #b6006f; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});

// Finance
sIFR.replace(albert, {
	selector: '#finance #header h2, #finance #content h2, #finance .pullout_quote',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #e58e1a; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5;letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#finance #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #e58e1a; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});
//Water
sIFR.replace(albert, {
	selector: '#water #header h2, #water #content h2, #water .pullout_quote',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #0089b1; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5; letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#water #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #0089b1; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});
//Wastewater
sIFR.replace(albert, {
	selector: '#wastewater #header h2, #wastewater #content h2, #wastewater .pullout_quote',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #57005f; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5; letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#wastewater #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #57005f; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});
//Climate
sIFR.replace(albert, {
	selector: '#climate #header h2, #climate #content h2, #climate .pullout_quote',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #8aa300; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5; letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#climate #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #8aa300; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});
//Sustaiability
sIFR.replace(albert, {
	selector: '#sustainability #header h2, #sustainability #content h2, #sustainability .pullout_quote',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #3f8493; font-size: 24px; line-height: 26px; margin:0; padding:0; font-weight:bold; leading:-5; letter-spacing:0.75;}',
	wmode: 'transparent',
	tuneHeight: -6
});
sIFR.replace(jeanna, {
	selector: '#sustainability #header_pullout',
	ratios:[8,1.43,11,1.38,16,1.33,23,1.32,24,1.29,28,1.3,36,1.29,45,1.28,73,1.27,76,1.26,77,1.27,1.26],
	css: '.sIFR-root { color: #3f8493; font-size: 18px; line-height: 20px; margin:0; padding:0; font-weight:normal;}',
	wmode: 'transparent',
	tuneHeight: 10
});