$(function(){
	$("#logo").css("opacity", 0.7);
	$(".thumbChange").css("opacity", 0.5);
	$(".navItem").css("opacity", 0.5);
	$(".navItemBig").css("opacity", 0.5);
	$("#home").css("opacity", 1);
	$(".thumbGroup").css("display", "none");
	$(".text").css("display", "none");
	$("#homeText").css("display", "block");
	$("#photoLarge").css("display", "block");
	contentSection = "home";
	content = "";
});
$(document).ready(function(){
	$(".thumbChange").hoverIntent(function(){$(this).fadeTo("fast", 1);}, function(){$(this).fadeTo("fast", 0.5);});
	$(".thumbChange").click(function(){
		get = this.id;
		if (content != get ) {
			newImg = this.id;
			loadImage = ("photos/"+newImg+".jpg");
			var objImage = new Image(); 
			$("#changer").fadeOut(
				function(){
					$(objImage).load(function() {
					$("#changer").empty();
					$("#changer").hide();
					$("#changer").append(this);
					$("#changer").fadeIn();
				});
				$(objImage).attr("src", loadImage);
				return false;
			});
		}
		content = get;
		last = content+"Content";
	});
	$(".navItem").click(function(){
		getSection = this.id;
		$(".navItem").css("opacity", 0.5);
		$(".navItemBig").css("opacity", 0.5);
		$("#"+getSection).css("opacity", 1);
		$(".navItem").css("color", "ffffff");
		if (contentSection != getSection ) {
			newSection = getSection+"Section";
			newText = getSection+"Text";
			$(".thumbGroup").css("display", "none");
			$("#"+newSection).css("display", "block");
			$("#"+newSection).css("opacity", 0);
			$("#"+newSection).fadeTo("normal", 1);
			$(".text").css("display", "none");
			$("#"+newText).css("display", "block");
			$("#"+newText).css("opacity", 0);
			$("#"+newText).fadeTo("normal", 1);

			loadImage = ("photos/"+getSection+"_start.jpg");
			var objImage = new Image(); 
			$("#changer").fadeOut(
				function(){
					$(objImage).load(function() {
					$("#changer").empty();
					$("#changer").hide();
					$("#changer").append(this);
					$("#changer").fadeIn();
				});
				$(objImage).attr("src", loadImage);
				return false;
			});


		}
		contentSection = getSection;
	});
	$("#home").click(function(){
		getSection = this.id;
		$(".navItem").css("opacity", 0.5);
		$(".navItemBig").css("opacity", 0.5);
		$("#"+getSection).css("opacity", 1);
		if (contentSection != getSection ) {
			if (contentSection == "contact" ) {
				$("#contactPhoto").fadeTo("normal", 0);
				$("#homePhoto").fadeTo("normal", 1);
				$(".text").css("display", "none");
				$("#homeText").css("display", "block");
				$("#homeText").css("opacity", 0);
				$("#homeText").fadeTo("normal", 1);
			}
			else {
				$(".thumbGroup").css("display", "none");
				$("#photoLarge").css("display", "block");
				$("#photoLarge").css("opacity", 0);
				$("#contactPhoto").css("opacity", 0);
				$("#homePhoto").css("opacity", 1);
				$("#photoLarge").fadeTo("normal", 1);
				$("#changer").empty();
				$("#changer").hide();
				$(".text").css("display", "none");
				$("#homeText").css("display", "block");
				$("#homeText").css("opacity", 0);
				$("#homeText").fadeTo("normal", 1);
			}
		}
		contentSection = getSection;
	});
	$("#contact").click(function(){
		getSection = this.id;
		$(".navItem").css("opacity", 0.5);
		$(".navItemBig").css("opacity", 0.5);
		$("#"+getSection).css("opacity", 1);
		if (contentSection != getSection ) {
			if (contentSection == "home" ) {
				$("#contactPhoto").fadeTo("normal", 1);
				$("#homePhoto").fadeTo("normal", 0);
				$(".text").css("display", "none");
				$("#contactText").css("display", "block");
				$("#contactText").css("opacity", 0);
				$("#contactText").fadeTo("normal", 1);
			}
			else {
				$(".thumbGroup").css("display", "none");
				$("#photoLarge").css("display", "block");
				$("#photoLarge").css("opacity", 0);
				$("#homePhoto").css("opacity", 0);
				$("#contactPhoto").css("opacity", 1);
				$("#photoLarge").fadeTo("normal", 1);
				$("#changer").empty();
				$("#changer").hide();
				$(".text").css("display", "none");
				$("#contactText").css("display", "block");
				$("#contactText").css("opacity", 0);
				$("#contactText").fadeTo("normal", 1);
			}
		}
		contentSection = getSection;
	});
});