window.onload = load_function;

var pages;
var currentpage;

function load_function() {
	dynamic_height();
}

function obj_height(id) {
	return(document.getElementById(id).offsetHeight);
}

function use(id) {
	return(document.getElementById(id));
}

function dynamic_height() {
	var submenu_height;

	if (use('submenu') != null) {
		submenu_height = obj_height('submenu');
	} else {
		submenu_height = 0;
	}

	if (use('content') != null) {
		content_height = obj_height('content');
	} else {
		content_height = 0;
	}

	if (use('pictures') != null) {
		pictures_height = obj_height('pictures');
	} else {
		pictures_height = 0;
	}


	var highest = Math.max(submenu_height, (content_height+221), (pictures_height)+221);
	use('container').style.height = highest + "px";
}

function next_page() {
	var x = currentpage+1;

	if(x > pages) {
		x = 1;
	}

	use('menu_3_layer_' + currentpage).style.display = 'none';
	use('menu_3_layer_' + x).style.display = 'block';

	currentpage = x;
}

function previous_page() {
	var x = currentpage-1;

	if(x < 1) {
		x = pages;
	}

	use('menu_3_layer_' + currentpage).style.display = 'none';
	use('menu_3_layer_' + x).style.display = 'block';

	currentpage = x;
}

function show() {
	var x = currentpage;

	use('menu_3_layer_' + currentpage).style.display = 'none';
	use('menu_3_layer_' + x).style.display = 'block';
}

function update_hover(txt) {
	use('short_info').innerHTML = txt;
}

function toggle(id) {
	if(use('submenu_p_' + id).style.display != 'block') {
		//display: none
		use('submenu_p_' + id).style.display = 'block';
		use('btnSub_' + id).innerHTML = "<b>-</b>";
		use('submenu_p_bottom_' +id).style.display = 'block';
	} else {
		//display: block
		use('submenu_p_' + id).style.display = 'none';
		use('btnSub_' + id).innerHTML = "<b>+</b>";
		use('submenu_p_bottom_' +id).style.display = 'none';
	}
}

function flip_img(id, omschrijving) {
	use('fotos_afbeelding').src = "images/afbeelding.php?id="+ id + "&type=grootformaat";
	use('fotos_beschrijving').innerHTML = omschrijving;
}