var insideLayer = false;

function fixCrap(){
	var dom = YAHOO.util.Dom;
		var contentHeight = dom.getRegion('content').bottom;
	dom.setStyle(document.body, "height", contentHeight+"px");

	var el = document.getElementById('menu');
	var width = dom.getViewportWidth();
	if(width > 1000){
		el.style.width = (width-164)+"px";
	}else{
		el.style.width = 836+"px";
	}

	
}

YAHOO.util.Event.on(window, "resize", fixCrap);

YAHOO.util.Event.onDOMReady(function () {
     fixCrap();       
});


function navOver(id, isSub, fc) {

	var pf = (isSub ? '' : '_root');

	document.getElementById('nav_item_'+id).className = 'navigation_item'+pf+'_over';
	document.getElementById('nav_label_'+id).className = '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');

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

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

}

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

function init_menu(id) {

	if (typeof(id) == 'undefined' || !id) id = 'nav';
	menus[id] = document.getElementById(id);
	if (menus[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 submitGZSearch(event,url) {
	if(typeof(event) != 'object' || (navigator.appName=="Netscape"?event.which:event.keyCode)==13)
		window.location.href = url + document.getElementById('search_query').value.replace(/\+/ig,"PLUS_SIGN");
	return true;
}

function sf(frmname) {
	submitForm(document.forms[frmname]);
}

function printVersion() {

	var il = document.getElementById('resource');
	if (il) {

		var wnd = window.open('about:blank', '_blank', 'width=450,height=400,location=no,menubar=no,titlebar=no,resizable=yes,scrollbars=yes');
		wnd.document.open('text/html');
		wnd.document.write('<html><link rel="stylesheet" href="/style/style.css"><link rel="stylesheet" href="/style/htmlcontrols.css" /><link rel="stylesheet" href="/style/controls.css"><body><br/><div id="content" ><div id="resource">'+il.innerHTML+'</div></div></body></html>');
		wnd.document.close();
		wnd.print();

	}

}

function confirmDeleteThread(vars, id) {

	if (confirm("Als u deze post weggooit worden ook alle bijbehorende reacties verwijderd! Doorgaan?")) {
		window.location.href += '&delete_thread=' + id;
	}

}

function generate_random(images, maxnr) {

	var banner_holder = document.getElementById('header_images');

	images.sort( randOrd );

	for (i=0; i < maxnr; i++) {

		banner = document.createElement('IMG');
		banner.setAttribute('src', '/uri/?uri='+images[i][0]);

		linkje = document.createElement('A');
		linkje.style.marginLeft = '20px';

		linkje.appendChild(banner);
		banner_holder.appendChild(linkje);
	}
}


function randOrd(a, b){
	return (Math.round(Math.random())-0.5);
}
