function imgHover(elements){
	$$(elements).each(function(element,index) {
		element.addEvents({'mouseover': function(){
            if (this.className.search("rollOver")>=0){
                  if (this.src.search("jpg")>=0){
                       this.src=this.src.replace('.jpg','_a.jpg');
                  }else if (this.src.search("png")>=0){
                       this.src=this.src.replace('.png','_a.png');
                  }else{
                       this.src=this.src.replace('.gif','_a.gif');
                  }
            }
		}});
		element.addEvents({'mouseout': function(){
            if (this.className.search("rollOver")>=0){
                  if (this.src.search("jpg")>=0){
                       this.src=this.src.replace('_a.jpg','.jpg');
                  }else if (this.src.search("png")>=0){
                       this.src=this.src.replace('_a.png','.png');
                  }else{
                       this.src=this.src.replace('_a.gif','.gif');
                  }
            }
		}});
	});
}

function tagHover(elements,cssOver,cssOut,auto) {
	$$(elements).each(function(element,index) { 
		if (auto) element.className = cssOver;
		element.addEvents({'mouseover': function(){  
			this.className = this.className.replace(cssOver,cssOut);			
		}});
		element.addEvents({'mouseout': function(){
			this.className = this.className.replace(cssOut,cssOver);			
		}});
	});
}

function bckHover(elements) {
	$$(elements).each(function(element,index) { 
		element.addEvents({'mouseover': function(){  
			this.style.backgroundImage = this.style.backgroundImage.replace('.gif','_a.gif');			
		}});
		element.addEvents({'mouseout': function(){
			this.style.backgroundImage = this.style.backgroundImage.replace('_a.gif','.gif');			
		}});
	});
}

/**
 * USAGE: 
 * 
 * <script language="javascript" type="text/javascript"> 
 *   window.addEvent('domready', function() {
 *   tagHover ('#menuSinistra LI','ulliSubMenuNotHover','ulliSubMenuHover',false);
 *   tagHover ('#menuSx LI','sfondoGrigio','coloreSfondo',false);
 *   tagHover ('#pageContent DIV','testoBottone bottone','testoBottoneHover bottoneHover',false);
 *   });
 * </script>
 * 
 * oppure
 * 
 * <script language="javascript" type="text/javascript"> 
 *   window.addEvent('domready', function() {
 *   imgHover('#menu IMG');
 *   });	
 * </script>
 */
