// JavaScript Document

//flash
function flash(arquivo, largura, altura)
{
    document.write("<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0' width='" + largura + "' height='" + altura + "' ID=flashad>")
    document.write("<param name='allowScriptAccess' value='sameDomain' /><param name='movie' value='" + arquivo + "'>")
    document.write("<param name='quality' value='high'><param name='wmode' value='transparent' />")
    document.write("<embed src='" + arquivo + "' quality='best' wmode='transparent'  bgcolor='#ffffff' pluginspage='http://www.macromedia.com/go/getflashplayer' type='application/x-shockwave-flash' width='" + largura + "' height='" + altura + "'></embed>")
    document.write("</object>")
}

//////////////////

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function fechar() {
	botao = document.getElementById("natal2010");
	botao.style.display = 'none';
	
	document.getElementById("detalheE").style.display = 'block';
	document.getElementById("detalheD").style.display = 'block';
}

////////////////

<!-- Dynamic Version by: Nannette Thacker -->
<!-- http://www.shiningstar.net -->
<!-- Original by :  Ronnie T. Moore -->
<!-- Web Site:  The JavaScript Source -->
<!-- Use one function for multiple text areas on a page -->
<!-- Limit the number of characters per textarea -->
<!-- Begin
function textCounter(field,cntfield,maxlimit) {
if (field.value.length > maxlimit) // if too long...trim it!
field.value = field.value.substring(0, maxlimit);
// otherwise, update 'characters left' counter
else
cntfield.value = maxlimit - field.value.length;
}
var char = maxlimit - field.value.length;
//  End -->

////////////////////////////////////


function validaLogin() {
var form = document.login;
	if (form.usuario.value == "" || form.usuario.value == "login"){
		window.alert("Preencha o Usuário");
		return false
	}
	if (form.senha.value == "" || form.senha.value == "senha"){
		window.alert("Preencha a Senha");
		return false
	}
}

function validaContato() {
var form = document.contato;
	if (form.nome.value == ""){
		window.alert("Preencha o Nome");
		form.nome.focus();
		return false
	}
	if (form.sobrenome.value == ""){
		window.alert("Preencha o Sobrenome");
		form.sobrenome.focus();
		return false
	}
	if (form.email.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1){
		alert("Preencha o Email corretamente!")
		form.email.focus()
		return false
	}
	if (form.telefone.value == ""){
		window.alert("Preencha o Telefone");
		form.telefone.focus();
		return false
	}
	if (form.telefone.value.length < 12 ){
		window.alert("Telefone Inválido");
		form.telefone.focus();
		return false
	}
	if (form.interesse.value == ""){
		window.alert("Selecione o Interesse");
		form.interesse.focus();
		return false
	}
	if (form.mensagem.value == ""){
		window.alert("Preencha a mensagem");
		form.mensagem.focus();
		return false
	}
}

function validaIndique() {
var form = document.indique;
	if (form.nomede.value == ""){
		window.alert("Preencha o Nome");
		form.nome.focus();
		return false
	}
	if (form.nomepara.value == ""){
		window.alert("Preencha o Sobrenome");
		form.sobrenome.focus();
		return false
	}
	if (form.emailde.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.emailde.value.indexOf('@',0)==-1 || form.emailde.value.indexOf('.',0)==-1){
		alert("Preencha o Email corretamente!")
		form.email.focus()
		return false
	}
	if (form.emailpara.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.emailpara.value.indexOf('@',0)==-1 || form.emailpara.value.indexOf('.',0)==-1){
		alert("Preencha o Email corretamente!")
		form.email.focus()
		return false
	}
	if (form.mensagem.value == ""){
		window.alert("Preencha a mensagem");
		form.mensagem.focus();
		return false
	}
}


function validaFornecedor() {
var form = document.fornecedor;
	if (form.nome.value == ""){
		window.alert("Preencha o Nome");
		form.nome.focus();
		return false
	}
	if (form.email.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1){
		alert("Preencha o Email corretamente!")
		form.email.focus()
		return false
	}
	if (form.razao.value == ""){
		window.alert("Preencha a Razão Social");
		form.razao.focus();
		return false
	}
	if (form.endereco.value == ""){
		window.alert("Preencha o Endereço");
		form.endereco.focus();
		return false
	}
	if (form.bairro.value == ""){
		window.alert("Preencha o Bairro");
		form.bairro.focus();
		return false
	}
	if (form.cep.value == ""){
		window.alert("Preencha o CEP");
		form.cep.focus();
		return false
	}
	if (form.cep.value.length < 9 ){
		window.alert("CEP Inválido");
		form.cep.focus();
		return false
	}
	if (form.estado.value == ""){
		window.alert("Preencha o Estado");
		form.estado.focus();
		return false
	}
	if (form.cidade.value == ""){
		window.alert("Preencha a Cidade");
		form.cidade.focus();
		return false
	}
	if (form.mensagem.value == ""){
		window.alert("Preencha a mensagem");
		form.mensagem.focus();
		return false
	}
}


function validaDepoimento() {
var form = document.depoimento;
	if (form.nome.value == ""){
		window.alert("Preencha o Nome");
		form.nome.focus();
		return false
	}
	if (form.email.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1){
		alert("Preencha o Email corretamente!")
		form.email.focus()
		return false
	}
	if (form.empresa.value == ""){
		window.alert("Preencha a Empresa");
		form.empresa.focus();
		return false
	}
	if (form.cargo.value == ""){
		window.alert("Preencha o Cargo");
		form.cargo.focus();
		return false
	}
	if (form.mensagem.value == ""){
		window.alert("Preencha a mensagem");
		form.mensagem.focus();
		return false
	}
}


function validaProduto() {
var form = document.cadastro;
	if (form.quantidade.value == ""){
		window.alert("Preencha a quantidade");
		form.quantidade.focus();
		return false
	}
	if (form.produto.value == ""){
		window.alert("Selecione o produto");
		form.produto.focus();
		return false
	}
	if (form.marca.value == ""){
		window.alert("Selecione a marca");
		form.marca.focus();
		return false
	}
	if (form.embalagem.value == ""){
		window.alert("Preencha a embalagem");
		form.embalagem.focus();
		return false
	}
}


function validaTrabalhe() {
var form = document.trabalhe;
	if (form.nome.value == ""){
		window.alert("Preencha o Nome");
		form.nome.focus();
		return false
	}
	if (form.sobrenome.value == ""){
		window.alert("Preencha o Sobrenome");
		form.sobrenome.focus();
		return false
	}
	if (form.email.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1){
		alert("E-mail inválido!")
		form.email.focus()
		return false
	}
	if (form.telefone.value == ""){
		window.alert("Preencha o Telefone");
		form.telefone.focus();
		return false
	}
	if (form.telefone.value.length < 12 ){
		window.alert("Telefone Inválido");
		form.telefone.focus();
		return false
	}
	if (form.arquivo.value == ""){
		window.alert("Selecione o Arquivo");
		form.arquivo.focus();
		return false
	}
	if (form.arquivo.value.indexOf('.doc',0)==-1 && form.arquivo.value.indexOf('.DOC',0)==-1 && form.arquivo.value.indexOf('.pdf',0)==-1 && form.arquivo.value.indexOf('.PDF',0)==-1){
		window.alert("Selecione um formato de arquivo válido(PDF ou DOC)");
		form.arquivo.focus();
		return false
	}
	if (form.mensagem.value == ""){
		window.alert("Preencha a mensagem");
		form.mensagem.focus();
		return false
	}
}


function validaCesta() {
var form = document.enviarCesta;
	if (form.nome.value == ""){
		window.alert("Preencha o Nome");
		form.nome.focus();
		return false
	}
	if (form.sobrenome.value == ""){
		window.alert("Preencha o Sobrenome");
		form.sobrenome.focus();
		return false
	}
	if (form.email.value == ""){
		window.alert("Preencha o Email");
		form.email.focus();
		return false
	}
	if (form.email.value.indexOf('@',0)==-1 || form.email.value.indexOf('.',0)==-1){
		alert("Preencha o Email corretamente!")
		form.email.focus()
		return false
	}
	if (form.telefone.value == ""){
		window.alert("Preencha o Telefone");
		form.telefone.focus();
		return false
	}
	if (form.telefone.value.length < 12 ){
		window.alert("Telefone Inválido");
		form.telefone.focus();
		return false
	}
	if (form.empresa.value == ""){
		window.alert("Preencha a Empresa");
		form.empresa.focus();
		return false
	}
}

//preenche campo de telefone
function Mascara(tipo, campo, teclaPress) {
	if (window.event) {
		var tecla = teclaPress.keyCode;
	} else {
		tecla = teclaPress.which;
	}

	var s = new String(campo.value);
	// Remove todos os caracteres à seguir: ( ) / - . e espaço, para tratar a string denovo.
	s = s.replace(/(\.|\(|\)|\/|\-| )+/g, '');

	tam = s.length + 1;

	if (tecla != 9 && tecla != 8) {
		switch (tipo) {
			case 'CPF':
				if (tam > 3 && tam < 7)
					campo.value = s.substr(0, 3) + '.' + s.substr(3, tam);
				if (tam >= 7 && tam < 10)
					campo.value = s.substr(0, 3) + '.' + s.substr(3, 3) + '.' + s.substr(6, tam - 6);
				if (tam >= 10 && tam < 12)
					campo.value = s.substr(0, 3) + '.' + s.substr(3, 3) + '.' + s.substr(6, 3) + '-' + s.substr(9, tam - 9);
				break;

			case 'CNPJ':

				if (!(tecla >= 48 && tecla <= 57)) {
					if (tecla != 0) {
						return false
					}
				} else {

					if (tam > 2 && tam < 6)
						campo.value = s.substr(0, 2) + '.' + s.substr(2, tam);
					if (tam >= 6 && tam < 9)
						campo.value = s.substr(0, 2) + '.' + s.substr(2, 3) + '.' + s.substr(5, tam - 5);
					if (tam >= 9 && tam < 13)
						campo.value = s.substr(0, 2) + '.' + s.substr(2, 3) + '.' + s.substr(5, 3) + '/' + s.substr(8, tam - 8);
					if (tam >= 13 && tam < 15)
						campo.value = s.substr(0, 2) + '.' + s.substr(2, 3) + '.' + s.substr(5, 3) + '/' + s.substr(8, 4) + '-' + s.substr(12, tam - 12);
				}

				break;

			case 'TEL':

				if (!(tecla >= 48 && tecla <= 57)) {
					if (tecla != 0) {
						return false
					}
				} else {
					if (tam > 2 && tam < 4)
						campo.value = s.substr(0, 2) + ' ' + s.substr(2, tam);
					if (tam >= 7 && tam < 11)
						campo.value = s.substr(0, 2) + ' ' + s.substr(2, 4) + '-' + s.substr(6, tam - 6);
				}

				break;

			case 'CEP':

				if (!(tecla >= 48 && tecla <= 57)) {
					if (tecla != 0) {
						return false
					}
				} else {
					if (tam >= 6 && tam < 8)
						campo.value = s.substr(0, 5) + '-' + s.substr(5, tam - 5);
				}

				break;

			case 'DATA':
				if (!(tecla >= 48 && tecla <= 57)) {
					if (tecla != 0) {
						return false
					}
				} else {
					if (tam > 2 && tam < 4)
						campo.value = s.substr(0, 2) + '/' + s.substr(2, tam);
					if (tam > 4 && tam < 11)
						campo.value = s.substr(0, 2) + '/' + s.substr(2, 2) + '/' + s.substr(4, tam - 4);
				}
				break;
		}
	}
}
