function openPopup(url, left, top, width, height, name, extra)
{
  if(top == '-1')
  {
    top = (0.5 * screen.availHeight) - (0.5 * height);
  }
  if(left == '-1')
  {
    left = (0.5 * screen.availWidth) - (0.5 * width); 
  }
  optionStr="toolbar=no,location=no,directories=no,status=no,menubar=no";
  if(extra=="resize")
  {
    optionStr+=",scrollbars=yes,resizable=yes";
  }
  else
  {
    optionStr+=",scrollbars=no,resizable=no";
  }
  optionStr+=",width="+width+",height="+height+",top="+top+",left="+left;
  if(name)
  {
    // OW 20070531: Verwijder elementen die niet in een pop-up titel horen volgens IE:
    // Definieer reguliere expressie:
	var re = new RegExp( '[ \t\r\n\W.-]' ,'g');
    // Vervang matches. met een underscore
	name = name.replace(re,"_");

    // open nu het venster:
        targ=window.open (url, name, optionStr);

  }
  else
  {
    targ=window.open (url, "", optionStr);
  }
  targ.focus();
}


var externalLinks = function() {
	$$('a').each(function (link) {
		if ( link.href.indexOf('www.mijnpve.nl') > -1 ) 
		{
			link.target=link.target;
		}
		else if ((link.href.indexOf(document.domain) < 0 && (link.href.indexOf('http://') > -1 || link.href.indexOf('https://') > -1)) || (link.href.indexOf('.pdf') > -1 || link.href.indexOf('.doc') > -1) ) {
			link.target = '_blank';
		}
                if(link.rel == 'external')
                {
                  link.target='_blank';
                }
	});
	$$('.article a').each(function (link) {
		if ((link.href.indexOf(document.domain) < 0 && (link.href.indexOf('http://') > -1 || link.href.indexOf('https://') > -1)) || (link.href.indexOf('.pdf') > -1 || link.href.indexOf('.doc') > -1) ) {

			/* wijzig alleen de classname voor links wiens inhoud alleen bestaat uit text   */
			var isImageLink = false;

			for (var i=0; i<link.childNodes.length; i++)
			{
				if (link.childNodes[i].nodeType != 3) isImageLink = true;
			}
			if (isImageLink == false)
			{
				link.className += ' external';
				link.title += ' (opent in een nieuw venster)';
			}
		}
	});
}



/* alleen voor A-Z? */
function removeAnchors() {
	$$('#letter-nav a').addEvent('domready', function () {
		if (!$('anker-'+this.id.charAt(7))) {
			this.parentNode.insertBefore(document.createTextNode(this.id.charAt(7)), this);
			this.parentNode.removeChild(this);
		}
	});
}



window.addEvent('domready', function() { externalLinks(); removeAnchors(); new SmoothScroll(); });
window.addEvent('domready', function () {
  if($('moduleWrapper') && $('nav'))
  {
    modCo = $('moduleWrapper').getCoordinates();
    navCo = $('nav').getCoordinates();
    if($('sectorNav'))
    {
      navCo = $('sectorNav').getCoordinates();
    }
    if((navCo.height + 100) > modCo.height)
    {
      $E('div.article','moduleWrapper').setStyle('height', navCo.height);
    }
  }
});

var sidebarHeight = function() {
  var coordinates = $('pageWrapper').getCoordinates();
  $('right').setStyle('height', coordinates.height - 87);
}

window.addEvent('domready', function() {sidebarHeight();});





 