/**
 * Simple function which resize an iframe-element to completely show its
 * contents in order to avoid scrollbars
 *
 * Usage:
 *  - load this script within the page where the iframe resides
 *  - within the iframecontent put insert:
 *      function adjustIFrameSize() {
 *          if (parent.adjustIFrameSize) {
 *              parent.adjustIFrameSize(window, 25);
 *          }
 *      }
 *  - call the function at body onload within the iframecontent
 */
function adjustIFrameSize (iframeWindow, extra)
{
  if (iframeWindow.document.height)
  {
    var iframeElement = document.getElementById(iframeWindow.name);
    iframeElement.style.height = iframeWindow.document.height + extra + 'px';
    if ((iframeWindow.document.height + extra) < 520) iframeElement.style.height = '520px';
  }
  else if (document.all)
  {
    var iframeElement = document.all[iframeWindow.name];
    if (iframeWindow.document.compatMode && iframeWindow.document.compatMode != 'BackCompat')
    {
      iframeElement.style.height = iframeWindow.document.documentElement.scrollHeight + extra + 'px';
      if ((iframeWindow.document.documentElement.scrollHeight + extra) < 600) iframeElement.style.height = '600px';
    }
    else
    {
      iframeElement.style.height = iframeWindow.document.body.scrollHeight + extra + 'px';
    }
  }
}

function change_menu_image(el, src) {
  el.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='scale')";
}


// MENU
var current_menu_active = 0;

function show_sub_menu(welke) {
  if(current_menu_active != welke) {
    // Hide all sub menu's
    for( i=1 ; i<=7 ; i++ ) {
      if(document.getElementById('submenu' + i)) {
        document.getElementById('submenu' + i).style.visibility = 'hidden';
      }
    }

    // Show selected sub menu.
    if(document.getElementById('submenu' + welke)) {
      document.getElementById('submenu' + welke).style.visibility = 'visible';
      current_menu_active = welke;
    }
  }
}
// EINDE MENU

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

// INFORMATION BAR
/***********************************************

* Animated Information Bar- by JavaScript Kit (www.javascriptkit.com)
* This notice must stay intact for usage
* Visit JavaScript Kit at http://www.javascriptkit.com/ for this script and 100s more

***********************************************/
function informationbar(){
  this.displayfreq="always"
  this.content='<a href="javascript:informationbar.close()"><img src="close.gif" style="width: 14px; height: 14px; float: right; border: 0; margin-right: 5px" /></a>'
}

informationbar.prototype.setContent=function(data){
  this.content=this.content+data
  document.write('<div id="informationbar" style="top: -500px">'+this.content+'</div>')
}

informationbar.prototype.animatetoview=function(){
  var barinstance=this
  if (parseInt(this.barref.style.top)<0){
    this.barref.style.top=parseInt(this.barref.style.top)+5+"px"
    setTimeout(function(){barinstance.animatetoview()}, 50)
  }
  else{
    if (document.all && !window.XMLHttpRequest)
    this.barref.style.setExpression("top", 'document.compatMode=="CSS1Compat"? document.documentElement.scrollTop+"px" : body.scrollTop+"px"')
  else
    this.barref.style.top=0
  }
}

informationbar.close=function(){
  document.getElementById("informationbar").style.display="none"
  if (this.displayfreq=="session")
    document.cookie="infobarshown=1;path=/"
}

informationbar.prototype.setfrequency=function(type){
  this.displayfreq=type
}

informationbar.prototype.initialize=function(){
  if (this.displayfreq=="session" && document.cookie.indexOf("infobarshown")==-1 || this.displayfreq=="always"){
    this.barref=document.getElementById("informationbar")
    this.barheight=parseInt(this.barref.offsetHeight)
    this.barref.style.top=this.barheight*(-1)+"px"
    this.animatetoview()
  }
}

window.onunload=function(){
  this.barref=null
}

// Flash Detection
var requiredMajorVersion = 9;
var requiredMinorVersion = 0;
var requiredRevision     = 0;
var hasReqestedVersion   = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if (!hasReqestedVersion) {
  var infobar=new informationbar()
  infobar.setContent('Je hebt geen flash geinstalleerd, of je hebt niet de juiste versie. Klik <a href="http://www.adobe.com/go/getflash/" target="_blank">hier</a> om de juiste versie te installeren.')
  //infobar.setfrequency('session') //Uncomment this line to set information bar to only display once per browser session!
  infobar.initialize()
}
// EINDE INFORMATION BAR



// OPSLAAN
function opslaan(welk, div, lokatie) {
  //document.getElementById(div).style.display = "block";
  document.getElementById(div).style.visibility = "visible";
  if(true == isIE(7)) {
    document.getElementById("WaitImage").innerHTML = "<img id='opslaan_img' name='opslaan_img' src='"+ lokatie +"/images/ajax-loader.gif' alt='' />";
  } else {
    document.getElementById("opslaan_img").src = lokatie +"/images/ajax-loader.gif";
  }
  eval("document." + welk +".submit();");
}

function isIE(versionNumber) {
  var detect = navigator.userAgent.toLowerCase();
  if(!(navigator && navigator.userAgent && navigator.userAgent.toLowerCase)) {
    return false;
  } else {
    if(detect.indexOf('msie') + 1) {
      // browser is internet explorer
      var ver = get_ie_ver();
      var valid = true;
      // if the version can be found and the version is less than our version number it is invalid
      // alert(ver +" - "+ versionNumber);
      if ((ver > -1) && (ver < versionNumber)) {
        valid = false;
      }
      return valid;
    } else {
      return false
    }
  }
}

function get_ie_ver() {
  // http://msdn.microsoft.com/workshop/author/dhtml/overview/browserdetection.asp
  // Returns the version of Internet Explorer or a -1
  // (indicating the use of another browser).
  var rv = -1; // Return value assumes failure
  if (navigator.appName == 'Microsoft Internet Explorer') {
    var ua = navigator.userAgent;
    var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
    if (re.exec(ua) != null) {
      rv = parseFloat( RegExp.$1 );
    }
  }
  return rv;
}
// EINDE OPSLAAN

