window.addEvent('domready', function(){
	
	////
	//PASTILLE CLICKS
	////
	
	var zindex = 100000;
	var isPlayer = false;

  var pastilles = $('pastilles').getElements('.action');
    
  var setPastilleClick = function(item) {
    item.addEvent('click', function(item){
      item.stop();
      showPlayer(this);
      soundManager.stopAll();
    });
  }
  
  var hidePlayers = function(item){
    item.getParent().getElement('div').fade('out');
  }
  
  var hidePlayer = function(item){
    item.fade('out');
    isPlayer = false;
  }  
  
  var showPlayer = function(item){
    $('edito').fade('out');
    pastilles.each(hidePlayers);
    var player = item.getParent().getElement('.player');
    player.setStyles({display: 'block', opacity:'0'});
    thisparent = player.getParent();
    thisparent.setStyle('z-index', zindex);
    zindex++;
    player.fade(0.92);
    
    //CLOSE BUTTON
    player.getElement('.close').addEvent('click', function(e){
      e.stop();
      hidePlayer(player);
      $('edito').fade('in');
      //setPastilleClick(item);
      soundManager.stopAll();     
    });
   // SHOW FLASH EMBED
   var Eembed = player.getElement('.embed_');
   Eembed.hide();
   player.getElement('.embed').addEvent('click', function(e){
    e.stop();
    Eembed.toggle();
   });
   isPlayer = true;
  }  
  
  var hidePastilles = function(item){
    item.setStyle('opacity', 0);
  }

  var showPastilles = function(item){
    item.fade('in');
  }    
  
  pastilles.each(setPastilleClick);


	////
	//MENU TOOL TIPS
	////  
  var tipz = new Tips($$('.mtip'), {
  	showDelay: 0,
  	hideDelay: 0,
  	fixed: true,
  	text: false,
  	offsets: {
		'x': -50,
		'y': 0
	 }
  });

	////
	//PASTILLES TOOL TIPS
	////  
  /*
var tipz = new Tips($$('.tooltip'), {
	showDelay: 200,
	hideDelay: 0,

	fixed: false
});

tipz.addEvents({
	'show': function(tip) {
	 //alert(isPlayer);
	  if(isPlayer == false){
		  tip.fade('in');
		}else{
		  tip.hide();
		}
	},
	'hide': function(tip) {
    if(isPlayer == false){
		  tip.fade('out');
		}
	}
});
*/
	////
	//PASTILLES WINDOW SCROLL
	//// 
	  
  var myFx = new Fx.Scroll(window, {
    offset: {
        'x': 0,
        'y': -60
    }
  });
  
  $('pastilles').getElements('.action').addEvent('click', function(item){
    var thisel = this.getNext();
    myFx.toElement(thisel);
  });
  
  /*ARTISTS LOAD CONTENT
  $beginArtist = 15;
  $('prevArtist').addEvent('click', function(e) {
    $('artists').set('text', '');
    artist.set('send', {url: 'h_artists_.inc.php', method: 'get'});
    artist.send();
  });

	var artist__ = new Request.HTML({url:'h_artists_.inc.php?start=', 		
		onSuccess: function(html) {
			$('artists').adopt(html);
			$beginArtist += 15;
		},
		onFailure: function() {
			$('result').set('text', 'The request failed.');
		}
	});  
	*/
});




