//  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);
}



function showTitleLeft(target){
	currentTarget = target;

	var positionTop = Position.cumulativeOffset(currentTarget)[1] + currentTarget.offsetHeight;
   
	descriptor = $('descriptor');
	description = $(currentTarget).getAttribute('title');

	descriptor.setStyle({
	"display" : "block",
		"top"     : positionTop + "px",
		"left"    : "0px",
		"backgroundColor" : "#FFFFFF",
		"zIndex" : 79
	});

	Element.update(descriptor, '<p>'+description+'</p>');
	$(currentTarget).setAttribute('title','');
}


/**************************************************************************************************************************
	LIGHTBOX
**************************************************************************************************************************/

function openLightBox() {
     //set how far from the top of the screen to display the lightbox
     var verticaloffset = 100;
     var element = document.getElementById('light');
     element.style.top =  verticaloffset + 'px';
     //Fade in the background to a 0.7 opacity
     new Effect.toggle('fade', 'appear', {duration: 1.0, from: 0.0, to: 0.7});
     //Use scriptaculous blind effect to show the lightbox, change effect to what you feel looks best
     new Effect.BlindDown('light');
}

function closeLightBox() {
     //Reverse the effects to hide the lightbox
     new Effect.BlindUp('light');
     new Effect.toggle('fade', 'appear', {duration: 1.0, from: 0.7, to: 0.0});
}

/**************************************************************************************************************************
	RSS
**************************************************************************************************************************/
/*function rss_click(){

	Event.observe('#rss', 'click', function(event){
		var elt = Event.element(event);
		
		var href = elt.readAttribute('href'); 

		return true;
	});		
}

Event.observe(window, 'load', function() {
	
	if($('rss')) {
		// srss_click();
	}
	
});*/

