var popupTimer;

//window.onload = function() { popupTimer = setTimeout('showPopup()', 5000) }

function showPopup() {
	if (!getCookie('iblPopup')) {
		var screen = document.createElement('div');
		screen.id = 'screen';
		screen.className = 'screen';
		screen.style.display = 'block';
		screen.style.width = document.body.scrollWidth;
		
		var container = document.getElementById('content');
		screen.style.height = parseInt((container.offsetHeight > container.scrollHeight)? container.offsetHeight: container.scrollHeight) + 'px';

		var popup = document.createElement('div');
		popup.className = 'popup';
		popup.id = 'popup';
		popup.style.display = 'block';
		popup.style.left = Math.round((parseInt(document.body.scrollWidth) - 465) / 2)+'px';
      
			var close = document.createElement('div');
			close.className = 'close';
				var closeLink = document.createElement('a');
				closeLink.href = 'javascript: void(0);';
				closeLink.innerHTML = 'close X';
				closeLink.onclick = function() {
					document.getElementById('screen').style.display = 'none';
					document.getElementById('popup').style.display = 'none';
					return false;
				}
				close.appendChild(closeLink);
			popup.appendChild(close);
		
			var flash = document.createElement('embed');
			flash.src = '/flash/instantleadbuilder.swf';
			flash.type = 'application/x-shockwave-flash';
			//flash.wmode = 'transparent';
			flash.setAttribute('wmode', 'transparent');
			flash.style.marginTop = '3px';
			flash.style.width = '460px';
			flash.style.height = '162px';
			popup.appendChild(flash);
			
			var sbmtBlock = document.createElement('div');
			sbmtBlock.className = 'overFlash';
		    sbmtBlock.style.left = '2px';
		    sbmtBlock.style.top = '18px';
			    var sbmtLink = document.createElement('a');
			    sbmtLink.href = 'http://instantleadbuilder.com/Home/Articles/Details/params/object/690/default.aspx';
				    sbmtLink.onclick = function() {
					    document.getElementById('screen').style.display = 'none';
					    document.getElementById('popup').style.display = 'none';
				    }
				    var sbmt = document.createElement('img');
				    sbmt.src = '/images/e/blank.gif';
				    sbmtLink.appendChild(sbmt);
			    sbmtBlock.appendChild(sbmtLink);
            popup.appendChild(sbmtBlock);
		
		document.body.appendChild(popup);
		document.body.appendChild(screen);
		
		setCookie('iblPopup', 1, 2, '/');
	}
	
	clearTimeout(popupTimer);
}

function setCookie(name, value, expires, path, domain, secure) {
	var today = new Date(); 
	today.setTime( today.getTime() ); 
	if (expires) expires = expires * 1000 * 60 * 60 * 24; 
	var expires_date = new Date(today.getTime() + (expires));
	
	document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires_date.toGMTString() : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure" : "");
}

function getCookie(name) {
	var cookie = " " + document.cookie;
	var search = " " + name + "=";
	var setStr = null;
	var offset = 0;
	var end = 0;
	if (cookie.length > 0) {
		offset = cookie.indexOf(search);
		if (offset != -1) {
			offset += search.length;
			end = cookie.indexOf(";", offset)
			if (end == -1) {
				end = cookie.length;
			}
			setStr = unescape(cookie.substring(offset, end));
		}
	}
	return(setStr);
}