// 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		
	}	
}

// Tickets form validation
function Tickets() {

	ticket = document.ticketsForm.cmbTicketBooks
	if (ticket.options(ticket.selectedIndex).value == "")
	{
		alert("Please select no. of ticket books");
		ticket.focus()
		return false		
	}

	title = document.ticketsForm.txtTitle
	if (title.value == "" || !isNaN(title.value))
	{
		alert("Please enter title");
		title.focus()
		return false		
	}

	firstName = document.ticketsForm.txtFirstname
	if (firstName.value == "" || !isNaN(firstName.value))
	{
		alert("Please enter your first name");
		firstName.focus()
		return false		
	}

	surName = document.ticketsForm.txtlastname
	if (surName.value == "" || !isNaN(surName.value))
	{
		alert("Please enter your sur name");
		surName.focus()
		return false		
	}

	address = document.ticketsForm.txtaddress
	if (address.value == "" || !isNaN(address.value))
	{
		alert("Please enter your address");
		address.focus()
		return false		
	}

	post = document.ticketsForm.txtPostcode
	if (post.value == "" || !isNaN(post.value))
	{
		alert("Please enter post code");
		post.focus()
		return false		
	}

	mailid = document.ticketsForm.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
	}
	
}

// Appointments form validation
function Appointment()
{
if (document.frmAppointment.mailname.value=="" || !isNaN(document.frmAppointment.mailname.value))
	{
	alert('Enter Name');
	document.frmAppointment.mailname.focus();
	return false;
	}
if (document.frmAppointment.txtemail.value=="")
	{
	alert('Enter Email Address');
	document.frmAppointment.txtemail.focus();
	return false;
	}
	else if (document.frmAppointment.txtemail.value.indexOf("@")==-1 || document.frmAppointment.txtemail.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		document.frmAppointment.txtemail.focus()	   
		return false
	}	
if (document.frmAppointment.txtworkphone.value=="")
	{
	alert('Enter Mobile Number');
	document.frmAppointment.txtworkphone.focus();
	return false;
	}
if (document.frmAppointment.txtSubject.value=="" || !isNaN(document.frmAppointment.txtSubject.value))
	{
	alert('Enter Subject');
	document.frmAppointment.txtSubject.focus();
	return false;
	}
if (document.frmAppointment.txtComments.value=="" || !isNaN(document.frmAppointment.txtComments.value))
	{
	alert('Enter Your Message');
	document.frmAppointment.txtComments.focus();
	return false;
	}
}

// BMI Calculator
function converttometers(ht)
{
    return (ht/100);
}
function calculatebmi(ht,wt)
{
return (wt/Math.pow(ht,2));
}
function btnCalcbmi()
{
if (document.frmbmi.txtheight.value != '')
{
	var ht=converttometers(document.frmbmi.txtheight.value);
	var wt=document.frmbmi.txtweight.value;
	var bmi=Math.round(calculatebmi(ht,wt));
	document.frmbmi.txtbmi.value=parseInt(bmi);
	
	if (parseInt(bmi) <19) 
document.frmbmi.comment.value = "Underweight";
if (parseInt(bmi) >=19 && parseInt(bmi) <=25) 
document.frmbmi.comment.value = "Desirable";
if (parseInt(bmi) >=26 && parseInt(bmi) <=29) 
document.frmbmi.comment.value = "Prone to health risks";
if (parseInt(bmi) >=30 && parseInt(bmi) <=40) 
document.frmbmi.comment.value = "Obese";
if (parseInt(bmi) >40) 
document.frmbmi.comment.value = "Extremely obese";
	
}
else 
{
	alert("Please enter your weight and height");
	return false;
}
}




// Membership form validation
function Membership() {


	title = document.fbmember.txttitle
	if (title.value == "" || !isNaN(title.value))
	{
		alert("Please enter your title");
		title.focus()
		return false		
	}


	firstName = document.fbmember.txtFirstname
	if (firstName.value == "" || !isNaN(firstName.value))
	{
		alert("Please enter your name");
		firstName.focus()
		return false		
	}
	
	surName = document.fbmember.txtSurname
	if (surName.value == "" || !isNaN(surName.value))
	{
		alert("Please enter your sur name");
		surName.focus()
		return false		
	}	
	
	
	address = document.fbmember.txtaddress
	if (address.value == "" || !isNaN(address.value))
	{
		alert("Please enter your address");
		address.focus()
		return false		
	}
	
	mailid = document.fbmember.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
	}

	
}



// Feedback form validation
function FamilyDirectory() {

	businessname = document.fdForm.businessname
	if (businessname.value == "")
	{
		alert("Please enter your Business Name");
		businessname.focus()
		return false		
	}



	mycategory = document.fdForm.cmbcategory
	
	if (mycategory.selectedIndex == 0)
	{
		alert("Please select your Category");
	mycategory.focus()
	return false		
	}	
	
		yourname = document.fdForm.yourname
	if (yourname.value == "")
	{
		alert("Please enter your Name");
		yourname.focus()
		return false		
	}

	invoiceaddress = document.fdForm.invoiceaddress
	if (invoiceaddress.value == "")
	{
		alert("Please enter your Address");
		invoiceaddress.focus()
		return false		
	}



	mailid = document.fdForm.contactemail
	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
	}


	phonenumber = document.fdForm.phonenumber
	if (phonenumber.value =="")
	{
		alert("Please enter your Phone Number");
		phonenumber.focus()
		return false		
	}

	if (document.fdForm.uword.value=="" )
	{
	alert('Enter the code as it is shown');
	document.fdForm.uword.focus();
	return false;
	}
	return jcap();
}




