//var domain = document.domain;
//var domainvals= domain.split('.');
//var domlength= domainvals.length - 1;
//document.domain=domainvals[domlength-1] + '.' + domainvals[domlength];


var timeToRemainOpen = 1000;      //tijd in miliseconden
var remainOpen = false;           //

var navigationAnimation = false;
var navigationAnimationDelay = 20;
var navigationAnimationStep = 15;
var navigationHeight = 0;
var navigationHeightMax = 300;

function pulloutNavigation(s) {
  document.getElementById('pngIE').style.display='block';
  document.getElementById('pngIE').style.pixelLeft=document.getElementById('pulldownnavigation').style.pixelLeft;
  //document.getElementById('pulldownnavigation').style.display='block';
  var uls= document.getElementById('headnav').getElementsByTagName('li');
  var groups= new Array();
  for (var i=0;i<uls.length;i++) {
    var thisId= uls[i].getAttribute('id');
    if (thisId!=s) uls[i].className='';
    else uls[i].className='active';
    groups[i]= thisId;
  }

  for (var i=0; i<groups.length; i++) {
    var groupName = 'group' + groups[i];
    var groupNode = document.getElementById(groupName);
    if (!groupNode) continue;
    if (groups[i] != s) groupNode.className = '';
    else groupNode.className = 'active';
  }
  remainOpen=true;

  if (!navigationAnimation) {
    navigationAnimation = true;
    navigationHeight = 0;
    pulloutNavigationAnimation();
  }
}

function pulloutNavigationAnimation() {
  if (navigationAnimation) {
    navigationHeight += navigationAnimationStep;
    document.getElementById('pulldownnavigation').style.display='block';
    document.getElementById('pulldownnavigation').style.clip='rect(0px 915px '+ navigationHeight +'px 0px)';
    if (navigationHeight < navigationHeightMax) {
      setTimeout("pulloutNavigationAnimation()", navigationAnimationDelay);
    }
  }
}

function leaveOpen() { remainOpen=true;}
function pullinNavigation() {
  remainOpen=false;
  setTimeout("closeNavigation()",timeToRemainOpen);
}

function closeNavigation() {
  if (!remainOpen) {
   navigationHeight = 0;
   navigationAnimation = false;
   var uls= document.getElementById('headnav').getElementsByTagName('li');
   for (var i=0;i<uls.length;i++) {
    uls[i].className='';
    var thisId= uls[i].getAttribute('id');
    if (document.getElementById('group' + thisId)) document.getElementById('group' + thisId).className='';
   }
   document.getElementById('pngIE').style.display='none';
   document.getElementById('pulldownnavigation').style.display='none';
  }
}

var oldQuestion='';
function showAnswer(a) {
  if (oldQuestion) answer_toggle(oldQuestion);
  if (oldQuestion!= a) {
   answer_toggle(a);
   oldQuestion = a;
  } else {
   oldQuestion = '';
  }
  a.blur();
  return false;
}

function answer_toggle(a) {
  var e= a.parentNode;
  var u= e.parentNode;
  if (hasClass(e,'active')) {
    removeClass(u,'active');
    removeClass(e,'active');
  } else {
    addClass(u,'active');
    addClass(e,'active');
  }
}

function hasClass(e,s) {
  if (!e.className) return false;
  if (e.className.indexOf(s)==-1) return false;
  return true;
}

function addClass(e,s) {
  if (!e.className) e.className=s; 
  else if(e.className.indexOf(s)==-1) e.className += " " + s;
}

function removeClass(e,s) {
  if (!e.className || e.className.indexOf(s)==-1) return;
  var clsss= e.className.split(" ");
  var nwcls= new Array();
  j=0;
  for (var i=0; i < clsss.length; i++) {
    if (clsss[i]!=s && clsss[i]!= " ") nwcls[j++] = clsss[i];
  }
  e.className=nwcls.join(" ");
}

var oldPage='';
function showThisPage(e) {
  if (oldPage) removeClass(oldPage,'active');
  if (oldPage!= e) {
   if (hasClass(e,'active')) removeClass(e,'active');
   else addClass(e,'active');
   oldPage = e;
  } else {
   oldPage = '';
  }
  e.blur();
  return false;
}


function popup(Link,Name,Width,Height){
  var breedte=Width;
  var hoogte=Height;
  if (breedte==-1) breedte=500;
  if (hoogte==-1) hoogte=500;
  var iMyWidth = (window.screen.width/2) - (breedte/2 + 10);
  var iMyHeight = (window.screen.height/2) - (hoogte/2 + 50);

  var win3 = window.open(Link,Name,"location=no,status=no,menubar=no,scrollbars=yes,resizable=no,width=" + breedte + ",height=" + hoogte + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight);
  win3.focus();
}

function popupNoScroll(Link,Name,Width,Height){
  var breedte=Width;
  var hoogte=Height;
  if (breedte==-1) breedte=500;
  if (hoogte==-1) hoogte=500;
  var iMyWidth = (window.screen.width/2) - (breedte/2 + 10);
  var iMyHeight = (window.screen.height/2) - (hoogte/2 + 50);

  var win3 = window.open(Link,Name,"location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=" + breedte + ",height=" + hoogte + ",left=" + iMyWidth + ",top=" + iMyHeight + ",screenX=" + iMyWidth + ",screenY=" + iMyHeight);
  win3.focus();
}

var pd='';
var npd='';

function language_toggle(s) {
  if (pd) pd.style.display='none';
  var lEl = document.getElementById('language_choices');
  if (lEl.style.display!='block') {
    lEl.style.display='block';
    pd=lEl;
  } else {
    lEl.style.display='none';
    pd='';
  }
}

function togglePullDown(s) {
  if (pd) pd.style.display='none';
  npd = s.tagName ? s : document.getElementById(s);
  if (pd == npd) {
    pd='';
  } else {
    npd.style.display='inline';
    pd=npd;
  }
}

function selectElement(selected, formfield, value) {
  var pulldown = selected.parentNode;
  var selectBar = pulldown.previousSibling;
  selectBar.lastChild.data = selected.firstChild.data;
  formfield.value = value;
  togglePullDown(pulldown);
  return false;
}

function releaseSelect(evt) {
  var srcEl= '';
  if (evt.target) srcEl= evt.target;
  else srcEl=event.srcElement;
  if (pd && !clickedIn(srcEl, pd.parentNode)) {
    pd.style.display='none';
    pd='';
  }
}

function clickedIn(eSrc, eTrg) {
  if (eSrc.innerHTML == eTrg.innerHTML) return true;
  while (eSrc.tagName!='BODY') {
    eSrc= eSrc.parentNode;
    if (eSrc.innerHTML == eTrg.innerHTML) return true;
  }
  return false;
}


/* Vincent van Gogh in vogelvlucht flase popup */
function open_pop_up(url){
  window.open('vogelvlucht/' + url,'vogelvlucht','width=660, height=520, resizable=1, scollbars=0');
}
