function videos_modal_block(eid)
{
	//Below are the settings you can change.
	this.blocker_opacity = 50;					//A number from 1 to 100
	this.blocker_background = "#000000";		//CSS background string for blocker
	this.blocker_zindex = 5000; 				//z-index of blocker.
	this.blocker_reuse = true;					//If 2 modals occur at once (bubbling), reuse existing blocker.
	this.blocker_id_base = "videos_modal_blocker_";	//ID of the blocker used for modal bubbling.
    this.blocker_close_on_click = true;         //Clicking the blocker closes the modal.

	//Do not change this unless you know what you're doing.
	this.blocker = null;
	this.block_id = eid;
	this.auto_focus_id = null;
	this.show_hook = null;
	this.hide_hook = null;
	this.version = "1.15";
}

videos_modal_block.prototype.create_blocker = function()
{
	var i;
	this.blocker = document.createElement('div');
	var b = this.blocker;
	var c = document.body;
	var width = this.get_window_width();
	var height = this.get_window_height();

	//Assign the next available blocker ID
	i = 0;
	while(b.id == "")
	{
		if(document.getElementById(this.blocker_id_base+i) === null)
		{
			b.id = this.blocker_id_base+i;
		}
		else
		{
			i++;
		}
	}

	//Setup defaults for blocker
	b.style.width = width + "px";
	b.style.height = height + "px";
	b.style.margin = '0';
	b.style.padding = '0';
	b.style.border = 'none';
	b.style.background = this.blocker_background;
	b.style.position = 'fixed';
	b.style.top = '0px';
	b.style.left = '0px';
	b.style.zIndex = this.blocker_zindex;

	//Blocker opacity	
	b.style.opacity = this.blocker_opacity / 100;
	b.style.filter = "alpha(opacity=" + this.blocker_opacity + ")";

    //Close on click
    if(this.blocker_close_on_click)
    {
        b.videos_modal_block_object = this;
        b.onclick=function () { this.videos_modal_block_object.hide(); }
    }

    //Attach to container.
	c.appendChild(b);

	return true;
}

videos_modal_block.prototype.get_window_width = function()
{
	var ret = false;

	if(window.innerWidth)
	{
		ret = document.body.clientWidth;
	}
	else
	{
		if(document.compatMode && document.compatMode != "BackCompat")
		{
			ret = document.documentElement.clientWidth;
		}
		else
		{
			ret = document.body.clientWidth;
		}
	}

	return ret;
}

videos_modal_block.prototype.get_window_height = function()
{
	var ret = false;

	if(window.innerHeight)
	{
		ret = window.innerHeight;
	}
	else
	{
		if(document.compatMode && document.compatMode != "BackCompat")
		{
			ret = document.documentElement.clientHeight;
		}
		else
		{
			ret = document.body.clientHeight;
		}
	}

	return ret;
}

videos_modal_block.prototype.get_document_height = function()
{
	var ret = false;

	if(window.innerHeight)
	{
		ret = document.documentElement.offsetHeight;
	}
	else
	{
		ret = document.body.clientHeight;
	}

	return ret;
}

videos_modal_block.prototype.destroy_blocker = function()
{
	if(this.blocker != null)
	{
		document.body.removeChild(this.blocker);
		this.blocker = null;
	}

	return true;
}

videos_modal_block.prototype.position_block = function()
{
	var e = document.getElementById(this.block_id);
	var screen_width = this.get_window_width();
	var screen_height = this.get_window_height();
	var y_offset = window.pageYOffset ? window.pageYOffset : document.documentElement.scrollTop;

	e.style.left = Math.floor((screen_width - e.offsetWidth) / 2) + "px";
	e.style.top = (Math.floor((screen_height - e.offsetHeight) / 2) + y_offset) + "px";

	return true;
}

videos_modal_block.prototype.show_block = function()
{
	var e = document.getElementById(this.block_id);

	e.style.display = "block";
	e.style.position = "absolute";
	e.parentNode.removeChild(e);
	document.body.appendChild(e);
	e.style.zIndex = this.blocker_zindex + 1;

	this.position_block();

	return true;	
}

videos_modal_block.prototype.hide_block = function()
{
	var e = document.getElementById(this.block_id);
	e.style.display = "none";

	return true;	
}

videos_modal_block.prototype.set_block = function(eid)
{
	this.block_id = eid;

	return true;	
}

videos_modal_block.prototype.set_auto_focus = function(eid)
{
	this.auto_focus_id = eid;

	return true;	
}

videos_modal_block.prototype.set_show_hook = function(func)
{
	this.show_hook = func;

	return true;	
}

videos_modal_block.prototype.set_hide_hook = function(func)
{
	this.hide_hook = func;

	return true;	
}


videos_modal_block.prototype.show = function()
{
	if(this.show_hook != null)
	{
		this.show_hook();
	}

	if(this.blocker == null)
	{
		if(this.blocker_reuse == false || document.getElementById(this.blocker_id_base+0) == null)
		{
			this.create_blocker();
		}

		this.show_block();

		if(this.auto_focus_id != null)
		{
			document.getElementById(this.auto_focus_id).focus();
		}
	}

	return true;
}

videos_modal_block.prototype.hide = function()
{
	if(this.hide_hook != null)
	{
		this.hide_hook();
	}

	this.destroy_blocker();
	this.hide_block();
	
	return true;
}

