// JavaScript Document

var homeController = {
	init: function() {
		$("header nav li").mouseover(function() {
			$("header nav li").css("background-image", "url('assets/images/hero-tab.png')");
			$(this).css("background-image", "url('assets/images/hero-tab-over.png')");
			
			if ($("header nav li").supersleight)
				$("header nav li").supersleight();
		});

		$("header nav li").mouseout(function() {
			$("header nav li").css("background-image", "url('assets/images/hero-tab.png')");
			if ($("header nav li").supersleight)
				$("header nav li").supersleight();
		});
		
		$("header nav li").click(function() {
			$("header nav li a").each(function() {
				$(this).removeClass("active");
			});
			$(this).children("a").addClass("active");
			
			var strSection = $(this).attr("id");
			$("header nav li").each(function() {
				var strLeft = ($(this).attr("id") == strSection) ? "0" : "-50px";
				$(this).animate({"margin-left":strLeft}, 100);
			});
			
			strSection = strSection.substr(4);
			$("#hero section").each(function(index) {
				if ($(this).attr("id").indexOf(strSection) >= 0) {
					$(this).fadeIn(800);
				} else {
					$(this).fadeOut(800);
				}
			});
			
			if ($("header nav li").supersleight)
				$("header nav li").supersleight();
		});
	}
}

$(function() { homeController.init(); });
