// To open a popup window
function MM_openBrWindow(theURL,winName,features) {
  window.open(theURL,winName,features);
}

// Newsletter Subscription Form
function Newsletter() {
  	mailid = document.newsMail.email
	if (mailid.value == '')
	{
		alert("Please enter E-mail Id");
		mailid.focus()
		return false
	}
	else if (mailid.value.indexOf("@")==-1 || mailid.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		mailid.focus()	   
		return false
	}
}

// Feedback form validation
function Feedback() {

	firstName = document.fbForm.txtFirstname
	if (firstName.value == "" || !isNaN(firstName.value))
	{
		alert("Please enter your first name");
		firstName.focus()
		return false		
	}

	lastName = document.fbForm.txtlastname
	if (lastName.value == "" || !isNaN(lastName.value))
	{
		alert("Please enter your last name");
		lastName.focus()
		return false		
	}

	dayPhone = document.fbForm.txtworkphone
	if (isNaN(dayPhone.value))
	{
		alert("Phone number you have entered is invalid");
		dayPhone.focus()
		return false		
	}

	eveningPhone = document.fbForm.txthomephone
	if (isNaN(eveningPhone.value))
	{
		alert("Phone number you have entered is invalid");
		eveningPhone.focus()
		return false		
	}

	mailid = document.fbForm.txtemail
	if (mailid.value == '')
	{
		alert("Please enter E-mail Id");
		mailid.focus()
		return false
	}
	else if (mailid.value.indexOf("@")==-1 || mailid.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		mailid.focus()	   
		return false
	}

	age = document.fbForm.cmbAgeRange
	if (age.options(age.selectedIndex).value == "")
	{
		alert("Please select your age group");
		age.focus()
		return false		
	}	

	sportsAct = document.fbForm.txtsports
	if (sportsAct.value != "" && !isNaN(sportsAct.value))
	{
		alert("Please enter Sports Activities");
		sportsAct.focus()
		return false		
	}

	comments = document.fbForm.txtComments
	if (comments.value == "" || !isNaN(comments.value))
	{
		alert("Please add your comments");
		comments.focus()
		return false		
	}	
}

// Appointments form validation
function Appointment()
{
if (document.frmAppointment.txtFirstName.value=="" || !isNaN(document.frmAppointment.txtFirstName.value))
	{
	alert('Enter FirstName');
	document.frmAppointment.txtFirstName.focus();
	return false;
	}
if (document.frmAppointment.txtSurname.value=="" || !isNaN(document.frmAppointment.txtSurname.value))
	{
	alert('Enter Surname');
	document.frmAppointment.txtSurname.focus();
	return false;
	}
	
if (document.frmAppointment.txtEmailAddress.value=="")
	{
	alert('Enter Email Address');
	document.frmAppointment.txtEmailAddress.focus();
	return false;
	}
	else if (document.frmAppointment.txtEmailAddress.value.indexOf("@")==-1 || document.frmAppointment.txtEmailAddress.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		document.frmAppointment.txtEmailAddress.focus()	   
		return false
	}	
}


// Seminar form validation
function Seminar()
{
if (document.frmSeminar.txtFirstName.value=="" || !isNaN(document.frmSeminar.txtFirstName.value))
	{
	alert('Enter FirstName');
	document.frmSeminar.txtFirstName.focus();
	return false;
	}
	
if (document.frmSeminar.txtLastname.value=="" || !isNaN(document.frmSeminar.txtLastname.value))
	{
	alert('Enter Surname');
	document.frmSeminar.txtLastname.focus();
	return false;
	}
if (document.frmSeminar.txtaddress.value=="" || !isNaN(document.frmSeminar.txtaddress.value))
	{
	alert('Enter Address');
	document.frmSeminar.txtaddress.focus();
	return false;
	}
	
if (document.frmSeminar.txtCity.value=="" || !isNaN(document.frmSeminar.txtCity.value))
	{
	alert('Enter City');
	document.frmSeminar.txtCity.focus();
	return false;
	}
if (document.frmSeminar.txtState.value=="" || !isNaN(document.frmSeminar.txtState.value))
	{
	alert('Enter State');
	document.frmSeminar.txtState.focus();
	return false;
	}
if (document.frmSeminar.txtZip.value=="" || isNaN(document.frmSeminar.txtZip.value))
	{
	alert('Enter Zip Code');
	document.frmSeminar.txtZip.focus();
	return false;
	}
	
if (document.frmSeminar.txtemail.value=="")
	{
	alert('Enter Email Address');
	document.frmSeminar.txtemail.focus();
	return false;
	}
else if (document.frmSeminar.txtemail.value.indexOf("@")==-1 || document.frmSeminar.txtemail.value.indexOf(".")==-1)
	{
		alert("Invalid E-mail ID")
		document.frmSeminar.txtemail.focus()	   
		return false
	}	

}
// BMI Calculator
function mod(div,base) 
{
	return Math.round(div - (Math.floor(div/base)*base));
}

function calcBmi() 
{
var w = document.bmi.weight.value * 1;
var HeightFeetInt = document.bmi.htf.value * 1;
var HeightInchesInt = document.bmi.hti.value * 1;
HeightFeetConvert = HeightFeetInt * 12;
h = HeightFeetConvert + HeightInchesInt;
displaybmi = (Math.round((w * 703) / (h * h)));
var rvalue = true;
	if ( (w <= 35) || (w >= 999)  || (h <= 48) || (h >= 120) ) 
	{
		alert ("Invalid data.  Please check and re-enter!");
		rvalue = false;
	}
	
	if (rvalue) 
	{
		if (HeightInchesInt > 11) 
		{
			reminderinches = mod(HeightInchesInt,12);
			document.bmi.hti.value = reminderinches;
			document.bmi.htf.value = HeightFeetInt + 
			((HeightInchesInt - reminderinches)/12);
			document.bmi.answer.value = displaybmi;
		}
		document.bmi.answer.value = displaybmi; 
	}
		return rvalue;
}

// Medical Professionals form validation
function OnlineOrder() {

	firstName = document.mpform.txtFirstname
	if (firstName.value == "" || !isNaN(firstName.value))
	{
		alert("Please enter your Name");
		firstName.focus()
		return false		
	}

if (document.mpform.txtproviderno.value=="" || isNaN(document.mpform.txtproviderno.value))
	{
	alert('Please enter Provider No.');
	document.mpform.txtproviderno.focus();
	return false;
	}

	TelePhone = document.mpform.txtTelePhoneNumber
	if (isNaN(TelePhone.value))
	{
		alert("Phone number you have entered is invalid");
		TelePhone.focus()
		return false		
	}
	
	mailid = document.mpform.txtemail
	if (mailid.value == '')
	{
		alert("Please enter E-mail Id");
		mailid.focus()
		return false
	}
	else if (mailid.value.indexOf("@")==-1 || mailid.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		mailid.focus()	   
		return false
	}
	
if (document.mpform.txtkits.value=="" || isNaN(document.mpform.txtkits.value))
	{
	alert('Please enter No. of Kits');
	document.mpform.txtkits.focus();
	return false;
	}

if (document.mpform.txtkits1.value=="" || isNaN(document.mpform.txtkits1.value))
	{
	alert('Please enter No. of Kits');
	document.mpform.txtkits1.focus();
	return false;
	}
	}
	
	// Patients form validation
function PatientsOnlineOrder() {

	firstName = document.patientform.txtFirstname
	if (firstName.value == "" || !isNaN(firstName.value))
	{
		alert("Please enter your Name");
		firstName.focus()
		return false		
	}

if (document.patientform.txtdob.value=="")
	{
	alert('Please enter your Date of Birth');
	document.patientform.txtdob.focus();
	return false;
	}
	
	TelePhone = document.patientform.txtTelePhoneNumber
	
	if (isNaN(TelePhone.value))
	{
		alert("Phone number you have entered is invalid");
		TelePhone.focus()
		return false		
	}

	mailid = document.patientform.txtemail
	if (mailid.value == '')
	{
		alert("Please enter E-mail Id");
		mailid.focus()
		return false
	}
	else if (mailid.value.indexOf("@")==-1 || mailid.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		mailid.focus()	   
		return false
	}
	
if (!document.patientform.ubh.checked && !document.patientform.libt.checked)
	{
	alert('Please select atleast one Breath Test');
	return false;
	}

if (document.patientform.txtdoctor.value=="")
	{
		alert('Please enter Referring Doctor');
		document.patientform.txtdoctor.focus();
		return false;
	}
}
	
// Referrals form validation
function ReferralsOnlineOrder() {

	firstName = document.referralsform.txtFirstname
	if (firstName.value == "" || !isNaN(firstName.value))
	{
		alert("Please enter Doctors Name");
		firstName.focus()
		return false		
	}

if (document.referralsform.txtproviderno.value=="" || isNaN(document.referralsform.txtproviderno.value))
	{
	alert('Please enter Provider No.');
	document.referralsform.txtproviderno.focus();
	return false;
	}

TelePhone = document.referralsform.txtTelePhoneNumber
	if (isNaN(TelePhone.value))
	{
		alert("Phone number you have entered is invalid");
		TelePhone.focus()
		return false		
	}

	mailid = document.referralsform.txtemail
	if (mailid.value == '')
	{
		alert("Please enter E-mail Id");
		mailid.focus()
		return false
	}
	else if (mailid.value.indexOf("@")==-1 || mailid.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		mailid.focus()	   
		return false
	}
	
	patientsName = document.referralsform.txtpatientname
	if (patientsName.value == "" || !isNaN(patientsName.value))
	{
		alert("Please enter Patients Name");
		patientsName.focus()
		return false		
	}
	
	Medicare = document.referralsform.txtmedicare
	if (isNaN(Medicare.value))
	{
		alert("Medicare number you have entered is invalid");
		Medicare.focus()
		return false		
	}

}	