// JavaScript Document


$(document).ready( function() { 

	$('#nome_news').focus(function() {
		if ( $('#nome_news').val() == "Nome Completo"){
			$('#nome_news').val('');
		}
	});	
	
	$('#email_news').focus(function() {
		if ( $('#email_news').val() == "E-mail"){
			$('#email_news').val('');
		}
	});	

});

function cadastraNews(){
	if (document.news.nome_news.value == "" || document.news.nome_news.value == "Nome Completo"){
		alert("Informe seu nome completo");
		document.news.nome.focus()
	}else if (document.news.email_news.value.indexOf ('@',0) == -1 || document.news.email_news.value.indexOf ('.',0) == -1){
		alert("Digite um e-mail válido.")
		document.news.email_news.focus();		  
	}else if (document.news.aceito_news.checked == false){
		alert("Informe se você aceita receber as notícias do Jequitibá Shopping");
	}else{
		var params = $("#news").serialize();
		$("#enviandonews").html('<img src="loading.gif" />');
		$.post('news.asp', params , function(data){
			if (data == 0){				
				alert("Dados salvos com sucesso");
			}else if (data == 1){				
				alert("E-mail já existente em nossa base de dados");
			}else{
				alert("Erro ao gravar dados! Tente mais tarde");
			}
		});
		$("#enviandonews").html(''); 		
	}
}

function fechaAbre(guia){
	$('#area_' + guia).slideToggle(800);	
}

function enviaContato()
{
	if (document.FormContato.nome.value == "")
	{
		alert("Informe o seu Nome!")
		document.FormContato.nome.focus();		
		return false;   
	}
	if (document.FormContato.email.value.indexOf ('@',0) == -1 || document.FormContato.email.value.indexOf ('.',0) == -1)
	{
		alert("Esse não é um e-mail válido.\nPor favor entre com um e-mail válido.")
		document.FormContato.email.focus();		
		return false;   
	}
	if (document.FormContato.assunto.value == "")
	{
		alert("Informe o assunto do contato!")
		document.FormContato.assunto.focus();		
		return false;   
	}			
	if (document.FormContato.msg.value == "")
	{
		alert("Digite conteúdo da Mensagem!")
		document.FormContato.msg.focus();		
		return false;   
	}			
	return (true);
} 

