var MetrixLab_Intercept = 5;

var MetrixLab_OverlayType = 'entry';

var MetrixLab_PopupFolderName = 'p07312';
var MetrixLab_ProjectNumber = 'p07312';
var MetrixLab_CookieFolderName = 'p07312';

//if true the MetrixLab_CookieFolderName name should be the same in all projects
var MetrixLab_GLOB_CookieSetup = false;

var MetrixLab_PrivacyLanguage = 'nl';

var MetrixLab_DivStartLeft = '100';
var MetrixLab_DivStartTop = '100';

var MetrixLab_OverlayWidth = 350;
var MetrixLab_OverlayHeight = 300;

var MetrixLab_Coordinate_YesButton = '185,245,281,270';
var MetrixLab_Coordinate_NoButton = '74,245,171,269';
var MetrixLab_Coordinate_CloseButton = '292,4,351,23';
var MetrixLab_Coordinate_PrivacyButton = '209,280,268,299';
var MetrixLab_Coordinate_MetrixButton = '273,280,349,299';

var MetrixLab_AutoCloseInterval=0;
var MetrixLab_ForceData='0';

var MetrixLab_CookieName = "MetrixLab"+MetrixLab_CookieFolderName;
var MetrixLab_UserID='';

var MetrixLabGLOB_cookie;
var MetrixLabGLOB_Try_count = 20;

function MetrixLab_SetUserID()
{
	var Today = new Date();
	MetrixLab_UserID=''+Today.getFullYear()+'_'+(Today.getMonth()+1)+'_'+Today.getDate()+'_'+Today.getHours()+'_'+Today.getMinutes()+'_'+Today.getSeconds()+'_'+Today.getMilliseconds();	
}

function MetrixLab_isCookieEnabled()
{
    var cookieEnabled=(navigator.cookieEnabled)? true : false
    
    if (typeof navigator.cookieEnabled=="undefined" && !cookieEnabled)
    { 
	    document.cookie="MetrixLabTestCookie"
	    cookieEnabled=(document.cookie.indexOf("MetrixLabTestCookie")!=-1)? true : false
    }    
    return cookieEnabled;      	
}

function MetrixLab_GetRandomNumber(MetrixLab_minValue,MetrixLab_maxValue)
{
    var MetrixLab_result = 0;

    if (MetrixLab_minValue<=MetrixLab_maxValue)
    {
	    MetrixLab_result=Math.round((Math.random()*(MetrixLab_maxValue-MetrixLab_minValue+1))+MetrixLab_minValue-0.5);
	}	
	return MetrixLab_result;
}

function MetrixLab_SetCookie()
{
    var MetrixLab_expires = new Date();
	MetrixLab_expires.setTime(MetrixLab_expires.getTime() + (180*24*60*60*1000));
	document.cookie = MetrixLab_CookieName+"=1; expires=" + MetrixLab_expires.toGMTString() + "; path=/;";

	if (MetrixLab_GLOB_CookieSetup)
	{	
		MetrixLab_GLOB_setCookie();
	}
}


function MetrixLab_ShowOverlay()
{
	MetrixLab_SetUserID();
    MetrixLab_SetCookie();
    MetrixLab_LoadOverlay();
    if (MetrixLab_AutoCloseInterval>0)
    {
            setTimeout("MetrixLab_CloseBanner();",MetrixLab_AutoCloseInterval*1000);
    }
}


function MetrixLab_GLOB_setCookie()
{
	var MetrixLabGLOB_Time = new Date();
	var MetrixLabGLOB_Script = document.createElement('script');
	MetrixLabGLOB_Script.src='http://invitation.opinionbar.com/popups/'+MetrixLab_PopupFolderName+'/cookie.asp?s='+MetrixLab_CookieName+'_GLOB&m=set&t='+MetrixLabGLOB_Time.getTime();
	MetrixLabGLOB_Script.type='text/javascript';
	var MetrixLabGLOB_Body = document.getElementsByTagName('body').item(0);
	MetrixLabGLOB_Body.appendChild(MetrixLabGLOB_Script); 
}



function MetrixLab_GLOB_getCookie()
{
	var MetrixLabGLOB_Time = new Date();
	var MetrixLabGLOB_Script = document.createElement('script');
	MetrixLabGLOB_Script.src='http://invitation.opinionbar.com/popups/'+MetrixLab_PopupFolderName+'/cookie.asp?s='+MetrixLab_CookieName+'_GLOB&m=get&t='+MetrixLabGLOB_Time.getTime();
	MetrixLabGLOB_Script.type='text/javascript';
	var MetrixLabGLOB_Body = document.getElementsByTagName('body').item(0);
	MetrixLabGLOB_Body.appendChild(MetrixLabGLOB_Script); 
}


function MetrixLabGLOB_checkCookie()
{                
    if (typeof MetrixLabGLOB_cookie != "undefined")
    {     
		if (MetrixLabGLOB_cookie==false)     
		{                         
			//cookie not set
			MetrixLab_ShowOverlay();
		}
		else
		{
			//cookie set
		}
		
    }
	else
	{ 
		MetrixLabGLOB_Try_count--;
		if (MetrixLabGLOB_Try_count>0)
		{
			setTimeout('MetrixLabGLOB_checkCookie();',500);
		}
	}
}

function MetrixLab_CheckCookie()
{
	if (document.cookie.indexOf(MetrixLab_CookieName)==-1)
	{
		if (MetrixLab_GLOB_CookieSetup)
		{
			MetrixLab_GLOB_getCookie();
			MetrixLabGLOB_checkCookie();
		}
		else
			MetrixLab_ShowOverlay();
	}
	 
}

function MetrixLab_CheckIntercept()
{
	
    MetrixLab_RandomNumber = MetrixLab_GetRandomNumber(1,MetrixLab_Intercept);
    if (MetrixLab_RandomNumber==1)
    {
        MetrixLab_CheckCookie();
    }
}

function MetrixLab_GoToPrivacy()
{
	PopupPrivacy = window.open('http://www.opinionbar.com/'+MetrixLab_PrivacyLanguage+'/privacy.asp','PopupPrivacy','resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,width=750,height=450');
}

function MetrixLab_GoToMetrixLab()
{
	PopupPrivacy = window.open('http://www.MetrixLab.com/','PopupPrivacy','resizable=yes,scrollbars=yes,toolbar=yes,menubar=yes,width=750,height=450');
}

function MetrixLab_GoToWebSurvey()
{
    switch(MetrixLab_OverlayType)
    {
        case 'entry':
            MetrixLab_GoToWebSurveyEntry();
        break;
        case 'exit':
            MetrixLab_GoToWebSurveyExit();
        break;
        case 'entryexit':
            MetrixLab_GoToWebSurveyEntryExit();
        break;
    }
}

function MetrixLab_GoToWebSurveyEntry()
{       
    if (MetrixLab_ForceData=='0')
    {					
        PopupWebSurvey = window.open('http://websurvey.opinionbar.com/go.asp?s='+MetrixLab_ProjectNumber+'&t=4','PopupWebSurvey','resizable=yes,scrollbars=yes,toolbar=no,menubar=no,width=750,height=450');					
    }
    else
    {
        PopupWebSurvey = window.open('http://websurvey.opinionbar.com/go.asp?s='+MetrixLab_ProjectNumber+'&t=4&f=;'+MetrixLab_ForceData+'','PopupWebSurvey','resizable=yes,scrollbars=yes,toolbar=no,menubar=no,width=750,height=450');
    }				

    MetrixLab_CloseBanner();
}

function MetrixLab_GoToWebSurveyExit()
{
   MetrixLab_SetCookie();
   MetrixLab_ShowPopupEntryExit();
   MetrixLab_CloseBanner();
}

function GoTowebSurveyEntryExit()
{
   MetrixLab_SetCookie();
   MetrixLab_ShowPopupEntryExit();
   MetrixLab_CloseBanner();
}

function MetrixLab_CloseBanner()
{
    var MetrixLab_Div=document.getElementById('MetrixLab_Div');
    if (MetrixLab_Div)
    {
        MetrixLab_Div.parentNode.removeChild(MetrixLab_Div);
    }
}

function MetrixLab_ShowPopupEntryExit()
{
	
	MetrixLab_PopupAttributes="resizable=yes,scrollbars=yes,toolbar=no,menubar=no,width=390,height=370";
	
	MetrixLab_PopupWin=open('inv.htm', 'new_window', MetrixLab_PopupAttributes);
	MetrixLab_PopupWin.document.write('<html><head><title></title></head>');
	MetrixLab_PopupWin.document.write('<body>');
	
	
	MetrixLab_PopupWin.document.write('<scr'+'ipt>');
	MetrixLab_PopupWin.document.write("var metrixlab_userid='"+MetrixLab_UserID+"';");
	MetrixLab_PopupWin.document.write("var metrixlab_ForceData='"+MetrixLab_ForceData+"';");
	MetrixLab_PopupWin.document.write('</scr'+'ipt>');	
	MetrixLab_PopupWin.document.write("<script language='javascript' src='http://invitation.opinionbar.com/popups/"+MetrixLab_PopupFolderName+"/exit.js'>");
	MetrixLab_PopupWin.document.write('</scr'+'ipt>');
	
	
	MetrixLab_PopupWin.document.write('</body></html>');	
	MetrixLab_PopupWin.blur();
	
}

function Metrixlab_SetDivVisible()
{
	document.getElementById('MetrixLab_overlay').style.display='block';
}

function MetrixLab_LoadOverlay()
{    
    var MetrixLab_HTMLString="";
    MetrixLab_HTMLString += "<MAP name='MetrixLab_Popup_Map'>\n";
    MetrixLab_HTMLString += " <AREA shape='rect' coords='"+MetrixLab_Coordinate_YesButton+"' href='javascript:MetrixLab_GoToWebSurvey();' target='_self'>\n";
    MetrixLab_HTMLString += " <AREA shape='rect' coords='"+MetrixLab_Coordinate_NoButton+"' href='javascript:MetrixLab_CloseBanner();' target='_self'>\n";
    MetrixLab_HTMLString += " <AREA shape='rect' coords='"+MetrixLab_Coordinate_CloseButton+"' href='javascript:MetrixLab_CloseBanner();' target='_self'>\n";
    MetrixLab_HTMLString += " <AREA shape='rect' coords='"+MetrixLab_Coordinate_PrivacyButton+"' href='javascript:MetrixLab_GoToPrivacy();' target='_self'>\n";
    MetrixLab_HTMLString += " <AREA shape='rect' coords='"+MetrixLab_Coordinate_MetrixButton+"' href='javascript:MetrixLab_GoToMetrixLab();' target='_self'>\n";    
    MetrixLab_HTMLString += "</MAP>\n";
    MetrixLab_HTMLString += "<div id='MetrixLab_overlay' style='display:none;position:absolute; z-index:9999; left: "+MetrixLab_DivStartLeft+"px; top: "+MetrixLab_DivStartTop+"px;'>";    
    MetrixLab_HTMLString += "<img onload='Metrixlab_SetDivVisible();' src='/static/sblpresentation/images/overlay.gif' USEMAP='#MetrixLab_Popup_Map' alt='' border='0' width='"+MetrixLab_OverlayWidth+"' height='"+MetrixLab_OverlayHeight+"' name='MetrixLab_overlay_gif' id='MetrixLab_gif'>";    
    MetrixLab_HTMLString += "</div>";
    
    var MetrixLab_Body=document.getElementsByTagName('body').item(0);
    var MetrixLab_Div = document.createElement('div');
    MetrixLab_Div.style.display='block';
    MetrixLab_Div.id='MetrixLab_Div';
    MetrixLab_Div.innerHTML = MetrixLab_HTMLString;
    MetrixLab_Body.appendChild(MetrixLab_Div);
}

function MetrixLab_AddEvent(object, type, handler)
{
	if (object.addEventListener) 
	{
		object.addEventListener(type, handler, false);
	} 
	else if (object.attachEvent) 
	{
		object.attachEvent(['on',type].join(''),handler);
	} 
	else 
	{
		object[['on',type].join('')] = handler;
	}
} 

MetrixLab_AddEvent(window,"load",MetrixLab_CheckIntercept);