$(document).ready(function(){
	$('.language').customStyle();	
	$('.language').change(function(){
		window.location = '/language.php?lang='+$(this).val();								   
	});
						   
	$('.project > a > img').css("height", "500px");
	$('.project > a  > img').load(function(){
		$(this).css("height", "inherit");
		if ($('a.active').attr('href') != null){
			var height = ($($('a.active').attr('href').replace('Content','')).height()+70);
			$('#contentBox').css("height", height+"px");
		}
	    $('#footer').animate({top: (($('body').height()-$('#footer').height())+'px')}, 500);									  
	});
	
	$("a.slideTo").click(function(){
		makePage($(this).attr('href'));
		return false;
	});
	
	
	makePage((window.location.hash != "" ? window.location.hash : '#whoAmIContent'));	
	$('#footer').animate({top: (($('body').height()-$('#footer').height())+'px')}, 500);			   
});

function makePage(href){	
	if (href == "" || href == "undefined" || href == null){
		return;	
	}
	
	href = href.replace('Content','');
	
	$("a.active").removeClass("active");
	$("a[href="+(href+'Content')+"]").addClass("active");	
	$('#pageTitle > h2').html($(href).find('h1:hidden').html());
	var height = ($(href).height()+70);
	
	$('#contentBox').css("height", height+"px");
	$('#contentBox').scrollTo( $(href), 800, {onAfter: function(){
															
			window.location.hash = href.replace("#", "")+'Content';
	}});
	
	
	$('#footer').animate({top: (($('body').height()-$('#footer').height())+'px')}, 500);
	
}
