function divHoogte()
{
	var inthoogtebalk;
	// we moeten bepalen of we in de webshop zitten, ivm andere hoogte top menu.
	if (pageInWebShop(document.location.href)) {
		inthoogtebalk = 210;
	} else {
		inthoogtebalk = 186;
	}	
	var intDivHoogte;

	if (document.compatMode == "CSS1Compat")
		intDivHoogte = document.documentElement.clientHeight - inthoogtebalk;
	else
		intDivHoogte = document.body.clientHeight - inthoogtebalk;
		
	obj = document.getElementById("main");
	if (obj) {
	    obj.style.height = intDivHoogte + "px";
	}
}


function pageInWebShop(url) {
	var lowerUrl = url.toLowerCase();
	return (lowerUrl.indexOf("webwinkel") != -1 || lowerUrl.indexOf("webshop") != -1);
}

function zoek(objTextbox, objEvent, zoekType) {
	if (objEvent.keyCode == 13) {
		return zoek_click(objTextbox, objEvent, zoekType)
	}
	return true;
}

function zoek_click(objTextbox, objEvent, zoekType) {
	var strKeyword = objTextbox.value;
	if (strKeyword.length > 0) {
	    if (zoekType != null) {
	        switch(zoekType) {
	            //zoeken
	            case 1: 
	                document.location = '/Zoeken.aspx?keyword=' + escape(strKeyword);    
	                break;  
	            //recept zoeken
	            case 2: 
	                // schema id hard coded, also hard coded in zoeken control
	                document.location = '/Zoeken.aspx?keyword=' + escape(strKeyword) + '&schemaid=4B4AC427-55F9-41DD-9025-553961625207';    
	                break;
	            default: 
	                break;
	        }
	    } else {
	        document.location = '/Zoeken.aspx?keyword=' + escape(strKeyword);    
	    }
	}
	return false; 
}

function resizeIFrameToMaxHeight(_sFrame) {
	aIframe = document.getElementById(_sFrame);
	if (aIframe != null) {
		if (document.compatMode == "CSS1Compat")
			aIframe.style.height = document.documentElement.clientHeight + 'px';
		else
			aIframe.style.height = document.body.clientHeight + 'px';		
		divHoogte();
	}
}

function resizeIFrameToHeight(_sFrame, _iHeight) {
	aIframe = document.getElementById(_sFrame);
	if (aIframe != null) {		
		aIframe.style.height = (_iHeight + 20) + 'px';
		//divHoogte();
	}
}


function resizeIframe(_sName) {
	var parentWin = window.parent;
	if (parentWin != null) {
		var parentFrames =  parentWin.frames;
		//alert(parentWin)
		if (parentFrames != null) {
			var framesCount = parentFrames.length;
			if (framesCount > 0) {
				parent.resizeIFrameToHeight(_sName, 10, false);
			
			
				var iHeight = document.body.scrollHeight;
					
				/*	alert('resizeIframe: document.compatMode: ' + document.compatMode);
					alert('resizeIframe: document.documentElement.scrollHeight:' + document.documentElement.scrollHeight);
					alert('resizeIframe: document.body.scrollHeight:' + document.body.scrollHeight);
					alert('resizeIframe: document.body.scrollHeight:' + document.body.scrollHeight); 
					alert('resizeIframe: document.body.clientHeight:' + document.body.clientHeight); 
					alert('resizeIframe: document.body.offsetHeight:' + document.body.offsetHeight); 
					*/
				parent.resizeIFrameToHeight(_sName, iHeight, true);
			}
		}
	}
}


function printIframe()
{
iframe.focus();
iframe.print();
}

function showL(lyr) {
	var objDiv = document.getElementById(lyr);
	if (objDiv) {
		objDiv.style.display='block'
	}
}

function hideL(lyr) {
	var objDiv = document.getElementById(lyr);
	if (objDiv) {
		document.getElementById(lyr).style.display='none'
	}
}

function toggleL(lyr) {
	var objDiv = document.getElementById(lyr);
	if (objDiv) {
		if (objDiv.style.display == 'none') {
			objDiv.style.display = 'block';
		} else {
			objDiv.style.display = 'none';
		}
	}
}

function showKleurplaat(voorbeeldImg, link, openDirectlyWhenNoPreview) {
	var detailDiv = document.getElementById('kleurplaat_preview');
	
	if (detailDiv) {
		// invullen van de detail controls.
		// voorbeeld:
		var previewImage = detailDiv.getElementsByTagName('img')[0];
		previewImage.src = voorbeeldImg;
		// link naar document:
		var anchors = detailDiv.getElementsByTagName('a');
		for (idx = 0; idx < anchors.length; idx++) {
			anchors[idx].href = link;
		}		 		
	} else { 
		// detail control staat niet op de pagina.
		// we openen gewoon de link
		if (openDirectlyWhenNoPreview) {
			window.open(link);			
		}
	}
}