$=jQuery;

$(document).ready(function() {
	
	//Hide all the interior links
	$('.subBackground').hide();
	
	
	//Main Links
	//When called, this will close all the interior links - when clicking on another main link
	function closeIt() {
		$('.subBackground:visible').slideUp('fast');
	}
	
	//Stops the default action of the <a> tag in the html so the whole page won't reload on click!
	$('.nav a').click(function(e) {
		e.preventDefault();
	});
	
	
	$('.nav').hover(function(){
		$('.nav').css("cursor","pointer");
	});
	
	//All the main links need to have the .nav class so they can call this on click.
	$('.nav').live("click", function(e) {
		//If it is hidden then call closeIt to make sure everything else gets closed, & then open it.
		if ($(this).next().is(":hidden")) {
			closeIt();
			$(this).next().slideDown('fast');
		}
		//If it isn't hidden, then closeIt and everything else.
		else {
			closeIt();
		}
		
		//Get the content in the a tag so you know what page to load in the div
		var href = $(this).children('a').attr('href');
			
		//Load the part of the page in the div
		if (href != "./faq.php"){
			$('#featureContent').load(href + ' #featureContent > *');
		}
		
		//Fix for the FAQ page
		if (href == "./faq.php"){
			$('#featureContent').load(href + ' #featureContent > *',function(){
				//Hide all the answers to the questions
				$('.answer').hide();
				//Hide the link that is used when Javascript is disabled to "return to top"
				$('.return').hide();
				$('.question').css("cursor","pointer");
			});
		}
	});
	
	
	//Change the color of the text on mouseover
	$('.navTitle').mouseover(function() {
		$(this).css("color","#2CAAE2");									  
	}).mouseout(function() {
		$(this).css("color","#ffffff");
	});
	
	
	//Interior Links
	//Stops the default action of the <a> tag in the html so the whole page won't reload
	$('a.navSubTitle').click(function(e) {
		e.preventDefault();
	});
	
	//On click, get the tag info for what link you are on and load it in the div.
	$('a.navSubTitle').live("click", function(e) {
		var href = $(this).attr('href');
		$('#featureContent').load(href + ' #featureContent > *');
	});
	
	$('a.navSubTitle').mouseover(function() {
		$(this).css("color","#2CAAE2");									  
	}).mouseout(function() {
		$(this).css("color","#000000");
	});
							   
	
	
	
	
	
});

