/**
 * Original Lightbox functions credit to Lokesh Dhakar (http://www.huddletogether.com).
 * The Following Javascript functions are the intellectual property of CPA Lead, LLC.
 * (c) 2008-2009 CPA Lead, LLC. All Rights Reserved. It is forbidden to reverse engineer, decompile, disassemble, decrypt or otherwise attempt to reconstruct the source code or object code for the My Gateway Premium Content Tool or any Company Property or Sponsor Property. If you violate this provision, CPA Lead, LLC will be entitled to (i) any and all revenues you may generate as a result of such violation and (ii) retain any payments that CPA Lead, LLC otherwise would have been obligated to make to you. Moreover, any copying, editing, or plagiarizing in any matter is prohibited without permission.
 */

var countdown = '0';
var popup_delay = '0';
var countdownStarted = false;
nomoreajax = 0;

function closeeverything() {

	var objText = document.getElementById('cpalead');
	objText.style.display = 'none';
	var objOverlay = document.getElementById('overlay');
	objOverlay.style.display = 'none';
	videos(1);
	nomoreajax = 1;
	alert("Premium Content Unlocked!");

}


function getPageScroll() {

	var yScroll;
	if (self.pageYOffset) {
		yScroll = self.pageYOffset;
	} else if (document.documentElement && document.documentElement.scrollTop){
		yScroll = document.documentElement.scrollTop;
	} else if (document.body) {
		yScroll = document.body.scrollTop;
	}
	arrayPageScroll = new Array('',yScroll)
	return arrayPageScroll;

}


function getPageSize() {

	var xScroll, yScroll;
	if (window.innerHeight && window.scrollMaxY) {
		xScroll = document.body.scrollWidth;
		yScroll = window.innerHeight + window.scrollMaxY;
	} else if (document.body.scrollHeight > document.body.offsetHeight){
		xScroll = document.body.scrollWidth;
		yScroll = document.body.scrollHeight;
	} else {
		xScroll = document.body.offsetWidth;
		yScroll = document.body.offsetHeight;
	}
	var windowWidth, windowHeight;
	if (self.innerHeight) {
		windowWidth = self.innerWidth;
		windowHeight = self.innerHeight;
	} else if (document.documentElement && document.documentElement.clientHeight) {
		windowWidth = document.documentElement.clientWidth;
		windowHeight = document.documentElement.clientHeight;
	} else if (document.body) {
		windowWidth = document.body.clientWidth;
		windowHeight = document.body.clientHeight;
	}
	if(yScroll < windowHeight){
		pageHeight = windowHeight;
	} else {
		pageHeight = yScroll;
	}
	if(xScroll < windowWidth){
		pageWidth = windowWidth;
	} else {
		pageWidth = xScroll;
	}
	arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight)
	return arrayPageSize;

}


function pause(numberMillis) {

	var now = new Date();
	var exitTime = now.getTime() + numberMillis;
	while (true) {
		now = new Date();
		if (now.getTime() > exitTime)
			return;
	}
	
}


function showGateway() {

	var objOverlay = document.getElementById('overlay');
	var browser=navigator.appName;
	var b_version=navigator.appVersion;
	var version=parseFloat(b_version);
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '11000';
	objOverlay.style.width = '100%';
	videos(0);
	var objText = document.getElementById('cpalead');
	objText.style.display = 'block';
	objText.style.position = 'absolute';
	objText.style.top = '0';
	objText.style.left = '0';
	objText.style.zIndex = '11005';
	objText.style.width = '100%';
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	objOverlay.style.height = (arrayPageSize[1] + 'px');
	objText.style.height = (arrayPageSize[1] + 'px');
	objOverlay.style.display = 'block';

}


function dontscroll() {

	scroll(0,0);
	if (nomoreajax == 0) {
		setTimeout("dontscroll();", 350);
	}
	
}


function myGatewayStart() {

	var objBody = document.getElementsByTagName("body").item(0);
	var objOverlay = document.createElement("div");
	objOverlay.setAttribute('id','overlay');
	objOverlay.style.display = 'none';
	objOverlay.style.position = 'absolute';
	objOverlay.style.top = '0';
	objOverlay.style.left = '0';
	objOverlay.style.zIndex = '11003';
 	objOverlay.style.width = '100%';
	objBody.insertBefore(objOverlay, objBody.firstChild);
	var arrayPageSize = getPageSize();
	var arrayPageScroll = getPageScroll();
	dontscroll();
	showGateway();

}


function secondpass() {

	countdown = countdown - 1;
	document.getElementById("closelink").innerHTML = countdown;
	if (countdown <= 0) {
		closelayers();
	} else {
		setTimeout("secondpass()", 1000);
	}
	
}


function closeGateway() {

	if ( countdownStarted == false ) {
		setTimeout("secondpass()", 1000);
		countdownStarted = true;
	}
	var spnCloseMessage = document.getElementById("spnCloseMessage");
	if ( spnCloseMessage ) {
		if (countdown <= 0) {
			spnCloseMessage.style.visibility = "hidden";
		} else {
			spnCloseMessage.style.visibility = "visible";

		}
	}

}


function closelayers() {

	var objOverlay = document.getElementById('overlay');
	var objText = document.getElementById('cpalead');
	videos(1);
	objText.style.display = 'none';
	objOverlay.style.display = 'none';
	nomoreajax = 1;
	return false;

}

function videos(onoroff) {

	if (onoroff==0){
		var embeds = document.getElementsByTagName('embed');
		for (var ems = document.embeds, i = 0, em; em = ems[i]; i++) {
			if (navigator.appName == 'Microsoft Internet Explorer') {
				em.style.visibility='hidden';
			}
			else {
				em.setAttribute('wmode', 'transparent');
				var nx = em.nextSibling, pn = em.parentNode;
				pn.removeChild(em);
				pn.insertBefore(em, nx);
			}
		}
	}
	
	if (onoroff==1){
		var embeds = document.getElementsByTagName('embed');
		for (var ems = document.embeds, i = 0, em; em = ems[i]; i++) {
			if (navigator.appName == 'Microsoft Internet Explorer') {
				em.style.visibility='visible';
			}
			em.setAttribute('wmode', 'window');
		}
	}

}

function addLoadEvent(func) {

	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
    	window.onload = func;
	} else {
		window.onload = function(){
		func();
		oldonload();
		}
	}

}

function startGateway() {

	if (popup_delay > 0) {
		setTimeout("myGatewayStart()", popup_delay+'000');
	} else {
		myGatewayStart();
	}

}

document.write('<style>');
document.write('#overlay{ background-color: #000; filter:alpha(opacity=90); opacity: 0.90; -moz-opacity: 0.90; }');
document.write('#cpalead a {background:none;font-weight:normal;color:#fff;}');
document.write('#cpalead img { border: 0px; }');
document.write('#cpalead a:hover {background:none;font-weight:normal;color:#fff;text-decoration:underline}');
document.write('</style>');
document.write('<div id="cpalead" style="display:none; text-align: center; line-height: normal; ">');
document.write('<div style="margin: 100px auto 0pt; background: transparent; width: 522px; height: 262px;">');
document.write('<div align="center" style="border: 1px solid black; background: #499BFA url(images/gradient_black.png) no-repeat scroll center bottom; left: 499px; top: 115px; height: 522px; height: 262px;">');
document.write('<div align="center" style="padding-top: 5px; padding-right: 5px; float: right;"></div>');
document.write('<div style="padding-top: 30px; font-family: Arial; color: #ffffff; font-weight: bold; font-size: 26px;" align="center">For Members Only</div>');
document.write('<div id="surveys_and_text" style="padding-left: 0px;"><div style="padding-top: 15px; padding-left: 5px; padding-right: 5px;" align="center"><div style="font-family:Verdana; font-size: 12px; font-weight: bold; color: #E9FF1F;">Please Sign up to view the video...</div><br/><br/>');
document.write('<div style="color: #E7FF0F; font-family: Verdana;font-weight: bold; font-size: 26px; ">');
document.write('<font><a style="color: #E7FF0F;" href= "http://www.hershow.net/movies.php"" target=_blank>Sign Up For Free</a></font><BR>');
document.write('</div></div>');
document.write('<div><span id="spnCloseMessage" style="visibility: hidden;"><font face="verdana" size="2" style="color: rgb(255, 255, 255);">Closing in <font id="closelink" style="font-weight: bold;"></font> seconds </font></span></div>');
document.write('</div></div>');

document.write('<div id="bottom_graphic" style="position: relative; float: left; left: -170px; top: -210px;"><img src="images/handprintstop.gif"></div>');
document.write('</div></div>');

addLoadEvent(startGateway);
