function toggle_nickname(nickname)       {
if (window.XMLHttpRequest) {
        http = new XMLHttpRequest();
                            } 
else if (window.ActiveXObject) {
        http = new ActiveXObject("Microsoft.XMLHTTP");
                               }
    handle = document.getElementById(nickname);
    var url = 'http://www.disign.it/admin/nick.php?';

if (handle.value.length > 0) {
        var fullurl = url + 'do=check_nickname_exists&nickname=' + handle.value;
        http.open("GET", fullurl, true);
        http.send(null);
        http.onreadystatechange = statechange_nickname;
                                  }
	else {    
        document.getElementById('nickname_exists').innerHTML = '';
         }
                                          }

function statechange_nickname() {
    if (http.readyState == 4) {
        var xmlObj = http.responseXML;
		var html = xmlObj.getElementsByTagName('risultato').item(0).firstChild.data;
        document.getElementById('nickname_exists').innerHTML = html + '<br />';
		
		if (html == 'Nickname non disponibile')
		{
		document.reg.nickname.focus();
		document.reg.nickname.value = '';
		}
		if (html == 'Il nickname non deve contenere spazi')
		{
		document.reg.nickname.focus();
		document.reg.nickname.value = '';
		}
    }
}

function trim(s){ 
  return ( s || '' ).replace( /^\s+|\s+$/g, '' ); 
}

function check() 
{
	
	document.reg.nickname.value = trim(document.reg.nickname.value);
	document.reg.password.value = trim(document.reg.password.value);
	document.reg.imail.value = trim(document.reg.imail.value);
	
     if(document.reg.nickname.value == "nickname" || document.reg.nickname.value == "") 
	 {
		 alert("scegliere un nickname");
		 return false;
	 }
	 
	      if(document.reg.password.value == "******" || document.reg.password.value == "") 
	 {
		 alert("scegliere una password");
		 return false;
	 }

     if(document.reg.imail.value == "email" || document.reg.imail.value == "") 
	 {
		 alert("inserire una email");
		 return false;
	 }


     return confirm( 'Informativa ai sensi dell\'art. 13 del decreto legislativo 30 giugno 2003 n. 196, recante il Codice in materia di protezione dei dati personali. \nAi sensi dell\'articolo 13 del citato decreto legislativo recante disposizioni in materia di protezione dei dati personali, desideriamo informarLa che i dati personali da Lei volontariamente forniti per l\'attivazione dei servizi richiesti saranno trattati adottando le misure idonee a garantirne la sicurezza e la riservatezza, nel rispetto della normativa sopra richiamata. \nLa informiamo inoltre che durante la procedura di registrazione a Disign.it verrà memorizzato il suo indirizzo IP di provenienza.' );
}

function mostra(div)
{    
    var stile=document.getElementById(div).style.display;
	
    if(stile=='block') {
        document.getElementById(div).style.display='none';
		               }
    else {
		document.getElementById(div).style.display='block';
	     }
}


function nascondi(div)
{
	    var stile=document.getElementById(div).style.display;
	
    if(stile=='block') {
        document.getElementById(div).style.display='none';
		               }
	
}

function cec() {
	if (document.commenta.testo.value=='') {
		alert('scrivere il commento');
		return false; }
		else
		return true;
}

function MM_validateForm() { //v4.0
  if (document.getElementById){
    var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
    for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=document.getElementById(args[i]);
      if (val) { nm=val.name; if ((val=val.value)!="") {
        if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
          if (p<1 || p==(val.length-1)) errors+='- '+nm+' deve contenere un indirizzo email.\n';
        } else if (test!='R') { num = parseFloat(val);
          if (isNaN(val)) errors+='- '+nm+' deve contenere un numero.\n';
          if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
            min=test.substring(8,p); max=test.substring(p+1);
            if (num<min || max<num) errors+='- '+nm+' deve contenere un numero tra '+min+' e '+max+'.\n';
      } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' è obbligatorio.\n'; }
    } if (errors) alert('Errore(i):\n'+errors);
    document.MM_returnValue = (errors == '');
} }


function controll()
{
	if (document.profilo.email.value =='') {
	alert('La mail è obbligatoria');
	return false;
	}
	
		if (document.profilo.sex.value !='M'  && document.profilo.sex.value !='F') {
	alert('Inserire M o F');
	return false;
	}

return true;
}
