// JavaScript Document
var topo = 0;
var subir = 0;
var descer = 0;
var altura = 0;
var limite =0;
function Dimensiona_tela(){
	altura = $("#conteudo_principal").height();
	limite = $("#tela_principal").height();
	//limite = parseInt(limite.substr(0, limite.length - 2));
	//altura = parseInt(altura.substr(0, altura.length - 2));
	if (altura <= limite){
		$('#seta_up').hide();
		$('#seta_down').hide();
	}
	else{
		$('#seta_up').show();
		$('#seta_down').show();
	}
}
$(document).ready(function(){
	Dimensiona_tela();
	function Subir_conteudo(){
		if (subir == 1){
			var valor = altura + topo;
			if (valor >= limite){
				topo = topo-5;
				$("#conteudo_principal").css("top", topo + "px");
				setTimeout(function(){Subir_conteudo()}, 50);
			}
		}
	}
	function Descer_conteudo(){
		if (descer == 1){
			if (topo < 0){
				topo = topo +5;
				$("#conteudo_principal").css("top", topo + "px");
				setTimeout(function(){Descer_conteudo()}, 50);
			}
		}
	}
	$("#seta_up").css({
					  opacity: ".5",
					  filter: "alpha(opacity=50)"
					}).mouseover(function(){
		subir = 1;
		Subir_conteudo();
		$(this).css({
					opacity: "1",
					filter: "alpha(opacity=100)"
					});
	}).mouseout(function(){
		subir = 0;
		$(this).css({
					opacity: ".5",
					filter: "alpha(opacity=50)"
					});
	});
	$("#seta_down").css({
						opacity: ".5",
						filter: "alpha(opacity=50)"
						}).mouseover(function(){
		descer = 1;
		Descer_conteudo();
		$(this).css({
					opacity: "1",
					filter: "alpha(oapcity=100)"
					});
	}).mouseout(function(){
		descer = 0;
		$(this).css({
					opacity: ".5",
					filter: "alpha(opacity=50)"
					});
	});
});