var LOADING='<div align="center" style="padding:6px;"><img src="/images/loading.gif" border="0" align="middle" /></div>';

function mostrar(div)
	{   
	var el = document.getElementById(div); //se define la variable "el" igual a nuestro div
	el.style.display = (el.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
	}

function enterkeypress(e)
	{
	var key=(document.all) ? e.keyCode : e.which;
	if (key==13) { process();}
	}

 mywindows=""; 
  function enviar (idcont) {
  var opciones="toolbar=no, statusbar=no, titlebar=no, location=no, directories=no, status=no, menubar=no,menubar=0, scrollbars=no, resizable=yes, width=500, height=400, left="+parseInt(((screen.width) / 2) - 250)+", top="+parseInt(((screen.height) / 2) - 200)+"";
  mywindows=window.open("/pop_enviar.php?idcont="+idcont+"","popup",opciones);

}

function process()
	{
	var val=document.frmform.s.value;
	if (val !="Busca poemas aqui.")
		{
		if (val.length>2)
			{
	 		document.frmform.submit(); 	
	 		}
		} 
	}

function resettext(text)
	{
	if (text=="Busca poemas aqui.")
		{ document.getElementById('s').value=""; }
	}
	
function ValidateUrl(variableurl) { 
    var v = new RegExp(); 
    v.compile("^[A-Za-z]+://+$"); 
    if (!v.test(variableurl)) { 
          return false;
    } else  {   return true; }
} 


function validateEmail(email)
{
// a very simple email validation checking. 
// you can add more complex email checking if it helps 
 
var splitted = email.match("^(.+)@(.+)$");
if(splitted == null) return false;
if(splitted[1] != null )
{
var regexp_user=/^\"?[\w-_\.]*\"?$/;
if(splitted[1].match(regexp_user) == null) return false;
}
if(splitted[2] != null)
{
var regexp_domain=/^[\w-\.]*\.[A-Za-z]{2,4}$/;
if(splitted[2].match(regexp_domain) == null) 
{
var regexp_ip =/^\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]$/;
if(splitted[2].match(regexp_ip) == null) return false;
}// if
return true;
}
return false;
}	
	
function validar_registro(){    
var accs=1;
	if(!validateEmail(document.FormValidacion.email.value) & accs!=0){
		alert("Debe ingresar email correcto.");
		document.FormValidacion.email.focus();  
		accs=0;
		}  
 	if (document.FormValidacion.password.value<=5 & accs!=0){
		alert("Debes ingresar su contraseña mayor a 5 caracteres.");
		document.FormValidacion.password.focus();  
		accs=0;
		}
 	if (document.FormValidacion.password.value!=document.FormValidacion.password2.value & accs!=0){
		alert("Debes ingresar contraseñas identicas.");
		document.FormValidacion.password2.focus();  
		accs=0;
		}
  	if (document.FormValidacion.usuario.value<=3 & accs!=0){
		alert("Debes ingresar su nick.");
		document.FormValidacion.usuario.focus();  
		accs=0;
		}
		
 	if (accs==1) { document.FormValidacion.submit(); }
	}	
	
function validar_mod3(){  
	var accs=1;
	if (document.formtres.password2.value<=5 & accs!=0){
		alert("Debes ingresar su contraseña mayor a 5 caracteres.");
		document.formtres.password2.focus();  
		accs=0;
		}
 	if (accs==1) { document.formtres.submit(); }

	}
	
	
function validar_contacto(){  
	var accs=1;
	if (document.frmcontact.asunto.value=="" & accs!=0){
		alert("Debes ingresar asunto.");
		document.frmcontact.asunto.focus();  
		accs=0;
		}
	if (document.frmcontact.asuntotext.value=="" & accs!=0){
		alert("Debes ingresar texto del asunto.");
		document.frmcontact.asuntotext.focus();  
		accs=0;
		}
	if (document.frmcontact.nombre.value=="" & accs!=0){
		alert("Debes ingresar su nombre o de la empresa.");
		document.frmcontact.nombre.focus();  
		accs=0;
		}
	if (document.frmcontact.email.value=="" & accs!=0){
		alert("Debes ingresar su email.");
		document.frmcontact.email.focus();  
		accs=0;
		}		
	if (document.frmcontact.mensaje.value=="" & accs!=0){
		alert("Debes ingresar su mensaje.");
		document.frmcontact.mensaje.focus();  
		accs=0;
		}		
 	if (accs==1) { document.frmcontact.submit(); }

	}
	
function validar_intercambio(){    
var accs=1;
	if (document.formulario.link.value=="" & accs!=0){
		alert("Debes ingresar link.");
		document.formulario.link.focus();  
		accs=0;
		}
	if (document.formulario.anchor.value=="" & accs!=0){
		alert("Debes ingresar Nombre /anchor.");
		document.formulario.anchor.focus();  
		accs=0;
		}		
	if (!validateEmail(document.formulario.email.value)	 & accs!=0){
		alert("Debes ingresar su email");
		document.formulario.anchor.focus();  
		accs=0;
		}	
 
	
	if (accs==1) { document.formulario.submit();}
	}
	
	
function validar_recordar(){  
	var accs=1;
	if (document.frmrecordar.email.value=="" & accs!=0){
		alert("Debes ingresar su email.");
		document.frmrecordar.email.focus();  
		accs=0;
		}
	if (document.frmrecordar.validacion.value=="" & accs!=0){
		alert("Debes ingresar codigo.");
		document.frmrecordar.validacion.focus();  
		accs=0;
		}
 	if (accs==1) { document.frmrecordar.submit(); }
	}
	
	
function validar_comentario(){    
var accs=1;

  	if (document.frmcomt.comentario.value.length<=10 & accs!=0){
		alert("Debes ingresar su comentario mayor a 10 letras.");
		document.frmcomt.comentario.focus();  
		accs=0;
		}
  	if (document.frmcomt.codehide.value!=document.frmcomt.code.value & accs!=0){
		alert("Codigo incorrecto.");
		document.frmcomt.code.focus();  
		accs=0;
		}		
 	if (accs==1) { document.frmcomt.submit(); }
	}
	
function CreateBookmarkLink() {
titulo="Tatuajes21.com";
url="http://www.postals21.com/";
if (window.sidebar) { // Mozilla Firefox 
window.sidebar.addPanel(titulo, url,"");
} else if( window.external ) { // IE 
window.external.AddFavorite( url, titulo); }
else if(window.opera && window.print) { // Opera
/**alert("Para agregar a tu pagina a sus favoritos presione control + D") }**/
window.external.AddFavorite( url, titulo); }
}
	
function nuevoAjax()
{ 
    /* Crea el objeto AJAX. Esta funcion es generica para cualquier utilidad de este tipo, por
    lo que se puede copiar tal como esta aqui */
    var xmlhttp=false; 
    try 
    { 
        // Creacion del objeto AJAX para navegadores no IE
        xmlhttp=new ActiveXObject("Msxml2.XMLHTTP"); 
    }
    catch(e)
    { 
        try
        { 
            // Creacion del objet AJAX para IE 
            xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); 
        } 
        catch(E) { xmlhttp=false; }
    }
    if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp=new XMLHttpRequest(); } 

    return xmlhttp; 
}
 
 

 function votar(idcont)
{
    document.getElementById("divvoto").innerHTML='Cargando...';
	ajax=nuevoAjax();
	ajax.open("GET", "/ajax_votar.php?idcont="+idcont+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    {   
    	if (ajax.readyState==4) { document.getElementById("divvoto").innerHTML=ajax.responseText;  } 
    }
    ajax.send(null);       
}

 


function favorito(idcont){
 
 document.getElementById("favoritoslista").style.display='block';
  document.getElementById("divfavorito"+idcont+"").style.display='none';
  ajax=nuevoAjax();
  ajax.open("GET", "/inc_favoritos.php?idcont="+idcont+"&num_ale="+Math.random(), true);
  ajax.onreadystatechange=function() 
   {  
   if (ajax.readyState==1) { document.getElementById("favoritoslista").innerHTML='<div align="center" style="font-size:11px;">Cargando Favoritos...</div>';  } 
   if (ajax.readyState==4) { document.getElementById("favoritoslista").innerHTML=ajax.responseText;  }  }
    ajax.send(null);    
  }
  
  
 function favorito_eliminar(idcont,idfavorito){
	if(document.getElementById("divfavorito"+idcont+""))
			{
   			document.getElementById("divfavorito"+idcont+"").style.display='block';
			}
  mostrar("favoritoslista");
  ajax=nuevoAjax();
  ajax.open("GET", "/inc_favoritos.php?idcont="+idcont+"&idfavorito="+idfavorito+"&num_ale="+Math.random(), true);
  ajax.onreadystatechange=function() 
   {  
   if (ajax.readyState==1) { document.getElementById("favoritoslista").innerHTML='<div align="center">Cargando Favoritos...</div>';  } 
   if (ajax.readyState==4) { document.getElementById("favoritoslista").innerHTML=ajax.responseText;  }  }
    ajax.send(null);    
  } 
  
   function cambiarpass(email,id){
 
  ajax=nuevoAjax();
  ajax.open("GET", "/ajax_contrasena.php?email="+email+"&id="+id+"&nueva=yes&num_ale="+Math.random(), true);
  ajax.onreadystatechange=function() 
   {  
    if (ajax.readyState==4) { document.getElementById("nuevacontrasena").innerHTML=ajax.responseText;  }  }
    ajax.send(null);    
  } 
 

function nombreenvia(datos){
 	document.getElementById("spanuser").innerHTML=datos;
	}

