// JavaScript Document

   function findimg()  
 {  
  var imgs,i;  
 // Loop through all images, check if they contain the class roll  
  uls=document.getElementById('nav')
  imgs=uls.getElementsByTagName('img');  
  for(i=0;i<imgs.length;i++)  
  {  
   if(/roll/.test(imgs[i].className))  
   {  
 // add the function roll to the parent Element of the image  
   imgs[i].parentNode.onmouseover=function(){roll(this);};  
   imgs[i].parentNode.onmouseout=function(){roll(this);};  
   imgs[i].parentNode.onfocus=function(){roll(this);};  
   imgs[i].parentNode.onblur=function(){roll(this);};  
   }  
  } 
  
  //se c'è una form assegna inizia la validazione
	var formv = document.getElementsByTagName("form");
	for(i=0;i<formv.length;i++)  
	  {
		  if(/valida/.test(formv[i].className))
		  {
			var nome = formv[i].getAttribute('id');
		  	var valid = new Validation(nome, {immediate : true, onFormValidate : formCallback});
		  	Validation.addAllThese([
							['validate-password', 'Password non valida', {
								minLength : 6,
								notOneOf : ['password','PASSWORD','1234567','0123456'],
								notEqualToField : 'username_'
							}],
							['validate-password-confirm', 'Le password non coincidono', {
								equalToField : 'password_'
							}]
						]);
		  }
	  } 
 } 
 
function formCallback(result, form) {
	window.status = "validation callback for form '" + form.id + "': result = " + result;
} 
 function roll(o)  
 {  
  var i,isnode,src,ftype,newsrc,nownode;  
 // loop through all childNodes  
  for (i=0;i<o.childNodes.length;i++)  
  {  
   nownode=o.childNodes[i];  
 // if the node is an element and an IMG set the variable and exit the loop  
   if(nownode.nodeType==1 && /img/i.test(nownode.nodeName))  
   {  
    isnode=i;  
    break;  
   }  
  }  
 // check src and do the rollover  
  src = o.childNodes[isnode].src;  
  ftype = src.substring(src.lastIndexOf('.'), src.length);  
  if(/_on/.test(src))  
  {  
   newsrc = src.replace('_on','');  
  }else{  
   newsrc = src.replace(ftype, '_on'+ftype);  
  }  
  o.childNodes[isnode].src=newsrc;  
 }  
   
 window.onload=function(){  
  findimg();  
 }  