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

//======================== W3C compliant Popup script
function popupLauncher()
{
  if( document && document.body && document.getElementById && document.getElementsByTagName )
   {
     var alinks = document.getElementsByTagName('A');

     for( i=0; i < alinks.length; i++ )
     {
      if( alinks[i].rel == "external" )
       {
         try
         {
          alinks[i].target = "_blank";
         }
         catch(e)
          {}
       }
     }
   }
}

//======================== Check if javascript is activated.
	var newclassname = 'js-active'; 				// define class 
	var ob = document.getElementsByTagName('HTML');// get the html tag 
	if (ob.length > 0){
	  ob = ob[0];									// check if there is already a class applied to html tag
	  if (ob.className == ''){
	      ob.className = newclassname;				// if there isn't then add class
	  } else {
	     ob.className += ' ' + newclassname;		// if there is a class already present add class js-active after it
	  }
	}

//======================== Email address obfuscation
$(document).ready(function(){
	var domain = "penpoint.nl";
	var atsign = "@";
	var emailLink = $(".obfuscate")	;
		
	if (emailLink.length > 0){
		for (var i = 0; i < emailLink.length; i++) {
		var userName =  $(emailLink[i]).attr("rel");
		var linkTitle =  $(emailLink[i]).attr("title");
		var addr = userName + atsign + domain;

			if (userName.length > 0){
					if (linkTitle[i] == null || ""){
						var contacttxt = addr;
					} else {
						var contacttxt = linkTitle;
					}
			$(emailLink[i]).replaceWith("<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + contacttxt + "<\/a>");
			}
			
		}
	}

});

//======================== Homepage Carousel
$(function() {
	$("#leader").tinycarousel({interval:true, intervaltime: 8000, pager: true,
		callback: function(){
			$(".pager a").blur();
		} 
	});

});



//======================== IE6 antiflicker
try {
  document.execCommand('BackgroundImageCache', false, true);
} catch(e) {}


addLoadEvent(popupLauncher);







