// JavaScript Document


function removeOk(tabela){
     $(document).ready(function(){ 
              var conteudo = "<div class='message-box'><p><span style='color:green;'>O conteudo foi removido,</span><br/>oque voc&ecirc; deseja fazer agora?</p><a href='gerenciador/listar/"+tabela+"'>Listar Cadastrados</a><a href='gerenciador/cadastrar/"+tabela+"'>Cadastrar Novo</a><a href='gerenciador/intranet'>Inicio<em></em></a></div>";
               $(".right").html(conteudo);
     });
}


function removeErr(tabela){
     $(document).ready(function(){ 
              var conteudo = "<div class='message-box'><p><span style='color:red;'>Falha ao remover conteudo,</span><br/>oque voc&ecirc; deseja fazer agora?</p><a href='gerenciador/listar/"+tabela+"'>Listar Cadastrados</a><a href='gerenciador/cadastrar/"+tabela+"'>Tentar Novamente</a><a href='gerenciador/intranet'>Inicio<em></em></a></div>";
               $(".right").html(conteudo);
     });
}




function insertOk(tabela){
     $(document).ready(function(){ 
              var conteudo = "<div class='message-box'><p><span style='color:green;'>O conteudo foi inserido,</span><br/>oque voc&ecirc; deseja fazer agora?</p><a href='gerenciador/listar/"+tabela+"'>Listar Cadastrados</a><a href='gerenciador/cadastrar/"+tabela+"'>Cadastrar Novo</a><a href='gerenciador/intranet'>Inicio<em></em></a></div>";
               $(".right").html(conteudo);
     });
}


function insertErr(tabela){
     $(document).ready(function(){ 
              var conteudo = "<div class='message-box'><p><span style='color:red;'>Falha ao inserir conteudo,</span><br/>oque voc&ecirc; deseja fazer agora?</p><a href='gerenciador/listar/"+tabela+"'>Listar Cadastrados</a><a href='gerenciador/cadastrar/"+tabela+"'>Tentar Novamente</a><a href='gerenciador/intranet'>Inicio<em></em></a></div>";
               $(".right").html(conteudo);
     });
}




function editOk(tabela,id){
     $(document).ready(function(){ 
              var conteudo = "<div class='message-box'><p><span style='color:green;'>O conteudo foi Editado,</span><br/>oque voc&ecirc; deseja fazer agora?</p><a href='gerenciador/listar/"+tabela+"/0/1/'>Listar Cadastrados</a><a href='gerenciador/editar/"+tabela+"/"+id+"'>Editar Novamente</a><a href='gerenciador/cadastrar/"+tabela+"'>Cadastrar Novo</a><a href='gerenciador/intranet'>Inicio<em></em></a></div>";
               $(".right").html(conteudo);
     });
}


function editErr(tabela,id){
     $(document).ready(function(){ 
              var conteudo = "<div class='message-box'><p><span style='color:red;'>Falha ao editar conteudo,</span><br/>oque voc&ecirc; deseja fazer agora?</p><a href='gerenciador/listar/"+tabela+"'>Listar Cadastrados</a><a href='gerenciador/editar/"+tabela+"/"+id+"'>Tentar Novamente</a><a href='gerenciador/cadastrar/"+tabela+"'>Cadastrar Novo</a><a href='gerenciador/intranet'>Inicio<em></em></a></div>";
               $(".right").html(conteudo);
     });
}



function resposta(msg){
	
	$(document).ready(function(){ 
		
		
		$("input:not(input[type=submit]),select,textarea").focus(function(){ $(this).animate({opacity:0.75}); });
		$("input:not(input[type=submit]),select,textarea").blur(function(){ $(this).animate({opacity:1}); });
		$("input[type=submit]").mouseover(function(){ $(this).animate({opacity:0.75}); });
		$("input[type=submit]").mouseout(function(){ $(this).animate({opacity:1}); });
		
		
		$(".mensagem p").html(msg);
		$(".lockscreen").slideDown();		
		$(".mensagem").fadeIn();
		setTimeout('$(".mensagem,.lockscreen").fadeOut();',2000);
		
     });

}




function uploadimg(newname){
	
	var myinput = "<input type='text' name='file' value='"+newname+"'/>";
	$("#myfile input").appendTo("#upload-container");
	$(myinput).appendTo("image-loader");
	$("#image-loader").fadeIn();
	document.myupload.submit();

}


function addfile(){
	
	$("#myfile").html("<input type='file' name='file' style='width:190px;' onchange='uploadimg();'/>");
	$("#container img").remove();
	$("#myupload input").remove();
	$("#container").fadeOut();
	document.oform.pic.value='';
	
}


function addimagem(){
	
	$("#imagens-container table").clone().prependTo("#imagens-reciver");

}


function addalt(){
	
	$("#imagens-container table").clone().appendTo("#imagens-reciver");

}




function votar(){
	
	var voto = $("#enquete input:checked").attr("value");
	vote('enquete-votar','indice='+voto,'stats');
	
}


function avaliar(id){
	
	$(document).ready(function(){ 	


		$("#"+id+" span input").click(function(){ 
			
			$("#"+id+" span").css({"background":"url(libs/img/star2.gif) center no-repeat","opacity":1}); 
			
			var valor = $("#"+id+" span input:checked").attr("value");
			$("#"+id+" span:lt("+valor+")").css({"background":"url(libs/img/star1.gif) center no-repeat","opacity":1}); 
			//$("#"+id+" em").html(valor);
		
		});

		$("#"+id+" span input").mouseover(function(){ 
			
			var valor = $(this).attr("value");
			$("#"+id+" span:lt("+valor+")").css({"opacity":0.5}); 			
			
			switch(valor){
			case "1": $("#"+id+" em").html("Insatisfat�rio"); break;
			case "2": $("#"+id+" em").html("Abaixo da Expectativa"); break;
			case "3": $("#"+id+" em").html("Satisfat�rio"); break;
			case "4": $("#"+id+" em").html("Acime da Expectativa"); break;
			}
		});

		$("#"+id+" span input").mouseout(function(){ 
			
			var valor = $(this).attr("value");
			$("#"+id+" span:lt("+valor+")").css({"opacity":1}); 			
			$("#"+id+" em").html("");

		});

	});
}


	$(document).ready(function(){ 

          $("#maior").click(function(){ $("#corpo *").css("font-size","15px"); });
          $("#menor").click(function(){ $("#corpo *").css("font-size","12px"); });


          $("#accordion").accordion({autoHeight:false});
		
		$("input[type=text],input[type=password],select,textarea").focus(function(){ $(this).animate({opacity:0.75},100); });
		$("input[type=text],input[type=password],select,textarea").blur(function(){ $(this).animate({opacity:1},100); });
		$("input[type=submit]").mouseover(function(){ $(this).animate({opacity:0.75},100); });
		$("input[type=submit]").mouseout(function(){ $(this).animate({opacity:1},100); });


		
		$("#data").datepicker();
		$("#tabs").tabs();		

/*		$("input[type=text],input[type=password],textarea,select").focus(function(){ $(this).animate({backgroundColor:"#FFE8F3"}); });
		$("input[type=text],input[type=password],textarea,select").blur(function(){ $(this).animate({backgroundColor:"#FFF9F9"}); });
	
		$("input[type=submit]").css({"background":"#ffb1d4","color":"#ffffff"});
*/   		
		//avaliar $("td:lt(4)").css("color", "red");
		
	});
	


$(function() {
		$('.gal-container a').lightBox(); // Select all links in object with gallery ID
});

/* GALERIA DE FOTOS */


	
	function editarLegenda(id){
	
		var myid = document.getElementById("myid");
		var myinput = document.getElementById("mylegend");
		myinput.value =  $("#leg"+id).text();
		myid.value = id;
		$("#legend-mask").fadeIn(); 	
	}



	function updateLegend(){
		
		var id = document.getElementById("myid").value;
		var legenda = document.getElementById("mylegend").value;
		var legendatext = document.getElementById("leg"+id);
		
		process('editar-legenda','legenda='+legenda+'&id='+id);
		
		legendatext.innerHTML = legenda;
		$("#legend-mask").fadeOut();
		
				
	}
	
	
	function removeImg(id){
		
		$("#img-container"+id).fadeOut();
		process('remover-imagem','id='+id);

	}

