//============================================= check scroll//
// this function from lightbox (http://www.huddletogether.com/projects/lightbox/)

function getPageScroll(){

	var yScroll;

	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){	 // Explorer 6 Strict
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {// all other Explorers
		yScroll = document.body.scrollTop;
	}
	return yScroll;
}

//=============================================//

var Popup = new Class({
	window: null,
	effect: null,
  
	initialize: function( open_link, close_link, window ) {
		open_link.addEvent('click', this.open.bind(this));
    	close_link.addEvent('click', this.close.bind(this));
    	this.window = window;
    
		this.effect = new Fx.Style(this.window, 'opacity',{duration:300})
    	if( window.hasClass('active') )
    		this.open();
		},
  
		open: function(event) {
			if( event ) {
				var event = new Event(event);
				event.stop();
			}
			
			if( Popup.active == this )
				return;
		  
			if( Popup.active )
				Popup.active.close.bind( Popup.active )();
	
			Popup.active = this;
			this.window.setStyle('top', (getPageScroll()-125));
			this.effect.set(0);	
			this.window.addClass('active');
			this.effect.start(0, 1);
			},
	  
		close: function(event) {
			var event = new Event(event);
			event.stop();
			
			Popup.active = null;
		
			this.window.removeClass('active');
			}
  
});
Popup.active = null;

function player_popups() {
	$$('ul#bios li').each( function(bio_entry) {
		new Popup( bio_entry.getElement('a'), bio_entry.getElement('div.bio a'), bio_entry.getElement('div.bio') );
	});
}

window.addEvent('load', player_popups);
