function buscar(){
    window.open('busca.php?key='+document.getElementById('input_busca').value,'','scrollbars=yes');
}

function enviar_orcamento(){
     urlBase = "http://localhost/generico/web/site/enviar_orcamento.php?___rnd=" + Math.random();

     if(navigator.appName == "Microsoft Internet Explorer") {
        http = new ActiveXObject("Microsoft.XMLHTTP");
      } else {
        http = new XMLHttpRequest();
      } 

      http.open("get", urlBase, true);
      http.onreadystatechange=function() {
        if(http.readyState == 4) {
              alert('Orçamento enviado com sucesso!');
        }
      }
      http.send(null);	
}

function add_produto(codigo){
    
    urlBase = "http://localhost/generico/web/site/add_produto.php?codigo=" + codigo + "&qtd="+ document.getElementById('qtd'+codigo).value + "&___rnd=" + Math.random();

     if(navigator.appName == "Microsoft Internet Explorer") {
        http = new ActiveXObject("Microsoft.XMLHTTP");
      } else {
        http = new XMLHttpRequest();
      } 

      http.open("get", urlBase, true);
      http.onreadystatechange=function() {
        if(http.readyState == 4) {
              alert('Produto adicionado com sucesso!');
        }
      }
      http.send(null);	
    
    
}


function cadastrar_cliente(){
    
    var campos = new Array('nome','telefone','email','login','senha','senha2');
    var submit = true;
    for(a=0; a<campos.length; a++){
        if(document.getElementById(campos[a]).value==""){
            document.getElementById(campos[a]).style.border="1px solid #FF0000";
            submit = false;
        }
    }
    
    if (!submit){
        alert('Há campos obrigatórios não preenchidos!');        
        return;
    }
    
    if(document.getElementById('senha').value!=document.getElementById('senha2').value){
        alert('As senhas não conferem!');
        return;
    }
    
    document.getElementById('clientes').submit();       
    
}


