function isDigit(strNum)
{
	return /^\-?\d+(\.\d+)?$/.test(strNum);
}

function checkEmail(strEmail)
{
	return /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})$/.test(strEmail);
}

//======= Validate Form Inputs ====================

var type_1 = "Null";
var type_2 = "Mail";
var type_3 = "Digit";
var type_4 = "NotZero";

function validateForm( theForm ) {

strErrorList = ":יש להזין/לתקן את השדות הבאים\n" + "-------------------------------\n";
strFocusField = "";

for ( f = 0; f < formElements.length; f++ )
{
	switch(formElements[f][2]) {
		case "Null":
		if (eval('theForm.'+formElements[f][0]+'.value')==''){
			strErrorList += '!'+ formElements[f][1] +' - יש להזין שדה זה *\n';
			strFocusField = ( strFocusField == '' )? formElements[f][0] : strFocusField;
		}
		break;
		case "Mail":
		if (checkEmail(eval('theForm.'+formElements[f][0]+'.value'))==false){
			strErrorList += '!'+ formElements[f][1] +' - לא הוזנה כתובת דוא\"ל חוקית *\n';
			strFocusField = ( strFocusField == '' )? formElements[f][0] : strFocusField;
		}
		break;
		case "Digit":
		if (isDigit(eval('theForm.'+formElements[f][0]+'.value'))==false){
			strErrorList += '!'+ formElements[f][1] +' - יש להזין מספרים בלבד *\n';
			strFocusField = ( strFocusField == '' )? formElements[f][0] : strFocusField;
		}
		break;
		case "NotZero":
		if (eval('theForm.'+formElements[f][0]+'.value')=='0'){
			strErrorList += '!'+ formElements[f][1] +' - בחר מהרשימה *\n';
			strFocusField = ( strFocusField == '' )? formElements[f][0] : strFocusField;
		}
		break;
	}
}

	if (strErrorList != ":יש להזין/לתקן את השדות הבאים\n" + "-------------------------------\n" )
	{
		alert( strErrorList );
		eval( "theForm." + strFocusField + ".focus( );" );
		return false;
	} else {
		return true;
	}
}
