var Overlay = new Class({
	
	Implements:[Options,Events],
	options:{
		infoContainer:$empty
	},
	initialize: function(els,options){
		this.setOptions(options);
		//mouse over event, gets coords of that element, then turns on info bubble
		this.els = els;
		els.addEvent('mouseenter',this.showInfoBubble.bind(this));
		els.addEvent('mouseleave',this.hideInfoBubble.bind(this));
		
		this.fadeEffect = new Fx.Morph(this.options.infoContainer,{duration:300});
		
		
	},
	
	getGameInfo: function(id){
		this.options.infoContainer.getElement('.content').set('html',"");
		var gameInfo = new Request({url:'game-release-schedule.php',method:'get',onComplete:function(responseText){
			this.options.infoContainer.getElement('.content').set('html',responseText);
			this.fadeEffect.start({'opacity':1})
			
		}.bind(this)});
		gameInfo.send({
			data:{
				'info':'dates-info',
				'id':id
			}
		});
	},
	showInfoBubble: function(e){
		this.fadeEffect.cancel();
		var target = $(e.target);
		for(var i = 0; i < this.els.length;i++){
			if(this.els[i] == target.getParent('.block-holder')){
				var idToGet = i;
			}
		}
		this.getGameInfo(idToGet);
		
		var position = target.getPosition();
		
		
		
		
		if(idToGet == 0){
			if(Browser.Engine.trident){
			
				var bottomNum = -21;
			
			} else {
				var bottomNum = -4;
			}
			var leftNum = position.x;
			
			
			this.options.infoContainer.getElement('img.overlay-pointer').setStyles({
				'left':12,
				'bottom':bottomNum
				
			});
		} else {
		
			if(Browser.Engine.trident){
			
				var bottomNum = -11;
			
			} else {
				var bottomNum = -4;
			}
		
			this.options.infoContainer.getElement('img.overlay-pointer').setStyles({
				'left':40,
				'bottom':bottomNum
				
				});
			var leftNum = position.x - 28;
		}
		
		this.options.infoContainer.setStyles({
				
				'left':leftNum,
				'top':position.y - 25,
				'z-index':9000
			});
		
	},
	hideInfoBubble: function(e){
		this.fadeEffect.cancel();
		this.fadeEffect.start({'opacity':0});
		//this.options.infoContainer.setStyle('display','none');
	}

});
