if (document.observe) document.observe("dom:loaded", function() {
  /*window.accordionMenu = new HM.Accordion('subMenu', {
    actindependant: true,
    handles: 'topItem',
    duration: 0.33
  });*/
  new HM.Accordion('subMenuSearch', {
    handles: 'topItem',
    duration: 0.33
  });

  new ProtoFish('navlist', '200', 'hover', false);

  try {
    if ($("divZoover")) $("divZoover").select("div div div").first().hide();
  } catch(e) {
  }

  if ($('ZoekenUitklap')) $(document.body).observe("click", function(event) {
    if (!Event.element(event).up("#divZoeken")) {
      $('ZoekenUitklap').hide();
    }
  }.bindAsEventListener());

  if ($('ZoekenUitklap')) $("divNavcontainer").observe("mouseover", function() {
    $('ZoekenUitklap').hide();
  });
});


function writeFlash(str) {
  document.write(str);
}
function printWindow() {
  window.print();
}

function openMap(strSrc) {
  var winMap = window.open(strSrc,'winMap','width=920,height=520,scrollbars=no,resizable=no');
  winMap.focus();
}

function swapDisplay(strObjName) {
  var obj = document.getElementById(strObjName);
  if (obj) obj.style.display = (obj.style.display == "none") ? "" : "none";
}

function isOverflowed(obj) {
  var w = obj.offsetWidth;
  var h = obj.offsetHeight;
  var overflow = obj.style.overflow;
  obj.style.overflow = "visible";
  obj.style.visibility = "hidden";
  var ow = obj.offsetWidth;
  var oh = obj.offsetHeight;
  obj.style.overflow = overflow;
  obj.style.visibility = "visible";
  return (w != ow || h != oh);
}

window.onload = function() {
  var breadcrumb_items = document.getElementById('divBreadcrumbItems');
  if (breadcrumb_items && isOverflowed(breadcrumb_items)) {
    //breadcrumb_items.innerHTML = "... " + breadcrumb_items.innerHTML;
    document.getElementById('divBreadcrumbItemsMore').style.visibility = "visible";
  }
}

function noenter() { //in aanmelden-evenement.lp
  return !(window.event && window.event.keyCode == 13); }

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' moet een geldig e-mail adres zijn.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+'.\n'; }
  } if (errors) alert('De volgende velden zijn nog niet volledig ingevuld:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateFormEN() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateFormEN.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must be an email address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+'.\n'; }
  } if (errors) alert('The following fields are required:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function myTwitterCallback(C){
  if (!$("twitter")) return;
  var A=[];for(var D=0;D<C.length;D++){
  var E=C[D].user.screen_name;
  var B=C[D].text.replace(/((https?|s?ftp|ssh)\:\/\/[^"\s\<\>]*[^.,;'">\:\s\<\>\)\]\!])/g,function(F){return'<a href="'+F+'">'+F+"</a>"}).replace(/\B@([_a-z0-9]+)/ig,function(F){return F.charAt(0)+'<a href="http://www.twitter.com/'+F.substring(1)+'">'+F.substring(1)+"</a>"});
    A.push('<p class="opsomming" style="overflow: hidden"><span>'+B+'</span><br style="clear: both" /><a style="float: right; font-size: 80%" href="http://twitter.com/'+E+"/statuses/"+C[D].id+'">'+relative_time(C[D].created_at)+'</a></p>')}
  $("twitter").update(A.join(""));
}

function relative_time(C){
  var B=C.split(" ");C=B[1]+" "+B[2]+", "+B[5]+" "+B[3];var A=Date.parse(C);var D=(arguments.length>1)?arguments[1]:new Date();var E=parseInt((D.getTime()-A)/1000);E=E+(D.getTimezoneOffset()*60);if(E<60){return"minder dan een minuut geleden"}else{if(E<120){return"ongeveer een minuut geleden"}else{if(E<(60*60)){return(parseInt(E/60)).toString()+" minuten geleden"}else{if(E<(120*60)){return"ongeveer een uur geleden"}else{if(E<(24*60*60)){return"ongeveer "+(parseInt(E/3600)).toString()+" uur geleden"}else{if(E<(48*60*60)){return"1 dag geleden"}else{return(parseInt(E/86400)).toString()+" dagen geleden"}}}}}}
};
