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

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

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


// Priscription Refill form validation
function Prescription()
{
if (document.frmPrescription.txtPatientPhone.value=="")
	{
	alert('Enter Patient Phone Number');
	document.frmPrescription.txtPatientPhone.focus();
	return false;
	}
if (document.frmPrescription.txtPharmacyPhone.value=="")
	{
	alert('Enter Pharmacy Phone Number');
	document.frmPrescription.txtPharmacyPhone.focus();
	return false;
	}
if (document.frmPrescription.txtPatientLastName.value=="" || !isNaN(document.frmPrescription.txtPatientLastName.value) )
	{
	alert('Enter Patient Last Name');
	document.frmPrescription.txtPatientLastName.focus();
	return false;
	}
	
	
	
if (document.frmPrescription.txtPatientFirstName.value=="" || !isNaN(document.frmPrescription.txtPatientFirstName.value))
	{
	alert('Enter Patient FirstName');
	document.frmPrescription.txtPatientFirstName.focus();
	return false;
	}
if (document.frmPrescription.txtDOB.value=="")
	{
	alert('Enter Patient Date of Birth');
	document.frmPrescription.txtDOB.focus();
	return false;
	}
if (document.frmPrescription.txtPhysician.value=="" || !isNaN(document.frmPrescription.txtPhysician.value) )
	{
	alert('Enter Patient Physician Name');
	document.frmPrescription.txtPhysician.focus();
	return false;
	}
if (document.frmPrescription.txtNameofMedicine.value=="" || !isNaN(document.frmPrescription.txtNameofMedicine.value))
	{
	alert('Enter Name of Medicine');
	document.frmPrescription.txtNameofMedicine.focus();
	return false;
	}
if (document.frmPrescription.txtNameofPharmacy.value=="" || !isNaN(document.frmPrescription.txtNameofPharmacy.value))
	{
	alert('Enter Name of Pharmacy');
	document.frmPrescription.txtNameofPharmacy.focus();
	return false;
	}
if (document.frmPrescription.textDrugAllergies.value=="" || !isNaN(document.frmPrescription.textDrugAllergies.value) )
	{
	alert('Enter Drug Allergies');
	document.frmPrescription.textDrugAllergies.focus();
	return false;
	}
	
	if (document.frmPrescription.uword.value=="" )
	{
	alert('Enter the code as it is shown');
	document.frmPrescription.uword.focus();
	return false;
	}
	return jcap();
}














// Interactivity //

<!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->

 //Detect Browser Type.
var agt=navigator.userAgent.toLowerCase();
var appVer = navigator.appVersion.toLowerCase();
var is_minor = parseFloat(appVer);
var is_major = parseInt(is_minor);
var iePos  = appVer.indexOf('msie');
if (iePos !=-1) {
  is_minor = parseFloat(appVer.substring(iePos+5,appVer.indexOf(';',iePos)));
  is_major = parseInt(is_minor);
}
var isMinNS4 = ((navigator.appName.indexOf("Netscape") >= 0 || agt.indexOf("gecko") >= 0) && is_major >= 4) ? true : false;
var isMinNS6 = (agt.indexOf("gecko") >=0 && is_major >= 6) ? true : false;
var isMinIE4 = (document.all) ? true : false;
var isMinIE5 = (isMinIE4==1 && is_major >= 6) ? true : false;
var isMinIE6 = (isMinIE4 && is_major >= 7) ? true : false;
var isDOM = (document.getElementById) ? true : false;
var isSafari = (agt.indexOf("safari") != -1) ? true : false
var isOpera = (agt.indexOf("opera") != -1) ? true : false
var isIE = (isMinIE4 || isMinIE5 ||  isMinIE6);
var isNN = (isMinNS4 || isMinNS6 );

/**
 Returns a single named DOM element or null if not found.
 @param elementName String _ID_ of element you want to retrieve
 @return element if found or null.
*/
function get(elementName) {
  var ret = null;
  var tm=20; 
  var sp=11;
  if (isDOM == 1) {
    if(document.getElementById(elementName)) {
      ret = document.getElementById(elementName);
    }
  }  else if (isMinIE4 == 1) {
    if(document.all(elementName)[0]) {
      ret = document.all(elementName)[0];
    }  else {
      ret = document.all(elementName);
    }
  }
  return ret;
}

	var newPos=0;
	function slideContent(divId,divPos) 
	{
	
	alert(divId+" "+divPos);
	
		tmpDivPos = divPos.substring(0,(divPos.length-2));
		if(tmpDivPos!="") newPos = parseInt(tmpDivPos)+3;
				
		slideDiv = eval("get('div"+divId+"')");
	   			
		if(newPos<=0) 
		{
			slideDiv.style.left=newPos+"px";
		
			setTimeout("slideContent("+divId+","+slideDiv.style.left+")",0);
		}
	}
	var count=1
	function showContent(divId) // 1 visible, 0 hidden
	{
	
		for(j=1;j<=3;j++)
		{
			showDiv = eval("get('div"+j+"')");
			if(j==divId)
			{
				showDiv.style.zIndex=16;
				count=j;
			} 
			if(j!=divId) {
				showDiv.style.zIndex=0;
			}
		}
	
	
		for(i=1;i<=3;i++)
		{
			showDiv1 = eval("get('div"+i+"')");
			if(i==divId)
			{
				showDiv1.style.display='';
				MM_swapImage('Image'+i,'','images/'+i+'b-on.gif',1);
			} else
			{
				MM_swapImage('Image'+i,'','images/'+i+'b.gif',1);
				showDiv1.style.display='none';
			}
			
			function setup(c,f){c.timer=setInterval(function(){slideContent(c,f)},tm)}
			function slideContent(c,f){
			var h,m,d; h=c.offsetHeight; m=c.maxh; d=(f==1)?Math.ceil((m-h)/sp):Math.ceil(h/sp);
			c.style.height=h+(d*f)+'px'; c.style.opacity=h/m; c.style.filter='alpha(opacity='+h*100/m+')';
			if(f==1&&h>=m){clearInterval(c.timer)}
			else if(f!=1&&h==1){c.style.display='none'; clearInterval(c.timer)}
			}
		}
		
	}
	var f = true;
	function pausContinue()
	{
		f=false;
	}
	function playOnload()
	{
		if(count<=3)
		{
			showContent(count)
		} 
		
		if(count==3) {
			count=0
		}
		
		count++
		
		if(!f)
		{
			return false;
		}	
		
		setTimeout("playOnload()",5000);
			
	}	

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
 

 <!--
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
//-->
 
