
function abrirCep(){
	//window.open ('http://www.correios.com.br/servicos/cep/cep_loc_log.cfm', 'idf_nf', 'width=700, height=500, scrollbars=1');
	
	window.open ('cep.asp', 'idf_nf', 'width=700, height=500, scrollbars=1');
}


function indicarAmigo(idProduto,url){
	window.open ('indicar.asp?id='+idProduto+'&url='+url, 'idf_nf', 'width=300, height=250, scrollbars=0');
}


function jump(tam,valor,idCampo){
	if(valor.length ==tam){
		document.getElementById(idCampo).focus();
	}
}

function isNumeric(e)
{
	var tecla = document.all ? e.keyCode : e.which;	
	if(tecla < '48' || tecla > '57'){
		//13=Enter 8=Backspace 0=Del
		if(tecla != '13' && tecla != '8' && tecla != '0'){
			return false;
		}
	}
	return true;
}

//Código de suporte ao browser
function verifyAjax(){
	var ajaxRequest;  // Variável que torna o Ajax possível
	// Internet Explorer Browsers
	if(window.ActiveXObject) {
		try {
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch(e) {
			try {
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch(e) {
				ajaxRequest = false;
			}
		}
	// Opera 8.0+, Firefox, Safari
	} else if( window.XMLHttpRequest ) {
		try {
			ajaxRequest = new XMLHttpRequest();
		} catch(e) {
			ajaxRequest = false;
		}
	}
	return ajaxRequest
}

function acessar_login(event,form){
	if(window.event) { //IE
		keyCode = event.keyCode
	} else if(event.which) { // Netscape/Firefox/Opera
		keyCode = event.which
	}
	if(keyCode == 13){
		if(form=="L"){
			document.frLogin.submit();
		}else{
			if(form=='N')
				document.frNovo.submit();
		}
	}
}

/*32611*/
function retornoSaldoVale(cupom,cliente){
	var url = "verificaSaldoVale.asp?cliente="+cliente+"&vale="+cupom;
	var ajaxRequest = verifyAjax();
	// Funcao que receberá dados enviados pelo servidor ao mudar de estado
	ajaxRequest.onreadystatechange = function(){
		//qdo completo (ready=4) executar
		if(ajaxRequest.readyState == 4){
			//busca conteudo do ajax
			alert(ajaxRequest.ResponseText);
		}
	}
	ajaxRequest.open("GET", url, true);
	ajaxRequest.send(null);	
		
}

function expande(codigo){
	var div = document.getElementById("prod_"+codigo);
	var span = document.getElementById("exp_rec_"+codigo);
	div.className="expandir";
	span.innerHTML = "<img src='imgs/menos.gif' title='Recolher' style='cursor:pointer;' onClick='javascript:recolhe("+codigo+");' />";
} 

function recolhe(codigo){
	var div = document.getElementById("prod_"+codigo);
	var span = document.getElementById("exp_rec_"+codigo);
	div.className="recolher"; 
	span.innerHTML = "<img src='imgs/mais.gif' title='Expandir' style='cursor:pointer;' onClick='javascript:expande("+codigo+");' />";
} 

function verData(){
	var hoje = document.getElementById("hoje");
	var dataEvento = document.getElementById("f_dataevento");

	//data.setFullYear(ano,mes,dia);

	var hoje1 = hoje.value;
	var dataEvento1 = dataEvento.value;

	//Testa data do evento, deve ser maior que hoje.
	if(parseInt(dataEvento1.split("/")[2].toString() + dataEvento1.split("/")[1].toString() + dataEvento1.split("/")[0].toString()) <= parseInt(hoje1.split("/")[2].toString() + hoje1.split("/")[1].toString() + hoje1.split("/")[0].toString())){
		alert("Data do Evento deve ser de amanhã em diante.");
		dataEvento.focus();
		return false;
	}
	
	/*var dataFechamento = document.getElementById("f_datafechamento");
	var dataFechamento1 = dataFechamento.value;
	//Testa data do fechamento, deve ser maior que hoje.
	if(parseInt(dataFechamento1.split("/")[2].toString() + dataFechamento1.split("/")[1].toString() + dataFechamento1.split("/")[0].toString()) <= parseInt(hoje1.split("/")[2].toString() + hoje1.split("/")[1].toString() + hoje1.split("/")[0].toString())){
		alert("Data do Fechamento deve ser de amanhã em diante.");
		dataFechamento.focus();
		return false;
	}
	
	//Testa data do fechamento, deve ser menor ou igual a data do evento.
	if(parseInt(dataEvento1.split("/")[2].toString() + dataEvento1.split("/")[1].toString() + dataEvento1.split("/")[0].toString()) < parseInt(dataFechamento1.split("/")[2].toString() + dataFechamento1.split("/")[1].toString() + dataFechamento1.split("/")[0].toString())){
		alert("Data do Fechamento não deve ser maior que a Data do Evento.");
		dataFechamento.focus();
		return false;
	}*/
}

function jump_decisao(tam,valor,form){
	var tipo;
	if(valor.length ==tam){
		if(form == "procura_lista"){
			tipo = procura_lista.tipo_lista.value;
			document.getElementById("nome_lista").focus();
		} else {
			tipo = form.split("/");
			if(tipo[0]=="f_dataevento")
				//document.getElementById("f_datafechamento").focus();
			//else
				document.getElementById("nome_lista").focus();
		}
	}
}

function limpa_campo(campo){
	campo.value = "";
}

function campoNumerico() {
	var tecla = (document.all) ? event.keyCode : event.which;
	return ((tecla >= 48 && tecla <= 57) || tecla == 9 || tecla == 8 || tecla == 13);
}
/*32611*/
