var scrollSpeed=1600;
var activeLeft = -1130;
var activeTop = -620;
var ativo = 0;

$(document).ready(function() {
						   
	/*		
		Left (colunas): 40, -1130, -2300, -3470	
		Top (linhas): 30, -620, -1270, -1920
	*/
	
	/*
	
	var lancamento = new Date(); 
	lancamento = new Date(2010, 6-1, 1); 
	$('#contador').countdown({until: lancamento, onTick: mudaCor, tickInterval:5}); 
	
	*/

	$("a.home").click(function(event){
		activeLeft = -1130;
		activeTop = -620;							   
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.evento").click(function(event){	
		activeLeft = 40;
		activeTop = -1270;						 
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$(".lnk_submenu").hover(function() {
		$(this).attr("src",$(this).attr("src").replace("OUT","ON"));
		}, function() {
			$(this).attr("src",$(this).attr("src").replace("ON","OUT"));		
		});
	
	$(".btn_enviar").hover(function() {
		$(this).attr("src",$(this).attr("src").replace("OUT","ON"));
		}, function() {
			$(this).attr("src",$(this).attr("src").replace("ON","OUT"));		
		});
		
	$("a.comites").hover(
	function() {
		$("#submenu_comites").slideDown('fast');

		$("#submenu_comites").hover(function() {
		}, function() {
			$("#submenu_comites").slideUp('slow');			
		});
	});
	
	$("#menu, #painel").hover(function() {
	}, function() {
		$("#submenu_comites").slideUp('slow');			
	});	
		
	$("a.modelos").click(function(event){
		activeLeft = -3470;
		activeTop = 30;
		movePainel(activeLeft,activeTop);		
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);	
		event.preventDefault();
	}); 
	
	$("a.atividades").click(function(event){
		activeLeft = -3470;
		activeTop = -1270;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);		
		event.preventDefault();
	}); 
	
	$("a.local").click(function(event){
		activeLeft = 40;
		activeTop = 30;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);		
		event.preventDefault();
	}); 
	
	$("a.inscricoes").click(function(event){								
		activeLeft = -2300;
		activeTop = -1270;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.contato").click(function(event){								
		activeLeft = -3470;
		activeTop = -1920;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#255C7C"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.cominform").click(function(event){								
		activeLeft = -1130;
		activeTop = 30;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#700e10"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.imprensa").click(function(event){								
		activeLeft = -2300;
		activeTop = 30;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#487a22"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.bandung").click(function(event){								
		activeLeft = 40;
		activeTop = -620;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#412b5e"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.aiea").click(function(event){								
		activeLeft = -2300;
		activeTop = -620;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#727a87"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.ce").click(function(event){								
		activeLeft = -3470;
		activeTop = -620;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#ad1a8f"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.csh").click(function(event){								
		activeLeft = -1130;
		activeTop = -1270;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#938105"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.sc").click(function(event){								
		activeLeft = 40;
		activeTop = -1920;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#58284a"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$("a.otan").click(function(event){								
		activeLeft = -2300;
		activeTop = -1920;
		movePainel(activeLeft,activeTop);
		$('body').stop().animate({backgroundColor: "#121d53"}, scrollSpeed);
		event.preventDefault();
	}); 
	
	$(".lnk_ano").click(function(event){								
		$("#ano_carregado").html($("#ano_"+$(this).attr("rel")).html());
	});
	
	$(".lnk_dia").click(function(event){								
		$("#dia_carregado").html($("#dia_"+$(this).attr("rel")).html());
	});
	
	
	$(window).resize(function()
	{ 
		movePainel(activeLeft,activeTop);
	}); 
	
	movePainel(activeLeft,activeTop);

});

function mudaCor(periods)
{
	var arrayCor = new Array("#121d53", "#58284a", "#938105", "#ad1a8f", "#727a87", "#412b5e", "#487a22", "#700e10");

	$('#contador').stop().animate({backgroundColor: arrayCor[Math.floor(periods[6]/7)]}, scrollSpeed);

}

function movePainel (left_1024, top_1024)
{

	//var percHeight = ($(window).height() * 100)/100;
	var percHeight = 500;
	
	/*if ( (($(window).width() > 1004) && ($.browser.msie)) || (($(window).width() > 1024) && (!$.browser.msie)) )
	{		
		var top_atual = top_1024 + (($(window).height() - percHeight) / 2);
	}
	else
	{
		//var top_atual = top_1024 + 100;
		var top_atual = top_1024 + (($(window).height() - percHeight) / 2);
	}
	*/
	var left_atual = left_1024 + (($(window).width() - 1024) / 2);
	var top_atual = top_1024 + (($(window).height() - percHeight) / 2);
		
	/*
	alert('Width: '+$(window).width()+' e Height: '+$(window).height());
	alert ('Left Atual: '+left_1024.toString()+' Top Atual: '+top_1024.toString());
	alert('left'+left_atual.toString()+'px , top'+top_atual.toString()+'px');
	*/
	
	$('#painel').stop().animate({'left':left_atual.toString()+'px', 'top':top_atual.toString()+'px'},scrollSpeed);
	$('#menu').stop().animate({'top':((($(window).height() - percHeight) / 2))+450+'px'},scrollSpeed);
}