$(function () {
	// Setup banner slider
	$('.anythingSlider2').anythingSlider({
		easing: "easeInOutExpo",        // Anything other than "linear" or "swing" requires the easing plugin
		autoPlay: true,                 // This turns off the entire FUNCTIONALY, not just if it starts running or not.
		delay: 6000,                    // How long between slide transitions in AutoPlay mode
		startStopped: false,            // If autoPlay is on, this can force it to start stopped
		animationTime: 1000,             // How long the slide transition takes
		hashTags: false,                 // Should links change the hashtag in the URL?
		buildNavigation: false,          // If true, builds and list of anchor links to link to each slide
		pauseOnHover: true,             // If true, and autoPlay is enabled, the show will pause on hover
		startText: "",             // Start text
		stopText: ""
	});
	$("#slide-jump").click(function(){
		$('.anythingSlider2').anythingSlider(4);
	});
	// Change fonts over
	Cufon.replace('#banner .anythingSlider2 p');
	Cufon.replace('#banner .maptext p');
	Cufon.replace('#bannerSupport p');
	// Set the height of each column the same so that our borders go the full length of the page
	var height = $('#left-nav').outerHeight();
	if($('#inside-body').outerHeight() > height) height = $('#inside-body').outerHeight();
	if($('#right-bar').outerHeight() > height) height = $('#right-bar').outerHeight();
	$('#left-nav').css({height : height});
	$('#inside-body').css({height : height});
	$('#right-bar').css({height : height});
	
	// Highlight the page in the menu
	var page = ''; 
	if (window.location.pathname == '/support/request-further-support.php') {
		page = document.referrer;
	} else {
		page = window.location.href;
	}
	$('#cmsNav5 a').each(function() {
		if($(this).attr('href') == page) {
			// Loop through any parents and highlight them
			$(this).parents('#cmsNav5 li').children('a:first-child').addClass('navPage');
			$(this).parents('#cmsNav5 ul').show();
		}
	});
	$('#cmsNav6 a').each(function() {
		if($(this).attr('href') == page) {
			// Loop through any parents and highlight them
			$(this).parents('#cmsNav6 li').children('a:first-child').addClass('navPage');
		}
	});
	// Highlight the top menu
	if($('#cmsNav6').length) {
		$('#cmsNav1 li:nth-child(2) a').addClass('navPage');
	} else {
		$('#cmsNav1 li:first-child(1) a').addClass('navPage');
	}
	// menu toggle
	$("#cmsNav5> li > ul > li > a").click(function() {
		$(this).parent().find('> ul').slideToggle("fast");
	});
	$("#cmsNav5> li > a").click(function() {
		$(this).parent().find('> ul').slideToggle("fast");
	});
	$("#nav a.navTop:nth-child(2)").css("color","#E8A740");
	$("#nav a.navTop:last-child").css("border","none")
});
