//VARIABLES PARA VERIFICAR
var hayerrores=false;
var semaforo=false;
var mirocaptcha=false;//Evita mirar captcha 2 veces

function cambiafoto(id,nfoto) { 
	document.getElementById(id).style.filter="alpha(opacity=40)";
	document.getElementById(id).style.opacity=0.4;

	var mitadcuadro=(imagenart.height/2)-16;
	var textoload = '<div style="position:absolute;display:inline;text-align:center;line-height:'+imagenart.height+'px;height:'+imagenart.height+'px;width:'+imagenart.width+'px;overflow:hidden;"><img src="/imagenes/loading.gif" style="margin-top:'+mitadcuadro+'px;"/></div>';
	document.getElementById(id).innerHTML = textoload + document.getElementById(id).innerHTML; 
	
	imagenart = new Image();
	imagenart.src = '/fotos/'+nfoto;
	
	checkImg(id,nfoto);
}

function checkImg(id,nfoto){
  if(imagenart.complete)
  {
	var textoimagen = '<img src="/fotos/'+nfoto+'" border=1 style="border-color:#000000">';
	document.getElementById(id).innerHTML = textoimagen; 
	document.getElementById(id).style.filter="";
	document.getElementById(id).style.opacity="";
  }else{
	setTimeout('checkImg(\''+id+'\',\''+nfoto+'\')',1000);
	// se repite la misma funcion cada un (1) segundo;
  }
}

var divsel = "divp1";
function cambiad() { 
	var textomostrar = "";
	if (divsel == "divp1"){
		divsel = "divp2";
		document.getElementById('divp2').style.background = "url(/imagenes/botpestana.gif) no-repeat top center";
		document.getElementById('divp2').style.color = "#000000";
		document.getElementById('divp1').style.zIndex = 0;		
		document.getElementById('divp2').style.zIndex = 2;
		document.getElementById('divp1').style.cursor = "pointer";		
		document.getElementById('divp2').style.cursor = "default";
		document.getElementById('divp1').innerHTML = "<div style=\"width:100%;\" onclick=\"cambiad();\">Datos de Contacto</div>";
		document.getElementById('divp2').innerHTML = "<b>Administrar Anuncio</b>";
		if(micuenta == "1"){
			textomostrar = "<div style=\"float:left;width:100%;margin-left:5px;padding-bottom:10px;\"><form action=\"javascript:login()\" name=\"formlogin\" method=post>Introduzca la contraseña: <input type=\"password\" name=\"pass\" size=20 maxlength=15>  <input type=submit value=\"Entrar\" style=\"width:100px;\" class=\"boton\"><span id=\"recpass\" class=\"letrapeq\" style=\"margin-left:20px;\"><a href=\"javascript:rcontrasena()\">¿Ha olvidado la contraseña?</a></span></form></div>";
		}else{
			textomostrar = "<div style=\"float:left;width:100%;margin-left:5px;padding-bottom:10px;\">Para administrar este anuncio debe entrar a su cuenta:<br/><br/><span style=\"margin-left:130px;\">* <a href=\"/usuarios/index.php\">Entrar a Mi Cuenta</a></span><br /></div>";
		}
		document.getElementById('divpc').innerHTML = textomostrar;
	}else{
		divsel = "divp1";
		document.getElementById('divp1').style.background = "url(/imagenes/botpestana.gif) no-repeat top center";
		document.getElementById('divp1').style.color = "#000000";
		document.getElementById('divp1').style.zIndex = 2;		
		document.getElementById('divp2').style.zIndex = 0;
		document.getElementById('divp1').style.cursor = "default";		
		document.getElementById('divp2').style.cursor = "pointer";
		document.getElementById('divp1').innerHTML = "<b>Datos de Contacto</b>";
		document.getElementById('divp2').innerHTML = "<div style=\"width:100%;\" onclick=\"cambiad();\">Administrar Anuncio</div>";
		
		textomostrar = tituloc+"<br /><br /><div style=\"float:left;width:100%;line-height:18px;\"><img src=\"/imagenes/iconombre.gif\" border=0 style=\"margin-right:5px;vertical-align:text-top;\">Nombre: "+nombrec+"<br>";
		if (telefonoc != 0){
			textomostrar = textomostrar+"<img src=\"/imagenes/icontelefono.gif\" border=0 style=\"margin-right:5px;vertical-align:text-top;\">Teléfono: "+telefonoc+"<br>";
		}
		textomostrar = textomostrar+"<img src=\"/imagenes/iconmail.gif\" border=0 style=\"margin-right:2px;vertical-align:text-top;\"> <a href=\"javascript:envemail()\">Enviar correo electrónico</a></div><div id=\"divpl\" style=\"float:left;width:650px;text-align:left;\">&nbsp;</div>";
		document.getElementById('divpc').innerHTML = textomostrar;
	}
}

function arribadiv(este) { 
	if (divsel != este.id){
		este.style.color = "#ffffff";
		este.style.background = "url(/imagenes/botpestanar.gif) no-repeat top center";
	}
}

function fueradiv(este) { 
	if (divsel != este.id){
		este.style.color = "#000000";
		este.style.background = "url(/imagenes/botpestana.gif) no-repeat top center";
	}
}

function login() { 
	var ajax3 = new ajaxFunction();
	
	ajax3.onreadystatechange=function(){
		if(ajax3.readyState==4){
			if(ajax3.responseText=='ok'){
				document.getElementById('divpc').innerHTML = "<div style=\"float:left;width:100%;line-height:18px;padding-bottom:10px;\"><img src=\"/imagenes/iconmodific.gif\" border=0 style=\"margin-right:2px;vertical-align:text-top;\"> <a href=\"/modificar.php?id="+identidad+"\">Modificar</a><br /><img src=\"/imagenes/redo.gif\" border=0 style=\"margin-right:2px;vertical-align:text-top;\"> <a href=\"javascript:renovaranuncio()\" onmouseover=\"inforenovar()\" onmouseout=\"inforenovarq()\">Renovar</a><span id=\"divrenovar\" style=\"margin-left:10px;\"></span><br /><img src=\"/imagenes/iconborrar.gif\" border=0 style=\"margin-right:2px;vertical-align:text-top;\"> <a href=\"javascript:borraranuncio()\">Borrar</a><br /></div>";
				imagen2 = new Image(); imagen2.src = "/imagenes/register-info.gif";
			}else{
				document.getElementById('divpc').innerHTML = "<img src=\"/imagenes/register-error.gif\" style=\"vertical-align:text-top;margin-left:5px;\">&nbsp;<b>La contraseña que ha introducido es incorrecta.</b>&nbsp;&nbsp;<a href=\"javascript:formloguin()\">Volver a Intentar</a>.<br /><span id=\"recpass\" class=\"letrapeq\" style=\"line-height:20px;margin-left:25px;\"><a href=\"javascript:rcontrasena()\">¿Ha olvidado la contraseña?</a></span><br />";
			}
		}
    }	
	ajax3.open("POST","/includes/loginusuario.php",true);
	ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax3.send("pass="+document.formlogin.pass.value+"&id="+identidad);
}

function rcontrasena() { 
	dv=new Date();
	document.getElementById('divpc').innerHTML = "<div style=\"float:left;margin-left:5px;\"><b>Recordar Contraseña:</b><br /><br /><form action=\"javascript:enviarpass()\" name=\"formupass\" method=post><div style=\"float:left;width:100px;\">Email: </div><div style=\"float:left;width:700px;padding-bottom:1px;\"><input type=text name=\"email\" size=\"38\" maxlength=\"70\" style=\"width:220px;\" onblur=\"validarEmail(this,'divemaili','divemail')\" /><span id=\"divemaili\" style=\"padding-left:3px;\" /><img border=\"0\" src=\"/imagenes/register-info.gif\" width=\"16\" height=\"16\" style=\"vertical-align: middle;\" > Escriba el email que uso para publicar el anuncio.</span><div id=\"divemail\" class=\"url\"><br /></div></div><div style=\"float:left;width:100px;\">Verificación:</div><div style=\"height:30px;float:left;width:550px;padding-bottom:3px;\"><img src=\"/captcha.php?text="+dv.getTime()+"&tipo=c\" alt=\"captcha\" width=\"100\" height=\"30\" /></div><div style=\"height:30px;float:left;width:650px;padding-left:100px;padding-bottom:5px;\"><input name=\"captcha\" type=\"text\" size=\"14\" maxlength=\"5\" style=\"float:left;width:100px;\" onBlur=\"vcaptcha(this,'divcaptchai','divcaptcha')\" /><span id=\"divcaptchai\" class=\"cabecera\" style=\"padding-left:3px;\"><img border=\"0\" src=\"/imagenes/register-info.gif\" width=\"16\" height=\"16\" style=\"vertical-align: middle;\" > Escriba el texto de la imagen.</span><div id=\"divcaptcha\" class=\"url\" style=\"margin-top:4px;\"><br /></div></div><div style=\"float:left;width:640px;padding-left:100px;padding-top:5px;padding-bottom:25px;\"><input type=\"hidden\" name=\"id\" value=\""+identidad+"\"><input type=submit value=\"Solicitar Contraseña\" class=\"boton\"/>&nbsp;&nbsp;&nbsp;<input type=button value=\"Volver\" class=\"boton\" onclick=\"javascript:formloguin();\"/></div></form></div>";
}

function enviarpass() { 
	hayerrores=false;
	semaforo=false;
	document.formupass.email.focus();
	document.formupass.email.blur();
	document.formupass.captcha.focus();
	document.formupass.captcha.blur();
	setTimeout("errorono2();", 500);	
}

function errorono2(){
	if ((semaforo==false) && (hayerrores==true)){
			alert("Revise los campos marcados en rojo.");
			return false;
	}else{
		if (semaforo){
			if (hayerrores){
				alert("Revise los campos marcados en rojo.");
				return false;
			}else{
				envialopass();
				return true;
			}
		}else{
			setTimeout("errorono();", 500);
		}
	}
}

function envialopass() { 
	var ajax3 = new ajaxFunction();
	
	ajax3.onreadystatechange=function(){
		if(ajax3.readyState==4){
			if(ajax3.responseText=='ok'){
				document.getElementById('divpc').innerHTML = "<div style=\"float:left;margin-left:5px;\"><b><img src=\"/imagenes/register-success.gif\" style=\"vertical-align:text-top;\">&nbsp;La contraseña ha sido enviada a su email ("+document.formupass.email.value+").</b> <a href=\"javascript:formloguin()\">Administrar Anuncio</a>.<br /><br /></div>";
			}else{
				document.getElementById('divpc').innerHTML = "<div style=\"float:left;margin-left:5px;\"><b><img src=\"/imagenes/register-error.gif\" style=\"vertical-align:text-top;\">&nbsp;Error al intentar recordar la contraseña, compruebe que los datos que introdujo en el formulario son correctos.</b><br/><div style=\"line-height:20px;margin-left:30px;margin-top:7px;\"><img src=\"/imagenes/backward.gif\" border=0 style=\"margin-right:5px;vertical-align:text-top;\"/><a href=\"javascript:rcontrasena()\">Recordar contraseña</a>.</div><div style=\"line-height:20px;margin-left:30px;\"><img src=\"/imagenes/backward.gif\" border=0 style=\"margin-right:5px;vertical-align:text-top;\"/><a href=\"javascript:formloguin()\">Administrar anuncio</a>.</div><br /></div>";
			}
		}
    }	
	
	ajax3.open("POST","/rpassword.php",true);
	ajax3.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax3.send("email="+document.formupass.email.value+"&captcha="+document.formupass.captcha.value+"&id="+identidad);
}

function inforenovar() { 
		document.getElementById('divrenovar').innerHTML = "<img border=\"0\" src=\"/imagenes/register-info.gif\" width=\"16\" height=\"16\" alt=\"registro\" style=\"vertical-align: middle;\" /> Renueve su anuncio para que aparezca más arriba en los listados.";
}

function inforenovarq() { 
		document.getElementById('divrenovar').innerHTML = "";
}

function formloguin() { 
		document.getElementById('divpc').innerHTML = "<div style=\"float:left;width:100%margin-left:5px;padding-bottom:10px;\"><form action=\"javascript:login()\" name=\"formlogin\" method=post>Introduzca la contraseña: <input type=\"password\" name=\"pass\" size=20 maxlength=15>  <input type=submit value=\"Entrar\" style=\"width:100px;\" class=\"boton\"><span id=\"recpass\" class=\"letrapeq\" style=\"margin-left:20px;\"><a href=\"javascript:rcontrasena()\">¿Ha olvidado la contraseña?</a></span></form></div>";
}

function borraranuncio() { 
if (confirm("¿Esta seguro que desea borrar el anuncio?") == true){
	var ajax4 = new ajaxFunction();	
	ajax4.onreadystatechange=function(){
		if(ajax4.readyState==4){
			if(ajax4.responseText=='ok'){
				location.replace('/borrado.php');
			}else{
				document.getElementById('divpc').innerHTML = "error al borrar";
			}
		}
    }	
	ajax4.open("POST","/includes/borraranuncio.php",true);
	ajax4.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax4.send("id="+identidad);	
}
}

var renovado = "no";
function renovaranuncio() { 
	if (renovado == "no"){
		var ajax4 = new ajaxFunction();	
		ajax4.onreadystatechange=function(){
			if(ajax4.readyState==4){
				if(ajax4.responseText=='ok'){
					renovado = "si";
					alert('Su anuncio ha sido renovado.');
				}else{
					if(ajax4.responseText=='error24h'){
						alert('Su anuncio tiene fecha de hoy, no hace falta renovarlo.\nDebe esperar 1 día para renovar su anuncio.');
					}else{
						alert('Se a producido un error al intentar renovar el anuncio.');
					}
				}
			}
		}
		ajax4.open("POST","/includes/renovaranuncio.php",true);
		ajax4.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		ajax4.send("id="+identidad);
	}else{
		alert('Su anuncio ya ha sido renovado.\nDebe esperar 1 día para volver a renovarlo.');
	}
}

function envemail() { 
	dv=new Date();
	document.getElementById('divpl').innerHTML = "<br><form action=\"javascript:enviaremail()\" name=\"formuemail\" method=post><div style=\"float:left;width:100px;\">Tu nombre: </div><div style=\"float:left;width:190px;padding-bottom:1px;\"><input type=text name=\"nombre\" size=\"25\" maxlength=\"20\" style=\"width:150px;\" onKeypress=\"verificar(this,'divnomi','divnom',0,'no')\" onKeyup=\"verificar(this,'divnomi','divnom',0,'no')\" onBlur=\"verificar(this,'divnomi','divnom',2,'si')\" /><span id=\"divnomi\" style=\"padding-left:3px;\" /> </span><div id=\"divnom\" class=\"url\"><br></div></div><div style=\"float:left;width:60px;\">Tu email: </div><div style=\"float:left;width:250px;padding-bottom:1px;\"><input type=text name=\"email\" size=\"38\" maxlength=\"70\" style=\"width:220px;\" onblur=\"validarEmail(this,'divemaili','divemail')\" /><span id=\"divemaili\" style=\"padding-left:3px;\" /> </span><div id=\"divemail\" class=\"url\"><br /></div></div><div style=\"float:left;width:100px;\">Texto del email: </div><div style=\"float:left;width:550px;padding-bottom:1px;\"><textarea name=\"texto\" rows=3 style=\"width:470px;\" onKeypress=\"verificarcaja(this,'divtextoi','divtexto',0,200,'no')\" onkeyup=\"verificarcaja(this,'divtextoi','divtexto',0,200,'no')\" onblur=\"verificarcaja(this,'divtextoi','divtexto',10,200,'si')\"></textarea><span id=\"divtextoi\" style=\"padding-left:3px;\"> </span><div id=\"divtexto\" class=\"url\"><br></div></div><div style=\"float:left;width:100px;\">Verificación:</div><div style=\"height:30px;float:left;width:550px;padding-bottom:3px;\"><img src=\"/captcha.php?text="+dv.getTime()+"&tipo=c\" alt=\"captcha\" width=\"100\" height=\"30\" /></div><div style=\"height:30px;float:left;width:650px;padding-left:100px;padding-bottom:5px;\"><input name=\"captcha\" type=\"text\" size=\"14\" maxlength=\"5\" style=\"float:left;width:100px;\" onBlur=\"vcaptcha(this,'divcaptchai','divcaptcha')\" /><span id=\"divcaptchai\" class=\"cabecera\" style=\"padding-left:3px;\"><img border=\"0\" src=\"/imagenes/register-info.gif\" width=\"16\" height=\"16\" style=\"vertical-align: middle;\" > Escriba el texto de la imagen.</span><div id=\"divcaptcha\" class=\"url\" style=\"margin-top:4px;\"><br /></div></div><div style=\"float:left;width:640px;padding-left:100px;padding-top:5px;padding-bottom:25px;\"><input type=submit value=\"Enviar Email\" class=\"boton\"/></div></form>"

	imagen2 = new Image();
	imagen2.src = "/imagenes/register-error.gif";
	imagen3 = new Image();
	imagen3.src = "/imagenes/register-success.gif";
}

function enviaremail() { 
	hayerrores=false;
	semaforo=false;
	document.formuemail.nombre.focus();
	document.formuemail.nombre.blur();
	document.formuemail.email.focus();
	document.formuemail.email.blur();
	document.formuemail.texto.focus();
	document.formuemail.texto.blur();
	document.formuemail.captcha.focus();
	document.formuemail.captcha.blur();
	setTimeout("errorono();", 500);
}

function errorono(){
	if ((semaforo==false) && (hayerrores==true)){
			alert("Revise los campos marcados en rojo.");
			return false;
	}else{
		if (semaforo){
			if (hayerrores){
				alert("Revise los campos marcados en rojo.");
				return false;
			}else{
				envialo();
				return true;
			}
		}else{
			setTimeout("errorono();", 500);
		}
	}
}

function envialo() { 
	var ajax2 = new ajaxFunction();
	
	ajax2.onreadystatechange=function(){
		if(ajax2.readyState==4){
			if(ajax2.responseText=='ok'){
				document.getElementById('divpl').innerHTML = "<br><b>&nbsp;&nbsp;<img src=\"/imagenes/register-success.gif\" style=\"vertical-align: middle;\">&nbsp;Correo electronico enviado.</b><br /><br />";
			}else{
				if(ajax2.responseText=='Error5'){
					document.getElementById('divpl').innerHTML = "<br><b>&nbsp;&nbsp;<img src=\"/imagenes/register-error.gif\" style=\"vertical-align: middle;\">&nbsp;Debe esperar al menos un minuto antes de volver a contactar con un usuario.</b><br /><br />";
				}else{
					document.getElementById('divpl').innerHTML = "<br><b>&nbsp;&nbsp;<img src=\"/imagenes/register-error.gif\" style=\"vertical-align: middle;\">&nbsp;Se ha producido un error al intentar enviar el correo electronico.</b><br /><br />";
				}
			}
		}
    }	
	
	ajax2.open("POST","/contactoemail.php",true);
	ajax2.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	ajax2.send("nombre="+document.formuemail.nombre.value+"&email="+document.formuemail.email.value+"&texto="+document.formuemail.texto.value+"&captcha="+document.formuemail.captcha.value+"&id="+identidad);
}

function verificar(f, divi, div, minc,ponrok){
  if((f.value.length < minc) && (f.value.match(/[^a-z0-9A-ZñÑáéíóúàèìòùÜüÁÉÍÓÚÀÈÌÒÙ.,:\ ]/))){
	WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
	f.style.borderColor="#FF0000";
	WriteLayer(div,null,'No use caracteres especiales y mínimo '+minc+' caracteres.');
	hayerrores=true;
  }else{
    if(f.value.length < minc){
		f.style.borderColor="#FF0000";
		WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
		WriteLayer(div,null,'Mínimo '+minc+' caracteres');
		hayerrores=true;
	}else{
		 if(f.value.match(/[^a-z0-9A-ZñÑáéíóúàèìòùÜüÁÉÍÓÚÀÈÌÒÙ.,:\ ]/)){
			f.style.borderColor="#FF0000";
			WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
			WriteLayer(div,null,'No caracteres especiales');
			hayerrores=true;
		}else{
		
			if (ponrok == 'si'){
				f.style.borderColor="#7f9db9";
				WriteLayer(divi,null,'<img src="/imagenes/register-success.gif" style="vertical-align: top;">');
				WriteLayer(div,null,'<br>');
			}else{
				f.style.borderColor="#7f9db9";
				WriteLayer(divi,null,'');
				WriteLayer(div,null,'<br>');	
			
			}
			
		}
	}
  }
}
 
 function validarEmail(valor,divi,div) {
  if (valor.value.match(/^(\w+[\.\-])*\w+@(\w+[\.\-])*\w+\.[a-z]{2,4}$/i) && (valor.value.length <= 70)){
  			valor.style.borderColor="#7f9db9";
			WriteLayer(divi,null,'<img src="/imagenes/register-success.gif" style="vertical-align: top;">');
			WriteLayer(div,null,'<br>');
  } else {
  			valor.style.borderColor="#FF0000";
			WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
			WriteLayer(div,null,'La dirección de e-mail no es válida');
			hayerrores=true;
  }
 }

function vcaptcha(esto,divi,div){
	if (mirocaptcha ==false){
		mirocaptcha=true;
		var ajax = new ajaxFunction();
		
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4) {
				if(ajax.responseText=='ok'){
					esto.style.borderColor="#7f9db9";
					WriteLayer(divi,null,'<img src="/imagenes/register-success.gif">');
					WriteLayer(div,null,'<br>');
				}else{
					if(ajax.responseText=='NoSession'){
						esto.style.borderColor="#FF0000";
						WriteLayer(divi,null,'<img src="/imagenes/register-error.gif">');
						WriteLayer(div,null,'Debe permitir el uso de cookies en su navegador.');
						hayerrores=true;
						alert("Debe permitir el uso de cookies en su navegador.");
					}else{
						esto.style.borderColor="#FF0000";
						WriteLayer(divi,null,'<img src="/imagenes/register-error.gif">');
						WriteLayer(div,null,'No es el texto de la imagen');
						hayerrores=true;
					}
				}
				mirocaptcha=false;
				semaforo=true;
			}
		}
		
		ajax.open("GET","/validarcaptcha.php?captcha="+esto.value+"&tipo=c",true);
		ajax.send(null);
	}
}
 
function ajaxFunction()
  { var xmlHttp;
  try { xmlHttp=new XMLHttpRequest();return xmlHttp; }
  catch (e) { try { xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");return xmlHttp; }
  catch (e) { try { xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");return xmlHttp; }
  catch (e) { alert("Tu navegador no soporta AJAX!");return false; }
}}}

function WriteLayer(ID,parentID,sText) {
 if (document.layers) {
   var oLayer;
   if(parentID){
     oLayer = eval('document.' + parentID + '.document.' + ID + '.document');
   }else{
     oLayer = document.layers[ID].document;
   }
   oLayer.open();
   oLayer.write(sText);
   oLayer.close();
 }
 else if (parseInt(navigator.appVersion)>=5&&navigator.
appName=="Netscape") {
   document.getElementById(ID).innerHTML = sText;
 }
 else if (document.all) document.all[ID].innerHTML = sText
}


function verificarcaja(f, divi, div, minc,max,ponrok){
if(longitudtextarea(f.value) < max){
  if((longitudtextarea(f.value) < minc) && (f.value.match(/[^a-z0-9A-ZñÑáéíóúàèìòùÜüÁÉÍÓÚÀÈÌÒÙ.,:;ºª*#&)(€$@%"'=?¿¡!\/\+\-\r\n\ ]/))){
	WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
	f.style.borderColor="#FF0000";
	WriteLayer(div,null,'No use caracteres especiales y minimo '+minc+' caracteres.');
	hayerrores=true;
  }else{
    if(longitudtextarea(f.value) < minc){
		f.style.borderColor="#FF0000";
		WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
		WriteLayer(div,null,'Minimo '+minc+' caracteres.');
		hayerrores=true;
	}else{
		if(f.value.match(/[^a-zA-Z!-;ñÑáéíóúàèìòùÜüÁÉÍÓÚÀÈÌÒÙºª€@=?¿¡ \r\n]/)){
			f.style.borderColor="#FF0000";
			WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
			WriteLayer(div,null,'No caracteres especiales.');
			hayerrores=true;
		}else{			
			if (ponrok == 'si'){
				f.style.borderColor="#7f9db9";
				WriteLayer(divi,null,'<img src="/imagenes/register-success.gif" style="vertical-align: top;">');
				WriteLayer(div,null,'<br>');
			}else{
				f.style.borderColor="#7f9db9";
				WriteLayer(divi,null,'');
				WriteLayer(div,null,'<br>');	
			
			}
		}
	}
  }
 }else{
 	WriteLayer(divi,null,'<img src="/imagenes/register-error.gif" style="vertical-align: top;">');
	f.style.borderColor="#FF0000";
	WriteLayer(div,null,'A excedido el número de caracteres permitidos, el número maximo de caracteres es '+max+'.');
	hayerrores=true;
 }
}

function longitudtextarea(contenido) {
	var arrayaux;
	arrayaux = contenido;
	pat = new RegExp(String.fromCharCode(13),"g")//usado en IE
	pat2 = new RegExp(String.fromCharCode(10),"g")//usado por IE y FX
	arrayaux = arrayaux.replace(pat, "");
	arrayaux = arrayaux.replace(pat2, "a");
	return arrayaux.length;
}



