$(document).ready(function(){
	
	var lang = $('#canvas_home').attr('class');
	
	var hide = '';
	var show = '';
	
	if(lang == 'english'){
		hide = 'Hide';
		show = 'Show';
	}else{
		hide = 'Cuddio';
		show = 'Dangos';
	}
	
	$('#vertical').each(function(){
		
		$(this).prepend('<a class="yellow" href="#">'+hide+'</a>');
	});
	
	
	adjustMargin(false);
	
	
	$(window).resize(function(){
		if($('#vertical #nav').css('display') != 'none'){
			adjustMargin(true);
		}
	});
	
	$('#vertical a.yellow').toggle(function(me){
			me.preventDefault();
			$('#vertical #nav').hide();
			$('#vertical #content').hide();
			$(this).text(show);
		},function(me){
			me.preventDefault();
			$('#vertical #nav').show();
			$('#vertical #content').show();
			$(this).text(hide);
			adjustMargin(true);
	});
});


function adjustMargin(anim){
	var wh = getWindowHeight();
	//var wh = window.innerHeight;
	var dh = $('#vertical').height();
	var lh = $('#lang').height();
	var fh = $('#foot').height();
	var extra = ((wh-dh)/2)-lh-fh;

	if(!anim){
		$('#vertical').css('margin-top',extra);
	}else{
		$('#vertical').animate({
			marginTop: extra
		},'fast');
	}
}

function getWindowHeight() {
	var windowHeight = 0;
	if (typeof(window.innerHeight) == 'number') {
		windowHeight = window.innerHeight;
	}
	else {
		if (document.documentElement && document.documentElement.clientHeight) {
			windowHeight = document.documentElement.clientHeight;
		}
		else {
			if (document.body&&document.body.clientHeight) {
				windowHeight = document.body.clientHeight;
			}
		}
	}
	return windowHeight;
}