var NIEUWSBRIEFVRAGEN = false;

function createCookie(name,value) {
	var date = new Date();
	date.setTime(date.getTime()+(10*365*24*60*60*1000));
	document.cookie = name+"="+value+"; expires="+date.toGMTString()+"; 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) {
	document.cookie = name+"=; expires=-1; path=/";
}

function hide(elementname){
	if ( document.getElementById(elementname) ){
		document.getElementById(elementname).style.display = 'none';
	}	
}
function show(elementname){
	if ( document.getElementById(elementname) ){
		document.getElementById(elementname).style.display = 'inline';
	}	
}

function correctScroll(divid, yoffset)
{
  if (document.getElementById(divid))
  {
    if (document.all)
    {
        docy = parseInt(document.body.scrollTop);
        menuy = parseInt(document.getElementById(divid).style.top);
        ay = 0;
        
        if (docy != menuy)
        {
          speed = Math.ceil(Math.abs(menuy - docy) / 10);
          
          if (speed > 0)
          {
            if (docy > menuy) ay = -speed;
            else
            if (docy < menuy) ay = speed;
            
            document.getElementById(divid).style.top = menuy - ay;
          }
          //window.status = speed;
        } 
    } else
      if ( document.getElementById(divid) ){
//        document.getElementById(divid).style.position = "fixed";
	  }
    }
	setTimeout("correctScroll('" + divid + "')", 10);
}

function showNieuwsbriefVraag()
{
  div = null;
  if (document.getElementById('content')) div = document.getElementById('content');
  if (document.getElementById('contenthoofdtabel')) div = document.getElementById('contenthoofdtabel');
  
  if (div)
  {
  	if ( false //nieuwsbriefvraag getter geset?
  		){
  		createCookie("nieuwsbriefvraag", "beantwoord");
  	} else 
  	  if ( readCookie("nieuwsbriefvraag") != "beantwoord" ){
        	var useragentFilter=/^.*irefox.*$/;
        	var popup = document.createElement('div');
  		popup.id = "nieuwsbrieflayer";
  		
      	if ( !useragentFilter.test(navigator.userAgent) )
        {
      	   	popup.style.position = "absolute";
      	   	popup.style.margin = (screen.height / 30) + "px 0px 0px 0px";
      	   	popup.style.top = "100px";
      	   	popup.style.left = "175px";
      	} else 
          {
          	popup.style.position = "fixed";
        		popup.style.top = "150px";
      	   	popup.style.left = "175px";
      	  }
        		
  		div.appendChild(popup);
  		popup.innerHTML = '<div id="nieuwsbrieflayerbuttonja" onclick="createCookie(\'nieuwsbriefvraag\', \'beantwoord\'); window.top.location = \'http://www.reizenportal.nl/nieuwsbrief/\'">&nbsp;</div><div id="nieuwsbrieflayerbuttonnee" onclick="createCookie(\'nieuwsbriefvraag\', \'beantwoord\'); hide(\'nieuwsbrieflayer\'); show(\'home_flash\')">&nbsp;</div>';
    	correctScroll('nieuwsbrieflayer', 20);
    }
	}
	
// reset alle cookies
//	if ( readCookie("nieuwsbriefvraag") == "beantwoord" ){
//		eraseCookie("nieuwsbriefvraag");
//	}
}
