// JavaScript Document

/*
Author: Alex Boyce
Copyright: 2009
Date: 4/20/09

Creative Commons License
*/

(function($) {
	$.fn.nav = function(options) {
		var defaultSettings = {
			b_imageBack: true,
			backgroundDefaultY: "0",
			backgroundHoverY: ($("li", this).height() * -2) + "px",
			activeClass: "active",
			inactiveClass: "inactive",
			homeID: "#home"
		},
		settings = $.extend({}, defaultSettings, options),
		arr_local = location.href.split("/"),
		page = arr_local[arr_local.length - 1],
		parent;
		
		if (page == "" || page == null)
			$(settings.homeID).removeClass(settings.inactiveClass).addClass(settings.activeClass);
		
		if (settings.b_imageBack) {
			$(this).children("li[id]").each(function() {
				parent = "#" + $(this).attr("id");
				$("a", parent).each(function() {
					if ($(this).attr("href") == page)
							$(parent).removeClass(settings.inactiveClass).addClass(settings.activeClass);
					});
				});
		}
		else {
			$(this).children("li").each(function() {
				$("a", this).each(function() {
					if ($(this).attr("href") == page)
							$(this).addClass(settings.activeClass);
					});
				});
		}
		
		if (settings.b_imageBack) {
			$("li[class=inactive]", this).bind("mouseleave", function() {
					$(this).css({backgroundPositionY: settings.backgroundDefaultY});
				}).mouseover(function() {
					$(this).css({backgroundPositionY: settings.backgroundHoverY});
				});
		}
		
		return this;
		}
	})(jQuery);
/*
$().ready(function() {
	var arr_local = location.href.split("/");
	var page = arr_local[arr_local.length - 1];
	var parent;
	
	if (page == "" || page == null)
		$("#home").removeClass("inactive").addClass("active");
	
	$("#navlist ul").children("li[id]").each(function() {
		parent = "#" + $(this).attr("id");
		$("a", parent).each(function() {
			if ($(this).attr("href") == page)
				$(parent).removeClass("inactive").addClass("active");
			});
		});
	
	$("#navlist li[class=inactive]").bind("mouseleave", function() {
				$(this).css({backgroundPositionY: "0"});
			}).mouseover(function() {
				$(this).css({backgroundPositionY: "-72px"});
			});
	});*/