var dyntexts = new Array();

// selezione blocchi di testo:
function getdyntexts ()
{
  var mainarea = document.getElementById('corp');

  var divs = mainarea.getElementsByTagName('div');
  var dyntexts = new Array();
  var j,k,i = 0;
  
  for ( k=0,i=0; i<divs.length; i++ )
  {
    j = divs.item(i);
      
    if ( j.className && j.className == 'dynhide' )
    {
      dyntexts[k++] = j;
     
    }
  }
  return dyntexts;
}


function hideblock (b)
{
  if ( ! b.style ) return false;
  b.style.display = 'none';
  b.style.visibility = 'hidden';
  return true;
}

function showblock (b)
{
  if ( ! b.style ) return false;
  b.style.display = 'block';
  b.style.visibility = 'visible';
  return true;
}

function showinline (b)
{
  if ( ! b.style ) return false;
  b.style.display = 'inline';
  b.style.visibility = 'visible';
  return true;
}

function dtshow (b)
{
  if ( ! showblock(b) ) return false;
  b.mbutton.show();
  b.pbutton.hide();
  return true;
}

function dthide (b)
{
  if ( ! hideblock(b) ) return false;
  b.pbutton.show();
  b.mbutton.hide();
  return true;
}

function btnshow ()
{
  return showinline(this);
}

function btnhide ()
{
  return hideblock(this);
}

//pulsantini:
plusbutton = document.createElement('SPAN');
plusbutton.style.fontSize = '90%';
plusbutton.setAttribute('class',"dontprint");
n = document.createTextNode(' ');
plusbutton.appendChild(n.cloneNode(true));
minusbutton = plusbutton.cloneNode(true);
n = document.createElement('IMG');
i1 = './images/ico_plus.gif';
i2 = './images/ico_minus.gif';
n.setAttribute('src',i1);
n.setAttribute('alt',"more");
n.setAttribute('title',"more");
plusbutton.appendChild(n.cloneNode(true));
n.setAttribute('src',i2);
n.setAttribute('alt',"close");
n.setAttribute('title',"close");
minusbutton.appendChild(n.cloneNode(true));
n = document.createTextNode('');
plusbutton.appendChild(n.cloneNode(true));



function dyntextinit ()
{

  var self = this;
  
  function selfshow ()
  {
    return dtshow(self);
  }
  
  function selfhide ()
  {
    return dthide(self);
  }

  this.show = selfshow;
  this.hide = selfhide;

  this.mbutton = minusbutton.cloneNode(true);
  this.pbutton = plusbutton.cloneNode(true);
  this.mbutton.show = btnshow;
  this.pbutton.show = btnshow;
  this.mbutton.hide = btnhide;
  this.pbutton.hide = btnhide;

  p = this;
  do
  {
    if ( p.previousSibling ) p = p.previousSibling;
    else p = p.parentNode.previousSibling;
    
  } while (p.nodeName != 'DT')
  p.appendChild(this.pbutton);
  p.appendChild(this.mbutton);

  this.mbutton.onclick = this.hide;
  this.pbutton.onclick = this.show;
      
  return this.hide();
}

function initdyntexts ()
{
  dyntexts = getdyntexts();
  for ( i=0; i<dyntexts.length; i++ )
  {
    dyntexts[i].init = dyntextinit;
    if ( ! dyntexts[i].init() )
    {
      break;
    }
  }
  return ( i == dyntexts.length );
}


function initdoc ()
{
  initdyntexts();
}

function validate_register()
{
if(!document.reg.nome.value)
{
	alert('Devi specificare il tuo nome!');
	return false;
}	

if(!document.reg.cognome.value)
{
	alert('Devi specificare il tuo cognome!');
	return false;
}	

if(!document.reg.email.value)
{
	alert('Devi specificare il tuo email!');
	return false;
}	

if(!checkemail(document.reg.email))
{
alert("Il tuo email non è valido!")
return false;	
}

return true;
}
function validate_contattaci()
{
if(!document.form_contattaci.nome.value)
{
	alert('Devi specificare il tuo nome!');
	return false;
}	

if(!document.form_contattaci.cognome.value)
{
	alert('Devi specificare il tuo cognome');
	return false;
}	

if(!document.form_contattaci.email.value)
{
	alert('Devi specificare il tuo email');
	return false;
}	

if(!document.form_contattaci.richieste.value)
{
	alert('Devi specificare le tue richieste');
	return false;
}	

return true;
}

function validate_modifica_password()
{
if(!document.form_modifica_password.username.value)
{
	alert('Devi specificare la tua username!');
	return false;
}	

if(!document.form_modifica_password.password.value)
{
	alert('Devi specificare la tua password');
	return false;
}	

return true;
}
function checkemail(x){
var str=x.value
var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
if (filter.test(str))
testresults=true
else{
testresults=false
}
return (testresults)
}



