﻿function setCookie(name, value, expires, path, domain, secure)
{
    document.cookie= name + "=" + escape(value) +
        ((expires) ? "; expires=" + expires.toUTCString() : "") +
        ((path) ? "; path=" + path : "") +
        ((domain) ? "; domain=" + domain : "") +
        ((secure) ? "; secure" : "");
}

function getCookie(name)
{
    var dc = document.cookie;
    var prefix = name + "=";
    var begin = dc.indexOf("; " + prefix);
    if (begin == -1)
    {
        begin = dc.indexOf(prefix);
        if (begin != 0) return null;
    }
    else
    {
        begin += 2;
    }
    var end = document.cookie.indexOf(";", begin);
    if (end == -1)
    {
        end = dc.length;
    }
    return unescape(dc.substring(begin + prefix.length, end));
}

function displayPOP(top, lft, link) {
  document.write('  <div id="popwin" style="background-image: url(/images/bg.png); visibility: hidden; width: 110%; height:100%; position:absolute; z-index:1; left:'+lft+'px; top:'+top+'px;">');
  document.write('  <div id="popwin3" style="padding:10px; background: #ccff99; position:absolute; left:33%; top:10%; width:33%; z-index:3; border:solid 2px #ffffff;">');
  document.write('  <div><span style="font-weight: bold; font-size: 18pt; color: #60288A; font-family: CG Omega, Arial, sans-serif; margin-bottom: -10px;">Extreme Makeover: ARF Edition II</span></div>');
  document.write('  <p style="font-family: Verdana, Arial; font-size: 10pt;">Play the Alzforum Matching Game! We are conducting research that will help us better understand how to organize our web site so it&#146;s easy for you to use. Thank you to all for your participation.</p>');
  document.write('  <p align="left">');
  document.write('  <a href="javascript:SetSurveyCookieAndLink();" style="text-decoration:none; color:#000000;"><img src="/images/play.gif" style="margin-top: 5px;" alt="Play"></a><br />');
  document.write('  <a href="javascript:CloseAndSetSurveyCookieLater();"><img src="/images/surveylater.gif"  style="margin-top: 5px;" alt="Later"></a><br />');
  document.write('  <a href="javascript:CloseAndSetSurveyCookieNever();"><img src="http://staging.alzforum.org/images/surveynothanks.gif" style="margin-top: 5px;" alt="No Thanks"></a></p></div>');
  document.write('  </div>');
}

function CloseAndSetSurveyCookieLater()
{
    Close();
    var myDate=new Date();
    myDate.setDate(myDate.getDate()+1);
    setCookie('nogamepopup', 'yes', myDate, '', 'www.alzforum.org', ''); 
}

function CloseAndSetSurveyCookieNever()
{
    Close();
    var myDate=new Date();
    myDate.setDate(myDate.getDate()+365);
    setCookie('nogamepopup', 'yes', myDate, '', 'www.alzforum.org', ''); 
}

function SetSurveyCookieAndLink()
{
    Close();
    var myDate=new Date();
    myDate.setDate(myDate.getDate()+365);
    setCookie('nogamepopup', 'yes', myDate, '', 'www.alzforum.org', ''); 
    window.open('http://websort.net/s/5BDA44/',''); 
}

function Close()
{
	var popwin = document.getElementById("popwin");
	popwin.style.visibility = 'hidden';
}

function ShowPop()
{
	var popwin1 = document.getElementById("popwin");
	popwin1.style.visibility = 'visible';
}

// Create the pop-up
// displayPOP(position_from_left, position_from_top, URL);
displayPOP(0,0, 'url');

if	( getCookie('nogamepopup') !='yes')
{
// Show Pop-Up after a few seconds after page loads
// setTimeout('ShowPop();',secs);
setTimeout('ShowPop();',2000);

// Automatically close Pop-Up a few secods after page loads
// setTimeout('Close();',secs);
//setTimeout('Close();',8000);

}





