// Enter your exit message here.
var exitMessage = "Get FREE Instant Access to Over 100,000 Movies and TV Shows!";

window.onbeforeunload = confirmExit;
//window.onload = confirmExit;
exitCheck();

// This is the actual dimming function.
function confirmExit()
{
	if (!window.exitBlock)
	{
		// If you want to dim using any special options, feel free to change this line.
		dimScreen(true);

		var content = document.getElementById('exitContent');
		content.style.zIndex = 51;
		content.style.display = 'block';
		return exitMessage;

	}
}

function dimScreen(vis, opts)
{
	// opts are options and are optional.
	// opts.opacity: 0 - 100
	// opts.index: elements with higher zindex appear on top.
	// opts.bgcolor: hex code
	// usage -- dimScreen(true, {'index':'1', 'bgcolor':'#0000ff', 'opacity':'70'});

	var opts = opts || {};
	var index = opts.index || 50;
	var opacity = opts.opacity || 70;
	var opaque = (opacity / 100);
	var bgcolor = opts.bgcolor || '#000000';
	var dark = document.getElementById('screenObject');
	
	// validate that the dark object exists. If not, create it.
	if (!dark)
	{
		var body = document.getElementsByTagName("body")[0];
		var node = document.createElement('div');
		node.style.position = 'absolute';
		node.style.top = '0px';
		node.style.left = '0px';
		node.style.overflow = 'hidden';
		node.style.display = 'none';
		node.id = 'screenObject';
		body.appendChild(node);
		dark = document.getElementById('screenObject');
	}

	if (vis)
	{
		// calculate screen width/height.
		if (document.body && (document.body.scrollWidth || document.body.scrollHeight))
		{
			var pageWidth = document.body.scrollWidth + 'px';
			if (document.body.scrollHeight < document.body.clientHeight)
			{
				var pageHeight = '100%';
			}
			else
			{
				var pageHeight = document.body.scrollHeight + 'px';
			}
		}
		else if (document.body.offsetWidth)
		{
			var pageWidth = document.body.offsetWidth + 'px';
			var pageHeight = document.body.offsetHeight + 'px';
		}
		else
		{
			var pageWidth = '100%';
			var pageHeight = '100%';
		}
		
		
		// darken the page body
		dark.style.opacity = opaque;
		dark.style.MozOpacity = opaque;
		dark.style.filter = 'alpha(opacity=' + opacity + ')';
		dark.style.zIndex = index;
		dark.style.backgroundColor = bgcolor;
		dark.style.width = pageWidth;
		dark.style.height = pageHeight;
		dark.style.display = 'block';
	}
	else
	{
		dark.style.display = 'none';
	}
}

function dimScreenPopup1()
{
	
	dimScreen(true, {'index':'50', 'bgcolor':'#444444', 'opacity':'70'});
	var dark = document.getElementById('screenObject');
	var content = document.getElementById('exitContentPopup1');
	content.style.zIndex = 51;
	content.style.display = 'block';
}

function closeExitWindowPopup1()
{
	var content = document.getElementById('exitContentPopup1');
	content.style.display = 'none';
	dimScreen(false);
}

function exitCheck()
{
	for (var i = 0; document.links.length; i++)
	{
		if ("function" == typeof(document.links[i].onclick))
			document.links[i].exit_onclick = document.links[i].onclick;
		document.links[i].onclick = exitLinkClicked;
	}
	for (var i = 0; document.forms.length > i; ++i) {
		if ("function" == typeof(document.forms[i].onsubmit))
			document.forms[i].exit_onsubmit = document.forms[i].onsubmit;
		document.forms[i].onsubmit = exitFormSubmitted;
	}
}

function exitLinkClicked(event) {
	window.exitBlock = true;
	if ("function" == typeof(this.exit_onclick))
		return this.exit_onclick(event);
	return true;
}
function exitFormSubmitted(event) {
	window.exitBlock = true;
	if ("function" == typeof(this.exit_onsubmit))
		return this.exit_onsubmit(event);
	return true;
}



