function volgendeVeld(resForm, strInputCurrent, intMaxChar, strInputNext)
{
	if (eval("resForm." + strInputCurrent + ".value.length >= " + intMaxChar))
	{
		eval("resForm." + strInputNext + ".focus()")
	}
}

function updateMenuCookie()
{
	var strMenuId = 'menu';
	
	var nodMenu = document.getElementById(strMenuId);
	var arrSubMenus = nodMenu.getElementsByTagName('ul');
	
	top.status = arrSubMenus.length;
}

function popupVenster(url, titel, breedte, hoogte, offset, scrollbars)
{
	window.open(url, titel, "height=" + hoogte + ",toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=" + scrollbars + ",resizable=1,width=" + breedte + ",top=" + offset + ",left=" + offset);
}

function toggleMenu(item)
{
	if (document.getElementById(item).style.display == "block")
	{
		document.getElementById(item).style.display = "none";
	}
	else
	{
		document.getElementById(item).style.display = "block";
	}
	updateMenuCookie();
}

function closeColorbox(){
	parent.$.fn.colorbox.close();
	parent.window.location.href = "/index.php?cat=bestellen&overzicht=ja";
}

if (typeof jQuery !== 'undefined') {
$(function(){

	// ColorBox
	if ($.fn.colorbox) {
//		$("#cboxClose").click(function(){ 
//			window.location.href = "/bestellijst/";
//			return false;
//		});
		
		// set html class on load & close
		$()
			.bind('cbox_load', function(){
			})
			.bind('cbox_closed', function(){
				var ref = window.location.pathname + window.location.search;
				//document.cookie = 'bestelRef=' + encodeURIComponent(ref) + '; path=/';
				window.location.href = "/index.php?cat=bestellen&overzicht=ja&ref=" + encodeURIComponent(ref);
			})
		;

		$("input.orderbutton")
			.removeAttr('disabled')
			.removeClass('submit-disabled')
			.click(function() {
				var url = "/index.php?cat=bestellen&action=add&id="+$(this).attr("id").split('-')[1]+"&a_id="+$(this).attr("id").split('-')[2]+"&e_id=";
				//var $this = $(this);
				//event_id = $this.data('event_id');
				$(".orderbutton").colorbox({resize: 'true',href:url,open:true,width:"800px", height:"90%", opacity:"0.4", iframe:true});
			})
		;
		$("input.afrekenen")
			.removeAttr('disabled')
			.removeClass('submit-disabled')
			.click(function(e) {
				var $this = $(this);
				if (confirm('Let op: verzeker uzelf ervan dat uw winkelmandje de juiste voorstellingen en kaarten bevat.\nAls u tijdens het afrekenen besluit te annuleren, wordt uw gehele winkelmandje geleegd.')) {
					window.location.href = $this.data('url'); // set in bestellen stpl
					e.preventDefault();
				//$(".afrekenen").colorbox({resize: 'true',href:$('.afrekenen').data('url'),open:true,width:"80%", height:"80%", iframe:true});
				}
			})
		;
	}
});
}