// JavaScript Document


	function validaData(dia, mes, ano) {

        if ((ano > 1900)&&(ano < 2100)){
            switch(mes)
            {
                case '01':
                case '03':
                case '05':
                case '07':
                case '08':
                case '10':
                case '12':
                    if (dia <= 31)
                        return true;
                    break
                case '04':
                case '06':
                case '09':
                case '11':
                    if (dia <= 30)
                        return true;
                    break
                case '02':
                    var bissexto;
                    /* Validando ano Bissexto / fevereiro / dia */
                    if ((ano % 4 == 0) || (ano % 100 == 0) || (ano % 400 == 0))
                    {
                        bissexto = 1;
                    }
                    if ((bissexto == 1) && (dia <= 29))
                    {
                        return true;
                    }
                    if ((bissexto != 1) && (dia <= 28))
                    {
                        return true;
                    }
                    break;
            }
        }
        return false;
    }


// FUNÇÃO - CAMPOS OBRIGATÓRIOS
function valida_campos_suporte(frm_suporte){
	
	// VARIAVEIS 
	var nome 			= document.frm_suporte.txt_nome.value;
	var ddd_tel 		= document.frm_suporte.txt_ddd_tel.value;	
	var telefone 		= document.frm_suporte.txt_telefone.value;
	var ddd_cel 		= document.frm_suporte.txt_ddd_cel.value;
	var celular 		= document.frm_suporte.txt_celular.value;
	var email 			= document.frm_suporte.txt_email.value;	
	var cidade 			= document.frm_suporte.txt_cidade.value;
	var mensagem		= document.frm_suporte.mensagem.value;	
	var tipo_contato 	= document.frm_suporte.tipo_contato.value;
	var flag			= false;

	

	var hj 			= new Date();
	var dia_valido 	= hj.getDate();
	var mes_valido	= hj.getMonth()+1;
	var ano_valido	= hj.getFullYear();
		
		
		
		
	
	if(dia_valido < 10){
		dia_valido = '0'+hj.getDate();
	}else{
		dia_valido = hj.getDate();
	}
	
	if((mes_valido)<10){
		mes_valido = '0'+mes_valido;
	}else{
		mes_valido = mes_valido;
	}
	// VALIDAÇÃO NOME
		if(nome == null || nome == ""){
		alert("O NOME e de preechimento obrigatorio");
		frm_suporte.txt_nome.focus();
		return false;
	}
	  
	// VALIDAÇÃO DDD TELEFONE
		if(ddd_tel == null || ddd_tel == ""){
		alert("O DDD e de preechimento obrigatorio");
		frm_suporte.txt_ddd_tel.focus();
		return false;
	}
	
		if(ddd_tel.length < 2){
		alert("O DDD esta incompleto");
		frm_suporte.txt_ddd_tel.focus();
		return false;
	}


	// VALIDAÇÃO  TELEFONE
		if(telefone == null || telefone == ""){
		alert("O TELEFONE e de preechimento obrigatorio");
		frm_suporte.txt_telefone.focus();
		return false;
	}
	
		if(telefone.length < 7){
		alert("O TELEFONE esta incompleto");
		frm_suporte.txt_telefone.focus();
		return false;
	}


		// VALIDAÇÃO DDD CELULAR
		if (ddd_cel.length!=0 && ddd_cel.length < 2){
		alert("O DDD esta incompleto");
		frm_suporte.txt_ddd_cel.focus();
		return false;
	}
		// VALIDAÇÃO CELULAR
		if (celular.length!=0 && celular.length < 8){
		alert("O CELULAR esta incompleto");
		frm_suporte.txt_celular.focus();
		return false;
	}
		//VALIDAÇÃO D0 CELULAR E DDD DO CELULAR
		if(ddd_cel.length!=0 && celular.length==0 ){
		alert("Por Favor, preencha o numero do CELULAR");
		frm_suporte.txt_celular.focus();
		return false;
	}
	
	
		if(ddd_cel.length==0 && celular.length!=0){
		alert("Por Favor, preencha o DDD DO CELULAR");
		frm_suporte.txt_ddd_cel.focus();
		return false;
	}
	

	// VALIDAÇÃO E-MAIL
		if(email == null || email == ""){
		alert("O E-MAIL e de preechimento obrigatorio");
		frm_suporte.txt_email.focus();
		return false;
	}
	
		if ((email.length != 0 && email.indexOf("@") < 1)||email.indexOf('.') < 1)  {
		alert("E-MAIL incorreto");
		frm_suporte.txt_email.focus();
		return false;	
	  }


		// VALIDAÇÃO CIDADE
		if(cidade == null || cidade == ""){
		alert("A CIDADE e de preechimento obrigatorio");
		frm_suporte.txt_cidade.focus();
		return false;
	}
	
		if(tipo_contato  == 'selecione o assunto'){
		alert("Por favor, selecione o tipo de contato. Obrigado");
		return false;
	}
	

	if(tipo_contato  == 'suporte'){
		
	var dia 			= document.frm_suporte.dia.value; 
	var mes 			= document.frm_suporte.mes.value; 
	var ano 			= document.frm_suporte.ano.value; 

	for (var i=0; i<frm_suporte.produto.length; i++){

		if(frm_suporte.produto[i].checked){
			flag = true;
		}
	}
		
		if(flag == false){
		alert("Por favor, em caso de contato para Suporte, informe o produto. Obrigado.");
		return false;
		}
		
		if(dia > dia_valido && mes  >= mes_valido  && ano_valido == ano){
					alert('A data de COMPRA necessita ser menor do que a data informada.');
			return false;
		}
		
		if (dia  < dia_valido && mes > mes_valido && ano_valido == ano){
					alert('A data de COMPRA necessita ser menor do que a data informada.');
			return false;
	}
		
	}
			
	
		// VALIDAÇÃO DE DATA CONFORME CALENDÁRIO
		if (!validaData(document.frm_suporte.dia.value,document.frm_suporte.mes.value,document.frm_suporte.ano.value)){
    	alert('Prezado Cliente, a data encontra - se incorreta.');
    	document.frm_suporte.dia.focus();
    	return false;            
    	}
		
		
		// VALIDAÇÃO CONFIRMAÇÃO DE MENSAGEM
		if(mensagem == null || mensagem == ""){
		alert("A MENSAGEM e de preechimento obrigatorio");
		frm_suporte.mensagem.focus();
		return false;
	}

	return true;
	}
	
		// BLOQUEIA NUMEROS
		function IsLetter(evt){
		var charCode = (evt.which) ? evt.which : event.keyCode;
      	return (charCode >= 65 && charCode <= 90 || charCode >= 61 && charCode <= 122 || charCode == 32 || charCode == 08 || charCode == 13 || charCode == 132);
      	}	  
		