function validaEmail(campo){
	if (campo.value == '') 
		{ alert('Digite seu e-mail, por favor.'); campo.focus(); return false; } 
		else {
		prim = campo.value.indexOf("@")
		strEmail = campo
		if(prim < 2) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("@",prim + 1) != -1) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf(".") < 1) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf(" ") != -1) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("zipmeil.com") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("hotmeil.com") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf(".@") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("@.") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf(".com.br.") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("/") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("[") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("]") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("(") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf(")") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
		if(strEmail.value.indexOf("..") > 0) {
			alert('O e-mail informado está incorreto.');
			strEmail.focus();
			return false;
		}
	}
}










//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
	function linkar(pagina, parametros_asp){
		if(pagina != '' || parametros != ''){
			document.form_href.action = pagina;
			document.form_href.parametros.value = 'onde=linkar&' + parametros_asp;
			document.form_href.submit();
		}
	}
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++










////////////////////////////////////////////////////////////////
//// VERIFICA SOMENTE Nº									////
////////////////////////////////////////////////////////////////
function somente_numero(campo){  
	var digits="0123456789-"  
	var campo_temp   
	 for (var i=0;i<campo.value.length;i++){  
	     campo_temp=campo.value.substring(i,i+1)   
	     if (digits.indexOf(campo_temp)==-1){  
	         campo.value = campo.value.substring(0,i);  
	     }  
	 }  
} 
function somente_qtde(campo){  
	var digits="0123456789"  
	var campo_temp   
	 for (var i=0;i<campo.value.length;i++){  
	     campo_temp=campo.value.substring(i,i+1)   
	     if (digits.indexOf(campo_temp)==-1){  
	         campo.value = campo.value.substring(0,i);  
	     }  
	 }  
} 
function somente_valor(campo){ 
	var digits="0123456789,."  
	var campo_temp   
	 for (var i=0;i<campo.value.length;i++){  
	     campo_temp=campo.value.substring(i,i+1)   
	     if (digits.indexOf(campo_temp)==-1){  
	         campo.value = campo.value.substring(0,i);  
			 campo.value = campo.value.replace(/,/, ".");
	     }  
	 }  
} 


function Left(str, n){
	if (n <= 0)
	    return "";
	else if (n > String(str).length)
	    return str;
	else
	    return String(str).substring(0,n);
}
function Right(str, n){
    if (n <= 0)
       return "";
    else if (n > String(str).length)
       return str;
    else {
       var iLen = String(str).length;
       return String(str).substring(iLen, iLen - n);
    }
}








function calculaFrete(x1, x2){
	cepTermino1	= x1;
	cepTermino2	= x2;
	urlGo		= "cesta.asp"
	parametros	= "?cepDestino1="+cepTermino1+"cepDestino2="+cepTermino2
	window.location.href = urlGo + parametros
}






/*************************************************************************\
	ABRE POPUP
\*************************************************************************/
function abrir(pagina,largura,altura) {
	
	//pega a resolução do visitante
	w = screen.width;
	h = screen.height;
	
	//divide a resolução por 2, obtendo o centro do monitor
	meio_w = w/2;
	meio_h = h/2;
	
	//diminui o valor da metade da resolução pelo tamanho da janela, fazendo com q ela fique centralizada
	altura2 = altura/2;
	largura2 = largura/2;
	meio1 = meio_h-altura2;
	meio2 = meio_w-largura2;
	
	//abre a nova janela, já com a sua devida posição
	window.open(pagina,'','height=' + altura + ', width=' + largura + ', top='+meio1+', left='+meio2+',scrollbars=1');
}








/*************************************************************************\
	BOLETOS
\*************************************************************************/
	function abrejan(valor, nr_pedido, nome_sacado, doc_sacado, data_emissao, data_vencto){	
		window.open('http://comercio.locaweb.com.br/comercio.comp?valor='+ valor +'&banco=itau&agencia=0268&carteira=175&codigo_cedente=262227&numdoc='+ nr_pedido +'&conta=timesmania-itau&sacado='+ nome_sacado +'&cgccpfsac='+ doc_sacado +'&datadoc='+ data_emissao +'&vencto='+ data_vencto +'&instr1=Entrega+em+3+dias+ap%F3s+a+confirma%E7%E3o%2E')
	}
	function abrejanSantos(url){	
		window.open('https://mup.comercioeletronico.com.br/sepsboleto/004500024/prepara_pagto.asp?merchantid=004500024&orderid='+url,'pagamento', 'toolbar=yes,location=no,directories=no,status=no,menubar=yes,scrollbars=yes,resizable=yes,menubar=no,width=750,height=510,left=0,top=0');
	}




function abreFechaDiv(nome_div){
	if (document.getElementById(nome_div).style.display == 'none'){
		document.getElementById(nome_div).style.display = '';		
	}else{
		document.getElementById(nome_div).style.display = 'none';		
	}
}




function trocaImgEstrelas(x){
	document.getElementById('img_estrelas').src = 'img/stars'+ x +'.png';
	document.getElementById('pontuacao').value = x;
	return false
}





//#############################################################
// ================== LIMITADOR DE CARACTERES =================
//#############################################################
function Contar(Campo,quantidade,resposta){
	if((quantidade-Campo.value.length) <= 0){
	   Campo.value = Campo.value.substr(0,quantidade);
	}
	if(resposta != ""){
		document.getElementById(""+resposta+"").value = quantidade-Campo.value.length
	}
}



function checar(isto, form, qtde) {
	caixaNome = isto.id;
	elementos = form.elements;
	total = qtde; //total de checkboxes que podem ser marcados
	count=0;
	for(var i=0 ; i < elementos.length; i++) {
		if(elementos[i].id==caixaNome && elementos[i].checked==true) {
			count++
		}
		if(count > total){
			isto.checked=false;
		}
	}
}


function ativaBTCadastrar(){
	if (document.getElementById('ic_termos').checked == true){
		document.getElementById('bt_cadastrar').style.display = '';
	}else{
		document.getElementById('bt_cadastrar').style.display = 'none';
	}
}







function confirmation(var_url, var_texto1, texto2) {
	var perguntar = confirm(var_texto1);
	if (perguntar){
		window.location = var_url;
	}else{
		if (texto2 != ''){
			alert(texto2)
		}
	}
}



function openPage(link) {
	var newWindow = window.open(link, '_blank');
	newWindow.focus();
}
