<!--//
function menuCheck(theField){ 
	n = theField.selectedIndex;
	if (theField.selectedIndex == 0){
   		return false;   
  	}
	else{
		return true;
	}
}

function isNumber(theField)
{
   for(var i = 0; i < theField.value.length; i++)
   {
       var ch = theField.value.substring(i, i+1);
    if (ch < "0" || "9" < ch)
    {  
       return false;
    }
   }
   return true;
}


function phoneCheck(theField, theLabel){
	j = theField.value.length;
	k = 0;
	for(var i = 0; i < j; i++){
		var ch = theField.value.substring(i, i+1);
		if ((ch < "0" || "9" < ch) && (ch != "-") &&(ch != " ")){
			alert('Your '+ theLabel +' should contain numerals only.');
			theField.focus();
			theField.select();
			i = j;
			k = 1;
			return false;
		}
	}
	if(k == 0){
		return true;
	} else {
		return false;
	}
}

function radiocheck(theField){
	typecheck = "no";
	o = 0;
	while(theField[o]){
		if(theField[o].checked){
			typecheck = "yes";
		}
		o++;
	}
	if(typecheck == "no"){
		return false;
	} else {
		return true;
	}
}



function isFieldBlank(theField){
	if(theField.value.length == 0)		
		return true;		
	else			
		return false;	
}

function checkYear(year) {
 
//Leap year checker

	var temp_year

	temp_year = parseFloat(year);

	return (((temp_year % 4 == 0) && (temp_year % 100 != 0)) || (temp_year % 400 == 0)) ? 1 : 0;

}
function date_check(month, date, year, text) { 

	var max_days;

	var temp_date;

	if (month == "January" || month == "1") { 

		max_days = 31;
	
	} else if (month == "February" || month == "2") { 

		if (checkYear(year)) { 

			max_days = 29;

		} else { 

			max_days = 28;

		}

	} else if (month == "March" || month == "3") { 

		max_days = 31;

	} else if (month == "April" || month == "4") { 
	
		max_days = 30;

	} else if (month == "May" || month == "5") { 

		max_days = 31;

	} else if (month == "June" || month == "6") { 

		max_days = 30;

	} else if (month == "July" || month == "7") { 

		max_days = 31;

	} else if (month == "August" || month =="8") { 

		max_days = 31;

	} else if (month == "September" || month == "9") { 

		max_days = 30;

	} else if (month == "October" || month == "10") { 

		max_days = 31;

	} else if (month == "November" || month == "11") { 

		max_days = 30;

	} else if (month == "December" || month == "12") { 

		max_days = 31;

	}

	temp_date = parseInt(date);

	if (temp_date > max_days) { 

		alert(text);

		return false;

	} else { 

		return true;

	} 
}

function isFieldBlank(theField){
	if(theField.value.length == 0){		
		return true;		
	}else	{		
		return false;
	}	
}

function Year(theField){
	if(theField.value.length == 4){		
		return true;		
	}else	{		
		return false;
	}	
}


	
function verify_form(form){
	
		var temp_year = form.year.value;

		temp_year = parseInt(temp_year);

		if(isFieldBlank(form.first_name)){
			alert('Please enter your first name');
			form.first_name.focus();
		} else if(isFieldBlank(form.last_name)){
			alert('Please enter your last name');
			form.last_name.focus();
		} else if (!menuCheck(form.month)){
   			alert("Please select your birth month");
   			form.month.focus();
		} else if (!menuCheck(form.date)){
   			alert("Please select your birth date");
   			form.date.focus();
		} else if(isFieldBlank(form.year)){
			alert('Please enter your birth year');
			form.year.focus();

		} else if (temp_year < 1754) {

			alert("The birth year you entered is invalid.");

			form.year.focus();
 
		} else if (!date_check(form.month.value, form.date.value, form.year.value, 'This birthday does not exist.')) {

			form.date.focus();
 
			return;

		} else if(isFieldBlank(form.home_phone)){
			alert('Please enter your home phone number');
			form.home_phone.focus();
		}else if(!phoneCheck(form.home_phone,'telephone number')){
			return;
		} else if (!menuCheck(form.exam_name)){
   			alert("Please select the name of exam");
   			form.exam_name.focus();
		} else if(isFieldBlank(form.symptoms)){
			alert('Please describe your symptoms');
			form.symptoms.focus();

		} else if (form.appoint_month.value != "MONTH" && form.appoint_date.value != "DATE" && form.appoint_year.value != "YEAR") { 

			if (!date_check(form.appoint_month.value, form.appoint_date.value, form.appoint_year.value, 'This appointment date does not exist.')) {

				form.appoint_date.focus();

				return;
			} else { 

				form.submit();

			} 

		} else {
			form.submit();
		}

}


// -->