﻿// JScript File

function clickWisselAssortiment()
{
    document.getElementById("divWisselAssortiment").style.display = "block";
	document.getElementById("divAssortiment").style.display = "none";
	$(".buttonAssortiment").removeClass("activeAssortiment");
	$(".buttonWissel").addClass("activeWissel");
}
	    
function clickAssortiment()
{
	document.getElementById("divAssortiment").style.display = "block";
    document.getElementById("divWisselAssortiment").style.display = "none";
	$(".buttonAssortiment").addClass("activeAssortiment");
	$(".buttonWissel").removeClass("activeWissel");
}

function validate(formname1, command1, commandId1)
{
    var formname = formname1;
    var command = command1; 
    var commandId = commandId1;
	var formerror = false;
	var inputs = Array();
	var tempinputs = document.getElementsByTagName('input');
    var sDivName;
    
	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 #cf8fbb'; 	// default bordercolor
						sDivName = "div_"+this.name;
					    document.getElementById(sDivName).innerHTML = "";
					}
					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 #ff0000';	// error bordercolor
						inputs[i].select(); 	<!-- this throws harmless firefox error (bug) -->
					//	inputs[i].focus(); 		<!-- this throws harmless firefox error (bug) -->
					    sDivName = "div_"+inputs[i].name;
					    document.getElementById(sDivName).innerHTML = "Dit veld is verplicht of het ingevoerde is niet correct.";
					    
						formerror = true;
					}
				}
			}
		}
	}
	
	// send
	if (formerror == false)
	{
	    //alert('send='+formname+' com'+command+' id'+commandId);
	    eval('document.'+formname+'.fldCommand.value=command');
		eval('document.'+formname+'.fldCommandId.value=commandId');
		eval('document.'+formname+'.submit()');
	   // this.fireCommand(formname, command, commandId);
	} 
	else 
	{
		alert ('Niet alle velden zijn correct ingevuld!  Vul alle rode velden in.');
	} 
}

function fireCommand(formname, command, commandId)
{
		eval('document.'+formname+'.fldCommand.value=command');
		eval('document.'+formname+'.fldCommandId.value=commandId');
		eval('document.'+formname+'.submit()');
}
