// To open a popup window

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

	}









	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		

	}	

	if (document.fbForm.uword.value=="" )

	{

	alert('Enter the code as it is shown');

	document.fbForm.uword.focus();

	return false;

	}

	return jcap();

	

	

}



// 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.txtHomePhoneNumber.value=="" )

	{

	alert('Enter Home Phone No.');

	document.frmAppointment.txtHomePhoneNumber.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

	}	

	

	if (document.frmAppointment.uword.value=="" )

	{

	alert('Enter the code as it is shown');

	document.frmAppointment.uword.focus();

	return false;

	}

	return jcap();

}



//Random Images



                function getCookie(c_name)

                {

                if (document.cookie.length>0)

                  {

                  c_start=document.cookie.indexOf(c_name + "=")

                  if (c_start!=-1)

                    {

                    c_start=c_start + c_name.length+1

                    c_end=document.cookie.indexOf(";",c_start)

                    if (c_end==-1) c_end=document.cookie.length

                    return unescape(document.cookie.substring(c_start,c_end))

                    }

                  }

                return null

                }



                function randImagesCookie()

                {

                        if(getCookie('name')==null || getCookie('name')=="NaN")

                        {

                                document.cookie="name"+"="+1;

                        }

                        var cimgnum=getCookie('name');

                        if(cimgnum >= 4) {

                                var simgnum=1;

                        } else {

                                var simgnum=parseInt(cimgnum)+1;

                        }

						

						for(i=1; i<=4; i++)

						{

						

	                        var imagename = "cori_header_"+simgnum+"_"+i

	                        document.cookie="name"+"="+simgnum;



							var tmp = eval("document.getElementById('index"+i+"')")

    	                    var picPath="images/"+imagename+".jpg";

	                        tmp.style.backgroundImage="url('"+picPath+"')";

						}

                }





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

}





// Contact Us form validation

function Contactus() {

	

	firstName = document.cuForm.txtName

	if (firstName.value == "" || !isNaN(firstName.value))

	{

		alert("Please enter your first name");

		firstName.focus()

		return false		

	}



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

	}



	comments = document.cuForm.txtMessage

	if (comments.value == "" || !isNaN(comments.value))

	{

		alert("Please add your comments");

		comments.focus()

		return false		

	}	

	if (document.cuForm.uword.value=="" )

	{

	alert('Enter the code as it is shown');

	document.cuForm.uword.focus();

	return false;

	}

	return jcap();

	

	

}



// Request Appointment form validation

function Requestappointment() {

	

	firstName = document.requestAppointment.txtName

	if (firstName.value == "" || !isNaN(firstName.value))

	{

		alert("Please enter your Name");

		firstName.focus()

		return false		

	}

	

	if (document.requestAppointment.txtEmail.value=="")

	{

	alert('Enter Email Address');

	document.requestAppointment.txtEmail.focus();

	return false;

	}

	else if (document.requestAppointment.txtEmail.value.indexOf("@")==-1 || document.requestAppointment.txtEmail.value.indexOf(".")==-1){

		alert("Invalid E-mail ID")

		document.requestAppointment.txtEmail.focus()	   

		return false

	}	



	phone = document.requestAppointment.txtphone

	if (phone.value == "")

	{

		alert("Please enter your Phone No");

		phone.focus()

		return false		

	}

	

	/*location2 = document.requestAppointment.txtlocation

	if (location2.value == "" || !isNaN(location2.value))

	{

		alert("Please enter your Preferred location");

		location2.focus()

		return false

	}

	

	day = document.requestAppointment.txtday

	if (day.value == "" || !isNaN(day.value))

	{

		alert("Please enter your Preferred day");

		day.focus()

		return false

	}*/

	

	

}



// Testimonials form validation

function Testimonials() {



	yourName = document.TestimonialsForm.txtyourname

	if (yourName.value == "")

	{

		alert("Please enter Your Name");

		yourName.focus()

		return false		

	}



	mailid = document.TestimonialsForm.txtyouremail

	if (mailid.value == '')

	{

		alert("Please enter Your 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

	}

	

	testimonial = document.TestimonialsForm.txttestimonial

	if (testimonial.value == "" || !isNaN(testimonial.value))

	{

		alert("Please add Your Testimonial");

		testimonial.focus()

		return false		

	}	

	

	if (document.TestimonialsForm.uword.value=="" )

	{

	alert('Enter the code as it is shown');

	document.TestimonialsForm.uword.focus();

	return false;

	}

	return jcap();

	

	

}



// Flash Text Banner Script



function recieveTextFromFlash(Txt) {

	PlayFlashMovie(Txt);

	}

	

function getFlashMovieObject(movieName)

{

  if (window.document[movieName]) 

  {

    return window.document[movieName];

  }

  if (navigator.appName.indexOf("Microsoft Internet")==-1)

  {

    if (document.embeds && document.embeds[movieName])

      return document.embeds[movieName]; 

  }

  else 

  {

    return document.getElementById(movieName);

  }

}



function PlayFlashMovie(Txt)

{



	var flashMovie=getFlashMovieObject("simplemovie");

	flashMovie.SetVariable("/:mes", Txt);

	

}

















// BMI Calculator



// BMI Calculator Home Page



function converttometers(ht)

{

    return (ht/100);

}

function calculatebmi(ht,wt)

{

return (wt/Math.pow(ht,2));

}

function btnCalcbmi()

{

if (document.frmbmi.txtheight.value != '' &&  document.frmbmi.txtweight.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;

}

}

// BMI Calculator for BMI Page



function converttometers2(ht)

{

    return (ht/100);

}

function calculatebmi2(ht,wt)

{

return (wt/Math.pow(ht,2));

}

function btnCalcbmi2()

{

if (document.frmbmi2.txtheight2.value != '')

{

	var ht=converttometers(document.frmbmi2.txtheight2.value);

	var wt=document.frmbmi2.txtweight2.value;

	var bmi=Math.round(calculatebmi2(ht,wt));

	document.frmbmi2.txtbmi2.value=parseInt(bmi);

	

	if (parseInt(bmi) <19) 

document.frmbmi2.comment2.value = "Underweight";

if (parseInt(bmi) >=19 && parseInt(bmi) <=25) 

document.frmbmi2.comment2.value = "Ideal BMI";

if (parseInt(bmi) >=26 && parseInt(bmi) <=30) 

document.frmbmi2.comment2.value = "Overweight";

if (parseInt(bmi) >=31 && parseInt(bmi) <=35) 

document.frmbmi2.comment2.value = "Obese";

if (parseInt(bmi) >40) 

document.frmbmi2.comment2.value = "Severely Obese";

if (parseInt(bmi) >40) 

document.frmbmi2.comment2.value = "Morbidly Obese";

if (parseInt(bmi) >50) 

document.frmbmi2.comment2.value = "Super Obese";

	

}

else 

{

	alert("Please enter your weight and height");

	document.frmbmi2.comment2.value="";

	document.frmbmi2.txtbmi2.value="";

	return false;

}

}



// Referrals form validation
function Referrals()
{
if (document.frmReferrals.txtName.value=="")
	{
	alert('Enter Your Name');
	document.frmReferrals.txtName.focus();
	return false;
	}
	

if (document.frmReferrals.txtdob.value=="" )
	{
	alert('Enter your Date of Birth.');
	document.frmReferrals.txtdob.focus();
	return false;
	}
	
	

	

if (document.frmReferrals.txtEmailAddress.value=="")
	{
	alert('Enter Email Address');
	document.frmReferrals.txtEmailAddress.focus();
	return false;
	}
	else if (document.frmReferrals.txtEmailAddress.value.indexOf("@")==-1 || document.frmReferrals.txtEmailAddress.value.indexOf(".")==-1){
		alert("Invalid E-mail ID")
		document.frmReferrals.txtEmailAddress.focus()	   
		return false
	}	
	
if (document.frmReferrals.txtphone.value=="" )
	{
	alert('Enter Your Contact Number');
	document.frmReferrals.txtphone.focus();
	return false;
	}
	
	
if (document.frmReferrals.txtReferral.value=="" )
	{
	alert('Enter Referral Name.');
	document.frmReferrals.txtReferral.focus();
	return false;
	}
	
if (document.frmReferrals.textGpName.value=="" )
	{
	alert('Enter General Practitioner Name.');
	document.frmReferrals.textGpName.focus();
	return false;
	}	
	
if (document.frmReferrals.textprovidernumber.value=="" )
	{
	alert('Enter Provider Number.');
	document.frmReferrals.textprovidernumber.focus();
	return false;
	}	
	
	
	if (document.frmReferrals.uword.value=="" )
	{
	alert('Enter the code as it is shown');
	document.frmReferrals.uword.focus();
	return false;
	}
	return jcap();
}

