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, title, body, bodybottom, closePauzePeriod,closeButton,imageUrl,imagePos)
{
    WriteCSS(closeButton);

    var i = MWM2POPUPReadCookie('MWM2POPUPCounter');
    if((i > - 1) || (i == null))
    {
        if(i > showCount)
        {          
            document.write('<div class="MWM2POPUP" id="MWM2POPUP">');
            document.write('    <table border=0 cellpadding=5 cellspacing=3 width=320 align=center>');
            document.write('        <tr>');
            document.write('            <td class="MWM2POPUPTopbar"><div class="MWM2POPUPTopbar" style="float:left;">' + title + '</div><div style="float:right;" 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>');
		    document.write('                <tr>');
            
            if (imagePos == 'top' || imagePos == 'left')
            {
		        document.write('                <td style="vertical-align:top"><img src="' + imageUrl + '" alt="" title=""></td>');
            }
            if (imagePos == 'top') 
            {
				document.write('                </tr><tr><td>');
            }
            else if (imagePos = 'left')
            {
	            document.write('                    <td>');
            }
            
            document.write(body);
            document.write('                    <center>');
            document.write('                        <input type=button name=Ja value="Ja" class="MWM2POPUPButtons MWM2POPUPButtonJA" onclick="MWM2PopupClickYes(\'' + link + '\')">');
            document.write('                    <input type=button name=Nee value="Nee" class="MWM2POPUPButtons MWM2POPUPButtonNEE" onclick="MWM2POPUPWriteCookie(\'MWM2POPUPCounter\',-1,\'2000\');document.getElementById(\'MWM2POPUP\').style.display=\'none\';">');
            document.write('                    </center></td></tr>');
            document.write('                </table>');
            
            if(bodybottom != null)
            {
                document.write(bodybottom);
            }
            
            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=1,width=800,height=600');
}

function MWM2ShowPopup(closeButton, image)
{
	var title = '';
	var body = '';
	var bodybottom = '';
	var imagePos = ''
	
	imagePos = 'left';
	if (image == null || image == '') imagePos = ''
	
	title = 'Website onderzoek';
	
	body += 'Om de website te verder aan te laten sluiten aan uw wensen hebben we een korte vragenlijst opgesteld over de website. Het onderzoek duurt ongeveer 5 minuten.'
	body += '<br><br>'
	body += 'Wilt u meedoen met dit onderzoek?'
	body += '<br><br>'

    PopupCounter('http://onderzoek.mwm2.nl/ga.asp?vp=CBFFA125-989B-4E24-8C88-EA85E7563F8D&alin=ja', 2, title, body, '', 14, closeButton, image, imagePos);
}

function WriteCSS(closeButton)
{
    document.write("<style>");

    document.write(".MWM2POPUPTopbar");
    document.write("{");
    document.write("    font-size:12pt;");
    document.write("    font-family:arial;");
    document.write("    color:white;");
    document.write("    font-weight:bold;");
    document.write("}");

    document.write(".MWM2POPUPButtons");
    document.write("{");
    document.write("    font-size:12px;");
    document.write("    width:45px;");
    document.write("    font-family:arial;");
    document.write("    margin-right:15px;");
    document.write("}");

    document.write(".MWM2POPUPBody");
    document.write("{");
    document.write("     background-color:white;");
    document.write("     font-size:12px;");
    document.write("    font-family:arial;");
    document.write("}");

    document.write(".MWM2POPUP");
    document.write("{");
    document.write("    width:324px;");
    document.write("    background-color:#95A5C6;");
    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: 250px;");
    document.write("    left: 350px;");
    document.write("    z-index:9999;");
    document.write("    border:solid 1px #516891;");
    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:arial;");
    document.write("}");

    document.write("</style>");
}
