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();}
	}

 

function process()
	{
	var val=document.frmform.s.value;
	if (val !="Busca avatares aqui.")
		{
		if (val.length>2)
			{
	 		document.frmform.submit(); 	
	 		}
		} 
	}

function resettext(text)
	{
	if (text=="Busca avatares 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_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 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(idavatar)
{
    document.getElementById("divvoto").innerHTML='Cargando...';
	ajax=nuevoAjax();
	ajax.open("GET", "/ajax_votar.php?idavatar="+idavatar+"&num_ale="+Math.random(), true);
    ajax.onreadystatechange=function() 
    {   
    	if (ajax.readyState==4) { document.getElementById("divvoto").innerHTML=ajax.responseText;  } 
    }
    ajax.send(null);       
}

    
