function solicitarInformacionMostrar(){
  medidas = getPageSize();
  $('capaBlanca').style.width = (medidas[0]-5)+'px';
  $('capaBlanca').style.height = (medidas[1]-5)+'px';
  cambiarOpacidad($('capaBlanca'),60);
  $('capaBlanca').style.display='';
  $('solicitarInfo').style.display='';
  return false;
}
function solicitarInformacionOcultar(){
  $('solicitarInfo').style.display='none';
  $('capaBlanca').style.display='none';
  return false;
}
function solicitarInformacionEnviar(idioma){
  if ( $('nombre').value == "" || $('campoobservaciones').value == "" ){
  	switch (idioma){
      case 'es' : alert('Por favor, complete los campos obligatorios ( * ).');
  		break;
    }
    $('nombre').focus();
    return false;
  }
  url = '?nombre='+$('nombre').value+'&telefono='+$('telefono').value+'&email='+$('email').value+'&observaciones='+$('campoobservaciones').value+'';
  xmlhttp=new XML();
  if (xmlhttp){
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        document.getElementById('formulariocontacto').innerHTML=xmlhttp.responseText;
      }
    }
    xmlhttp.open("GET", "/solicitarInformacion.php"+url,true);
    xmlhttp.send(null);
    return false;
  }
}
function distribuidorValidar(login, password){
  if ( $('dis_login').value == "" || $('dis_password').value == "" ){
    alert('Por favor, introduzca su usuario y contraseña.');
    $('dis_login').focus();
    return false;
  }
  url = '?dis_login='+$('dis_login').value+'&dis_password='+$('dis_password').value+'';
  xmlhttp=new XML();
  if (xmlhttp){
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        document.getElementById('avisoFormulario').innerHTML=xmlhttp.responseText;
        respuesta = xmlhttp.responseText;
        if ( respuesta.indexOf("Bienvenido") != -1 ){
          $('formularioValidacion').style.display = "none";
        }
        //Si no estamos en la home, hacemos un histori back, para que puedan ver los precios.
        pagina = window.location.href ;
        if ( pagina.indexOf("index.html") == -1 )
          window.history.back();
      }
    }
    xmlhttp.open("GET", "/php_lib/distribuidorValidar.php"+url,true);
    xmlhttp.send(null);
    return false;
  }
}

function solicitarAltaDistribuidor(){
  if ( $('empresa').value == "" || $('cif').value == "" 
       || $('personacontacto').value == "" ||
      ( $('email').value == "" && $('telefono').value == "") ){
  	alert('Por favor, complete los campos obligatorios ( * ).');
    $('empresa').focus();
    return false;
  }
  url = '?empresa='+$('empresa').value+'&personacontacto='+$('personacontacto').value+'&cif='+$('cif').value+'&direccion='+$('direccion').value+'&cp='+$('cp').value+'&fax='+$('fax').value+'&telefono='+$('telefono').value+'&email='+$('email').value+'&observaciones='+$('campoobservaciones').value+'';
  xmlhttp=new XML();
  if (xmlhttp){
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        document.getElementById('formulariocontacto').innerHTML=xmlhttp.responseText;
      }
    }
    xmlhttp.open("GET", "/solicitarAltaDistribuidor.php"+url,true);
    xmlhttp.send(null);
    return false;
  }
}

function solicitarAltaBoletin(){
  if ( !emailValidar($('sus_email')) ) { $('sus_email').focus(); return false; }
  if ( $('sus_email').value == "" ) {
  	alert('Por favor, introduzca la dirección de email donde desea recibir el boletin.');
    $('sus_email').focus();
    return false;
  }
  url = '?email='+$('sus_email').value+'';
  xmlhttp=new XML();
  if (xmlhttp){
    xmlhttp.onreadystatechange=function() {
      if (xmlhttp.readyState==4) {
        document.getElementById('avisoBoletin').innerHTML=xmlhttp.responseText;
      }
    }
    xmlhttp.open("GET", "/solicitarAltaBoletin.php"+url,true);
    xmlhttp.send(null);
    return false;
  }
}