var main_div = "";
var webshop = false;
var org_bottom = 0;
var grow_height = 0;
var _correction = 0;

windowOnload = function(){
	setContent();
	if ($('#gallery').length ) {
		$(function() {
			$('#gallery a').lightBox();
		});
	}
}


function setContent(){
	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;
	var gewenst_hoogte_content = document.getElementById(main_div).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'){
			_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';
			}
		}
	}
}

//if (document.getElementById("gallery") != null){

//} else {
//	window.alert('tt');
//}

$("#pageflip").hover(function() { //On hover...
	$("#pageflip img , .msg_block").stop()
		.animate({ //Animate and expand the image and the msg_block (Width + height)
			width: '307px',
			height: '319px'
		}, 500);
	} , function() {
	$("#pageflip img").stop() //On hover out, go back to original size 50x52
		.animate({
			width: '50px',
			height: '52px'
		}, 220);
	$(".msg_block").stop() //On hover out, go back to original size 50x50
		.animate({
			width: '50px',
			height: '50px'
		}, 200); //Note this one retracts a bit faster (to prevent glitching in IE)
});
