function navOver(id, isSub, fc) {

	var pf = (isSub ? '' : '_root');
	var blk = (document.getElementById('nav_item_'+id).className.substr(0, 6) == 'block_');

	document.getElementById('nav_item_'+id).className = (blk ? 'block_' : '') + 'navigation_item'+pf+'_over';
	document.getElementById('nav_label_'+id).className = (blk ? 'block_' : '') + 'navigation_label'+pf+'_over';

	if (fc) {
		var arrow = document.getElementById('nav_arrow_'+id);
		if (arrow) arrow.src = "/mod_bin/general/arrow.php?fc="+fc;
	}

}

function navOut(id, isSub, fc) {

	var pf = (isSub ? '' : '_root');
	var blk = (document.getElementById('nav_item_'+id).className.substr(0, 6) == 'block_');

	document.getElementById('nav_item_'+id).className = (blk ? 'block_' : '') + 'navigation_item'+pf;
	document.getElementById('nav_label_'+id).className = (blk ? 'block_' : '') + 'navigation_label'+pf;

	if (fc) {
		var arrow = document.getElementById('nav_arrow_'+id);
		if (arrow) arrow.src = "/mod_bin/general/arrow.php?fc="+fc;
	}

}

// Cart functions

function submit_cart(action) {
	if (action) document.frm_cart.frm_action.value = action;
	document.frm_cart.submit();
}

function empty_cart() {
	if (confirm('Weet u het zeker?')) submit_cart('clear');
}

function del_cart(id) {
	document.frm_cart.elements['prd_amt['+id+']'].value = 0;
	submit_cart('update');
}

// Werkt nu anders, zit er nog in voor bw compatibility
function print_cart() {
	window.open('/print_barcodes.php', 'print_barcodes', 'width=300,height=200,scrollbars=no,resizable=no,menubar=no,locationbar=no');
}

function print_element_content(element_id, org_id) {

	var il = document.getElementById(element_id);
	if (il) {

		var newwin = window.open('', 'element_content', 'width=500,height=500,scrollbars=yes,location=no,resizable=no,menubar=no');
		newwin.document.open();
		newwin.document.write('<html><head><link rel="stylesheet" href="/style/style.css"><link rel="stylesheet" href="/style/style.php?org_id='+org_id+'"></head><body>'+il.innerHTML+'</body></html>');
		newwin.document.close();
		newwin.print();

	}

}

var menus = new Array();
var timers = new Array();

function lomberg_init_menu(id) {

	if (typeof(id) == 'undefined' || !id) id = 'nav';
	menus[id] = document.getElementById(id);

	var li = menus[id].getElementsByTagName('li'), i = li.length;
	while (i--) {
		li[i].onmouseover = showMenu;
		li[i].onmouseout = hideMenu;
	}

	menus[id].onmouseout = timeout;
	menus[id].onmouseover = cleartimer;

}

function timeout() {
	timers[this.id] = setTimeout("hideMenus(menus['"+this.id+"'], null)", 1000);
}

function cleartimer() {

	if (timers[this.id]) {
		clearTimeout(timers[this.id]);
		timers[this.id] = null;
	}

}

function showMenu() {

	var ul = this.parentNode;
	this.className += ' hover';

	while (ul) {

		if (ul.tagName.toLowerCase() == 'ul') {
			hideMenus(ul, this);
			break;
		}

		ul = ul.parentNode;

	}

	ul = this.firstChild;
	while (ul) {

		if (ul.nodeType == 1 && ul.tagName.toLowerCase() == 'ul') {
			ul.style.display = 'block';
			ul.style.visibility = 'visible'; /* necessary for IE*/
			break;
		}

		ul = ul.nextSibling;

	}

}

function hideMenu() {
	this.className = this.className.replace('hover','');
}

function hideMenus(level, skipli) {

	var stack = [level], i = 0, li, j, el, tag;

	do {

		li = stack[i].childNodes, j = li.length;

		while (j--) {

			el = li[j];
			if (el.nodeType == 1 && el != skipli) {

				tag = el.tagName.toLowerCase();

				if (tag == 'li') {

					stack[i++] = el;

				} else if (tag == 'ul' && el.style.display == 'block') {

					stack[i++] = el;
					el.style.display = 'none';
					el.style.visibility = 'hidden'; /* necessary for IE*/

				}

			}

		}

	} while (i--);

}


function print_single_barcode(code, text, desc, name) {

	var old_abbg_barcodes = abbg_barcodes;

	abbg_barcodes = [];
	abbg_barcodes[0] = [];
	abbg_barcodes[0]['code'] = code;
	abbg_barcodes[0]['text'] = text;
	abbg_barcodes[0]['desc'] = desc;
	abbg_barcodes[0]['name'] = name;
	abbg_barcodes[0]['num'] = '1';
	abbg_post();

	abbg_barcodes = old_abbg_barcodes;

}

var active_detail = null;
function toggleDetail(prd_id) {

	if (active_detail) {
		document.body.removeChild(active_detail);
		active_detail = null;
	}

	if (prd_id) {

		active_detail = document.createElement('DIV');
		active_detail.className = 'product_layer';
		active_detail.id = 'product_detail';
		active_detail.style.display = 'none';
		document.body.appendChild(active_detail);

		center_layer('product_detail', 500, 300);
		active_detail.style.display = '';
		xmlHttp.get('/prd_detail.php?id='+prd_id, 'prd_detail');

	}

}

function xmlHttp_onReadyStateCompleted(text, id) {

	switch (id) {

		case 'prd_detail':
			if (active_detail) active_detail.innerHTML = text;
			break;

	}

}

function show_layer(id) {
	var layer = document.getElementById(id);
	if (layer) layer.style.display = '';
}
function hide_layer(id) {
	var layer = document.getElementById(id);
	if (layer) layer.style.display = 'none';
}

function center_layer(id, layer_width, layer_height) {

	var docElem = (window.document.documentElement)
					? docElem = window.document.documentElement
					: window.document.body;
	var layer = document.getElementById(id);

	if (docElem) {
		var wdw_x		= (window.pageXOffset ? window.pageXOffset : docElem.scrollLeft);
		var wdw_y		= (window.pageYOffset ? window.pageYOffset : docElem.scrollTop);

		var wdw_width	= (docElem.clientWidth ? docElem.clientWidth : docElem.innerWidth);
		var wdw_height	= (docElem.clientHeight ? docElem.clientHeight : docElem.innerHeight);

		if (layer) {
			var offset_left = ((wdw_width - layer_width) / 2) + wdw_x;
			var offset_top = ((wdw_height - layer_height) / 2) + wdw_y;

			layer.style.left = offset_left + 'px';
			layer.style.top  = offset_top + 'px';
		}
	}
}

function show_conditions() {

	center_layer('layer_conditions', 600, 400);
	show_layer('layer_conditions');

}

function vote(poll_id) {

	var frm = document.forms['form_poll_' + poll_id];
	if (frm) frm.submit();
}
