//OBJ ROLLOVER

function Rollover (img_name, src_on, src_off) {
    this.on   = new Image(); 
    this.on.src  = src_on;
    this.off  = new Image(); 
    this.off.src = src_off;
    this.name = img_name;
    this.turn_on   = turn_on;
    this.turn_off  = turn_off;
    
    
}



function turn_on() { 
    var immagine = window.document.images[this.name];
    immagine.src = this.on.src;
    
    
}

function turn_off() {   
    var immagine = window.document.images[this.name];
    immagine.src = this.off.src;
      
}





//OBJ MENU

function Menu() {    

  this.selected = null; // nessun elemento selezionato
  this.on       = on;  // turn on  an item
  this.off      = off; // turn off an item
  this.reset_menu         = reset_menu;  // menu reset
  this.sel           = sel;    // select an item and turn off the previus selected
  this.select        = select; // just select an item whithout turning off the previous selected
  this.selected_item = selected_item; // return the selected item
  this.turn_off_current = turn_off_current; // turn off the selected item
}


function on(roller) {                   
  if (this.selected != roller)  roller.turn_on();  
}

function off(roller){
  if (this.selected != roller)  roller.turn_off();
}                  

function turn_off_current() {
  this.selected.turn_off();
}

function reset_menu() {
 if (this.selected != null) {	
  this.selected.turn_off();
  this.selected = null;      
 } 
}


function sel(roller){
  if (this.selected != roller) {
     roller.turn_on();  
     if (this.selected!=null) this.selected.turn_off();
     this.selected = roller;
  }
}

function selected_item() {
  return this.selected;
}

function select(item) {
  this.selected=item; 
}

