function positionBox(box) {
	bWidth = box.getStyle('width').toInt();
	bHeight = box.getStyle('height').toInt();
	box.style.left = ((getWidth() / 2) - (bWidth / 2)) + 'px';
	box.style.top = ((getHeight() / 2) - (bHeight / 2)) + getScrollTop() + 'px';
}

function keepbox() {
	fx.start({
		'top': ((getHeight() / 2) - (bHeight / 2)) + getScrollTop(),
		'left': ((getWidth() / 2) - (bWidth / 2))
	})
	//theBox.style.top = ((getHeight() / 2) - (bHeight / 2)) + getScrollTop() + 'px';
	theKeeper=setTimeout('keepbox()', 100 );
}

function openMask(boxID) {
	corrIE = 0;			
	var theMask = $('mask');
	theBox = $(boxID);
	theMask.style.display = 'block';
	if (!window.XMLHttpRequest) {
		corrIE = 25;
	}
	theMask.style.height = getScrollHeight() + 'px';
	theBox.style.visibility = 'hidden';
	theBox.style.display = 'block';			
	//fx = theBox.effects({duration: 1000, transition: Fx.Transitions.Quart.easeOut});

	fx = new Fx.Morph(theBox, {
		duration: 500,
		wait: false,
		transition: Fx.Transitions.Quad.easeOut
	});

	var bHeight = theBox.getStyle('height').toInt() - corrIE;
	positionBox(theBox);
	theBox.style.overflow	= 'hidden';
	theBox.style.width 		= '0px';
	theBox.style.height 	= '0px';
	theBox.style.visibility = 'visible';
	//alert(fx.bHeight);
	fx.start({
		'height': bHeight,
		'width': 370
	}).chain(function() {
		keepbox();
	});
	return false;
}

function closeMask(id) {
	clearTimeout(theKeeper);
	fx.start({
		'height': 0,
		'width': 0
	}).chain(function() {
		$(id).style.display = 'none'
		$('mask').style.display = 'none'
		this.start({
			'height': bHeight,
			'width': bWidth
		});
	});
}

function openCloseMask(id1,id2) {
	clearTimeout(theKeeper);
	fx.start({
		'height': 0,
		'width': 0
	}).chain(function() {
		$(id1).style.display = 'none'
		$('mask').style.display = 'none'
		this.start({
			'height': bHeight,
			'width': bWidth
		});
	}).chain(function() {
		openMask(id2);
	});
}



function getLogin( form )
{	
	var theUserNameLog		= form.theUserNameLog.value;
	var thePassWordLog		= form.thePassWordLog.value;
	
	var req = new Request.HTML({
		method			: 'post',
		url				: '/ajax/login.php',
		data			: { 'theUserNameLog' : theUserNameLog, 'thePassWordLog' : thePassWordLog },
		update			: $('login_result'),
		onComplete		: function(response) { 
			// alert(response);
		}
	}).send();
	return false;
}


function zoekGerechten(form)
{
	var val = form.zoekterm.value;
	
	var req = new Request.HTML({
		method			: 'post',
		url				: '/ajax/zoekgerechten.php',
		data			: { 'zoekterm' : val },
		update			: $('zoekresultaat'),
		onComplete		: function(response) { 
/* 			alert(response); */
		}
	}).send();
	return false;
}

function toggle_visibility(id) {
   if (document.getElementById('alfA') != null) document.getElementById('alfA').style.display='none';
   if (document.getElementById('alfB') != null) document.getElementById('alfB').style.display='none';
   if (document.getElementById('alfC') != null) document.getElementById('alfC').style.display='none';
   if (document.getElementById('alfD') != null) document.getElementById('alfD').style.display='none';
   if (document.getElementById('alfE') != null) document.getElementById('alfE').style.display='none';
   if (document.getElementById('alfF') != null) document.getElementById('alfF').style.display='none';
   if (document.getElementById('alfG') != null) document.getElementById('alfG').style.display='none';
   if (document.getElementById('alfH') != null) document.getElementById('alfH').style.display='none';
   if (document.getElementById('alfI') != null) document.getElementById('alfI').style.display='none';
   if (document.getElementById('alfJ') != null) document.getElementById('alfJ').style.display='none';
   if (document.getElementById('alfK') != null) document.getElementById('alfK').style.display='none';
   if (document.getElementById('alfL') != null) document.getElementById('alfL').style.display='none';
   if (document.getElementById('alfM') != null) document.getElementById('alfM').style.display='none';
   if (document.getElementById('alfN') != null) document.getElementById('alfN').style.display='none';
   if (document.getElementById('alfO') != null) document.getElementById('alfO').style.display='none';
   if (document.getElementById('alfP') != null) document.getElementById('alfP').style.display='none';
   if (document.getElementById('alfQ') != null) document.getElementById('alfQ').style.display='none';
   if (document.getElementById('alfR') != null) document.getElementById('alfR').style.display='none';
   if (document.getElementById('alfS') != null) document.getElementById('alfS').style.display='none';
   if (document.getElementById('alfT') != null) document.getElementById('alfT').style.display='none';
   if (document.getElementById('alfU') != null) document.getElementById('alfU').style.display='none';
   if (document.getElementById('alfV') != null) document.getElementById('alfV').style.display='none';
   if (document.getElementById('alfW') != null) document.getElementById('alfW').style.display='none';
   if (document.getElementById('alfX') != null) document.getElementById('alfX').style.display='none';
   if (document.getElementById('alfY') != null) document.getElementById('alfY').style.display='none';
   if (document.getElementById('alfZ') != null) document.getElementById('alfZ').style.display='none';
   
   var e = document.getElementById(id);
   
   if (e != null) {
	   if(e.style.display == 'block')
	      e.style.display = 'none';
	   else
	      e.style.display = 'block';
   }
}

