// JavaScript Document
function plan_login() {
	
	with( document.forms[0] ){
		
		if( login_usuario.value == "" ) {
			
			window.alert("Digite o usuário.");
			login_usuario.focus();
			return false;
		}

		if( login_senha.value == "" ) {
			
			window.alert("Digite a senha.");
			login_senha.focus();
			return false;
		}
		
		
		method = "POST";
		action = "plan_login_exec.php";
		submit();

	}
}



function GetFocus(IDElemento) {
	
	if( document.getElementById(IDElemento) ){
		
		document.getElementById(IDElemento).focus();
	}else{
	window.alert("Elemento "+IDElemento+" não encontrado.");	
	}
}


function onRelatoriosExportarToExcel(url) {
	
	document.location =  url;
}


function onOpenPopUp(url, frame, param) {
	
	newWin = window.open(url, frame, param);
	
	if( newWin == null )
	{
		alert('Seu navegador está com o bloqueador do popups ativado.');
		return;
	}
}

function onClosePopup(){
	
	this.close();
}


function onProdutosFilter() {
	
	with( document.forms[0] ){
	
	textfield.disabled = true;
	
	method = "GET";
	action = "plan_produtos.php";
	submit();
	}
}


function onCadastro(URL) {
	
	with( document.forms[0] ){
		
		if(nome.value == ""){
			
			window.alert("Digite seu nome.");
			nome.focus();
		}else{
		if(email.value.indexOf("@") == "-1" || email.value.indexOf(".") == "-1"){
			
			window.alert("Digite seu e-mail.");
			email.focus();
		}else{
		if(dia.value == "" || mes.value == "" || ano.value == "" ){
			
			window.alert("Selecione a data de nascimento.");
			dia.focus();
		}else{
		if(senha.value == ""){
			
			window.alert("Digite a senha.");
			senha.focus();
		}else{
		if(endereco.value == ""){
			
			window.alert("Digite o endereço.");
			endereco.focus();
		}else{
		if(numero.value == ""){
			
			window.alert("Digite o número.");
			numero.focus();
		}else{
		if(bairro.value == ""){
			
			window.alert("Digite o bairro.");
			bairro.focus();
		}else{
		if(cep.value == ""){
			
			window.alert("Digite o CEP.");
			cep.focus();
		}else{
		if(cidade.value == ""){
			
			window.alert("Digite a cidade.");
			cidade.focus();
		}else{
		if(estado.value == ""){
			
			window.alert("Selecione o estado.");
			estado.focus();
		}else{
		if(ddd.value == ""){
			
			window.alert("Digite o código DDD.");
			ddd.focus();
		}else{
		if(fone.value == ""){
			
			window.alert("Digite o telefone.");
			fone.focus();
		}else{
		if(civil.value == ""){
			
			window.alert("Selecione o estado civil.");
			civil.focus();
		}else{
		if(filhos.value == ""){
			
			window.alert("Selecione se você tem filhos.");
			filhos.focus();
		}else{
		if(sexo.value == ""){
			
			window.alert("Selecione seu sexo.");
			sexo.focus();
		}else{
		if(numero_calca.value == ""){
			
			window.alert("Digite o número que calça.");
			numero_calca.focus();
		}else{
		if(escolaridade.value == ""){
			
			window.alert("Selecione a escolaridade.");
			escolaridade.focus();
		}else{
		if(profissao.value == ""){
			
			window.alert("Selecione a profissão.");
			profissao.focus();
		}else{
		if(renda.value == ""){
			
			window.alert("Selecione sua renda familiar.");
			renda.focus();
		}else{
		if(produtos_vizzano.value == ""){
			
			window.alert("Selecione se possui produtos vizzano.");
			produtos_vizzano.focus();
		}else{
		if(revista1.value == ""){
			
			window.alert("Digite pelo menos 1 revista que você lê.");
			revista1.focus();
		}else{
		if(programa_tv.value == ""){
			
			window.alert("Digite o seu programa de TV favorito.");
			programa_tv.focus();
		}else{
		if(programa_canal.value == ""){
			
			window.alert("Digite o nome do canal de tv, que você assiste este programa.");
			programa_canal.focus();
		}else{
		if(!perfil[0].checked && !perfil[1].checked ){
			
			window.alert("Marque uma das opções de promoção.");
			perfil[0].focus();
		}else{
			
			method = "POST";
			action = URL;
			submit();
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}
		}			
		}
		}						
		}			
		}			
		}						
		}						
		}						
		}			
		}			
		}
		}
		}
		}
	}
}



function onLiberarRecado(ID, URL, PG) {
	
	if( ID != '' && URL != '' && PG != '' ) {
		
		if( confirm("Deseja liberar esse recado.") ) {
		
		document.location = URL+"?act=liberar&id="+ID+"&pg="+PG;
		}
	}else{

	alert("Faltam parâmetros.");
	}
}

var img = new Image();

openPopup = function()
{
	jQuery("#popup").html("<img src=\""+img.src+"\" alt=\"\" title=\"\" />");
	var width = (jQuery.browser.msie)?(img.width+10):(img.width+8);
	var height = (jQuery.browser.msie)?(img.height+31):(img.height+29);
	var popup = new Popup("popup",width,height);
	popup.init();
	popup.show();
}
