function foco(elemento) {
	elemento.style.border = "1px solid #000000";
}

function no_foco(elemento) {
	elemento.style.border = "1px solid #CCCCCC";
}	

function valida_reg(){
    //valido el nombre
    if (document.register.name.value.length==0){
       document.register.name.focus()
       document.register.name.style.background="#cccccc"
       return 0;              
    }

    //valido el mail
    if (document.register.email.value.length==0){
       document.register.email.focus()
       document.register.email.style.background="#cccccc"
       return 0;              
    }else{
    	if (!validate_email(document.register.email)){
    		document.register.email.focus()
       document.register.email.style.background="#cccccc"
       return 0;
    	}
    	
    }        

    if (document.register.username.value.length==0){
       document.register.username.focus()
       document.register.username.style.background="#cccccc"
       return 0;              
    }
    
    if (document.register.password.value.length==0){
       document.register.password.focus()
       document.register.password.style.background="#cccccc"
       return 0;              
    }
    
    if (!document.register.privacity.checked){
       document.register.privacity.focus()
       document.getElementById('p').bgColor='#cccccc'       
       return 0;              
    }
    
    /*if (!document.register.conditions.checked){
       document.register.conditions.focus()
       document.getElementById('c').bgColor='#cccccc' 
       return 0;              
    }*/

    //el formulario se envia
    //alert("Muchas gracias por enviar el formulario");
    document.register.submit();
} 

function validate_email(field){
with (field){
  apos=value.indexOf("@");
  dotpos=value.lastIndexOf(".");
	  if (apos<1||dotpos-apos<2){
	  	return false;
	  }else{
	  	return true;
	  }
  }
}

function comprobar(nick)   {  	
	 var url = 'http://'+location.host+'/inc/ajax_comprobar_nick.php';  
	 var pars= ("nickname=" + nick);  	 
	 var myAjax = new Ajax.Updater( 'comprobar_mensaje', url, { method: 'get', parameters: pars});  
} 