function MWM2POPUPWriteCookie(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+"; path=/";
}

function MWM2POPUPReadCookie(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 MWM2POPUPEraseCookie(name)
{
    createCookie(name, "", -1);
}


function PopupCounter(link, showCount, closePauzePeriod, closeButton, type)
{
    WriteCSS(closeButton);
    
    var i = MWM2POPUPReadCookie('MWM2POPUPCounter');
    
    if((i > - 1) || (i == null))
    {
        if(i > showCount)
        {
			var title = 'Pearson ' + type + ' Onderzoek';
			var body = '';
			
			body += 'Beste Bezoeker,<br><br>'
			body += 'Pearson wil graag uw mening weten over de nieuwe ' + type + '.'
			body += '<br/>'
			body += 'Dit onderzoek wordt verzorgt door MWM2, een onafhankelijk onderzoeksbureau.'
			body += '<br/>'
			body += '<br/>'
			body += '<span style="margin-bottom:2px;">Wilt u meedoen aan dit onderzoek?</span><br/><br/>'
			
            document.write('<div class="MWM2POPUP" id="MWM2POPUP" style="padding-left:5px;">');
            document.write('    <table border="0" cellpadding="3" cellspacing="2" width="425" align="center" >');
            document.write('        <tr>');
            document.write('            <td class="MWM2POPUPTopbar"><div class="MWM2POPUPTopbar" style="float:left;">' + title + '</div><div style="float:right;position:relative;top:-2px;" class="MWM2POPUPCloseButton" onclick="document.getElementById(\'MWM2POPUP\').style.display=\'none\';MWM2POPUPWriteCookie(\'MWM2POPUPCounter\',-1,' + closePauzePeriod + ');"></div></td>');
            document.write('        </tr>');
            document.write('        <tr>');
            document.write('            <td class="MWM2POPUPBody">');
            document.write('				<table><tr>');
            document.write('				<td>');
            document.write(body);
            document.write('                <center>');
            document.write('                    <input type=button name=Yes value="Ja" class="MWM2POPUPButtons MWM2POPUPButtonJA" onclick="MWM2PopupClickYes(\'' + link + '\')">');
            document.write('                    <input type=button name=No value="Nee, misschien later" style="width:130px;" class="MWM2POPUPButtons MWM2POPUPButtonNEE" onclick="MWM2POPUPWriteCookie(\'MWM2POPUPCounter\',-1,\'3\');window.location.reload();">');
            document.write('                    <input type=button name=No value="Nee" class="MWM2POPUPButtons MWM2POPUPButtonNEE" onclick="MWM2POPUPWriteCookie(\'MWM2POPUPCounter\',-1,\'2000\');window.location.reload();">');
            document.write('                </center><br>');
            document.write('                * Deelname is anoniem.');
            document.write('                </td></tr></table>');
            document.write('            </td>');
            document.write('        </tr>');
            document.write('    </table>');
            document.write('</div>');
        }
        
        i++;
        MWM2POPUPWriteCookie('MWM2POPUPCounter',i);
    }
}

//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
//
//                                          CHANGEBLE PARTS BELOW
//
//-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

function MWM2PopupClickYes(link)
{
    MWM2POPUPWriteCookie('MWM2POPUPCounter',-1,'31');
    document.getElementById('MWM2POPUP').style.display='none';

    window.open(link,'MWM2Onderzoekapplicatie','resizable=yes,width=800,height=600,scrollbars=yes,status=yes');
}

function PearsonPopup(closeButton, ond_uniek,type)
{
    PopupCounter('http://onderzoek.mwm2.nl/ga.asp?vp=' + ond_uniek, 2, 31, closeButton, type);
}

function WriteCSS(closeButton)
{
    document.write("<style>");

    document.write(".MWM2POPUPTopbar");
    document.write("{");
    document.write("    font-size:12px;");
    document.write("    font-family:verdana;");
    document.write("    color:#FFE900;");
    document.write("    font-weight:bold;");
    document.write("}");

    document.write(".MWM2POPUPButtons");
    document.write("{");
    document.write("    font-size:10px;");
    document.write("    width:45px;");
    document.write("    font-family:verdana;");
    document.write("    margin-right:15px; border:1px solid #003C74;");
    document.write("}");

    document.write(".MWM2POPUPBody");
    document.write("{");
    document.write("     background-color:white;border:solid 1px #22368C;");
    document.write("     font-size:10px;");
    document.write("    font-family:verdana;");
    document.write("}");

    document.write(".MWM2POPUP");
    document.write("{");
    document.write("    width:440px;");
    document.write("    background-color:#0076C0;border:solid 1px #22368C;");
    document.write("    padding-top:2px;");
    document.write("    padding-bottom:2px;");
    document.write("    font-family:arial;");
    document.write("    padding-left:2px;");
    document.write("    padding-right:2px;");
    document.write("    position: absolute;");
    document.write("    top: 255px;");
    document.write("    left: 450px;");
    document.write("    z-index:999;");
    document.write("}");

    document.write(".MWM2POPUPCloseButton");
    document.write("{");
    document.write("    margin-top:2px;");
    document.write("    width:15px;");
    document.write("    background-image:url(" +  closeButton +");");
    document.write("    height:15px;");
    document.write("    cursor:pointer;");
    document.write("    font-family:verdana;");
    document.write("}");

    document.write(".MWM2PopupAd");
    document.write("{");
    document.write("    font-size:12px;");
    document.write("    color:white;");
    document.write("    font-weight:bold;");
    document.write("	background-color: #E32336;");
    document.write("    width:410px;");
    document.write("    text-align:center;");
    document.write("    font-family:verdana;");
    document.write("    padding:5px;");
    document.write("}");

    document.write("</style>");
}// JScript File
