// JavaScript Document
$(document).ready(function() {
	var current_nav_id = null;					   
						   
	/* Creates the navigation hover effect */
	function getIdNumber(id) {
		id = id.split('_');
		return id[1];	
	}
	
	$(".nav_el").hover(
		function () {
			$(this).attr("src", "/media/nav_" + getIdNumber($(this).attr("id")) + "_on.gif");
		}, 
		function () {
			if(current_nav_id != $(this).attr("id")) { // We don't change current page selected navigation
				$(this).attr("src", "/media/nav_" + getIdNumber($(this).attr("id")) + "_off.gif");	
			}
		}
	);
	
	/* Selects the current navigation element */
	function getPageName () {
		/*
		var sPath = window.location.pathname;
		var sPage = sPath.substring(sPath.indexOf('/') + 1);
		*/
		return (window.location.pathname);
	}
	
	jQuery('.nav_el').each(function() {
		if(jQuery(this).parent('a').attr('href') == getPageName()) {
			current_nav_id = $(this).attr("id");
			$(this).attr("src", "/media/nav_" + getIdNumber($(this).attr("id")) + "_on.gif");
		}
	});
	
	if(getPageName() == "/contact_confirm.html") {
		current_nav_id = "nav_4";
		$("#nav_4").attr("src", "/media/nav_4_on.gif");
	}
	
	if(getPageName () == '/mentions.html') {
		//$("#mentions").addClass('footer_nav_sel');
		$("#mentions").css('text-decoration', 'underline');	
	}
});