//  menu
//  configuration

var finished = true;

function hideElementsWithClass(name){
    
    //  prendo tutti gli oggetti HTML che hanno per classe "name"
    var ulList = $$('.'+name);
    //  per ogni elemento
    ulList.each(function(element){
        // li nascondo
        element.setStyle({
            display : "none"
        });
    });
    
}

var menu_1 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menuCollezione').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menuCollezione', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menuCollezione').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menuCollezione', {duration:.3, fps:40})},300);
  }
 }
}

var menu_2 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('subVisite').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('subVisite', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('subVisite').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('subVisite', {duration:.3, fps:40})},300);
  }
 }
}

var menu_3 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('subInformazioni').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('subInformazioni', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('subInformazioni').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('subInformazioni', {duration:.3, fps:40})},300);
  }
 }
}

var menu_4 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('subNews').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('subNews', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('subNews').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('subNews', {duration:.3, fps:40})},300);
  }
 }
}

var menu_5 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('subPress').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('subPress', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('subPress').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('subPress', {duration:.3, fps:40})},300);
  }
 }
}

var menu_6 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('subMMP').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('subMMP', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('subMMP').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){    new Effect.BlindUp('subMMP', {duration:.3, fps:40})},300);
  }
 }
}

var x = 0 ;
var y = 0 ;
var followMouseTimeout ;
var descriptor ;
var description ;
var currentTarget;

function showTitle(target){
    
    currentTarget = target;
    
    descriptor = $('descriptor');
    description = $(currentTarget).getAttribute('title');
    
    if(descriptor.getAttribute('class') == 'artistDesc'){
        Element.update(descriptor, description);
		var leftVal = x+2;
    }else{
		var leftVal = x+2;
	}
    
    descriptor.setStyle({
        display : "block",
        top     : (y+2) + "px",
        left    : leftVal + "px",
        backgroundColor : "#FFFFFF",
        zIndex : 79
    });
    
    Element.update(descriptor, '<p>'+description+'</p>');
    $(currentTarget).setAttribute('title','');
}

function hideTitle(){
    descriptor.setStyle({
        display : "none"
    });
    $(currentTarget).setAttribute('title', description);
}

Event.observe(window, 'load',function() {
    Event.observe(document, 'mousemove', onMouseMove);
    hideElementsWithClass('sottoMenu');
});

function onMouseMove(e){
    x = Event.pointerX(e);
    y = Event.pointerY(e);
}
