// JavaScript Document

	var Geral = {
		Inicio: function () {
			$('a').click(function (){if ($(this).attr("href") == "#") {return false}});
			$('.voltar').click(function (){history.back(); return false;});
			$('.print').click(function (){window.print(); return false;});
			$('.op').hover(function(){$(this).children("img").stop().fadeTo(250,.7);}, function () {$(this).children("img").stop().fadeTo(250,1);});
			$('.opb').hover(function(){$(this).stop().fadeTo(250,.7);}, function () {$(this).stop().fadeTo(250,1);});
			$(".po").children("img").stop().fadeTo(0, .5);
			$(".po").hover(function () {$(this).children("img").stop().fadeTo(250, 1);}, function() {$(this).children("img").stop().fadeTo(250, .5);});
			$('.tr').hover(function(){$(this).children("img").stop().fadeTo(250,.0);}, function () {$(this).children("img").stop().fadeTo(250,1);});
			$('.zoon').click(function(){return hs.expand(this);});
			$("input[type=text], textarea").focus(function(){if ($(this).attr("title") == $(this).val()) {$(this).val("");}});	
			$("input[type=text], textarea").blur(function(){if ($(this).val() == "" && $(this).attr("title")) {var tt = $(this).attr("title");$(this).val(tt);}});	
		} ,		
		BVersion: function() {
			var version = 999; 
			if (navigator.appVersion.indexOf("MSIE") != -1)
			version = parseFloat(navigator.appVersion.split("MSIE")[1]);
			return version;
		}
	}

	/* Funçoes de news padrao. */
	
	function retAjax() {
			$("#ocultNewsJan").show();
			$("#janContSub").html(" ");
			$("#aguardeJanNews").css("display", "none");
			$("#ocultNewsJan").css("color", "#a4a4a4");
			$("#ocultNewsJan").html("<p>&nbsp;</p><p>&nbsp;</p>Seu cadastro foi efetuado com sucesso.<br/> Obrigado!");
			$('#JanEnvNews').animate({top: '+=80', height: '190px'}, 500, function() {});
			setTimeout('fechaJanNews()', 5000);
	}
	
	function fechaJanNews () {
		var _body 		= $('body')[0];
		$("#takeAll").remove();
		$("#JanEnvNews").remove();
	}
	
	function newsCad () {
		var _body 		= $('body')[0];
		var _h = $(document).height();
		var _w = $(document).width();
		$( _body).append('<div id="takeAll"></div>');
		$('#takeAll').height(_h).width(_w).css('background',"#666").css('position','absolute').css('z-index',99).css('top',0).css('left',0).css('display','none');
		$('#takeAll').fadeTo(400,.6);

		$( _body).append('<div id="JanEnvNews"></div>');
		$('#JanEnvNews').height("433px").width("518px").css('background',"#fff").css('position','absolute').css('z-index',100).css('top','80px').css('left','50%').css('display','none').css('margin-left','-259px');
		$('#JanEnvNews').fadeTo(700,1);
		
		var content = '';
		
		content += '<form id="newsJanForm" name="newsJanForm">';
			content += '<talbe cellspace="0" cellpadding="0" border="0" width="474px" id="camposJanNews">';
				content += '<tr><td align="right"><a href="#" id="closeJanNews"><img src="img/alertas/news/closenews.gif" width="22" height="15" align="right" /></a></td></tr>';
			content += '<div id = "ocultNewsJan">';				
				content += '<tr id="escJanNews"><td align="left" id="janContSub"><img src="img/alertas/news/titulonews.gif" width="474" height="19" /></td></tr>';
				content += '<tr><td align="left"><img src="img/alertas/news/nomett.gif" width="474" height="42" /></td></tr>';
				content += '<tr><td align="left"><input type="text" name="nomeJan" id="nomeJan" class="newsJanInp"  /></td></tr>';		
				content += '<tr><td align="left"><img src="img/alertas/news/emailtt.gif" width="474" height="29" /></td></tr>';
				content += '<tr><td align="left"><input type="text" name="emailJan" id="emailJan" class="newsJanInp"  /></td></tr>';		
				content += '<tr><td align="left"><img src="img/alertas/news/cidadett.gif" width="474" height="33" /></td></tr>';
				content += '<tr><td align="left"><input type="text" name="cidadeJan" id="cidadeJan" class="newsJanInp"  /></td></tr>';		
				content += '<tr><td align="left"><img src="img/alertas/news/estadott.gif" width="474" height="34" /></td></tr>';
				content += '<tr><td align="left"><input type="text" name="estadoJan" id="estadoJan" class="newsJanInp"  /></td></tr>';
				content += '<tr><td align="center"><input type="image" src="img/alertas/news/env.gif" id="envJanOpc"  /></td></tr>';
		    content += '</div>';
			content += '</table>';
			content += '<div id="aguardeJanNews">&nbsp;</div>';
		content += '</form>';		
		
		
		
		$("#JanEnvNews").append('<div id="centraContJan">'+content+'</div>');
		$('#centraContJan').height("408px").width("474px").css('display','block').css('margin-left','22px').css('margin-top','12px');

		$('#takeAll, #closeJanNews').click(function() {
			var _body 		= $('body')[0];
			$("#takeAll").remove();
			$("#JanEnvNews").remove();
			return false;
		});		
		
		$("#newsJanForm").submit(function () {
			$("#ocultNewsJan").hide();
			$("#aguardeJanNews").css("display", "block");
			var valida = 0;
			
			  if ($("#nomeJan").val() == "") {
				valida =1;
				$("#nomeJan").css("border-color", "#900").css("color", "#900");
			} else {
				$("#nomeJan").css("border-color", "#EFEBE7").css("color", "#555450");				
			}
			  if ($("#emailJan").val() == "") {
				valida =1;
				$("#emailJan").css("border-color", "#900").css("color", "#900");
			}  else {
				$("#emailJan").css("border-color", "#EFEBE7").css("color", "#555450");				
			}
			  if ($("#cidadeJan").val() == "") {
				valida =1;
				$("#cidadeJan").css("border-color", "#900").css("color", "#900");
			}  else {
				$("#cidadeJan").css("border-color", "#EFEBE7").css("color", "#555450");				
			}
			  if ($("#estadoJan").val() == "") {
				valida =1;
				$("#estadoJan").css("border-color", "#900").css("color", "#900");
			}  else {
				$("#estadoJan").css("border-color", "#EFEBE7").css("color", "#555450");				
			}
			if (valida ==1) {
				$("#ocultNewsJan").show();
				$("#aguardeJanNews").css("display", "none");
			} else {
				var nome = $("#nomeJan").val();
				var email = $("#emailJan").val();
				var cidade = $("#cidadeJan").val();
				var estado = $("#estadoJan").val();
				
				$("#ocultNewsJan").load('senders/cadastroNewsPadrao.php', {nome:nome, estado:estado, cidade:cidade, email:email}, function() {
					setTimeout('retAjax()', 2000);
				});						
			}
			return false;	
		});
		
		
		$("#envJanOpc").hover(function () { $(this).fadeTo(250, .5);} , function () {$(this).fadeTo(250, 1);});
		
	}
	
	/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
	
	function constErro (valor) {
		var _body 		= $('body')[0];
		var _h = $(document).height();
		var _w = $(document).width();
		$( _body).append('<div id="takeAll"></div>');
		$( _body).append('<div id="cccjjj"><a href="#" id="closeJan"><img src="img/alertas/fechar.gif" width="38" height="27" /></a></div>');
		$( _body).append('<div id="flttt"><img src="/img/alertas/nenv.gif" width="573" height="187" /></div>');
		$('#takeAll').height(_h).width(_w).css('background',"#000").css('position','absolute').css('z-index',99).css('top',0).css('left',0).css('display','none');
		$('#cccjjj').height(_h).width(_w).css('position','absolute').css('z-index',101).css('top',valor).css('left',"50%").css('width','30px').css('height','30px').css('margin-left','260px');
		$('#flttt').height(_h).width(_w).css('position','absolute').css('z-index',100).css('top',valor).css('left',"50%").css('display','none').css('width','600px').css('height','220px').css('margin-left','-300px').css('background',"#FFF");
		 $('#takeAll').fadeTo(250,.45);
		 $('#flttt').fadeTo(250, 1);
		$('#takeAll,#closeJan').click(function() {
			var _body 		= $('body')[0];
			$("#takeAll").remove();
			$('#flttt').remove();
			$('#cccjjj').remove();
			return false;
		});		
	}

	function constOk () {
		var _body 		= $('body')[0];
		var _h = $(document).height();
		var _w = $(document).width();
		$( _body).append('<div id="takeAll"></div>');
		$( _body).append('<div id="cccjjj"><a href="#" id="closeJan"><img src="img/alertas/fechar.gif" width="38" height="27" /></a></div>');
		$( _body).append('<div id="flttt"><img src="/img/alertas/msgenv.gif" width="576" height="192"  /></div>');
		$('#takeAll').height(_h).width(_w).css('background',"#000").css('position','absolute').css('z-index',99).css('top',0).css('left',0).css('display','none');
		$('#cccjjj').height(_h).width(_w).css('position','absolute').css('z-index',101).css('top',"350px").css('left',"50%").css('width','30px').css('height','30px').css('margin-left','260px');
		$('#flttt').height(_h).width(_w).css('position','absolute').css('z-index',100).css('top',"350px").css('left',"50%").css('display','none').css('width','600px').css('height','220px').css('margin-left','-300px').css('background',"#FFF");
		 $('#takeAll').fadeTo(250,.45);
		 $('#flttt').fadeTo(250, 1);
		$('#takeAll,#closeJan').click(function() {
			var _body 		= $('body')[0];
			$("#takeAll").remove();
			$('#flttt').remove();
			$('#cccjjj').remove();
			return false;
		});		
	}
	
	
	var _x = new Array(23, 81, 140, 210, 334);
	var _w = new Array(60, 60,  70, 120,  70);
	function ajusta(valor) {
		var valor = new Number(valor);
		$('#underline').stop().animate({left: _x[valor]+'px', width: _w[valor]+'px'}, 500);
	}
	
	function compartilhaFace () {
		var url=location.href;
		var compoe = "";
		$("#cface").click(function () {
			window.open('http://www.facebook.com/sharer.php?u='+url+'','Compartilhamento', 'toolbar=0, status=0, width=650, height=450');			
			return false;
		});
	}
	
