<!--//
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 verify_form(form){
	
		if(isFieldBlank(form.clinical_history)){
			alert('Please enter a clinical history');
			form.clinical_history.focus();
			return;
		} else if(!radiocheck(form.prior_studies)){
			alert('Please indicate if prior EPIC Imaging studies have been done');
		} else if(isFieldBlank(form.diff_diagnosis)){
			alert('Please enter your differential diagnosis');
			form.diff_diagnosis.focus();
			return;
		} else if(isFieldBlank(form.points)){
			alert('Please outline the points you would like to discuss');
			form.points.focus();
			return;
		} else if(isFieldBlank(form.doc_fname)){
			alert('Please enter your first name');
			form.doc_fname.focus();
			return;
		} else if(isFieldBlank(form.doc_lname)){
			alert('Please enter your last name');
			form.doc_lname.focus();
			return;

		} else if(isFieldBlank(form.doc_phone)){
			alert('Please enter your phone number');
			form.doc_phone.focus();
			return;
		}else if(!phoneCheck(form.doc_phone,'telephone number')){
			return;

		} else if (form.month.value != "MONTH" && form.date.value != "DATE" && form.year.value != "YEAR") { 

			if (!date_check(form.month.value, form.date.value, form.year.value, 'This birth date does not exist.')) {

				form.date.focus();

				return;
			} else { 

				form.submit();

			}

		} else {
			form.submit();
		}

}


// -->