function Webcast(options) {
	
	this.options = options;
	this.container = jQuery('#' + options.target);
	
	this.link = jQuery('a', '#' + options.target)[0];
	this.type = options.type;
	this.options = options;
	
	this.webcastWindow = null;
	this.webcastModalOpener = options.modalOpener;
	
	
	this.message = jQuery('span', '#' + options.target);
	
	var defaultMessageStyle = {
			colorHover      : '#333333',	
			color           : '#000000',
			fontSize        : '2em',
			fontWeight      : 'bold',
			opacity         : '0.4',
			backgroundColor : '#ddd'
	};
	this.messageStyle  = jQuery.extend(defaultMessageStyle, (this.options.message ? this.options.message : {}));  

	this.initialize();
}


Webcast.prototype.initialize = function() {
	this.displayMessage();
	this.observeHover();
	this.observeClick();
}

Webcast.prototype.observeHover = function() {
	
	jQuery(this.container).bind("mouseenter", {parent: this}, function(e){
		var parent = e.data.parent;
		
		parent.message.css({
			color      : parent.messageStyle.colorHover
		});
	});
	jQuery(this.container).bind("mouseleave", {parent: this}, function(e){
		var parent = e.data.parent;
		parent.message.css({
			color      : parent.messageStyle.color
		});
	});
}



Webcast.prototype.displayMessage = function() {
	this.container.css({
		position : 'relative'
	});
	
	var dynamicMessageStyle = {
			display    : 'block',
			lineHeight : jQuery('img',this.container).height() + 'px',
			width      : jQuery('img',this.container).width() + 'px',     
			position   : 'absolute',
			textAlign  : 'center',
			cursor     : 'pointer'
			
	};
	
	this.message.css(jQuery.extend(this.messageStyle, dynamicMessageStyle));
}


Webcast.prototype.observeClick = function() {
	this.message.bind("click", {parent: this}, function(e){
		var parent = e.data.parent;
		jQuery(parent.link).click();
	});
	
	jQuery(this.link).bind("click", {parent: this, url: this.link.href}, this.openPage);
}

Webcast.prototype.openPage = function(e)
{
	var url    = e.data.url;
	var parent = e.data.parent;
	
	switch(parent.type)
	{
		case 'popin':
			parent.webcastModalOpener(url, parent.options);
		break;
		
		case 'popup':
			parent.webcastWindow = window.open(url, 'webcast', 'menubar=0,resizable=0,width=' + parent.options.width + ',height=' + parent.options.height);
		break;
		
		case 'target':
			window.open(url);
		break;
	}
	return false;
}
	



