$('html').addClass('js');
$(document).ready( function(){
	var currentButton;
	var currentProjectBtn;						
							
	//hide all
	$("#projectDescriptionContainer").children().hide();
	if(currentPage == "1") {
		$("#projectsPage2").hide();
	} else {
		$("#projectsPage1").hide();
	}
	
	//show default
	$("#" + currentProject).show();
	$("#projectDescriptionContainer").show();
	$("#projectNavContainer").show();
	
	//get default button
	if(currentProject != "") {
		currentButton = $("#" + currentProject + " .imgNavBtn:eq(0)");	
		
		//set the default project button		
		currentProjectBtn = $("#projectsPage" + currentPage + " div:eq(" + currentProjectBtnIdx + ")");	
		currentProjectBtn.css("background", "url(images/selectedProject.gif) no-repeat");
	}
		
	//set the default project navs button
	$("#projectsNav img:eq(" + (parseInt(currentPage) - 1) + ")").attr("src", "images/button_" + currentPage + "_dn.gif");					
	
	$(".imgNavBtn").click(function() {
		if($(this).attr("myNum") != currentButton.attr("myNum")) {
			$("#projectImage_" + currentProject).attr("src", "images/projects/" + currentProject + "_" + $(this).attr("myNum") + ".jpg");
			$(this).attr("src", "images/button_" + $(this).attr("myNum") + "_dn.gif");
			currentButton.attr("src", "images/button_" + currentButton.attr("myNum") + "_up.gif");
			currentButton = $(this);
		}
	});
  
	$(".imgNavBtn").mouseover(function() {
		var path = $(this).attr("src");
		if(path.indexOf("_dn.gif") == -1) {
			var newPath = "images/button_" + $(this).attr("myNum") + "_rl.gif";
			$(this).attr("src", newPath);	
		}
	});
	
	$(".imgNavBtn").mouseout(function() {
		var path = $(this).attr("src");
		if(path.indexOf("_dn.gif") == -1) {
			var newPath = "images/button_" + $(this).attr("myNum") + "_up.gif";
			$(this).attr("src", newPath);	
		}
	});
	
	/*** Project Button ***/ 
	$(".projectBtn").click(function() {
		 window.location.href = $(this).attr("projectID") + ".html"; 

	  });
	  
		$(".projectBtn").mouseover(function() {
			if(currentProjectBtn == undefined) {
				$(this).css("background", "url(images/selectedProject.gif) no-repeat");
			} else if($(this).attr("projectID") != currentProjectBtn.attr("projectID")) {
				$(this).css("background", "url(images/selectedProject.gif) no-repeat");
			}
		});	
		
		$(".projectBtn").mouseout(function() {
			if(currentProjectBtn == undefined) {
				$(this).css("background", "");
			} else if($(this).attr("projectID") != currentProjectBtn.attr("projectID")) {
				$(this).css("background", "");
			}
		});				  
	  
	  /*** Projects Nav Button ***/
	$("#projectsNav img").click(function() {
		var page = $(this).attr("myNum");
		if(page != currentPage) {
			currentPage = page;
			if(page == "1") {
				$("#projectsPage2").hide();
				$("#projectsPage1").show();
				$("#projectsNav img:eq(0)").attr("src", "images/button_1_dn.gif");
				$("#projectsNav img:eq(1)").attr("src", "images/button_2_up.gif");
			} else {
				$("#projectsPage1").hide();
				$("#projectsPage2").show();
				$("#projectsNav img:eq(0)").attr("src", "images/button_1_up.gif");
				$("#projectsNav img:eq(1)").attr("src", "images/button_2_dn.gif");				
			}
		}
		return false;
	  });	  
	  
		$("#projectsNav img").mouseover(function() {
			var path = $(this).attr("src");
			if(path.indexOf("_dn.gif") == -1) {
				var newPath = "images/button_" + $(this).attr("myNum") + "_rl.gif";
				$(this).attr("src", newPath);	
			}
		});
		
		$("#projectsNav img").mouseout(function() {
			var path = $(this).attr("src");
			if(path.indexOf("_dn.gif") == -1) {
				var newPath = "images/button_" + $(this).attr("myNum") + "_up.gif";
				$(this).attr("src", newPath);	
			}
		});	  
});