$(document).ready(
  function(){
     if(geen_eerste_niveau == true){
      var first_element_class = $(".nav_menu li").first().find("a").attr("class");
      
      $(".nav_menu li").each(function(){
        if($(this).find("a").attr("class") == "inpath" || first_element_class == "inpath"){
          $(this).css("display", "block");
        }
        else{
          $(this).css("display", "none");
        }
      })

      $(this) == $(".nav_menu li").first().css("display", "block");
      $(".subnav_menu li").toggle();
      $(".inpath").parent("li").css("display", "block");
     }
     
     // if(!(jQuery.browser.msie && jQuery.browser.version == "8.0")){
     //  var content_html = $(".contents").html();
     
     //  $(".contents").remove();
      
      
     //  if(content_html != null){
            
     //     $(".contentsbar").append('<div class="contents">' + content_html + '</div>');
     //  }
     // }
  }
);

// JavaScript Document
function getClient() {
  this.exclude=1;
  this.agt=navigator.userAgent.toLowerCase();
  this.win=0;
  this.mac=0;
  this.lin=1;
  if (this.agt.indexOf('win')!=-1) {
    this.win=1;
    this.lin=0;
  }
  if (this.agt.indexOf('mac')!=-1) {
    this.mac=1;
    this.lin=0;
  }
  this.lnx=0;
  if (this.lin) {
    this.lnx=1;
  }
  this.ice=0;
  this.ie=0;
  this.ie4=0;
  this.ie5=0;
  this.ie6=0;
  this.ie7=0;
  this.com=0;
  this.dcm;
  this.op5=0;
  this.op6=0;
  this.op7=0;
  this.ns4=0;
  this.ns6=0;
  this.ns7=0;
  this.mz7=0;
  this.kde=0;
  this.saf=0;
  if (typeof navigator.vendor!="undefined" && navigator.vendor=="KDE") {
    this.thisKDE=this.agt;
    this.splitKDE=this.thisKDE.split("konqueror/");
    this.aKDE=this.splitKDE[1].split("; ");
    this.KDEn=parseFloat(this.aKDE[0]);
    if (this.KDEn>=2.2) {
      this.kde=1;
      this.ns6=1;
      this.exclude=0;
    }
  }
  else if (this.agt.indexOf('webtv')!=-1) {
    this.exclude=1;
  }
  else if (typeof window.opera!="undefined") {
    this.exclude=0;
    if (/opera[\/ ][5]/.test(this.agt)) {
      this.op5=1;
    }
    if (/opera[\/ ][6]/.test(this.agt)) {
      this.op6=1;
    }
    if (/opera[\/ ][7-9]/.test(this.agt)) {
      this.op7=1;
    }
  }
  else if (typeof document.all!="undefined"&&!this.kde) {
    this.exclude=0;
    this.ie=1;
    if (typeof document.getElementById!="undefined") {
      this.ie5=1;
      if (this.agt.indexOf("msie 6")!=-1) {
        this.ie6=1;
        this.dcm=document.compatMode;
        if (this.dcm!="BackCompat") {
          this.com=1;
        }
      }
      if (this.agt.indexOf("msie 7")!=-1) {
        this.ie7=1
      }
    }
    else{
      this.ie4=1;
    }
  }
  else if (typeof document.getElementById!="undefined") {
    this.exclude=0;
    if (this.agt.indexOf("netscape/6")!=-1||
        this.agt.indexOf("netscape6")!=-1) {
      this.ns6=1;
    }
    else if (this.agt.indexOf("netscape/7")!=-1||
             this.agt.indexOf("netscape7")!=-1) {
      this.ns6=1;
      this.ns7=1;
    }
    else if (this.agt.indexOf("gecko")!=-1) {
      this.ns6=1;
      this.mz7=1;
    }
    if (this.agt.indexOf("safari")!=-1 ||
        (typeof document.childNodes!="undefined" &&
         typeof document.all=="undefined" &&
         typeof navigator.taintEnabled=="undefined")) {
      this.mz7=0;
      this.ns6=1;
      this.saf=1;
    }
  }
  else if ((this.agt.indexOf('mozilla')!=-1)&&
           (parseInt(navigator.appVersion)>=4)) {
    this.exclude=0;
    this.ns4=1;
    if (typeof navigator.mimeTypes['*']=="undefined") {
      this.exclude=1;
      this.ns4=0;
    }
  }
  if (this.agt.indexOf('escape')!=-1) {
    this.exclude=1;
    this.ns4=0;
  }
  if (typeof navigator.__ice_version!="undefined") {
    this.exclude=1;
    this.ie4=0;
  }
}

var is=new getClient();


function getRotation() {
  this.images=new Array();
  this.duration=4;
  this.ind=0;
}

var rotation=new getRotation();

function startRotate(id, imgs, root) {
  rotation.elm=document.getElementById(id);
  for (preLoadInd=0;preLoadInd<imgs.length;preLoadInd++) {
    rotation.images[preLoadInd+1]=new Image();
    rotation.images[preLoadInd+1].src=root+imgs[preLoadInd];
  }
  window.setTimeout('rotate()',2000);
}

function rotate(){
  if (!rotation.images[0]) {
    rotation.images[0]=new Image();
    rotation.images[0].src=rotation.elm.src;
  }
  rotation.ind=(rotation.ind+1)%rotation.images.length;
  if (is.ie5 || is.ie6 || is.ie7) {
    rotation.elm.style.filter='blendTrans(duration='+rotation.duration+')';
    rotation.elm.filters.blendTrans.Apply()
    rotation.elm.src=rotation.images[rotation.ind].src;
    rotation.elm.filters.blendTrans.Play();
  }
  else {
    rotation.elm.src=rotation.images[rotation.ind].src;
  }
  window.setTimeout('rotate()',6000);
}

function setColors(elt) {
  elt.onmouseover = function() {
    elt.className+=" over";
  }
  elt.onmouseout = function() {
    elt.className=elt.className.replace(" over", "");
  }
  /*for (i=0; i<navRoot.childNodes.length; i++) {
    node = navRoot.childNodes[i];
    if (node.nodeName=="h1") {
      node.onmouseover=function() {
        this.className+=" over";
      }
      node.onmouseout=function() {
        this.className=this.className.replace(" over", "");
      }
    }
  }*/
}

var formMessage = 'Niet alle verplichte velden zijn ingevuld:\n';

function checkForm(formName) {
  name=formName;
  obj=document.getElementById(formName);
  invalidFields = new Array();
  invalidNames = new Array();
  for (var i=0; i<requiredFields[name].length; i++) {
    if (obj.elements[requiredFields[name][i]].length) {
      optionChecked = false;
      for (var j=0; j<obj.elements[requiredFields[name][i]].length; j++) {
        if (obj.elements[requiredFields[name][i]][j].checked || obj.elements[requiredFields[name][i]][j].selected) {
          optionChecked = true;
        }
      }
      if (!optionChecked) {
        invalidFields[invalidFields.length] = obj.elements[requiredFields[name][i]][0];
        invalidNames[invalidNames.length] = requiredLabels[name][i];
      }
    }
    else if (obj.elements[requiredFields[name][i]].type != "hidden" &&
        (obj.elements[requiredFields[name][i]].value == "" ||
        (obj.elements[i].name.indexOf("Tab.Src") != -1) && (
        (""+obj.elements[i].value).indexOf("@")<0 ||
        (""+obj.elements[i].value).indexOf(".")<0))) {
      invalidFields[invalidFields.length] = obj.elements[requiredFields[name][i]];
      invalidNames[invalidNames.length] = requiredLabels[name][i];
    }
  }
  if (invalidFields.length > 0) {
    msg = formMessage;
    for (var i=0; i<invalidFields.length; i++) {
      if (document.all && invalidFields[i].type == "input") {
        invalidFields[i].style.borderColor = "#ff6600";
        invalidFields[i].style.backgroundColor = "#ffeecc";
      }
      msg += (i==0?'':'\n') + '- ' + invalidNames[i];
    }
    alert(msg);
    return false;
  }
 return (invalidFields.length == 0);
}

// Geeft de omringende 'form' van een element
function getForm(formName,elt) {
  if(is.opera || is.ns6comp) {
    return document.forms[formName];
  }
  else if(is.ns4comp || is.ie4comp) {
    if(getForm.arguments.length == 2) {
      return eval("elt.document." + formName);
    } else {
      return eval("document." + formName);
    }
  }
}

// Verstuur het formulier
function formSubmit(formName,elt) { 
  formRef = getForm(formName,elt);
  formRef.submit();
}

