$(document).ready(function() {
	$("#page").fadeOut(0);
	
	var winHeight = windowSize('height');
	var frameHeight = winHeight-310;
	
	$("#content").css({ 'height':winHeight-180-35+'px' });
	
	$.preload('imagens/bg.jpg', {
		base: 'http://127.0.0.1/',
		onFinish:function() {
			$("body").prepend('<div id="welcome"><img src="media/imagens/logo.png" alt="Seja bem vindo!" /></div>');
			$("#welcome").css({ 'text-align': 'center', 'marginTop' : (winHeight/2)-60+'px' });
			$("#welcome").delay(1000).fadeOut(600);
			$("#page").delay(1650).fadeIn(600);
		}
	});
	//$("#page").fadeIn(0);
	
	var menuopen;
	var frames = new Array();
	frames['sobremim'] 	= false;
	frames['portfolio'] = false;
	frames['curriculo'] = false;
	frames['contato'] 	= false;
	
	$("#menu .bttmh").hover(function() {
		$(this).parent().addClass('mbh');
		$(this).find('a').css({ 'color': '#fff' });	
	},function() {
		if($(this).find('a').attr('href') != menuopen) {
			$(this).parent().removeClass('mbh');
			$(this).find('a').css({ 'color': '#999' });	
		}
	});
	$("#menu .bttmh").click(function() {
		var linkhref = $(this).find('a').attr('href');
		if(menuopen) {
			$("#menu").find('.'+menuopen).removeClass('mbh');
			$("#menu").find('.'+menuopen+' a').css({ 'color': '#999' });
		}
		$("#frame .fr").fadeOut(300);
		
		if(menuopen != linkhref) {
			$("#frame").slideUp();
			$("#frame").css({ 'height': frameHeight+'px' }).slideDown();
			if(frames[linkhref] != true) {
				$("#frame").find('.'+linkhref).html('<div class="loading" style="padding-top:'+(frameHeight/2)+'px"><img src="media/imagens/ajaxloader.gif" alt="carregando página, aguarde." /></div>');
				$.ajax({
					url: linkhref,
					cache: false,
					success: function(data) {
						$("#frame").find('.'+linkhref).html(data);
						frames[linkhref] = true;
					}
				});
			}
			$("#frame").find('.'+linkhref).delay(300).fadeIn(300);
			menuopen = linkhref;
		} else {
			$("#frame").slideUp();
			menuopen = null;
		}
		return false;
	});
});
