var Worker = new Class(
{
	overlay : null,
	overlay_contents: null,
	inner: null,
	overlay_contents_left: null,
	overlay_contents_title: null,
	overlay_contents_text: null,
	overlay_contents_image: null,
	overlay_close_button: null,
	
	options:
	{
		'worker' : null,
		'name' : '',
		'function_name' : '',
		'image' : '',
		'text' : "",
		'close_button' : ''
	},
	
	initialize: function(options)
	{
		this.setOptions(options);
		this.createOverlay();
		this.setEvents();
		//Cufon.replace("h1");
		
	},
	
	setEvents: function()
	{
		$('worker_' + this.options.worker).addEvent('click', function()
		{
			this.showOverlay();
		}.bind(this));
		
		$('worker_' + this.options.worker).addEvent('mouseover', function()
		{
			this.setStyle("border", "2px solid #3B6BB7");
		});

		$('worker_' + this.options.worker).addEvent('mouseout', function()
		{
			this.setStyle("border", "2px solid #E0B514");
		});
		
		window.addEvent('resize', function()
		{
			this.resizeOverlay();
		}.bind(this));

		$('close_button_' + this.options.worker).addEvent('click', function()
		{
			this.hideOverlay();
		}.bind(this));
	},
	
	createOverlay: function()
	{
		if ((Browser.Engine.trident) && (Browser.Engine.version == 4))
		{
			this.overlay = new Element('div', {'id' : 'worker_overlay_' + this.options.worker, 'class' : 'worker_overlay_ie6'});
			this.overlay.setStyle('height', window.getHeight() + 'px');
		}
		else
		{
			this.overlay = new Element('div', {'id' : 'worker_overlay_' + this.options.worker, 'class' : 'worker_overlay'});
			this.overlay.setStyle('height', '100%');
		}
		
		this.overlay_contents = new Element('div', {'class' : 'worker_contents'});
		this.overlay_contents.setStyle('margin-left', ((window.getWidth() - 800) / 2) + 'px');
		this.overlay_contents.setStyle('margin-top', ((window.getHeight() - 450) / 2) + 'px');
		
		this.inner = new Element('div', {'class' : 'worker_contents_inner'});
		this.overlay_contents_title = new Element('h1');
		this.overlay_contents_text = new Element('div', {'class' : 'worker_contents_text'});
		
		if (this.options.image != "")
		{
			this.overlay_contents_image = new Element('img', {'src' : this.options.image, 'class' : 'worker_contents_image'});	
		}

		this.overlay_contents_title.set("html", this.options.name + ", " + this.options.function_name);
		this.overlay_contents_text.set("html", this.options.text);
		
		this.overlay_close_button = new Element('img', {'id' : 'close_button_' + this.options.worker, 'src' : this.options.close_button, 'class' : 'close_button'});
		
		this.inner.adopt(this.overlay_contents_title);
		if (this.options.image != "")
		{
			this.inner.adopt(this.overlay_contents_image);
		}
		this.inner.adopt(this.overlay_contents_text);
		this.overlay_contents.adopt(this.inner);
		this.overlay_contents.adopt(this.overlay_close_button);
		
		this.overlay.adopt(this.overlay_contents);
		$(document.body).adopt(this.overlay);
	},
	
	showOverlay: function()
	{
		$('worker_overlay_' + this.options.worker).setStyle('display', 'block');
	},
	
	hideOverlay: function()
	{
		$('worker_overlay_' + this.options.worker).setStyle('display', 'none');
	},
	
	resizeOverlay: function()
	{
		this.overlay.setStyle('height', '100%');
		this.overlay_contents.setStyle('margin-top', ((window.getHeight() - 450) / 2) + 'px');
		this.overlay_contents.setStyle('margin-left', ((window.getWidth() - 800) / 2) + 'px');
	}
});
Worker.implement(new Options, new Events);
