﻿function isNumeric(str)
{var len= str.length;
  if (len==0) return false;

  var p=0;
  var ok= true;
  var ch= "";
  while (ok && p<len)
  {
    ch= str.charAt(p);
    if ('0'<=ch && ch<='9' || ch==".") p++;
    else ok= false;
  }
  return ok;
}
function sendListaByCep(){
if(document.getElementById('txtCEP').value == ''){
    alert(' - O campo cep está em branco');return;
}else if(!isNumeric(document.getElementById('txtCEP').value)){
    alert(' - Cep inválido. Digite somente números');return;
}else if(document.getElementById('txtCEP').value.length < 8){
    alert(' - Cep inválido');return;
}var url = 'listabycep.aspx?cep=' + document.getElementById('txtCEP').value;
if(document.getElementById('chkServico_0').checked)url = url + '&restaurante=s'; 
if(document.getElementById('chkServico_1').checked)url = url + '&quiosque=s'; 
if(document.getElementById('chkServico_2').checked)url = url + '&drivethru=s'; 
//if(document.getElementById('chkServico_3').checked)url = url + '&mcfesta=s'; 
if(document.getElementById('chkServico_3').checked)url = url + '&mccafe=s'; 
if(document.getElementById('chkServico_4').checked)url = url + '&mccafeexpr=s'; 
//if(document.getElementById('chkServico_6').checked)url = url + '&mcinternet=s';
if(document.getElementById('chkServico_5').checked)url = url + '&ronaldsplace=s';
if(document.getElementById('chkServico_6').checked)url = url + '&atendimento24h=s';
window.location = url;
}

function sendCep(){
if(document.getElementById('txtCEP').value == ''){
    alert(' - O campo cep está em branco');return;
}else if(!isNumeric(document.getElementById('txtCEP').value)){
    alert(' - Cep inválido. Digite somente números');return;
}else if(document.getElementById('txtCEP').value.length < 8){
    alert(' - Cep inválido');return;
}
var url = 'listabycep.aspx?cep=' + document.getElementById('txtCEP').value + '&local=inst';
alert(url);
window.location = url;
}

//funcao q retorna se a tecla pressionada foi numerica
function isNumberKey(evt){
    var e;
    if(evt)
        e = evt;
    else
        e = window.event;  
    var charCode = (e.which) ? e.which : e.keyCode
    if (charCode > 31 && (charCode < 48 || charCode > 57))
       return false;
    return true;
}

function sendListaByCepPromocao(){
if(document.getElementById('txtCep').value == ''){
    alert(' - O campo cep está em branco');return;
}else if(!isNumeric(document.getElementById('txtCep').value)){
    alert(' - Cep inválido. Digite somente números');return;
}else if(document.getElementById('txtCep').value.length < 8){
    alert(' - Cep inválido');return;
}var url = 'listabycep.aspx?cep=' + document.getElementById('txtCep').value + '&promocao=' + document.getElementById('txtPromocao').value ;
window.location = url;
}