var valid = new Boolean();

function checkForm(maxStep, nextStep, wizStep)
{
	var f = document.forms["stdForm"];
	var errMsg = "";
	var step = parseInt(wizStep+nextStep,10);

	valid = true;

	switch (step)
	{
		case 1:
		{
			if (!f.main.value)
			{
				valid = false;
				errMsg += '> Main selection';
				f.main.focus();
			}
			break;
		}
		case 2:
		{
			if (!f.group.value)
			{
				valid = false;
				errMsg += '> Anntenna group';
				f.group.focus();
			}
			break;
		}
		case 3:
		{
			if (!f.catgy.value)
			{
				valid = false;
				errMsg += '> Antenna family';
				f.catgy.focus();
			}
			break;
		}
	}

	if (valid == false)
	{
		// show error message
		alert("\n\n" + errMsg);
	}
	else
	{
		// submit the form
		if (step < maxStep)
		{
			f.action = '';
		}

		if (step == maxStep)
		{
			f.applied.value = 1;
			f.selected.value = 1;
		}

		if (f.area && nextStep < 0)
		{
			f.area.value = null;
		}

		f.wizard.value = parseInt(f.wizard.value,10) + parseInt(nextStep,10);
		f.wizardNav.value = parseInt(nextStep,10);

		f.submit();
	}

}

function keyHandler(evt)
{
    if (parseInt(navigator.appVersion) >= 4)
	{
        if (navigator.appName == 'Netscape')
		{
            if (evt.which == 13)
			{
				return checkForm('');
			}
		}
		else
		{
            if (window.event.keyCode == 13)
			{
				return checkForm('');
			}
		}
	}
}

/* check for digits within input elements */
function checkDigitFields(actField, errMsg)
{
	var err_digit = "Only digits allowed\n";
	var checkDigits = /^[0-9\.]{1,}$/i;

	if (actField.value.length > 0 && !checkDigits.test(actField.value))
	{
		valid = false; 
		actField.value = '';
		actField.focus();
		return '> ' + errMsg + ': ' + err_digit;
	}
	else
	{
		return '';
	}
}

/* Closes the popup window if opened */
function closePopUpWindow()
{
	if (popUpWin)
	{
		popUpWin.close();
	}

	return true;
}
