/* get_window_size()
 * Functie om de grootte van het scherm te bepalen. Niet de resolutie maar het scherm.
 * Dit is dus variabel.
 */
 
function get_window_size() {
  var myWidth = 0
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
  } else if( document.documentElement && ( document.documentElement.clientWidth) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth + 21;  /* Afwijking? */
  }
 return myWidth;
}

/* lock_website()
 * Kan worden gebruikt om de website helemaal af te schermen.
 */
function lock_website(noScroll)
{
	var lock = document.getElementById('lock_website');
	if(lock.style.display == 'none')
	{
		var content_height	= document.body.scrollHeight;
		if(content_height < document.body.clientHeight)
		{
			website_height		= document.body.clientHeight;	
		} else website_height = content_height;
		var client_width		= get_window_size();
		if(client_width > 1324)
		{
			lock.style.width	= client_width;
		}
		else
		{
			lock.style.width	= 1324;
		}
		
		hideDropdowns();

		lock.style.height		= website_height;
		lock.style.display	= '';

		if (!noScroll) {
			var scrOfX = 0, scrOfY = 0;
			if( typeof( window.pageYOffset ) == 'number' ) {
				//Netscape compliant
				scrOfY = window.pageYOffset;
				scrOfX = window.pageXOffset;
			} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
				//DOM compliant
				scrOfY = document.body.scrollTop;
				scrOfX = document.body.scrollLeft;
			} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
				//IE6 standards compliant mode
				scrOfY = document.documentElement.scrollTop;
				scrOfX = document.documentElement.scrollLeft;
			}
			if (scrOfY > 140) window.scrollTo(scrOfX,0);
		}
	}
	else
	{
		lock.style.display = 'none';
		showDropdowns();
	}
}

function getTrueHeight(element) {
	var fullheight = 0;
	var tmpheight = 0;
	for (var i = 0; i < element.childNodes.length; i++) {
		tmpheight = 0;
		if (!isNaN(element.childNodes[i].offsetHeight)) tmpheight = element.childNodes[i].offsetHeight;
		if (tmpheight < 25) tmpheight = getTrueHeight(element.childNodes[i]);
		fullheight += tmpheight;
	}
	return fullheight;
}

// event handler voor resizen van het venster
function resizedWindow() {
	// correcte plaatsing van popupcontainer
	//if (document.getElementById('popup_contact')) document.getElementById('popup_contact').style.left = (document.getElementById('space_holder').offsetLeft + 151) + 'px';
	if (document.getElementById('popup_customersupport')) document.getElementById('popup_customersupport').style.marginLeft = (document.getElementById('space_holder').offsetLeft + 151) + 'px';
	//if (document.getElementById('ideal_popup')) document.getElementById('ideal_popup').style.marginLeft = (document.getElementById('space_holder').offsetLeft + 151) + 'px';
	if (document.getElementById('CONTENT_CENTER')) {
					/* Block hoogte aanpassen  */
					var content_height = document.getElementById('CONTENT_CENTER').offsetHeight;
					if (content_height < 25) {
						// this is very small, please check all child elements to see if this is correct
						content_height = getTrueHeight(document.getElementById('CONTENT_CENTER'));
					}
					if (document.getElementById('block_right_wrapper')) {
						if (document.getElementById('block_right_wrapper').offsetHeight > (content_height + 30)) {
							content_height = document.getElementById('block_right_wrapper').offsetHeight;
						}
					}
					if(content_height + 25 > 910) //lange pagina
					{
						if (document.getElementById('blocks_right')) document.getElementById('blocks_right').style.height			= (content_height + 30) + 'px';	
						if (document.getElementById('NAVIGATION')) document.getElementById('NAVIGATION').style.height				= (content_height + 30) + 'px';
						if (document.getElementById('center_wrapper')) document.getElementById('center_wrapper').style.height		= (content_height + 30) + 'px';
							if (document.getElementById('left_space')) document.getElementById('left_space').style.height				= (content_height + 232) + 'px';
							if (document.getElementById('right_space')) document.getElementById('right_space').style.height			= (content_height + 232) + 'px';
					}
					else //korte pagina
					{
						if (document.getElementById('blocks_right')) document.getElementById('blocks_right').style.height = '930px';
						if (document.getElementById('NAVIGATION')) document.getElementById('NAVIGATION').style.height = '930px';
						if (document.getElementById('center_wrapper')) document.getElementById('center_wrapper').style.height	= '930px';
						if (document.getElementById('left_space')) document.getElementById('left_space').style.height = '1132px';
						if (document.getElementById('right_space')) document.getElementById('right_space').style.height = '1132px';
					}
	}
}


/* Functie om de scroll balk te laten zien indien het scherm niet op 100% is.
 */
function setScroll()
{
	var window_width = get_window_size();
	var screen_width = screen.width;		
	var body_el		 = document.getElementsByTagName('body')[0];
	
	if(screen_width	 > window_width)
	{
		body_el.style.overflowX = ''; 
	}
	else
	{
		body_el.style.overflowX = 'hidden'; 
		
		var scrOfX = 0, scrOfY = 0;
		if( typeof( window.pageYOffset ) == 'number' ) {
			//Netscape compliant
			scrOfY = window.pageYOffset;
			scrOfX = window.pageXOffset;
		} else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
			//DOM compliant
			scrOfY = document.body.scrollTop;
			scrOfX = document.body.scrollLeft;
		} else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
			//IE6 standards compliant mode
			scrOfY = document.documentElement.scrollTop;
			scrOfX = document.documentElement.scrollLeft;
		}
		window.scrollTo(0, scrOfY);
	} 
}

function close_message_popup()

{

	var div_el	= document.getElementsByTagName('div');



	/* Sluit eerst

	 * alle huidige popups

	 */

	for(var i = 0; i < div_el.length; i++)

	{

		/* Als 'popup' 

		 * in de class naam voorkomt

		 * moet het (meestal) element worden aangepast.

		 * Met uitzondering van de container en element id.

		 */

		 

		if(div_el[i].className.indexOf('popup') != -1)

		{

			/* Sluit alleen 

			 * de popups die open zijn.

			 */

			 

			if(div_el[i].style.display != 'none' && div_el[i].id != 'popup_container' && div_el[i].className != 'popup_product_enlarge')

			{

				div_el[i].style.display = 'none';

			}

		}

	}

	lock_website();


}

/* show_popup()

 * Laat soort van pop up zien als tabel over de website heen.

 * Is dus geen nieuw venster.

 * Heeft wel CSS nodig om te functioneren (position: absolute; z-index: 1; etc..)

 */

function show_popup(element_id)

{

	document.currentPopup = element_id;



	var popup_container	= document.getElementById('popup_container');

	var el		= document.getElementById(element_id);

	var div_el	= document.getElementsByTagName('div');

	/* Open dan eventueel een nieuwe popup

	 */

	

	if(el.style.display == 'none')

	{

		/*

		 Geef het element weer

		*/

		popup_container.style.display = '';

		el.style.display	= '';



		hideDropdowns();

	}

	else

	{

		popup_container.style.display = 'none';

		el.style.display = 'none';	



		showDropdowns();

	}

	

	/* Sluit eerst

	 * alle huidige popups

	 */

	for(var i = 0; i < div_el.length; i++)

	{

		/* Als 'popup' 

		 * in de class naam voorkomt

		 * moet het (meestal) element worden aangepast.

		 * Met uitzondering van de container en element id.

		 */

		 

		if(div_el[i].className.indexOf('popup') != -1)

		{

			/* Sluit alleen 

			 * de popups die open zijn.

			 */

			 

			if(div_el[i].style.display != 'none' && div_el[i].id != element_id && div_el[i].id != 'popup_container' && div_el[i].className != 'popup_product_enlarge')

			{

				div_el[i].style.display = 'none';

			}

		}

	}

}

function getIEVersionNumber() {

    var ua = navigator.userAgent;

    var MSIEOffset = ua.indexOf("MSIE ");

    

    if (MSIEOffset == -1) {

        return 0;

    } else {

        return parseFloat(ua.substring(MSIEOffset + 5, ua.indexOf(";", MSIEOffset)));

    }

}

// hide dropdowns if IE6 or below

function hideDropdowns() {

	if ( (navigator.appName == 'Microsoft Internet Explorer') && (getIEVersionNumber() < 7) ) {

		hideAllByTag('select');

	}

}

function showDropdowns() {

	if ( (navigator.appName == 'Microsoft Internet Explorer') && (getIEVersionNumber() < 7) ) {

		showAllByTag('select','inline');

	}

}

function showAllByTag(tagName,dispType) {

        var elements = document.getElementsByTagName(tagName);

        var i = 0;

        if (dispType == "") {

                dispType = inline;

        }

        while (i < elements.length) {

		if (elements[i].style)

	                elements[i].style.display = dispType;

                i++;

                }

}

function hideAllByTag(tagName) {

        var elements = document.getElementsByTagName(tagName);

        var i = 0;

        while (i < elements.length) {

		if (elements[i].style)

	                elements[i].style.display = "none";

                i++;

                }

}
