//**** Função que permite apenas a digitação de números em um campo ****
function somenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    
	if (tecla >95 && tecla<106)
		return true;
		    
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if ((tecla != 8)&& (tecla != 16) && (tecla != 37) && (tecla != 39) && (tecla != 46) && (tecla != 35) && (tecla != 36)) return false;
    else return true;
    }
}



//**** Função para determinar o maxLength em campos textarea ****
function maxLength(textAreaField, limit) {
	var ta = document.getElementById(textAreaField);
	
	if (ta.value.length >= limit) {
		ta.value = ta.value.substring(0, limit-1);
	}
}


//**** Função para limpar o texto do input de Cadastre-se ****
function limparTexto(obj){
	if(obj!=null)
		if((obj.value =='/Digite aqui o seu email')||(obj.value =='/Digite aqui o seu nome')||(obj.value =='/Digite aqui o seu e-mail')||(obj.value =='/Assunto')||(obj.value =='/Mensagem')||(obj.value =='/Digite aqui o seu telefone com DDD')||(obj.value =='/Digite o nome dos seus convidados separados por virgula (,)'))
			obj.value ='';
}


function showAgenda(dia)
{
    //document['foto_agenda'].src = "img/img_"+dia+".jpg";
    document.getElementById('home_quinta').style.display='none';
    document.getElementById('home_sexta').style.display='none';
    document.getElementById('home_sabado').style.display='none';
    document.getElementById('home_domingo').style.display='none';
    document.getElementById('home_segunda').style.display='none';
    document.getElementById('home_'+dia).style.display='';
}

//**** Função para cadastrar o e-mail no Mailing ****
function enviarCadastro(){
	if(validarEmail()){
		document.frm_cadastro.action='cadastra-email.asp';
		document.frm_cadastro.submit();
		alert('E-mail cadastrado com sucesso!');
		document.location.href='index.asp';
		document.getElementById('email').value="";
	}
	else
	{
	    alert( "Preencha seu e-mail corretamente!" );
	}
}

function validarEmail(){
	if( document.getElementById('email').value=="" || document.getElementById('email').value.indexOf('@')==-1 || document.getElementById('email').value.indexOf('.')==-1 )
	{
		document.getElementById('email').value="";
		document.getElementById('email').focus();
		return false;
	}
	else
	{
		return true;	
	}									
}


function validarContato()
{
	if(document.frm_contato.contato_nome.value == "" || document.frm_contato.contato_nome.value == "/Digite aqui o seu nome")
	{
		alert('Por favor, informe seu nome.');
		document.frm_contato.contato_nome.focus();
		return false;
	}
	else if(document.frm_contato.contato_email.value == "" || document.frm_contato.contato_email.value == "/Digite aqui o seu e-mail" || document.frm_contato.contato_email.value.indexOf('@')==-1 || document.frm_contato.contato_email.value.indexOf('.')==-1)
	{
		alert('Por favor, preencha seu e-mail corretamente.');
		document.frm_contato.contato_email.focus();
		return false;
	}
	else if(document.frm_contato.contato_assunto.value == "" || document.frm_contato.contato_assunto.value == "/Assunto")
	{
		alert('Por favor, informe o Assunto.');
		document.frm_contato.contato_assunto.focus();
		return false;
	}
	else if(document.frm_contato.contato_msg.value == "" || document.frm_contato.contato_msg.value == "/Mensagem")
	{
		alert('Por favor, digite uma mensagem.');
		document.frm_contato.contato_msg.focus();
		return false;
	}
	else
	{
		return true;	
	}		
}



function enviarContato()
{
	if(validarContato()){
		document.frm_contato.action='envia-email-contato.aspx';
		document.frm_contato.submit();
		alert('Mensagem enviada com sucesso!');
	}
}


function validarLista()
{
	if(document.frm_aniversario.niver_nome.value == "" || document.frm_aniversario.niver_nome.value == "/Digite aqui o seu nome")
	{
		alert('Por favor, informe seu nome.');
		document.frm_aniversario.niver_nome.focus();
		return false;
	}
	else if(document.frm_aniversario.niver_email.value == "" || document.frm_aniversario.niver_email.value == "/Digite aqui o seu e-mail" || document.frm_aniversario.niver_email.value.indexOf('@')==-1 || document.frm_aniversario.niver_email.value.indexOf('.')==-1)
	{
		alert('Por favor, preencha seu e-mail corretamente.');
		document.frm_aniversario.niver_email.focus();
		return false;
	}
	else if(document.frm_aniversario.niver_telefone.value == "" || document.frm_aniversario.niver_telefone.value == "/Digite aqui o seu telefone com DDD")
	{
		alert('Por favor, informe seu telefone.');
		document.frm_aniversario.niver_telefone.focus();
		return false;
	}
	else
	{
		return true;	
	}		
}


function enviarLista()
{
	if(validarLista()){
		document.frm_aniversario.action='envia-email-lista.aspx';
		document.frm_aniversario.submit();
		alert('Lista enviada com sucesso!');
	}
}



function openLink(mypage, myname, w, h, scroll)
{
    pos_left = (screen.width - w) / 2
	pos_top = (screen.height - h) / 2
	winprops = 'height='+h+',width='+w+',scrollbars='+scroll+',left='+ pos_left +',top='+ pos_top +''
	win = window.open(mypage, myname, winprops)
	if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}