function checkEmailC(campo,id){
	var id
if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo.value))
 {
   return (true)
 } if(campo.value!=""){ 
	document.getElementById('alert'+id).style.display='block';
	document.getElementById('alert'+id).innerHTML = 'E-mail Inválido';
   return (false)
 }
}

function valTwin(){

email = document.getElementById('inp_email')

if( document.getElementById('inp_nome').value==''){
	 document.getElementById('inp_nome').focus();
	return false
	}
if( document.getElementById('inp_email').value==''){
	 document.getElementById('inp_email').focus();
	return false		
	}
	else{
	 if(checkEmail(email)==false){
	  return false     
	  }
	}
}


function validaEmailDepo(){
	var email = document.getElementById('inp_email').value

	if (email == ''){
		document.getElementById('inp_email').focus();
	}else{

		document.getElementById('btenvia').value = 'AGUARDE VALIDANDO...';
		document.getElementById('btenvia').disabled=1;
				
		var data = new Date().getTime();
		var url ="/curso/depoimentos/depo_2.asp?email="+email+"&i="+data

		ajaxLink('valida',url)

		document.getElementById('email').style.display='none';
	}
}

function validaFormDepo(){

if( document.getElementById('inp_nome').value==''){
	 document.getElementById('inp_nome').focus();
	return false
	}
if( document.getElementById('inp_moto').value==''){
	 document.getElementById('inp_moto').focus();
	return false
	}
if( document.getElementById('inp_depoimento').value==''){
	 document.getElementById('inp_depoimento').focus();
	return false
	}
}

function subC(id){
	
	var	email = document.getElementById('inp_email'+id)
	
	if(id != "" ){
		if(document.getElementById('inp_email'+id).value=='' || document.getElementById('inp_email'+id).value=='E-mail:'){
			document.getElementById('alert'+id).style.display='block';
			document.getElementById('alert'+id).innerHTML = 'E-mail Obrigatório';
			document.getElementById('inp_email').focus();
			return false;
		}else{
		 	if(checkEmailC(email,id)==false){
		     return false
			} 	     
	  	 }
			window.location="insc_2.asp?id="+id+"&emailAluno="+email.value;
	}else{
		window.location="insc_1.asp"		
		}
	}

function Agree(button){
if (document.getElementById(button).disabled==0)
{document.getElementById(button).disabled=1}
else
{document.getElementById(button).disabled=0}
}

function valCampo(campo,valor){
	var campo
	var valor
	
	if(campo =='inpNewsNome'){
		nome = 'Nome:'
	}else{
		nome = 'Email:'
	}
	if(valor==''){
		document.getElementById(campo).value=nome
	}
	 document.getElementById(campo).className='inp'
}

function checkEmail(campo)
{
 if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo.value))
 {
   return (true)
 } if(campo.value!=""){
   //document.getElementById('alerta').innerHTML = "<span class='Vermelho10'><strong>E-mail Inválido</strong></span>";
   campo.value='E-mail Inválido!';   
   campo.focus();
 
   return (false)
 }
}

function abre(Pagina,w,h) 
{
window.open(Pagina,"","resizable=no,toolbar=no,status=no,menubar=no,maximize=false,scrollbars=no,width="+w+",height="+h+"")
}

function loadFabricante(tipo){
var data = new Date().getTime();
var url = "/galeria/fabricante.asp?tipo="+tipo+"&i="+data;
ajaxLink('fabricante',url);
}

function loadVeiculos(tipo,fabricante){
var data = new Date().getTime();
var url = "/galeria/veiculos.asp?tipo="+tipo+"&fabricante="+fabricante+"&i="+data;
ajaxLink('veiculos',url);

}

function validaSearch(){
if( document.getElementById('i').value==''){
	 document.getElementById('i').focus();
	return false
	}	
}

function sendSearch(){

	var busca = document.getElementById('inpSearch').value;
	if (busca == ""){
		 document.getElementById('inpSearch').focus();
	}else{
		var url = "/galeria/load.asp?i="+busca;
		ajaxLink('veiculos',url);
	}
}

function sendNews(){

email = document.getElementById('inpNewsEmail')
var emailV = document.getElementById('inpNewsEmail').value;
var nome = document.getElementById('inpNewsNome').value;

if( document.getElementById('inpNewsNome').value==''){
	 document.getElementById('inpNewsNome').focus();
	return false
	}

if( document.getElementById('inpNewsEmail').value==''){
	 document.getElementById('inpNewsEmail').focus();
	return false		
	}
	else{
	 if(checkEmail(email)==false){
	  return false     
	  }
	}

	var url = "/includes/sendNews.asp?nome="+nome+"&email="+emailV;
	ajaxLink('newsletter',url);
}


function loadUf(id) {
var id
var url = "/contato/cidade.asp?uf="+id;
ajaxLink('cidade',url);
}


function Atualiza1(id,tipo) {
var id
var tipo
var data = new Date().getTime();
if (tipo == 1){
	var url = "/includes/depoimentos.asp?id="+id+"&i="+data+"&tipo=1";	
}else{
	var url = "/includes/depoimentos.asp?id="+id+"&i="+data;	
	}

setTimeout("Atualiza2("+id+","+tipo+")", 8000);
ajaxLink('depoimentos',url);
};

function Atualiza2(id, tipo) {
var id
var tipo

var data = new Date().getTime();
if (tipo == 1){
	var url = "/includes/depoimentos.asp?id="+id+"&i="+data+"&tipo=1";	
}else{
	var url = "/includes/depoimentos.asp?id="+id+"&i="+data;	
	}

setTimeout("Atualiza1("+id+","+tipo+")", 8000);
ajaxLink('depoimentos',url);
};

function hideDiv(id){
	document.getElementById(id).style.display='none';
}


/**
*	"Rate This"
*
*	@author Rogerio Alencar Lino Filho
*	@date  31 de dezembro de 2007
*	@link http://rogeriolino.wordpress.com/
*/
var Rate = function(total_stars) {
	var self = this;
	this.stars = new Array(total_stars);
	this.clicked = 0;
	this.padrao = 0;
	this.container;
	
	function createStars() {
		self.container = document.createElement("div");
		for (var i=0; i<self.stars.length; i++) {
			var star = document.createElement("span");
			star.innerHTML = (i+1);
			star.setAttribute("class", "off");
			star.className = "off";
			star.onmouseover = function() {
				rollOver(this.innerHTML);
			}
			star.onmouseout = function() {
				rollOut();
			}
			star.onmousedown = function() {
				self.clicked = this.innerHTML;
				self.onclick();
			}
			self.stars[i] = star;
			self.container.appendChild(star);
		}
	}
	
	function rollOver(n) {
		clear();
		for (var i=0; i<n; i++) {
			self.stars[i].setAttribute("class", "on");
			self.stars[i].className = "on";
		}
	}
	
	function rollOut() {
		clear();
		markDefault();
	}
	
	function clear() {
		for (var i=0; i<self.stars.length; i++) {
			self.stars[i].setAttribute("class", "off");
			self.stars[i].className = "off";
		}
	}
	
	function markDefault() {
		if (self.padrao > 0 && self.padrao <= self.stars.length) {
			rollOver(self.padrao);
		}
	}

	/**
	*	Define o titulo do tooltip da estrela
	*	@param int star
	*/
	this.setTitle = function(star, title) {
		self.stars[star-1].setAttribute("title", title);
	}
	
	/**
	*	Retorna o valor escolhido (clicado)
	*	@return int
	*/
	this.getValue = function() {
		return self.clicked;
	}
	
	/**
	*	Evento que e acionado ao clicar em algum item
	*	Metodo null, para ser personalizado
	*/
	this.onclick = function() { }
	
	/**
	*	Define um valor padrao,
	*	ficando marcado
	*/
	this.setDefault = function(n) {
		self.padrao = n;
	}

	/**
	*	Adiciona o objeto a algum elemento HTML
	*	atravez do Id do mesmo
	*/	
	this.append = function(id) {
		createStars();
		markDefault();
		document.getElementById(id).appendChild(self.container);
	}
}



function v_NR(tecla){

if(typeof(tecla) == 'undefined')
	var tecla = window.event;
	var codigo = (tecla.which ? tecla.which : tecla.keyCode ? tecla.keyCode : tecla.charCode);

// permite números, 8=backspace, 46=del e 9=tab
if ( (codigo >= 48 && codigo <= 57) || (codigo >= 96 && codigo <= 105) || codigo == 8 || codigo == 46 || codigo == 9 ){
	return true; }
	else{
		alert("Apenas números são permitidos !"); return false; 
		} 
}

function Mascara(o,f){
        v_obj=o
        v_fun=f
        setTimeout("execmascara()",1)
    }
    
    /*Função que Executa os objetos*/
    function execmascara(){
        v_obj.value=v_fun(v_obj.value)
    }
    
    /*Função que Determina as expressões regulares dos objetos*/
    function leech(v){
        v=v.replace(/o/gi,"0")
        v=v.replace(/i/gi,"1")
        v=v.replace(/z/gi,"2")
        v=v.replace(/e/gi,"3")
        v=v.replace(/a/gi,"4")
        v=v.replace(/s/gi,"5")
        v=v.replace(/t/gi,"7")
        return v
    }

function Telefone(v){
        v=v.replace(/\D/g,"")                 
        v=v.replace(/^(\d\d)(\d)/g,"($1) $2") 
        v=v.replace(/(\d{4})(\d)/,"$1-$2")    
        return v
    }
function valFormCont(){
	
email=document.form.email

if(document.form.nome.value==''){
	document.form.nome.focus();
	return false
	}
if(document.form.email.value==''){
	document.form.email.focus();
	return false		
	}
	else{
	 if(checkEmail(email)==false){
	  return false     
	  }
	}
if(document.form.estado.value==''|| document.form.estado.value=='Selecione um Estado'){
	document.form.estado.focus();
	return false
	}
if(document.form.cidade.value=='' || document.form.cidade.value=='Selecione uma Cidade'){
	document.form.cidade.focus();
	return false
	}
if(document.form.comentario.value==''){
	document.form.comentario.focus();
	return false
	}
	if(document.form.inp_cod.value==''){
		document.form.inp_cod.focus();
	return false
	}else{
		var inp_img = document.form.inpimg.value;
		var inp_cod = document.form.inp_cod.value;

		if(inp_img == 1){inp_img = 0266};
		if(inp_img == 2){inp_img = 9032};	
		if(inp_img == 3){inp_img = 5610};
		if(inp_img == 4){inp_img = 1277};
		if(inp_img == 5){inp_img = 0501};
		if(inp_img == 6){inp_img = 7090};
		if(inp_img == 7){inp_img = 2111};
		if(inp_img == 8){inp_img = 9831};
		if(inp_img == 9){inp_img = 0003};
		if(inp_img == 10){inp_img = 1012};		
		if(inp_img == 11){inp_img = 5123};
		if(inp_img == 12){inp_img = 2299};
		if(inp_img == 13){inp_img = 6974};
		if(inp_img == 14){inp_img = 4415};
		if(inp_img == 15){inp_img = 7618};
		if(inp_img == 16){inp_img = 8870};
		if(inp_img == 17){inp_img = 1610};
		if(inp_img == 18){inp_img = 0102};
		if(inp_img == 19){inp_img = 6048};
		if(inp_img == 19){inp_img = 5599};		
		
		if(inp_img != inp_cod){
			alert("Código Inválido")			
			document.form.inp_cod.focus();
			
			var data = new Date().getTime();
			var url = "/contato/captcha.asp?i="+data;
			
			ajaxLink('loadCod',url);
			
			return false			
			}	
	}
} 	


function validaForm(){
	if(document.form.inp_1.value==''){
	document.form.inp_1.focus();
	return false
	}
if(document.form.inp_3.value==''){
	document.form.inp_3.focus();
	return false
	}
if(document.form.inp_4.value==''){
	document.form.inp_4.focus();
	return false
	}
if(document.form.inp_5.value==''){
	document.form.inp_5.focus();
	return false
	}
if(document.form.inp_6.value==''){
	document.form.inp_6.focus();
	return false
	}	
if(document.form.inp_7.value==''){
	document.form.inp_7.focus();
	return false
	}
if(document.form.inp_10.value==''){
	document.form.inp_10.focus();
	return false
	}
if(document.form.inp_11.value==''){
	document.form.inp_11.focus();
	return false
	}
if(document.form.inp_12.value==''){
	document.form.inp_12.focus();
	return false
	}
if(document.form.inp_13.value==''){
	document.form.inp_13.focus();
	return false
	}
if(document.form.inp_20.value==''){
	document.form.inp_20.focus();
	return false
	}
if(document.form.inp_21.value==''){
	document.form.inp_21.focus();
	return false
	}
if(document.form.inp_22.value==''){
	document.form.inp_22.focus();
	return false
	}

	document.getElementById('btenvia').value = 'AGUARDE ENVIANDO...';
	document.getElementById('btenvia').disabled=1;

	
}

function validaCard(){

	if(document.form.inp_nome.value==""){
		document.form.inp_nome.focus();
		return false;
	}
	if(document.form.inp_cartao.value==""){
		document.form.inp_cartao.focus();
		return false;
	}
	if(document.form.inp_cod.value==""){
		document.form.inp_cod.focus();
		return false;
	}

	document.getElementById('btenvia').value = 'AGUARDE VALIDANDO...';
	document.getElementById('btenvia').disabled=1;
	

	var data = new Date().getTime();
	
	var idC =  document.form.inp_cartao.value;
	var idB =  document.getElementById('inp_guarda').value;
	var url = "https://web356.kinghost.net/~motorsco/curso/check.asp?idC="+idC+"&idB="+idB+"&i="+data;

	ajaxLink('valida',url);
	return false;
	
}

function checkCard(){

	var checado = document.form.inp_checado;

	if (checado.value == 'False'){
			document.getElementById('btenvia').value = 'Enviar...';
			document.getElementById('btenvia').disabled=0;
			
			alert("Cartão Inválido")
			return false;
		}else{
			document.getElementById('btenvia').value = 'AGUARDE VALIDANDO...';
			document.getElementById('btenvia').disabled=1;
			form.submit();
		}
}

function Agree(button){
	if (document.getElementById(button).disabled==0)
		{document.getElementById(button).disabled=1}
	else
		{document.getElementById(button).disabled=0}
	}

function SomenteNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;   
    if((tecla>47 && tecla<58)) return true;
    else{
    	if (tecla==8 || tecla==0) return true;
	else  return false;
    }
}

