function contactar(){var nombre=$F("nombre");var de=$F("de");var asunto=$F("asunto");var departamento=$F("cmbDepartamento");var mensaje=$F("mensaje");var errores='';if(nombre=="")errores+='<li>No has introducido tu nombre</li>';if(!validarEmail(de))errores+='<li>El email introducido no es válido</li>';if(asunto=="")errores+='<li>No has introducido el asunto del mensaje</li>';if(departamento==0)errores+='<li>No has seleccionado ningún departamento</li>';if(mensaje=="")errores+='<li>No has introducido el mensaje</li>';if(errores==""){$("botonEnviar").style.display="none";$("imagenCarga").style.display="block";var url="/gestion/contactar.php";var pars="nombre="+nombre+"&de="+de+"&asunto="+asunto+"&departamento="+departamento+"&mensaje="+mensaje;var myAjax=new Ajax.Request(url,{method:"post",parameters:pars,onComplete:function(transport){limpiarCampos();$("imagenCarga").style.display="none";$("botonEnviar").style.display="block";$("errores").update('<a name="ok"></a><p style="font-weight:bold">Gracias por contactar con Comprar.es</p><p>&nbsp;<br/>En breve recibirás una respuesta a tu mensaje.</p>&nbsp;<br/><a class="linkAzul" href="javascript:muestraContactar();">Volver</a>');$("errores").style.display="block";$("formulario").style.display="none";document.location.href="#ok";}});}
else{$("errores").update('<a name="errores"></a><p style="color:#ff0000">No se ha podido enviar el mensaje:</p><ul class="listaNoOk">'+errores+'</ul><a class="linkAzul" href="javascript:muestraContactar();">Volver</a>');$("errores").style.display="block";$("formulario").style.display="none";document.location.href="#errores";}}
function muestraContactar(){$("errores").style.display="none";$("formulario").style.display="block";}
function limpiarCampos(){$("nombre").value="";$("de").value="";$("asunto").value="";$("cmbDepartamento").selectedIndex=0;$("mensaje").value="";}
function validarCCC(entidad,oficina,dc,cuenta){var wtotal,wcociente,wresto;if(entidad.length!=4||oficina.length!=4||dc.length!=2||cuenta.length!=10){return false;}
wtotal=entidad.charAt(0)*4;wtotal+=entidad.charAt(1)*8;wtotal+=entidad.charAt(2)*5;wtotal+=entidad.charAt(3)*10;wtotal+=oficina.charAt(0)*9;wtotal+=oficina.charAt(1)*7;wtotal+=oficina.charAt(2)*3;wtotal+=oficina.charAt(3)*6;wcociente=Math.floor(wtotal/11);wresto=wtotal-(wcociente*11);wtotal=11-wresto;if(wtotal==11)wtotal=0;if(wtotal==10)wtotal=1;if(wtotal!=dc.charAt(0)){return false;}
wtotal=cuenta.charAt(0)*1;wtotal+=cuenta.charAt(1)*2;wtotal+=cuenta.charAt(2)*4;wtotal+=cuenta.charAt(3)*8;wtotal+=cuenta.charAt(4)*5;wtotal+=cuenta.charAt(5)*10;wtotal+=cuenta.charAt(6)*9;wtotal+=cuenta.charAt(7)*7;wtotal+=cuenta.charAt(8)*3;wtotal+=cuenta.charAt(9)*6;wcociente=Math.floor(wtotal/11);wresto=wtotal-(wcociente*11);wtotal=11-wresto;if(wtotal==11){wtotal=0;}
if(wtotal==10){wtotal=1;}
if(wtotal!=dc.charAt(1)){return false;}
return true;}
function validarEmail(valor){if(/^[a-zA-Z0-9\-\_\.]+@[a-zA-Z\-\_\.]*\.[a-zA-Z0-9\-\_]{2,6}$/.test(valor))return true
else return false;}
