// 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=="" || isNaN(document.frmAppointment.txtHomePhoneNumber.value))
	{
	alert('Enter Home Phone No.');
	document.frmAppointment.txtHomePhoneNumber.focus();
	return false;
	}
if (document.frmAppointment.txtBusinessPhoneNumber.value!="" && isNaN(document.frmAppointment.txtBusinessPhoneNumber.value))
	{
	alert('Enter a valid Business Phone Number');
	document.frmAppointment.txtBusinessPhoneNumber.focus();
	return false;
	}
	
if (document.frmAppointment.txtMobileNumber.value!="" && isNaN(document.frmAppointment.txtMobileNumber.value))
	{
	alert('Mobile number you have entered is invalid');
	document.frmAppointment.txtMobileNumber.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
	}	
}

// 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);
	
}
else 
{
	alert("Please enter your weight and height");
	return false;
}
}

// 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<=6; i++)

						{

						

	                        var imagename = "index"+simgnum+"_"+i

	                        document.cookie="name"+"="+simgnum;



							var tmp = eval("document.getElementById('index"+i+"')")

	                        var thePicture=tmp;
							var picPath="images/"+imagename+".jpg";
							if(i==4) {
								thePicture.background=picPath;
							} else {
								thePicture.src=picPath;
							}

	                        						}

                }
				
// Random Images admin

                function randImagesCookie1()

                {

                        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<=6; i++)

						{

						

	                        var imagename = "index"+simgnum+"_"+i

	                        document.cookie="name"+"="+simgnum;



							var tmp = eval("document.getElementById('index"+i+"')")

	                        var thePicture=tmp;
							var picPath="../images/"+imagename+".jpg";
							if(i==4) {
								thePicture.background=picPath;
							} else {
								thePicture.src=picPath;
							}

	                        						}

                }	
				
// video popup code

function openitCustom1(sURL){
newwindow5=window.open(sURL,"newwin5",
"scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,resizable=yes,status=no,width=180,height=130");
newwindow5.window.focus();
}
function openitCustom2(sURL){
newwindow5=window.open(sURL,"newwin5",
"scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,resizable=yes,status=no,width=518,height=400");
newwindow5.window.focus();
}
function openitCustom3(sURL){
newwindow5=window.open(sURL,"newwin5",
"scrollbars=yes,toolbar=no,location=no,directories=no,menubar=no,resizable=yes,status=no,width=340,height=250");
newwindow5.window.focus();
}

function setBandwidth (connectionSpeed) { 
if ((navigator.userAgent.indexOf("IE") > -1) && (navigator.platform == "Win32")) { 
MediaPlayer.autoStart = true; 
MediaPlayer.Filename = connectionSpeed + '.wmv'; 
} else { 
document.MediaPlayer.SetAutoStart(true); 
document.MediaPlayer1.SetFileName(connectionSpeed + '.wmv'); 
} 
} 

// Date Time Picker

function LZ(x) {return(x<0||x>9?"":"0")+x}


function validateForm()
{
var eventName = document.eventsForm.eventName;
	
	if(eventName.value == "")
	{
		alert("Please enter \"Meeting/ Event\"")
		eventName.focus();
		return false;
	}

var stdate = document.eventsForm.stdate.value;
var sdate = stdate.split(' ');
sd = sdate[0].split('-')
var d1 = LZ(sd[2])+""+LZ(sd[0])+""+LZ(sd[1]);
var tdate = new Date()
var today = LZ(tdate.getFullYear())+""+LZ(parseInt(tdate.getMonth())+1)+""+LZ(tdate.getDate());
	
	if(stdate == "")
	{
		alert("Please enter \"Start date\"")
		return false;
	}
	
	if(d1<today)
	{
		alert("\"Start date\" should be greater than or equal to \"Current date\"")
		return false;
	}
	

var email = document.eventsForm.email;
	
	if(email.value != "")
	{
		if(email.value.indexOf('@') == -1 || email.value.indexOf('.') == -1)
		{
			alert("Please enter a valid \"E-Mail address\"")
			email.focus();
			return false;
		}
	}
	
}				