 // 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.txtSurname.value=="" || !isNaN(document.frmAppointment.txtSurname.value))
	{
	alert('Enter Surname');
	document.frmAppointment.txtSurname.focus();
	return false;
	}
if (document.frmAppointment.txtFirstName.value=="" || !isNaN(document.frmAppointment.txtFirstName.value))
	{
	alert('Enter FirstName');
	document.frmAppointment.txtFirstName.focus();
	return false;
	}

if (document.frmAppointment.txtHomePhoneNumber.value=="" )
	{
	alert('Enter 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.getElementById('findout').value == "")
	{
		alert("How do you find out?");
		document.getElementById('findout').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 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;
}
}













// 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();
	
	
}

// 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();
	
	
}


// Moving Background


var scrollSpeed = 40; 		// Speed in milliseconds
			var step = 1; 				// How many pixels to move per step
			var current = 0;			// The current pixel row
			var imageWidth = 980;		// Background image width
			var headerWidth = 980;		// How wide the header is.
			
			//The pixel row where to start a new loop
			var restartPosition = -(imageWidth - headerWidth);
			
			function scrollBg(){
				//Go to next pixel row.
				current -= step;
				
				//If at the end of the image, then go to the top.
				if (current == restartPosition){
					current = 0;
				}
				
				//Set the CSS of the header.
				$('#header').css("background-position",current+"px 0");
			}
			
			//Calls the scrolling function repeatedly
			var init = setInterval("scrollBg()", scrollSpeed);


//Flash Banners

function recieveTextFromFlash(Txt) {
	//alert(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("Inner_hampton_park_text_banner");
	flashMovie.SetVariable("/:mes", Txt);
	
}





//BMI
			<!--
function cal_bmi(lbs, ins){   h2 = ins * ins;
   bmi = lbs/h2 * 703   
   f_bmi = Math.floor(bmi);
   diff  = bmi - f_bmi;
   diff = diff * 10;
   diff = Math.round(diff);
   if (diff == 10){
      // Need to bump up the whole thing instead
      f_bmi += 1;
      diff = 0;
   }
   bmi = f_bmi + "." + diff;
   return bmi;
}
function compute(){
  // var f = self.document.forms[0];
	var f = document.bmiform;

   w = f.txtWeight.value;
   v = f.txtFeet.value;
   u = f.txtInch.value;

   // Format values for the BMI calculation

   if (!chkw(u)){
     var ii = 0;
     f.txtInch.value = 0;
   } else {
     var it = f.txtInch.value*1;
     var ii = parseInt(it);
       }

   var fi = parseInt(f.txtFeet.value * 12);
   var i = fi + ii;

  // Do validation of remaining fields to check for existence of values

   if (!chkw(v)){
     alert("Please enter a number for your height.");
     f.txtFeet.focus();
     return;
   }
   if (!chkw(w)){
     alert("Please enter a number for your weight.");
     f.txtWeight.focus();
     return;
   }

   // Perform the calculation
	// initial: Compute your BMI and find out the classificaiton of your weight here.
	var iVal=0;
	var sVal="";
	iVal=cal_bmi(w, i);
	if (iVal<18.5)
		highlightRow("under_18.5"); //sVal="You are Under Weight";
	if (iVal>=18.5 && iVal<24.9)
		highlightRow("under_25"); //sVal="You are of Normal Weight";
	if (iVal>=25 && iVal<29.9)
		highlightRow("under_30"); //sVal="You are Over Weight";
	if (iVal>=30 && iVal <34.9)
		highlightRow("under_35"); //sVal="You are Obese";
	if (iVal>=35 && iVal<39.9)
		highlightRow("under_40"); //sVal="You are Severely Obese";
	if (iVal>=40)
		highlightRow("under_therest"); //sVal="You are Morbidly Obese";

/*				under_25
				under_30
				under_35
				under_40
				under_therest*/


//alert(sVal);
//	writeBMI(sVal, iVal);
	f.txtBMI.value = iVal;
	
   
   /* *************************Code for Overweight/UnderWeight **************************/


   f.txtBMI.focus();
}

function chkw(w){
   if (isNaN(parseInt(w))){
      return false;
   } else if (w < 0){
  return false;
  }
  else{
  return true;
  }
}

var ie4 = false; 
//document.write = ""
if(document.all) { ie4 = true; }

function getObject(id) { 
	if (ie4) { 
		return document.all[id]; 
	} 
	else { 
		return document.getElementById(id); 
	} 
}		 

function highlightRow(rowName){
	// first remove all highlighting
	clearRows();

	// then highlight row
	document.getElementById(rowName).style.backgroundColor='#d4d7c3';

//	var d = getObject('txtBMI');
//	var graphtxt =sTxt;
	//	myLayer = document.getElementById("BMI");
	//    myLayer.innerHTML=graphtxt;
//	alert(sTxt);
//	d.value=graphtxt;
}         

function clearRows() {
	var bmirows = document.getElementsByTagName("tr");
	//alert(divs);
	for (i=0;i<bmirows.length;i++) {
		if (bmirows[i].id.substr(0,6) == 'under_') {
			bmirows[i].style.backgroundColor='';
		}
//		alert(bmirows[i].id);
	}
}

// -->











