// JavaScript Document
$(document).ready(function(){
	
	function nav_label(){	
		//first we label the first and second levels for styling
		$("#nav").children("ul").addClass("lev1").children("li").addClass("lev1").children("a").addClass("lev1")
		.parent().children("ul").addClass("lev2").children("li").addClass("lev2").children("a").addClass("lev2");
		
		//then we check to see which page is active (done using the section[0] from the pages.txt
		var current_page = document.URL.substr(document.URL.lastIndexOf("/") + 1);
		if(current_page.search("home.html") == -1){
			$("#nav a").each(function(i){
				if($(this).attr("href").search(section) != -1){
					$(this).parent("li").addClass("active");
					if($(this).hasClass("lev2")){
						$(this).parent().parent().parent().addClass("active");	
					}
				}
			});
		}
		else{
			$("#nav li.home a").parent().addClass("active");
		}
		
		//finally we add the hover to the li on the first level for the brackets
		$("#nav > ul li").hover(
									function(){
										if((! $(this).hasClass("active")) && ($(this).hasClass("lev1"))){
											$(this).children("a").addClass("right_bracket").parent().addClass("left_bracket");
										}
									},
									function(){
										if((! $(this).hasClass("active")) && ($(this).hasClass("lev1"))){
											$(this).children("a").removeClass("right_bracket").parent().removeClass("left_bracket");
										}
									});
	}
	

	
	function textbox_clear(){
		//this is to fill or remove the text in the newsletter box
		var input_value = $("input#email").attr("value");
		$("input#email").focus(function(){
										if($(this).attr("value") == input_value){
											$(this).attr("value", "");   
									   }
		});
		$("input#email").blur(function(){
									   if($(this).attr("value") == ""){
											$(this).attr("value", input_value);   
									   }
		});
								
	}
						   
						   
						   
	nav_label();
	textbox_clear();		   
	
});