	function windowOnload(){
		//window.alert('Go');
		if(main_div.length) setContent();
		if ($('#gallery').length ) {
			$(function() {
				$('#gallery a').lightBox();
			});
		}
	}

	function setContent(){
	
		// CONTENT
		var offset			= $('#content').offset();
		var height			= $('#content').height();
		
		var content			= {};
			content.height  = height;
			content.bottom	= offset.top + height;
				
		// FOOTER
		var offset			= $('#bottom').offset();
		
		var footer			= {};
			footer.top		= offset.top;
		
		// VERSCHIL
		var _correctie		= _correctie||0;
		var org_bottom		= org_bottom||0;
		
		var cnt_max = 0;
		$('#hoofd div').each(function(index){
			switch($(this).attr('id')) {
			case 'header':
			case 'content':
			case 'bottom':
				// skipp
				break;
			default:
				var offset 			= $(this).offset();
				var height 			= $(this).height() + offset.top;
				if(offset.top<footer.top) {
				cnt_max				= (height>cnt_max?height:cnt_max);
				}
			}
		});
		
		// producten in txt element
		$('.txt div').each(function(index){
			// alleen als parent txt top < footer.top
			if($(this).parent().offset().top<footer.top) {
				var offset 			= $(this).offset();
				var height 			= $(this).height() + offset.top;
				cnt_max				= (height>cnt_max?height:cnt_max);
			}
		});
		
		var verschil		= cnt_max - footer.top + _correctie;
		
		if(verschil>0) {
			verschil += 20; // ruimte tussen main en footer
			
			// increase content height
			$('#content').css('height',content.height + verschil);
			
			$('#hoofd div').each(function(index){
				var className = $(this).attr('class');
				switch(className) {
					case 'static':
					case 'stxt':
					case 'stat':
					case 'imgs':
					case 'simg':
					case 'show':
						// DIV
						var offset 			= $(this).offset();
						var div				= {};
							div.top			= offset.top;
		
						// 100 == fix voor kruisweg
						if((div.top+100)>footer.top) {
						$(this).css('top',div.top + verschil);
						}
						
						break;
					default:
						// nothing
				}
			});
		}
	}

function setContent2(){
	var hoofdhoogte = document.getElementById('header').clientHeight;;
	var contenthoogte = document.getElementById('content').clientHeight;
	var bottomheight = document.getElementById('bottom').clientHeight;
	var bottom_start_old = document.getElementById('bottom').offsetTop;
	var bottom_start_old2 = document.getElementById('bottom').style.top;
	var cathoogte = 0;

	if(document.getElementById('cat') != null){
		cathoogte = document.getElementById('cat').clientHeight;
	}

	var content_start = document.getElementById('content').offsetTop;
	var oldTotlaal = content_start + contenthoogte;

	if(oldTotlaal > org_bottom){
		min_terug = bottom_start_old - org_bottom;
	} else {
		min_terug = 0;
	}

	var verschil = 0;
	
	/**
	 * Firefox fix.
	 * When there is no overflow, then there are no scrollbars and there is no scrollheight.
	 * Chrome and Explorer calculate it nontheless, Firefox doesn't. 
	 * This is correct behaviour, but they could've let this one slide
	 * */
	var e = document.getElementById(main_div);
		e.style.overflow = "scroll"; 
	var scrollHeight = e.scrollHeight; 
		e.style.overflow = "hidden"; 
	
	var gewenst_hoogte_content = scrollHeight;

	if(cathoogte > gewenst_hoogte_content){
		gewenst_hoogte_content = cathoogte;
	}
	gewenst_hoogte_content = gewenst_hoogte_content + document.getElementById(main_div).offsetTop;
	gewenst_hoogte_content = gewenst_hoogte_content - hoofdhoogte;

	if(document.getElementById('cat_inhoud') != null){
		if(document.getElementById('cat_inhoud').clientHeight > gewenst_hoogte_content){
			gewenst_hoogte_content = document.getElementById('cat_inhoud').clientHeight;
		}
	}
	if(document.getElementById('checkout_form') != null){
		//window.alert(document.getElementById('checkout_form').scrollHeight);
		if(document.getElementById('checkout_form').scrollHeight > (gewenst_hoogte_content - 50)){
			gewenst_hoogte_content = document.getElementById('checkout_form').scrollHeight + 50;
		}
		//window.alert(gewenst_hoogte_content);
	}
	if(grow_height > gewenst_hoogte_content) { gewenst_hoogte_content = grow_height; }
	verschil = gewenst_hoogte_content - contenthoogte;
	document.getElementById('content').style.height = gewenst_hoogte_content + 'px';

	document.getElementById(main_div).style.overflow = 'visible';

	var bottom_start = document.getElementById('bottom').offsetTop;
	array_dom = document.getElementById('hoofd').childNodes;

	for(i = 0; i < array_dom.length; i++){
		if(array_dom[i].className == 'static' || array_dom[i].className == 'stxt' || array_dom[i].className == 'stat' || array_dom[i].className == 'imgs' || array_dom[i].className == 'simg' || array_dom[i].className == 'show'){
			_startx = array_dom[i].offsetLeft;
			_starty = array_dom[i].offsetTop;
			_height = array_dom[i].clientHeight;
			_totalstart = _starty + _height;

			if((_totalstart > bottom_start_old) && (verschil > 0)){
				if(grow_height > 100){
					array_dom[i].style.top = oldTotlaal + ( _starty + _correction + verschil - min_terug) + 'px';
				} else {
					array_dom[i].style.top = oldTotlaal + ( _starty + _correction + verschil - min_terug) + 'px';
				}
			}
		} else {
			if(typeof(array_dom[i].id) != 'undefined' && array_dom[i].className != 'txt'){
				//array_dom[i].style.overflow = 'hidden';
			}
		}
	}
}

function qSearchVoordeel(){
	var qstr = "";
	qstr = qstr + document.q_zoeken.kleur.value + "_";  
	qstr = qstr + document.q_zoeken.prijs.value + "_";
	qstr = qstr + document.q_zoeken.materiaal.value + "_";
	qstr = qstr + document.q_zoeken.afmetingen.value + "_";
	window.location.href = '/qzoeken/1/' + qstr; 
}

function makePrijs(){
		phpNaarDiv('prijs_gadgets','/action/custom/gadgetsMakePrijs.php',false,'&id1='+document.getElementById('pro1').value+'&id2=' + +document.getElementById('pro2').value);
}

function showAflever(){
	document.getElementById('afleverDiv1').style.display = 'block';
	phpNaarDiv('afleverDiv1','/action/databases/ajax.afleveradres.php',false,''); 
}
function veranderTekst(){ 
	document.getElementById('aflevertekst').innerHTML = "<a href=\"javascript:phpNaarDiv('afleverDiv1','/action/databases/ajax.afleveradres.php',false,'&verberg=J');\" >Geen afleveradres >></a>";
}
function copyFactuur(){
	document.getElementById('afl_anaam').value = document.checkout_form.anaam.value; 
	document.getElementById('afl_vnaam').value = document.checkout_form.vnaam.value;
	document.getElementById('afl_adres').value = document.checkout_form.adres.value;
	document.getElementById('afl_nummer').value = document.checkout_form.nummer.value;
	document.getElementById('afl_letters').value = document.checkout_form.letters.value;
	document.getElementById('afl_postcode').value = document.checkout_form.postcode.value;
	document.getElementById('afl_woonplaats').value = document.checkout_form.woonplaats.value;
}
function doLogin(){
	document.checkout_form.action.value = 'login_now'; 
	postForm(document.checkout_form,'checkout_form','checkout_div','/action/databases/ajax.checkout3.php');

}		
function doVergeten(){
	document.checkout_form.action.value = 'vergeten'; 
	postForm(document.checkout_form,'checkout_form','checkout_div','/action/databases/ajax.checkout3.php');

	}
function doLogin2(){
	document.checkout_form.action.value = 'mijn-account-login'; 
	postForm(document.checkout_form,'checkout_form','checkout_div','/action/databases/ajax.checkout3.php');

	}
function checkAlgemeneVoorwaarden(){
	if(document.getElementById('nieuwsbrief') == null){
		phpNaarDiv('checkout_div','/action/databases/ajax.checkout3.php',false,'&action=update_form&go_to=3');
	} else {
		if(document.getElementById('nieuwsbrief').checked == true){
			//window.alert('nieuwsbrief');
			phpNaarDiv('checkout_div','/action/databases/ajax.checkout3.php',false,'&action=update_form&go_to=3&nb=' + document.getElementById('nieuwsbrief').value);
		} else {
			phpNaarDiv('checkout_div','/action/databases/ajax.checkout3.php',false,'&action=update_form&go_to=3');
		}
	}
}  
function loadAdd(){
	document.getElementById('inhoudLight').style.width = 620 + 'px';
	document.getElementById('contentLight').style.width = 620 + 'px';
	document.getElementById('inhoudLight').style.height = 150 + 'px';
	document.getElementById('contentLight').style.height = 170 + 'px';

	phpNaarDiv('contentLight','/action/ajax.loadVoordeel.php',false,'&divNaam=contentLight');
	document.getElementById('headerLight').innerHTML = '&nbsp;';
	loadLight(); 
	centerPopup();
}
function loadCheckout(){
    //window.alert('Go'); 
	document.getElementById('inhoudLight').style.width = 820 + 'px';
	document.getElementById('contentLight').style.width = 820 + 'px';
	document.getElementById('inhoudLight').style.height = 680 + 'px';
	document.getElementById('contentLight').style.height = 680 + 'px';

	
	document.getElementById('headerLight').innerHTML = '&nbsp;';
	loadLight(); 
	centerPopup();
	setTimeout("phpNaarDiv('contentLight','/action/databases/ajax.loadcheckout.php',false,'');",1000);
}
function replaceT(obj){
	var newO=document.createElement('input');
	newO.setAttribute('type','password');
	newO.setAttribute('name',obj.getAttribute('name'));
	newO.setAttribute('id',obj.getAttribute('id'));
	obj.parentNode.replaceChild(newO,obj);
	//setTimeout("newO.focus();",100);
	setTimeout("document.getElementById('pass1').focus();",100);
	//$('#pass1').focus();
}
