var scripts = Array(
   'http://www.kennisnet.nl/js/embedmedia.js',
   'http://www.kennisnet.nl/js/jquery.js',
   'http://www.kennisnet.nl/js/popup.js',
   'http://www.kennisnet.nl/js/sifr.js',
   'http://www.kennisnet.nl/js/swfobject.js'
);

for (src in scripts) {
   document.write('<script type="text/javascript" src="'+scripts[src]+'"></script>');
}

var DomLoaded =
{
   onload: [],
   loaded: function()
   {
      if (arguments.callee.done) return;
      arguments.callee.done = true;
      for (i = 0;i < DomLoaded.onload.length;i++) DomLoaded.onload[i]();
   },
   load: function(fireThis)
   {
      this.onload.push(fireThis);
      if (document.addEventListener) 
         document.addEventListener("DOMContentLoaded", DomLoaded.loaded, null);
      if (/KHTML|WebKit/i.test(navigator.userAgent))
      { 
         var _timer = setInterval(function()
         {
            if (/loaded|complete/.test(document.readyState))
            {
               clearInterval(_timer);
               delete _timer;
               DomLoaded.loaded();
            }
         }, 10);
      }
      /*@cc_on @*/
      /*@if (@_win32)
      var proto = "src='javascript:void(0)'";
      if (location.protocol == "https:") proto = "src=//0";
      document.write("<scr"+"ipt id=__ie_onload defer " + proto + "><\/scr"+"ipt>");
      var script = document.getElementById("__ie_onload");
      script.onreadystatechange = function() {
          if (this.readyState == "complete") {
              DomLoaded.loaded();
          }
      };
      /*@end @*/
      window.onload = DomLoaded.loaded;
   }
};

function getElement(id) {

   if (document.getElementById) {
      return document.getElementById(id);
   } else if (document.all) {
      return document.all[id];
   }

}

function trim(str) {

   while (str.substr(0,1) == ' ') {
      str = str.substr(1,str.length);
   }
   while (str.substr(str.length-1,str.length) == ' ') {
      str = str.substr(0,str.length-1);
   }
   return str;

}

function NewWindow(uri,name,w,h,scroll) {

   var winl = (screen.width - w) / 2;
   var wint = ((screen.height - 50) - h) / 2;

   winprops = 'width='+w+',height='+h+',left='+winl+',top='+wint+',scrollbars='+scroll+',status=yes,noresize';
   win = window.open(uri, name, winprops);

   if (parseInt(navigator.appVersion) >= 4) {
      win.window.focus();
   }

}

function submitForm(form,input,message) {

   if (!trim(input.value)) {
      alert(message);
   } else {
      form.submit();
   }

}

function clearDefaultValue(input) {

   if (typeof input.defaultValue == 'undefined') {
      input.defaultValue = input.value;
   }
   if (input.value == input.defaultValue) {
      input.value = '';
   }

}

function transformIntoJumpMenu(list) {

   if (list) {

      jumpMenu = document.createElement('select');
      jumpMenu.setAttribute('id',list.id);
      jumpMenu.onchange = function jumpTo() { if (this.value && this.value != 'javascript:void(0)') { window.location = this.value } };

      items = list.getElementsByTagName('a');

      for (i=0;i<items.length;i++) {
         jumpMenu.options[i] = new Option(items[i].firstChild.nodeValue,items[i].href);
      }

      list.parentNode.insertBefore(jumpMenu,list);
      list.parentNode.removeChild(list);

   }

}

function wrapElement(node,wrapper,attributes) {

   if (node) {

      var container = node.parentNode;
      var wrapper = document.createElement(wrapper);

      if (attributes) {

         attributes = attributes.split(',');

         for (i=0;i<attributes.length;i++) {

            attribute = attributes[i].split('=');
            wrapper.setAttribute(attribute[0],attribute[1]);

         }

      }

      container.replaceChild(wrapper,node);
      wrapper.appendChild(node);

   }

}

function getStyleProperty(node,property) {

   if (node) {
      if (node.currentStyle) {
         return node.currentStyle[property];
      } else {
         return document.defaultView.getComputedStyle(node,null).getPropertyValue(property);
      }
   }

}

function toHex(dec) {

   hD = '0123456789ABCDEF';

   hex = hD.substr(dec&15,1);
   while (dec>15) {
      dec >>= 4;
      hex = hD.substr(dec&15,1)+hex;
   }

   return hex;

}

function toHexColor(color) {

   if (color.charAt(0) != '#') {

      rgb = color.substring(color.indexOf('(')+1,color.indexOf(')')).split(',');
      color = '#';

      for (i=0;i<rgb.length;i++) {
         if (toHex(rgb[i]) < 2) { color += '0'; }
         color += toHex(rgb[i]);
      }

   } else if (color.length <= 4) {

      color = color.split('');
      for (i=1;i<color.length;i++) { color[i] += color[i]; }
      color = color.join('');

   }

   return color;

}

DomLoaded.load(function() {

   if (document.getElementById('header') && sIFR.UA.bHasTransparencySupport) {

      wrapElement(getElement('header_link_01'),'span','className=sIFR,class=sIFR');

      sIFR.replaceElement('#header .sIFR,#header h1',named({sFlashSrc:'http://www.kennisnet.nl/js/InfoOffice-Medium.swf',sBgColor:'#000000',sColor:toHexColor(getStyleProperty(getElement('header'),'color')),sWmode:'transparent'}));

   }

});


/*old stuff*/

// ++++++++++++++++++++++++++++++++++++++++++ //
// GERALATEERDE SITES JUMPMENU                //
// ++++++++++++++++++++++++++++++++++++++++++ //

function jumpMenu(targ,selObj,restore){
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

// ++++++++++++++++++++++++++++++++++++++++++ //
// OPEN NEW WINDOW IN CENTER OF SCREEN        //
// ++++++++++++++++++++++++++++++++++++++++++ //

function NewWindow(mypage, myname, w, h, scroll) {

var winl = (screen.width - w) / 2;
var wint = ((screen.height - 50)- h) / 2;

winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',noresize'
win = window.open(mypage, myname, winprops)

if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}


// ++++++++++++++++++++++++++++++++++++++++++++++ //
// OPEN NEW WINDOW IN CENTER OF SCREEN FOR NOTIFY //
// ++++++++++++++++++++++++++++++++++++++++++++++ //

function NotifyWarn(notifyurl, linkid, mypage) {

var width = 450;
var height = 275;
var winl = (screen.width - width) / 2;
var wint = ((screen.height - 50)- height) / 2;

winprops = 'height='+height+',width='+width+',top='+wint+',left='+winl+',scrollbars=no,noresize'

win = window.open(notifyurl + "?linkId=" + linkid, 'Warning', winprops)

if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// ++++++++++++++++++++++++++++++++++++++++++ //
// OPEN NEW WINDOW FOR IMAGES                 //
// ++++++++++++++++++++++++++++++++++++++++++ //

var newWindow;

function NewImgWindow(newURL, newTitle, w, h) {
var baseURL = '/js/imgwindow.html?';
baseURL += escape(newURL);
baseURL += "&" + escape(newTitle);

var winLeft = (screen.width - w) / 2;
var winTop = ((screen.height - 50)- h) / 2;

if(newWindow && !newWindow.closed) {
newWindow.close();
}

newWindow = window.open(baseURL,'imgWindow','width='+w+',height='+h+',top='+winTop+',left='+winLeft+',scrollbars=no');
if (parseInt(navigator.appVersion) >= 4) { newWindow.window.focus(); }
}

// ++++++++++++++++++++++++++++++++++++++++++ //
// SPAWN EXTERNAL LINK NOTICE WINDOW          //
// ++++++++++++++++++++++++++++++++++++++++++ //

function extern(mypage) {
var w = 500;
var h = 350;
var winl = (screen.width - w) / 2;
var wint = ((screen.height - 50)- h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars=no,noresize'
win = window.open(mypage, 'extern', winprops)
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}

// sample link:
//<a href="http://kinderen.kennisnet.nl/extern.html?theLink=http://www.omroep.nl" onClick="extern(this.href);return false;">