$(function() {

	/*-- ALL OF THESE ARE CSS RULES DONE THROUGH JQUERY BECAUSE OF IE'S LACK OF PROPER SUPPORT FOR CSS SELECTORS --*/
	
	/*-- adds padding to the main container if the window is too small --*/
	AdjustContainerHeight();
	$(window).resize(function() {
		AdjustContainerHeight();
	});

	/*-- Shows sub menu when hovered --*/
	$("ul#menu li").hover(function(){
		$(this).addClass("hover");
	},function(){
		$(this).removeClass("hover");
	});
	
	/*-- last menu item needs to be narrower --*/
	$("ul#menu li:last-child").addClass("last");

	$("#about h1:first").css({ "padding-top" : "0" });
});

function AdjustContainerHeight() {
	var win_height = $(window).height();
	var main_height = $("#main-container").height();
	var content_height = ($.browser.msie) ? $(".content-container").height() : parseInt($(".content-container").css("height"));
	// 220px for header, height of content, 133px for footer and 15px for good measure
	var total = 220 + content_height + 133 + 15;
	if (win_height < total) {
		var diff = ((total - win_height) > 133) ? 133 : total - win_height;
		$("#main-container").css("padding-bottom",diff);
	} else {
		$("#main-container").css("padding-bottom",0);
	}
}

$(function() {

	$(".thumbs a").click( function() {
		MoveTo(this);
		//console.log(this);
		return false;
	});

	/*$("#back, #next").click( function() {
		var direction = $(this).attr("id");
		Move(direction);
		return false;
	});*/

});

function GetProjectImage(img_id) {
	var src = $("#"+img_id).attr("href");
	//console.log("SRC: "+src);
	//var params = $("#"+img_id+" img").attr("alt").split("|");
	if( src ) {
		$("#img img").attr("src", src);
		AdjustContainerHeight();
		//$("#desc em").html(params[0]);
		//var new_width = (eval(params[1]) + 40);
		//var new_height = params[2];
		//var style = "width:"+new_width+"px; height:"+new_height+"px;";
		//$("#photo-wrapper").attr("style", style);
	} else {
		return false;
	}
}

function MoveTo(info) {
	var id = $(info).attr("id");
	$(info).addClass("here");
	GetProjectImage(id);
	$(".thumbs a").not("#"+id).each(function() {
		$(this).removeClass("here");
	});
}

/*function Move(direction) {
	var curr = $(".thumbs .here");
	var back = $(curr).prev("a");
	var next = $(curr).next("a");

	if( (direction == "back" && curr.hasClass("first")) || (direction == "next" && curr.hasClass("last")) ) {
		return false;
	} else {
		if( direction == "back" ) {
			MoveTo(back);
		} else if( direction == "next" ) {
			MoveTo(next);
		} else {
			return false;
		}
	}
}*/