

function getHTTPObject() {
  var xmlhttp;
  /*@cc_on
  @if (@_jscript_version >= 5)
    try {
      xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
      try {
        xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
      } catch (E) {
        xmlhttp = false;
      }
    }
  @else
  xmlhttp = false;
  @end @*/
  if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
      xmlhttp = new XMLHttpRequest();
    } catch (e) {
      xmlhttp = false;
    }
  }
  return xmlhttp;
}



var http = getHTTPObject(); // We create the HTTP Object


function handleHttpResponse() 
{
  if (http.readyState == 4)
  {
    if ((http.responseText.indexOf("<!--1-->") == 1) || (http.responseText.indexOf("Error") == 0))
    {
      document.getElementById("zoekresultatencontainer").innerHTML = http.responseText;
      setTimeout("doHttpRequest(searchRequestUrl);", 1000);
    }
    else 
    {
      window.location.href = searchURL;
    }
  }
}

function doHttpRequest(url) 
{
  http.open("GET", url, true);
  http.onreadystatechange = handleHttpResponse;
  http.send(null);
}

function initSearch (url)
{
  searchRequestUrl = url;
  setTimeout("doHttpRequest(searchRequestUrl)", 1000);
}

var searchRequestUrl = "";

var sectorToContext = new Array();
sectorToContext[sectorToContext.length] = ["xiMsHsuOpbPREgBpB", "gfMsHsuOpbPRED"];sectorToContext[sectorToContext.length] = ["yiMsHsuOpbPREgBnB", "nfMsHsuOpbPREC"];sectorToContext[sectorToContext.length] = ["ziMsHsuOpbPREgBlB", "qfMsHsuOpbPREM"];sectorToContext[sectorToContext.length] = ["ajMsHsuOpbPREgBjB", "pfMsHsuOpbPREQ"];sectorToContext[sectorToContext.length] = ["cjMsHsuOpbPREgBhB", "kfMsHsuOpbPREW"];sectorToContext[sectorToContext.length] = ["bjMsHsuOpbPREgBfB", "hfMsHsuOpbPREY"];sectorToContext[sectorToContext.length] = ["djMsHsuOpbPREgBdB", "ofMsHsuOpbPREaB"];sectorToContext[sectorToContext.length] = ["ejMsHsuOpbPREgBbB", "ffMsHsuOpbPREcB"];

function convertSectorToContext(elementToSet, valueToConvert) {
  for(i=0; i<sectorToContext.length; i++)
  {
    if(sectorToContext[i][0] == valueToConvert)
    {
      elementToSet.value = sectorToContext[i][1];
    }
  }
}

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();});





 