var COOKIE_DAYS = 30;
var CLOSE_TIME  = 30;

/*
 * Begin QuirksMode Cookie Library: http://www.quirksmode.org/js/cookies.html
 */
function createCookie(name,value,days) {
        if (days) {
                var date = new Date();
                date.setTime(date.getTime()+(days*24*60*60*1000));
                var expires = "; expires="+date.toGMTString();
        }
        else var expires = "";
        document.cookie = name+"="+value+expires+"; domain=trackdaysdriver.co.uk; path=/";
}

function readCookie(name) {
        var nameEQ = name + "=";
        var ca = document.cookie.split(';');
        for(var i=0;i < ca.length;i++) {
                var c = ca[i];
                while (c.charAt(0)==' ') c = c.substring(1,c.length);
                if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
        }
        return null;
}

function eraseCookie(name) {
        createCookie(name,"",-1);
}
/*
 * End QuirksMode Cookie Library: http://www.quirksmode.org/js/cookies.html
 */

function showLightBox()
{
    if ( readCookie('lightboxShow') == null )
    {
        document.getElementById('lightbox').innerHTML = '<div id="lightbox-bar"><a href="#" onclick="hideLightBox();">X Close</a></div><h1>Thanks for stopping by...</h1><p>Apologies for the intrusion, you will only see this message once.</p><p>The Track Days Driver team are so excited about their newsletter that they had to tell you about it.</p><p>Be the first to hear track day news & receive our fantastic How To articles.</p> <p>To sign up please <a href="javascript:PopWindow("https://secure.campaigner.com/CSB/Public/Form.aspx?fid=387135">click here</a></p><p>Thank You,<br />The Track Days Driver Team</p>';
     
        document.getElementById('lightbox-overlay').style.display = 'block';
        document.getElementById('lightbox').style.display = 'block';
    
        setTimeout('hideLightBox();', CLOSE_TIME * 1000);
        createCookie('lightboxShow', 1, COOKIE_DAYS);
    }
}

function hideLightBox()
{
    document.getElementById('lightbox-overlay').style.display = 'none';
    document.getElementById('lightbox').style.display = 'none';
}

window.onload = showLightBox;