// JavaScript Document
function fireCommand(formname, command, commandId) 
{	
	eval('document.'+formname+'.fldCommand.value=command');
	eval('document.'+formname+'.fldCommandId.value=commandId');
	eval('document.'+formname+'.submit()');
}


function validate(formname, command, commandId)
{
	var formerror = false;
	
	var inputs = Array();
	var tempinputs = document.getElementsByTagName('input');
	
	var textareas = Array();
	var temptextareas = document.getElementsByTagName('textarea');
		
	for (i in tempinputs) 
	{
		inputs[i] = tempinputs[i];
	}
		
	// validate input fields
	for (i in inputs) 
	{
		if (inputs[i].type == 'text')
		{
			if (inputs[i].style.display != 'none')
			{ 
				var tempClassName = inputs[i].className.substring(0, 8);
				if (tempClassName == "validate")
				{
					inputs[i].onkeydown = function ()
					{
						this.style.border = '1px solid #e9cbd5'; 	// default bordercolor
						document.getElementById(inputs[i].name + "_errormsg").style.display="none";
						
					}
					
					var expr = eval(inputs[i].className.substring(9, inputs[i].className.length));
					var val  = inputs[i].value;
					
					if((val.search(expr))==-1)
					{
						inputs[i].style.border = '1px solid #f00000';	// error bordercolor
						inputs[i].select(); 	<!-- this throws harmless firefox error (bug) -->
					//	inputs[i].focus(); 		<!-- this throws harmless firefox error (bug) -->
					
						document.getElementById(inputs[i].name + "_errormsg").style.display="block";
						
						formerror = true;
					}
				}
			}
		}
	}
	
	
	for (j in temptextareas) 
	{
		textareas[j] = temptextareas[j];
	}
		
	for (j in textareas) 
	{
		if (textareas[j].type == 'textarea')
		{
			if (textareas[j].style.display != 'none')
			{ 
				var tempClassName = textareas[j].className.substring(0, 8);
				if (tempClassName == "validate")
				{
					textareas[j].onkeydown = function ()
					{
						this.style.border = '1px solid #e9cbd5'; 	// default bordercolor
						document.getElementById(textareas[j].name + "_errormsg").style.display="none";
					}
					
					var expr = eval(textareas[j].className.substring(9, textareas[j].className.length));
					var val  = textareas[j].value;
					
					if((val.search(expr))==-1)
					{
						textareas[j].style.border = '1px solid #f00000';	// error bordercolor
						textareas[j].select(); 	<!-- this throws harmless firefox error (bug) -->
					//	textareas[j].focus(); 		<!-- this throws harmless firefox error (bug) -->
					
						document.getElementById(textareas[j].name + "_errormsg").style.display="block";
						
						formerror = true;
					}
				}
			}
		}
		
	}
	
	eval('document.'+formname+'.fldCommand.value=command');
	eval('document.'+formname+'.fldCommandId.value=commandId');
	
	// send
	if (formerror == false)
	{
		eval('document.'+formname+'.submit()');
	} 
	else 
	{
		document.getElementById('alertbox').style.display = 'block';
		//alert ('Niet alle velden zijn correct ingevuld!');
	} 
}