﻿/*****************************************************/
/*USER CUSTOMIZABLE FIELDS*/

var	zip_file = '[INSERT YOUR INCENTIVE DOWNLOAD PAGE URL HERE]';
    
/*END OF USER CUSTOMIZABLE FIELDS*/
/******************************************************/

var blocker_originalHtmlOverflow;
var blocker_originalBodyOverflow;

function blocker_addLoadEvent(func)
{    
    var oldonload = window.onload;
    if (typeof window.onload != 'function')
    {
        window.onload = func;
    } 
    else 
    {
        window.onload = function()
        {
            oldonload();
            func();
        }
    }
}

function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}

function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}

function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
var urltarget = null;
var blocker_init=function(urlnya)
{    
urltarget = urlnya;
    /*if(blocker_getCookie('content_unlocked')=='1')
	{
		unblockContent;
		window.location = zip_file;
        return;
	}/**/

    blocker_originalHtmlOverflow = document.getElementsByTagName('body')[0].style.overflow;
    blocker_originalBodyOverflow = document.getElementsByTagName('html')[0].style.overflow;

    document.getElementsByTagName('body')[0].style.overflow = 'hidden';
    document.getElementsByTagName('html')[0].style.overflow = 'hidden';

    var haze = document.createElement('div');
    haze.id = 'blocker_haze';
    haze.style.filter = 'alpha(opacity=50)';
    haze.style.opacity = .5;
    haze.style.height = document.body.clientHeight + "px";//f_clientHeight();//'100%';
    haze.style.width = document.body.clientWidth + "px";//f_clientWidth();//'100%';
    haze.style.backgroundColor = '#000';
    haze.style.position = 'absolute';
    haze.style.top = 0;//f_scrollTop();
    haze.style.left = 0;//f_scrollLeft();
    haze.style.zIndex = 1000000;/**/

    var centerPane = document.createElement('div');
    centerPane.id = 'blocker_centerPane';
    centerPane.style.width = '500px';
    centerPane.style.border = '5px solid #CCC';
    centerPane.style.position = 'absolute';
    centerPane.style.left = '50%';
    centerPane.style.marginLeft = '-250px';
    centerPane.style.top = (f_scrollTop() + 150) +"px";
    centerPane.style.backgroundColor = '#FFF';
	centerPane.style.opacity = '.90';
	centerPane.style.filter = 'alpha(opacity=90)';
    centerPane.style.zIndex = 1000001;
    centerPane.style.backgroundImage = 'url(http://i41.tinypic.com/2znsvti.png)';
    centerPane.style.backgroundRepeat = 'no-repeat';
    centerPane.style.backgroundPosition = '20px 10px';
    centerPane.style.padding = '20px';

    var h1 = document.createElement('h1');
    h1.style.color = '#466805';
    h1.style.textAlign = 'center';
    h1.style.fontSize = '38px';
    h1.style.margin = '0 0 10px 0';
    h1.style.padding = '8px 0 0 15px';
    h1.style.fontFamily = 'arial';
    h1.style.lineHeight = '38px';
    h1.innerHTML = blocker_headline;
    centerPane.appendChild(h1);

    var p1 = document.createElement('p');
    p1.innerHTML = blocker_instructionalText;
    p1.style.textAlign = 'center';
    p1.style.padding = '20px 0 20px 0';
    p1.style.margin = '0';
    p1.style.fontSize = '18px';
    p1.style.lineHeight = '18px';
    p1.style.color = '#000';
    p1.style.fontFamily = 'arial';/**/
    centerPane.appendChild(p1);

    var ul = document.createElement('ul');
    ul.style.textAlign = 'center';
    ul.style.margin = '0 0 10px 0';
    ul.style.fontSize = '14px';
    ul.style.padding = '0';
    ul.style.listStyleType = 'none';
    for(var i = 0;i<blocker_surveryLinks.length;i++){
        var li = document.createElement('li');        
        //var a = document.createElement('a');
		/*
        a.style.display = 'block';
        a.style.fontSize = '14px';
        a.style.lineHeight = '22px';
        a.style.color = 'Blue';
        a.style.fontFamily = 'arial';
        a.style.textDecoration = 'underline';
        a.target = '_blank';        */
        //a.href = blocker_surveryLinks[i].url;
        li.innerHTML = blocker_surveryLinks[i].text;
        //a.onclick = function(){
        //    window.setTimeout(unblockContent, 5000); //Time out!
        //}
        //li.appendChild(a)    
        ul.appendChild(li);
    }

    centerPane.appendChild(ul);

    var p2 = document.createElement('p');
    p2.style.textAlign = 'center';
    p2.innerHTML = blocker_footerText;
    p2.style.padding = '20px 0 0 0';
    p2.style.margin = '0';
    p2.style.color = '#000';
    p2.style.fontFamily = 'arial';
    p2.style.fontSize = '13px';
    p2.style.lineHeight = '13px';
    centerPane.appendChild(p2);

    document.getElementsByTagName('body')[0].appendChild(haze);
    document.getElementsByTagName('body')[0].appendChild(centerPane);
	window.setTimeout(unblockContent, popupTimeout*1000); //Time out!
}

function unblockContent(){
    document.getElementsByTagName('body')[0].style.overflow = blocker_originalBodyOverflow;
    document.getElementsByTagName('html')[0].style.overflow = blocker_originalHtmlOverflow;

    document.getElementById('blocker_haze').style.display = 'none';
    document.getElementById('blocker_centerPane').style.display = 'none';
    //blocker_setCookie("content_unlocked", 1, 1000);
	window.location = urltarget;
}

function blocker_setCookie(c_name,value,expiredays){
    var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);
    document.cookie=c_name+ "=" +escape(value)+((expiredays==null) ? "" : ";expires="+exdate.toGMTString());
}

function blocker_getCookie(c_name){
    if (document.cookie.length>0){
        c_start=document.cookie.indexOf(c_name + "=");
        if (c_start!=-1){ 
            c_start=c_start + c_name.length+1; 
            c_end=document.cookie.indexOf(";",c_start);
            if (c_end==-1) c_end=document.cookie.length;
            return unescape(document.cookie.substring(c_start,c_end));
        } 
    }
    return "";
}