function showSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "visible";
	}
}

function hideSelectBoxes(){
	var selects = document.getElementsByTagName("select");
	for (i = 0; i != selects.length; i++) {
		selects[i].style.visibility = "hidden";
	}
}

function montaFlash(swf, vars, width, height, id, wmode, cache) {
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param NAME=FlashVars value=\""+ vars +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"false\" />";
	monta_swf += "<param name=\"wmode\" value=\""+ wmode +"\" />";
	monta_swf += "<embed src=\""+ swf + noCache +"\"  FlashVars=\""+ vars + "\" quality=\"high\" menu=\"false\" wmode=\""+ wmode +"\"  pluginspage=\"http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash\" type=\"application/x-shockwave-flash\" id=\""+ id +"\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";
	document.write(monta_swf);
}

function popWin(URL,NAME,WIDTH,HEIGHT,RESIZE,SCROLL) {
   winId = window.open(URL,NAME,'width='+WIDTH+',height='+HEIGHT+',resizable='+RESIZE+',scrollbars='+SCROLL+',menubar=no,toolbar=no,location=no,directories=no,status=no');
	var clientWidth = screen.availWidth;
	var clientHeight = screen.availHeight;
	var xPos = (clientWidth - WIDTH)/2;
	var yPos = (clientHeight - HEIGHT)/2;
	winId.moveTo(xPos,yPos);
}

function checkemail(str){
	var testresults
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str)) testresults=false
	else testresults=true
	return (testresults)
}

function trim(str) { return str.replace(/^\s+|\s+$/g,""); }

function txtAmplia(iD) {
	atual = parseInt($("#"+iD).css("font-size").slice(0,-2))+1;
	if(atual<=15) {
		$("#"+iD).css({'font-size': atual+'px'});
	}
}

function txtReduz(iD) {
	atual = parseInt($("#"+iD).css("font-size").slice(0,-2))-1;
	if(atual>=11) {
		$("#"+iD).css({'font-size': atual+'px'});
	}
}

function ajaxLink(divId,theLink) {
	$.post(theLink,{teste:'1'}, function(vixi){ $("#"+divId).html(vixi); });
}

function checkLogin() {
	$("#msgErro,#msgErro2").html('');
	if($("#logEmail").val()=='') {
		$("#msgErro").html('<b>Erro:</b> Digite seu e-mail');
	} else if(checkemail($("#logEmail").val())) {
		$("#msgErro").html('<b>Erro:</b> Digite seu e-mail corretamente');		
	} else if($("#logSenha").val()=='') {
		$("#msgErro").html('<b>Erro:</b> Digite sua senha');		
	} else {
		$.post("_ajaxAux.php",{email:$("#logEmail").val(),senha:$("#logSenha").val(), tela:'tryLogin'}, function(r){ retLogin(r); });
	}
	return false;
}

function retLogin(i) {
	if(i=='1') {
		window.parent.location.href="contato.php?tela=imprensa"; 
		$("#msgErro").html('Acesso liberado');		
	} else if(i=='X') {
		$("#msgErro").html('Seu cadastro ainda não foi liberado!');		
	} else if(i=='0') {
		$("#msgErro").html('Verifique, e-mail ou senha incorreto!');				
	}
}

function recSenha() {
	$("#msgErro,#msgErro2").html('');
	$("#msgErro2").html('');
	if($("#logEmail").val()=='') {
		$("#msgErro2").html('<b>Erro:</b> Digite seu e-mail');
	} else if(checkemail($("#logEmail").val())) {
		$("#msgErro2").html('<b>Erro:</b> Digite seu e-mail corretamente');		
	} else {
		$("#msgErro2").html('Aguarde, verificando ...');
		$.get("_ajaxAux.php",{email:$("#cadEmail").val(), tela:'recuperarSenha'}, function(r){ retRecSenha(r); });
	}
}

function retRecSenha(i) {
	if(i=='1') {
		$("#msgErro2").html('Sua senha foi enviada em seu e-mail.');		
	} else if(i=='0') {
		$("#msgErro2").html('Seu cadastro ainda não foi liberado, aguarde!');
	} else if(i=='X') {
		$("#msgErro2").html('Este e-mail não foi encontrado em nosso sistema');
	}
}

function check_news(i) {
	var msg1 = new Array();
	var msg2 = new Array();
	var msg3 = new Array();
	msg1['BR'] = 'Preencha seu nome'; 
	msg1['US'] = 'Type your name'; 
	msg1['ES'] = '';
	msg2['BR'] = 'Preencha seu e-mail'; 
	msg2['US'] = 'Type your e-mail'; 
	msg2['ES'] = '';
	msg3['BR'] = 'Preencha seu e-mail, corretamente'; 
	msg3['US'] = 'Type a valid e-mail'; 
	msg3['ES'] = '';
	if($("#n_nome").val()=='') {
		alert(msg1[i]);
		$("#n_nome").focus();
	} else if($("#n_email").val()=='') {
		alert(msg2[i]);
		$("#n_email").focus();
	} else if(checkemail($("#n_email").val())) {
		alert(msg3[i]);
		$("#n_email").focus();
	} else {
		$.post("_ajaxAux.php",{nome:$("#n_nome").val(),email:$("#n_email").val(), tela:'cadCad'}, function(r){ alert(r); $("#n_nome").val(''); $("#n_email").val(''); });
	}
	return false;
}

function check_fSenha() {
	$("#msgErro3").html('');
	if($("#cadNome").val()=='') {
		$("#msgErro3").html('<b>Erro:</b> Preencha seu nome');		
	} else if($("#cadVeiculo").val()=='') {
		$("#msgErro3").html('<b>Erro:</b> Preencha o veículo de comunicação');		
	} else if($("#cadEmail").val()=='') {
		$("#msgErro3").html('<b>Erro:</b> Digite seu e-mail');
	} else if(checkemail($("#cadEmail").val())) {
		$("#msgErro3").html('<b>Erro:</b> Digite seu e-mail corretamente');		
	} else {
		$("#msgErro3").html('Aguarde, verificando ...');
		$.post("_ajaxAux.php",{nome:$("#cadNome").val(),email:$("#cadEmail").val(),veiculo:$("#cadVeiculo").val(), tela:'solicitarSenha'}, function(r){ retSenha(r); });
	}
	return false;
}

function retSenha(i) {
	if(i=='1') {
		$("#msgErro3").html('Sua solicitação foi enviada. O Departamento de Imprensa do Portal entrará em contato no e-mail informado.');		
	} else if(i=='0') {
		$("#msgErro3").html('Este e-mail já esta cadastrado, caso tenha esquecido a senha utilize o formulário ao lado!');
	} else {
		$("#msgErro3").html('Dados de retorno inválido');
	}
}

var timeout;
function abreWin(url) {
	hideSelectBoxes();
	$("#divBg").height(document.body.clientHeight); $("#divBg").show(); $("#divBg").fadeTo(0.01, 0.7); $("#divMeio").show();
	$("#divMeio").width(550); $("#divMeio").height(350); $("#divMeio").load(url); upWin();
	
}

function upWin() {
	aVw = document.documentElement.clientWidth/2;
	aVh = document.documentElement.clientHeight/2;
	cWi = $("#divMeio").width()/2;
	cHe = $("#divMeio").height()/2;
	$("#divMeio").css({ top:(aVh-cHe)+document.documentElement.scrollTop, left:(aVw-cWi)+document.documentElement.scrollLeft });
	timeout = setTimeout('upWin()', 200);
}
function abre() { $("#idiomas").slideToggle("normal");}
var menuTimer = -1;
var menuDelay = 350;

function showMenu(id) { window.clearTimeout(menuTimer); menuTimer = window.setTimeout('open_sub(\'' + id + '\')',menuDelay); }
function closeOverlay() { $("#divMeio").html(''); $("#divMeio").css({width:"1px", height:"1px", marginLeft:"0px", marginTop:"0px"}); $("#divMeio").hide(); $("#divBg").fadeTo("fast", 0, function() { $("#divBg").hide(); showSelectBoxes(); }); timeout = window.clearInterval(timeout); }
$(document).ready(function() {
	$(document).pngFix();
	showMenu(atual);
	$('.gb').hover(function(){
		pega = this.id;
		showMenu(pega);
	}, function(){
		showMenu(atual);
	});
	$("#divBg").click(function() { closeOverlay() });
	$(".imgOver4").hover(function(){
 		theID = $(this).html();
		$(this).children().css("background-position","-76px");
	}, function(){
		$(this).children().css("background-position","-38px");
	});
	$(".imgOver4").mousedown(function(){
 		theID = $(this).html();
		$(this).children().css("background-position","-114px");
	});
	$(".imgOver4").mouseup(function(){
 		theID = $(this).html();
		$(this).children().css("background-position","-38px");
	});
	$(".imgOverCL").hover(function(){
		$(this).children().css("background-position","right");
	}, function(){
		$(this).children().css("background-position","left");
	});
	$(".imgOver").hover(function(){
		$(this).children().css("background-position","bottom");
	}, function(){
		$(this).children().css("background-position","top");
	});
});


