// JavaScript Document

   function init()  
 {  
 //assegna le funzioni di rollover ai menu con id "navx" dove x è da 1 a nNav
  var nNav=2;
  var imgs,j,i;  
  var tag = '';
 // Loop through all images, check if they contain the class roll  
 	for (var j=1;j<=nNav;j++) {
	  var uls=document.getElementById('nav'+j)
	  if (uls){
		  imgs=uls.getElementsByTagName('img');  
		  for(var i=0;i<imgs.length;i++)  
		  {  
		   if(/roll/.test(imgs[i].className))  
		   {  
		 // add the function roll to the parent Element of the image  
			   if(tag!='' && imgs[i].getAttribute('name')==tag) {
				   sr = imgs[i].src
				   ft = sr.substring(sr.lastIndexOf('.'), sr.length);  
				   imgs[i].src= sr.replace(ft, '_on'+ft);;
			   }else{
			   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'è il box delle news scorrevole assegna i comportamenti di cambio variabile
	var mc = document.getElementById("marqueecontainer");
	if (mc){
		initializemarquee();
		mc.onmouseover=function(){copyspeed=pausespeed;};
		mc.onmouseout=function(){copyspeed=marqueespeed;};	
	}
	//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', '%L%-err_password-%L%', {
								minLength : 7,
								notOneOf : ['password','PASSWORD','1234567','0123456'],
								notEqualToField : 'username_form'
							}],
							['validate-password-confirm', '%L%-err_confirm_password-%L%', {
								equalToField : 'password_form_r'
							}]
						]);
		  }
	  }
   //se c'è un'area per la comparsa e scomparsa dei div qui la configura
   var div_effetto = document.getElementById("effetto");
	 if (div_effetto) {
	 links =  div_effetto.getElementsByTagName("div");
	 var attivita = new Array();
	 var icone = new Array();
	 var nt = "";
	 for(var i=0;i<links.length;i++)  
	  {  
	   if(/blind/.test(links[i].className))  
	   {		
	   		var jj=links[i].getAttribute('id').replace("toggle","");
				icone[jj] = links[i].getElementsByTagName("img");
				attivita[jj] = new Fx.Slide('attivita_'+jj);
				$('toggle'+jj).addEvent('click', function(e){
					e = new Event(e);				
					h = this.getAttribute('id').replace("toggle","");
					if (icone[h][0]) icone[h][0].src = "img/close.gif";
					if (nt!="") {
						icone[nt][0].src = "img/open.gif";
					}
					attivita[h].toggle();
					if (nt!="") attivita[nt].toggle();
					if (h!=nt){
						nt = h;
					}else{
						nt="";
					}
					e.stop();
				});
				
			
        if (icone[jj][0].getAttribute('src') && icone[jj][0].getAttribute('src').indexOf('close.gif') == -1) {
		      attivita[jj].hide();
		    } else {
          nt=jj;
        }
	   }
	  }
	 }
 }  
 
 //funzioni richiamate dalla init
 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(){  
  init();  
 }  
 */
 /***********************************************
* Cross browser Marquee II- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/

var delayb4scroll=2000 //Specify initial delay before marquee starts to scroll on page (2000=2 seconds)
var marqueespeed=1 //Specify marquee scroll speed (larger is faster 1-10)
var pauseit=1 //Pause marquee onMousever (0=no. 1=yes)?

////NO NEED TO EDIT BELOW THIS LINE////////////

var copyspeed=marqueespeed
var pausespeed=(pauseit==0)? copyspeed: 0
var actualheight=''

function scrollmarquee(){
if (parseInt(cross_marquee.style.top)>(actualheight*(-1)+8))
cross_marquee.style.top=parseInt(cross_marquee.style.top)-copyspeed+"px"
else
cross_marquee.style.top=parseInt(marqueeheight)+8+"px"
}

function initializemarquee(){
cross_marquee=document.getElementById("vmarquee")
cross_marquee.style.top=0
marqueeheight=document.getElementById("marqueecontainer").offsetHeight
actualheight=cross_marquee.offsetHeight
if (window.opera || navigator.userAgent.indexOf("Netscape/7")!=-1){ //if Opera or Netscape 7x, add scrollbars to scroll and exit
cross_marquee.style.height=marqueeheight+"px"
cross_marquee.style.overflow="scroll"
return
}
setTimeout('lefttime=setInterval("scrollmarquee()",30)', delayb4scroll)
}
function formCallback(result, form) {
	window.status = "validation callback for form '" + form.id + "': result = " + result;
}

// e qui parte tutto
if (window.addEventListener)
window.addEventListener("load", init, false)
else if (window.attachEvent)
window.attachEvent("onload", init)
else if (document.getElementById)
window.onload=init

