function verificarLogin(form) {
  var buf = '';
  var len = 0;
  var emailID=form.email	
  
  if ((form.password.value == '') || (form.email.value == '')){
		
		buf = "Debes introducir ";
		if (form.email.value == '')
		  { buf = buf + " tu email, "; }
		if (form.password.value == '')
		  { buf = buf + " tu contrase" + String.fromCharCode(241) + "a, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
    }
}

function verificarContacto(form) {
  var buf = '';
  var len = 0;
  var emailID=form.email	
  
  if ((form.nombre.value == '') || (form.comentario.value == '') || (form.email.value == '')){
		
		buf = "Debes introducir ";
		if (form.nombre.value == '')
		  { buf = buf + " tu nombre, "; }
		if (form.comentario.value == '')
		  { buf = buf + " tu comentario, "; }
		if (form.email.value == '')
		  { buf = buf + " tu email, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
		
		if (form.comentario.value.length > 1000)
	    {
			alert('No puedes escribir m' + String.fromCharCode(225) + 's de 1000 caracteres');
			return false;
	    }
    }
}

function verificarEncuesta(form) {
  var buf = '';
  var len = 0;	  
  var is_respondido = 0;
  
  for (var i=0; i<form.opcion.length; i++) 
  { 
	if ((form.opcion[i].checked))
	{ is_respondido=1; }
  }
  
   if (is_respondido==0)
   {
	   alert('Debes escoger alguna opci' + String.fromCharCode(243) + 'n para votar');
	   return false;
   }
}

function verificarRegistro(form) {
  var buf = '';
  var len = 0;
  var emailID=form.usuario_email
  var sexo = 0;
  
  if ((form.usuario_sexo_0.checked))
  { sexo=1; }
  if ((form.usuario_sexo_1.checked))
  { sexo=1; }

  
  if ((form.usuario_nombre.value == '') || (form.usuario_apellido.value == '') || (form.usuario_login.value == '') || (sexo==0) || (form.usuario_password.value == '') || (form.usuario_password_repeat.value == '') || (form.usuario_email.value == '') || (form.usuario_email_repeat.value == '') || (form.usuario_celular1.value == '') || (form.usuario_id_pais.value == '') || (form.usuario_id_estado.value == '')){
		
		buf = "Debes introducir ";
		if (form.usuario_nombre.value == '')
		  { buf = buf + " tu nombre, "; }
		if (form.usuario_apellido.value == '')
		  { buf = buf + " tu apellido, "; }
		if (form.usuario_login.value == '')
		  { buf = buf + " tu login, "; }
		if (sexo == 0)
		  { buf = buf + " tu sexo, "; }
		if (form.usuario_password.value == '')
		  { buf = buf + " tu contrase" + String.fromCharCode(241) + "a, "; }
		if (form.usuario_password_repeat.value == '')
		  { buf = buf + " repite tu contrase" + String.fromCharCode(241) + "a, "; }
		if (form.usuario_email.value == '')
		  { buf = buf + " tu email, "; }
		if (form.usuario_email_repeat.value == '')
		  { buf = buf + " repite tu email, "; }
		if (form.usuario_celular1.value == '')
		  { buf = buf + " tu celular, "; }
		if (form.usuario_id_pais.value == '')
		  { buf = buf + " tu pa" + String.fromCharCode(237) + "s, "; }
		if (form.usuario_id_estado.value == '')
		  { buf = buf + " tu estado, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (form.acepto.checked == false){ 
			alert("Para continuar debes marcar la casilla de aceptar los t" + String.fromCharCode(233) + "rminos"); 
			return false
		}
		if (form.usuario_password.value != form.usuario_password_repeat.value)
		{ 
			alert("La contrase" + String.fromCharCode(241) + "a no coincide. Por favor, intenta de nuevo"); 
			return false
		}
		if (form.usuario_email.value != form.usuario_email_repeat.value)
		{ 
			alert("El email no coincide por favor intente de nuevo"); 
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
    }
}

function verificarUsuario(form) {
  var buf = '';
  var len = 0;
  var emailID=form.usuario_email
  var sexo = 0;
  
  if ((form.usuario_sexo_0.checked))
  { sexo=1; }
  if ((form.usuario_sexo_1.checked))
  { sexo=1; }

  
  if ((form.usuario_nombre.value == '') || (form.usuario_apellido.value == '') || (form.usuario_login.value == '') || (sexo==0) || (form.usuario_password.value == '') || (form.usuario_password_repeat.value == '') || (form.usuario_email.value == '') || (form.usuario_celular1.value == '') || (form.usuario_perfil.value == '') || (form.usuario_id_pais.value == '') || (form.usuario_id_estado.value == '')){
		
		buf = "Debes introducir ";
		if (form.usuario_nombre.value == '')
		  { buf = buf + " nombre, "; }
		if (form.usuario_apellido.value == '')
		  { buf = buf + " apellido, "; }
		if (form.usuario_login.value == '')
		  { buf = buf + " login, "; }
		if (sexo == 0)
		  { buf = buf + " sexo, "; }
		if (form.usuario_password.value == '')
		  { buf = buf + " contrase" + String.fromCharCode(241) + "a , "; }
		if (form.usuario_password_repeat.value == '')
		  { buf = buf + " repite contrase" + String.fromCharCode(241) + "a, "; }
		if (form.usuario_email.value == '')
		  { buf = buf + " email, "; }
		if (form.usuario_celular1.value == '')
		  { buf = buf + " celular, "; }
		if (form.usuario_perfil.value == '')
		  { buf = buf + " perfil, "; }
		if (form.usuario_id_pais.value == '')
		  { buf = buf + " pa" + String.fromCharCode(237) + "s, "; }
		if (form.usuario_id_estado.value == '')
		  { buf = buf + " estado, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (form.usuario_password.value != form.usuario_password_repeat.value)
		{ 
			alert("El password no coincide por favor intente de nuevo"); 
			return false
		}
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
    }
}

function verificarCambiarClave(form) {
  var buf = '';
  var len = 0;
  var emailID=form.email

  
  if (form.email.value == '')
  {	
		buf = "Debes introducir ";
		if (form.email.value == '')
		  { buf = buf + " tu email, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
    }
}

function verificarPublicacionMascota(form,bool) {
  var buf = '';
  var len = 0;
  var emailID=form.publicacion_email
  var raza = "";
  var raza_num = 0;
  
  switch (form.publicacion_id_mascota.value)
  {
	case 1:
		raza = form.publicacion_id_perro.value;
		raza_num = 1;
	break;
	case 2:
		raza = form.publicacion_id_gato.value;
		raza_num = 2;
	break;
	case 3:
		raza = form.publicacion_id_otro.value;
		raza_num = 3;
	break;
	default:
	
	break;
  }

  var content = tinyMCE.activeEditor.getContent(); // get the content
  $('#publicacion_descripcion').val(content);
	
  if ((form.publicacion_nombre.value == '') || (form.publicacion_id_mascota.value == '') || (form.publicacion_num_machos.value == '') || (form.publicacion_num_hembras.value == '') || (form.publicacion_pedigree.value == '') || (form.publicacion_vacunas.value == '') || (form.publicacion_fecha_nacimiento_month.value == '') || (form.publicacion_fecha_nacimiento_day.value == '') || (form.publicacion_fecha_nacimiento_year.value == '') || (form.publicacion_precio.value == '') || (form.publicacion_email.value == '') || (form.publicacion_id_tipo_oferta.value == '') || (form.publicacion_id_pais.value == '') || (form.publicacion_id_estado.value == '') || (form.publicacion_id_ciudad.value == '') || (form.publicacion_descripcion.value == '') || (form.publicacion_foto1.value == '' && bool==true)){
		
		buf = "Debes introducir ";
		if (form.publicacion_nombre.value == '')
		  { buf = buf + " t" + String.fromCharCode(237) + "tulo, "; }
		if (form.publicacion_id_mascota.value == '')
		  { buf = buf + " tipo de mascota, "; }
		if (raza_num == 1)
		{
		  if (form.publicacion_id_perro.value == '')
		  { buf = buf + " raza de perro, "; }
		}
		if (raza_num == 2)
		{
		  if (form.publicacion_id_gato.value == '')
		  { buf = buf + " raza de gato, "; }
		}
		if (raza_num == 3)
		{
		  if (form.publicacion_id_otro.value == '')
		  { buf = buf + " especie de animal, "; }
		}
		if (form.publicacion_descripcion.value == '')
		  { buf = buf + " descripci" + String.fromCharCode(243) + "n, "; }
		if (form.publicacion_num_machos.value == '')
		  { buf = buf + " machos, "; }
		if (form.publicacion_num_hembras.value == '')
		  { buf = buf + " hembras, "; }
		if (form.publicacion_pedigree.value == '')
		  { buf = buf + " pedigree, "; }
		if (form.publicacion_vacunas.value == '')
		  { buf = buf + " vacunas, "; }
		if (form.publicacion_fecha_nacimiento_month.value == '' || form.publicacion_fecha_nacimiento_day.value == '' || form.publicacion_fecha_nacimiento_year.value == '')
		  { buf = buf + " fecha de nacimiento, "; }
		if (form.publicacion_precio.value == '')
		  { buf = buf + " precio, "; }
		if (form.publicacion_email.value == '')
		  { buf = buf + " email, "; }
		if (form.publicacion_id_tipo_oferta.value == '')
		  { buf = buf + " tipo de oferta, "; }
		if (form.publicacion_id_pais.value == '')
		  { buf = buf + " pa" + String.fromCharCode(237) + "s, "; }
		if (form.publicacion_id_estado.value == '')
		  { buf = buf + " estado, "; }
		if (form.publicacion_id_ciudad.value == '')
		  { buf = buf + " ciudad, "; }
		if (form.publicacion_foto1.value == '' && bool==true)
		  { buf = buf + " foto 1, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
		
		if (form.publicacion_precio.value != '')
		{
			patron = /(^\d+$)|(^\d+(\.|\,)\d{1,2}$)/;
			if (!patron.test(form.publicacion_precio.value))
			{ 
				alert("Precio tiene un formato inv" + String.fromCharCode(225) + "lido"); 
				return false
			}
		}
		if ((form.publicacion_fecha_entrega_month.value != '') || (form.publicacion_fecha_entrega_day.value != '') || (form.publicacion_fecha_entrega_year.value != ''))
		{
			if ((form.publicacion_fecha_entrega_month.value == '') || (form.publicacion_fecha_entrega_day.value == '') || (form.publicacion_fecha_entrega_year.value == ''))
			{
				alert("Formato de fecha de entrega inv" + String.fromCharCode(225) + "lido"); 
				return false
			}
		}
		/*if ((form.publicacion_fecha_vencimiento_month.value != '') || (form.publicacion_fecha_vencimiento_day.value != '') || (form.publicacion_fecha_vencimiento_year.value != ''))
		{
			if ((form.publicacion_fecha_vencimiento_month.value == '') || (form.publicacion_fecha_vencimiento_day.value == '') || (form.publicacion_fecha_vencimiento_year.value == ''))
			{
				alert("Formato de fecha de vencimiento inv" + String.fromCharCode(225) + "lido"); 
				return false
			}
		}*/

		ProgressImage = document.getElementById('progress_image');
		document.getElementById("progress").style.visibility = "visible";
		setTimeout("ProgressImage.src = ProgressImage.src",100);
		return true;
    }
}

function verificarPublicacionServicio(form,bool) {
  var buf = '';
  var len = 0;
  var emailID=form.publicacion_email
  
  var content = tinyMCE.activeEditor.getContent(); // get the content
  $('#publicacion_descripcion').val(content);

  if ((form.publicacion_nombre.value == '') || (form.publicacion_id_servicio.value == '') || (form.publicacion_telefono1.value == '') || (form.publicacion_email.value == '') || (form.publicacion_id_pais.value == '') || (form.publicacion_id_estado.value == '') || (form.publicacion_descripcion.value == '') || (form.publicacion_id_ciudad.value == '') || (form.publicacion_foto1.value == '' && bool==true)){
		
		buf = "Debes introducir ";
		if (form.publicacion_nombre.value == '')
		  { buf = buf + " t" + String.fromCharCode(237) + "tulo, "; }
		if (form.publicacion_id_servicio.value == '')
		  { buf = buf + " tipo de servicio, "; }
		if (form.publicacion_telefono1.value == '')
		  { buf = buf + " tel" + String.fromCharCode(233) + "fono, "; }
		if (form.publicacion_email.value == '')
		  { buf = buf + " email, "; }
		if (form.publicacion_descripcion.value == '')
		  { buf = buf + " descripci" + String.fromCharCode(243) + "n, "; }
		if (form.publicacion_id_pais.value == '')
		  { buf = buf + " pa" + String.fromCharCode(237) + "s, "; }
		if (form.publicacion_id_estado.value == '')
		  { buf = buf + " estado, "; }
		if (form.publicacion_id_ciudad.value == '')
		  { buf = buf + " ciudad, "; }
		if (form.publicacion_foto1.value == '' && bool==true)
		  { buf = buf + " foto 1, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);

		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
		
		if (form.publicacion_precio.value != '')
		{
			patron = /(^\d+$)|(^\d+(\.|\,)\d{1,2}$)/;
			if (!patron.test(form.publicacion_precio.value))
			{ 
				alert("Precio tiene un formato inv" + String.fromCharCode(225) + "lido"); 
				return false
			}
		}

		ProgressImage = document.getElementById('progress_image');
		document.getElementById("progress").style.visibility = "visible";
		setTimeout("ProgressImage.src = ProgressImage.src",100);
		return true;
    }
}

function verificarPublicacionProducto(form,bool) {
  var buf = '';
  var len = 0;
  var emailID=form.publicacion_email
  
  var content = tinyMCE.activeEditor.getContent(); // get the content
  $('#publicacion_descripcion').val(content);

  if ((form.publicacion_nombre.value == '') || (form.publicacion_id_producto.value == '') || (form.publicacion_precio.value == '') || (form.publicacion_telefono1.value == '') || (form.publicacion_email.value == '') || (form.publicacion_id_pais.value == '') || (form.publicacion_id_estado.value == '') || (form.publicacion_id_ciudad.value == '') || (form.publicacion_descripcion.value == '') || (form.publicacion_foto1.value == '' && bool==true)){
		
		buf = "Debes introducir ";
		if (form.publicacion_nombre.value == '')
		  { buf = buf + " t" + String.fromCharCode(237) + "tulo, "; }
		if (form.publicacion_id_producto.value == '')
		  { buf = buf + " tipo de producto, "; }
		if (form.publicacion_precio.value == '')
		  { buf = buf + " precio, "; }
		if (form.publicacion_telefono1.value == '')
		  { buf = buf + " tel" + String.fromCharCode(233) + "fono, "; }
		if (form.publicacion_email.value == '')
		  { buf = buf + " email, "; }
		if (form.publicacion_descripcion.value == '')
		  { buf = buf + " descripci" + String.fromCharCode(243) + "n, "; }
		if (form.publicacion_id_pais.value == '')
		  { buf = buf + " pa" + String.fromCharCode(237) + "s, "; }
		if (form.publicacion_id_estado.value == '')
		  { buf = buf + " estado, "; }
		if (form.publicacion_id_ciudad.value == '')
		  { buf = buf + " ciudad, "; }
		if (form.publicacion_foto1.value == '')
		  { buf = buf + " foto 1, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}
		
		if (form.publicacion_precio.value != '')
		{
			patron = /(^\d+$)|(^\d+(\.|\,)\d{1,2}$)/;
			if (!patron.test(form.publicacion_precio.value))
			{ 
				alert("Precio tiene un formato inv" + String.fromCharCode(225) + "lido"); 
				return false
			}
		}
		
		ProgressImage = document.getElementById('progress_image');
		document.getElementById("progress").style.visibility = "visible";
		setTimeout("ProgressImage.src = ProgressImage.src",100);
		return true;
    }
}

function verificarOrganizacion(form,bool) {
  var buf = '';
  var len = 0;
  var emailID=form.organizacion_email
  
  var content = tinyMCE.activeEditor.getContent(); // get the content
  $('#organizacion_descripcion').val(content);

  if ((form.organizacion_nombre.value == '') || (form.organizacion_telefono1.value == '') || (form.organizacion_email.value == '') || (form.organizacion_id_pais.value == '') || (form.organizacion_id_estado.value == '') || (form.organizacion_descripcion.value == '') || (form.organizacion_id_ciudad.value == '') || (form.organizacion_foto1.value == '' && bool==true)){
		
		buf = "Debes introducir ";
		if (form.organizacion_nombre.value == '')
		  { buf = buf + " nombre, "; }
		if (form.organizacion_telefono1.value == '')
		  { buf = buf + " tel" + String.fromCharCode(233) + "fono, "; }
		if (form.organizacion_email.value == '')
		  { buf = buf + " email, "; }
		if (form.organizacion_descripcion.value == '')
		  { buf = buf + " descripci" + String.fromCharCode(243) + "n, "; }
		if (form.organizacion_id_pais.value == '')
		  { buf = buf + " pa" + String.fromCharCode(237) + "s, "; }
		if (form.organizacion_id_estado.value == '')
		  { buf = buf + " estado, "; }
		if (form.organizacion_id_ciudad.value == '')
		  { buf = buf + " ciudad, "; }
		if (form.organizacion_foto1.value == '' && bool==true)
		  { buf = buf + " foto 1, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }else{
		if (echeck(emailID.value)==false){
			emailID.value="";
			emailID.focus();
			alert("Has introducido un email inv" + String.fromCharCode(225) + "lido.");
			return false
		}

		ProgressImage = document.getElementById('progress_image');
		document.getElementById("progress").style.visibility = "visible";
		setTimeout("ProgressImage.src = ProgressImage.src",100);
		return true;
    }
}

function verificarRazapedia(form,bool) {
  var buf = '';
  var len = 0;
  var raza = "";
  var raza_num = 0;

  switch (form.enciclopedia_id_mascota.value)
  {
	case 1:
		raza = form.enciclopedia_id_perro.value;
		raza_num = 1;
	break;
	case 2:
		raza = form.enciclopedia_id_gato.value;
		raza_num = 2;
	break;
	case 3:
		raza = form.enciclopedia_id_otro.value;
		raza_num = 3;
	break;
	default:
	
	break;
  }
  
  var content0 = tinyMCE.get('enciclopedia_titulo').getContent(); // get the content
  $('#enciclopedia_titulo').val(content0);
  
  var content1 = tinyMCE.get('enciclopedia_descripcion').getContent(); // get the content
  $('#enciclopedia_descripcion').val(content1);
  
  if ((form.enciclopedia_titulo.value == '') || (form.enciclopedia_descripcion.value == '') || (form.enciclopedia_id_mascota.value == '') || (form.enciclopedia_foto1.value == '' && bool==true)){
		
		buf = "Debes introducir ";
		if (form.enciclopedia_titulo.value == '')
		  { buf = buf + " t" + String.fromCharCode(237) + "tulo, "; }
		if (form.enciclopedia_id_mascota.value == '')
		  { buf = buf + " tipo de mascota, "; }
		if (raza_num == 1)
		{
		  if (form.enciclopedia_id_perro.value == '')
		  { buf = buf + " raza de perro, "; }
		}
		if (raza_num == 2)
		{
		  if (form.enciclopedia_id_gato.value == '')
		  { buf = buf + " raza de gato, "; }
		}
		if (raza_num == 3)
		{
		  if (form.enciclopedia_id_otro.value == '')
		  { buf = buf + " especie de animal, "; }
		}
		if (form.enciclopedia_descripcion.value == '')
		  { buf = buf + " descripci" + String.fromCharCode(243) + "n, "; }
		if (form.enciclopedia_foto1.value == '' && bool==true)
		  { buf = buf + " foto 1, "; }
		 
		len = buf.length;
		buf = buf.substring(0,len-2);
		alert(buf);
		return false;
    }
}

function verificarPregunta(form) {
  var buf = '';
  var len = 0;
  
  if ((form.pregunta_descripcion.value == ''))
  {
	alert('Debes escribir alguna pregunta');
	return false;
  }
  
  if (form.pregunta_descripcion.value.length > 800)
  {
	alert('No puedes escribir m' + String.fromCharCode(225) + 's de 800 caracteres');
	return false;
  }
}

function verificarComentarEvento(form) {
  var buf = '';
  var len = 0;
  
  if ((form.comentar_evento_descripcion.value == ''))
  {
	alert('Debes escribir un comentario');
	return false;
  }
  
  if (form.comentar_evento_descripcion.value.length > 800)
  {
	alert('No puedes escribir m' + String.fromCharCode(225) + 's de 800 caracteres');
	return false;
  }
}

function verificarComentarNoticia(form) {
  var buf = '';
  var len = 0;
  
  if ((form.comentar_noticia_descripcion.value == ''))
  {
	alert('Debes escribir un comentario');
	return false;
  }
  
  if (form.comentar_noticia_descripcion.value.length > 800)
  {
	alert('No puedes escribir m' + String.fromCharCode(225) + 's de 800 caracteres');
	return false;
  }
}

function verificarComentarSabias(form) {
  var buf = '';
  var len = 0;

  if ((form.comentar_sabias_descripcion.value == ''))
  {
	alert('Debes escribir un comentario');
	return false;
  }

  if (form.comentar_sabias_descripcion.value.length > 800)
  {
	alert('No puedes escribir m' + String.fromCharCode(225) + 's de 800 caracteres');
	return false;
  }
}

function verificarNoticia(form) {
  
  var content0 = tinyMCE.get('noticia_descripcion').getContent(); // get the content
  $('#noticia_descripcion').val(content0);
  
  if (form.noticia_descripcion.value == '')
  {
	alert('Debes escribir una descripci' + String.fromCharCode(243) + 'n');
	return false;
  }
  
  if (form.noticia_subtitulo.value.length > 150)
  {
	alert('No puedes escribir m' + String.fromCharCode(225) + 's de 150 caracteres');
	return false;
  }
}

function echeck(str) 
{
  var at="@"
  var dot="."
  var lat=str.indexOf(at)
  var lstr=str.length
  var ldot=str.indexOf(dot)
  
  if (str.indexOf(at)==-1)
  {
	return false
  }
  if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr)
  {
	return false
  }
  if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
	return false
  }
  if (str.indexOf(at,(lat+1))!=-1)
  {
	return false
  }

  if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot)
  {
	return false
  }
  if (str.indexOf(dot,(lat+2))==-1)
  {
	return false
  }
  if (str.indexOf(" ")!=-1)
  {
	return false
  }
  return true					
}

$(document).ready(function(){
						   
	$('#publicacion_precio').keypress(function(event){
	
		patron = /(\d)|(\.|\,)/;
		tecla = (document.all) ? event.keyCode : event.which; 
		
		if (tecla==0 || tecla==8 || tecla==13) 
		{ 
			return true; 
		}
		
		te = String.fromCharCode(tecla);
		if (!patron.test(te))
		{
			alert("Precio tiene un formato inv" + String.fromCharCode(225) + "lido"); 
			return false;
		}
		
		if ($('#publicacion_precio').val() != '')
		{
			patron = /(^\d+$)|(^\d+(\.|\,)\d{1,2}$)|(^\d+\.$)|(^\d+\,$)/;
			if (!patron.test($('#publicacion_precio').val()+te))
			{ 
				alert("Precio tiene un formato inv" + String.fromCharCode(225) + "lido"); 
				return false
			}
		}
	});
	
	$('#evento_titulo').keypress(function(event){
		
		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#evento_titulo').val().length+1 > 200)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 200 caracteres"); 
				return false;
			}
		}
	});
	
	$('#evento_hora').keypress(function(event){
		
		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#evento_hora').val().length+1 > 100)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 100 caracteres"); 
				return false;
			}
		}
	});
	
	$('#evento_lugar').keypress(function(event){
		
		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#evento_lugar').val().length+1 > 300)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 300 caracteres"); 
				return false;
			}
		}
	});
	
	$('#noticia_subtitulo').keypress(function(event){
		
		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#noticia_subtitulo').val().length+1 > 150)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 150 caracteres"); 
				return false;
			}
		}
	});
	
	$('#galeria_nombre_foto').keypress(function(event){
		
		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#galeria_nombre_foto').val().length+1 > 100)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 100 caracteres"); 
				return false;
			}
		}
	});
	
	$('#galeria_evento_nombre_foto').keypress(function(event){

		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#galeria_evento_nombre_foto').val().length+1 > 100)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 100 caracteres"); 
				return false;
			}
		}
	});
	
	$('#sabias_que_titulo').keypress(function(event){

		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#sabias_que_titulo').val().length+1 > 150)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 150 caracteres"); 
				return false;
			}
		}
	});
	
	$('#sabias_que_descripcion_corta').keypress(function(event){

		tecla = (document.all) ? event.keyCode : event.which; 
		
		if ($('#sabias_que_descripcion_corta').val().length+1 > 500)
		{
			if (tecla==0 || tecla==8) 
			{ 
				return true; 
			} else {
				alert("No puedes escribir m" + String.fromCharCode(225) + "s de 500 caracteres"); 
				return false;
			}
		}
	});
});


function validarLenght(long,event,maxlenght)
{
	tecla = (document.all) ? event.keyCode : event.which; 
	
	if (long+1 > maxlenght)
	{
		if (tecla==9 || tecla==8 || tecla==37 || tecla==38 || tecla==39 || tecla==40) 
		{ 
			return true; 
		} else {
			alert("No puedes escribir m" + String.fromCharCode(225) + "s de "+ maxlenght + " caracteres"); 
			return false;
		}
	}
}




