$(function(){
	//Stylesheet switcher
		// 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;
			}
		);
			
	// Clock
		var gmt = new Date;
		
		var uk_s = new Date;
		var uk_e = new Date;
		var lsun_s = 0;
		var lsun_e = 0;
		var uk_offset = 0;
		
		// Last Sun of March
		uk_s.setMonth(2);				// March
		uk_s.setDate(31);				// 31st of the month
		lsun_s = 31 - uk_s.getDay();	// L Sunday = no of days - number day of last day
		uk_s.setDate(lsun_s);			// Set day
		// Last Sun October
		uk_e.setMonth(9);				// October
		uk_e.setDate(31);				// 1st of the month
		lsun_e = 31 - uk_e.getDay();	// L Sunday = no of days - number day of last day
		uk_e.setDate(lsun_e);			// Set day
		
		if (gmt >= uk_s || gmt < uk_e) uk_offset = +1;
		var optionsGBT = {
			utc: true,
			utc_offset: uk_offset	
		}
		$('#jclock1').jclock(optionsGBT);

		var la_s = new Date;
		var la_e = new Date;
		var fsun = 0;
		var ssun = 0;
		var la_offset = -8;
		
		// 2nd Sun of March
		la_s.setMonth(2);				// March
		la_s.setDate(1);				// 1st of the month
		fsun = 8 - la_s.getDay();
		if (fsun == 8) fsun = 1;		// 1st Sunday
		ssun = fsun+7;					// 2nd Sunday
		la_s.setDate(ssun);				// Set day 2nd Sunday
		// 1st Sun November
		la_e.setMonth(10);				// November
		la_e.setDate(1);				// 1st of the month
		fsun = 8 - la_e.getDay();
		if (fsun == 8) fsun = 1;		// 1st Sunday
		la_e.setDate(fsun);				// Set day 2nd Sunday
		
		if (gmt >= la_s || gmt < la_e) la_offset = -7;
		var optionsPST = {
			utc: true,
			utc_offset: la_offset
		}
		$('#jclock2').jclock(optionsPST);
			
	//Scroll bar
		$('.scroll-pane').jScrollPane({dragMinHeight:20, dragMaxHeight:20});
	
	//Menu hover effects
		$("ul#primary-nav li a, #secondary-nav ul li a").hover(function() {
			// get body text
			// the dark style sheet has rollover of lighter grey then light style sheet
			var text_colour = $('body').css("color"); // "#C7C8CA"
			$(this).animate({ color: text_colour }, 600);
			},function() {
			$(this).animate({ color: "#EF5BA1" }, 400);

		});
		
		$("ul#primary-nav li.selected a, #secondary-nav ul li.selected a").hover(function() {
		$(this).stop();
		});
		
		//For primary sub menus
		$("ul#primary-nav li.selected li a").hover(function() {
			// get body text
			// the dark style sheet has rollover of lighter grey then light style sheet
			var text_colour = $('body').css("color"); // "#C7C8CA"
			$(this).animate({ color: text_colour }, 400);
			},function() {
			$(this).animate({ color: "#EF5BA1" }, 400);

		});
		
		$("ul#primary-nav li.selected li.selected a").hover(function() {
		$(this).stop();
		});
		
	
	//Superfish Drop Down menu
		$("ul#primary-nav ul").show();
		$("ul#primary-nav").superfish( {
				autoArrows:    false,
			}
		);

});

