function gogym()
{
	if(document.getElementById("GymId").value!='0')
	{
		//alert("not submitting");
		document.forms.gymLocatorform.submit();
	}
	else
	{
		alert("Please select a Gym");
	}
}


function setgofocus()
{
	//alert("hi");
	document.getElementById("Go").focus();
}



    function BMICalculation() {
		var feet;
		var inches;
		var kg;
		var meter;
		var BMICalc;
		if (isEmpty(document.BMICalc.HeightF.value)) {			
			return warnInvalid(document.BMICalc.HeightF, iHeight);
		}
		if (!parseFloat(document.BMICalc.HeightF.value)) {
			return warnInvalid(document.BMICalc.HeightF, iHeight);
		}
		if (isEmpty(document.BMICalc.HeightI.value)) {			
			document.BMICalc.HeightI.value=0;
		}
		/*
		if (!parseFloat(document.BMICalc.HeightI.value)) {
			return warnInvalid(document.BMICalc.HeightI, iHeight);
		}*/
		if (isEmpty(document.BMICalc.Weight.value)) {			
			return warnInvalid(document.BMICalc.Weight, iWeight);
		}
		if (!parseFloat(document.BMICalc.Weight.value)) {
			return warnInvalid(document.BMICalc.Weight, iWeight);
		}
		feet=document.BMICalc.HeightF.value;
		inches=document.BMICalc.HeightI.value;
		kg=document.BMICalc.Weight.value;
		
		feet=parseFloat(feet) + parseFloat((inches * 0.0833));
		
		meter= feet* 0.3048;
		
		
		BMICalc= kg /(meter*meter);
		
		//document.getElementById("BMICalcRes").innerHTML="You have a BMI of " + BMICalc.toFixed(2);
		document.forms.BMICalc.submit();
		
    }
   
     function validateHeightF() {
		if (isEmpty(document.BMICalc.HeightF.value)) {			
			//return warnInvalid(document.BMICalc.HeightF, iHeight);
			alert ("Height should not be blank");
			return false;
		}
		if (!parseFloat(document.BMICalc.HeightF.value)) {
			alert ("Height should be a number");
			return false;
			//return warnInvalid(document.BMICalc.HeightF, iHeight);
		}
	}
	
	function validateHeightI() {
		if (isEmpty(document.BMICalc.HeightI.value)) {			
			document.BMICalc.HeightI.value=0;
		}
	}
	
	function validateWeight() {		
		if (isEmpty(document.BMICalc.Weight.value)) {
			alert ("Weight should not be blank");
			return false;			
			//return warnInvalid(document.BMICalc.Weight, iWeight);
		}
		if (!parseFloat(document.BMICalc.Weight.value)) {
			alert ("Weight should be a number");
			return false;
			//return warnInvalid(document.BMICalc.Weight, iWeight);
		}
	}
	
	function moveNext()
	{
		
		currentImg = currentImg + 1;
		//alert( photogallery[currentImg]);		
		if((currentImg) <= recCount) 
		{			
			document.images["img1"].src = "admin/content/photogallery/" + photogallery[currentImg];					
		}
		else 
		{
			currentImg = currentImg - 1;
		}
		
		enableDisbleNavButtons();		
		
	}
	
	function movePrevious()
	{
		 
		currentImg = currentImg - 1;
		//alert( photogallery[currentImg]);		
		if((currentImg) >= 1) 
		{			
			document.images["img1"].src = "admin/content/photogallery/" + photogallery[currentImg];					
		}
		else 
		{
			currentImg =  1;
		}

		enableDisbleNavButtons();
	}
	
	function enableDisbleNavButtons() {
		
		
		if (currentImg == 1) {
			document.getElementById("movePrevious").style.display = "none";
		}
		else {
			document.getElementById("movePrevious").style.display = "block";
		}

		if((currentImg) < recCount) 
		{			
			document.getElementById("moveNext").style.display = "block";
		}
		else 
		{
			document.getElementById("moveNext").style.display = "none";
		}
		
	}
	
	function dispTHR() {
		document.getElementById("BMI").style.display = "none";
		document.getElementById("THR").style.display = "block";
	
	}
	
	function dispBMI() {
		document.getElementById("BMI").style.display = "block";
		document.getElementById("THR").style.display = "none";
	
	}
	
	function validateAge() {
		if (isEmpty(document.THRCalc.Age.value)) {			
			alert ("Age should not be blank");
			return false;
			//return warnInvalid(document.THRCalc.Age, iAge);
		}
		if (!parseFloat(document.THRCalc.Age.value)) {
			alert ("Age should be a number");
			return false;
			//return warnInvalid(document.THRCalc.Age, iAge);
		}
	}
	
	function validateRHR() {
		if (isEmpty(document.THRCalc.RHR.value)) {			
			alert ("RHR should not be blank");
			return false;
			//return warnInvalid(document.THRCalc.RHR, iRHR);
		}
		if (!parseFloat(document.THRCalc.RHR.value)) {
			alert ("RHR should be a number");
			return false;
			//return warnInvalid(document.THRCalc.RHR, iRHR);
		}
	}
	
	function THRCalculation() {
		var age;
		var rhr;
		var mhr;
		var thr60;
		var thr75;
		var thr80;
		var thr85;
		var thr90;
		
		if (isEmpty(document.THRCalc.Age.value)) {			
			return warnInvalid(document.THRCalc.Age, iAge);
		}
		if (!parseFloat(document.THRCalc.Age.value)) {
			return warnInvalid(document.THRCalc.Age, iAge);
		}
		if (isEmpty(document.THRCalc.RHR.value)) {			
			return warnInvalid(document.THRCalc.RHR, iRHR);
		}
		if (!parseFloat(document.THRCalc.RHR.value)) {
			return warnInvalid(document.THRCalc.RHR, iRHR);
		}
		
		age= document.THRCalc.Age.value;
		rhr = document.THRCalc.RHR.value;
		
		mhr = 220 - parseFloat(age);
		
		thr60=(parseFloat(mhr) - parseFloat(rhr)) * 0.6 + parseFloat(rhr);
				
		thr75=(parseFloat(mhr) - parseFloat(rhr)) * 0.75 + parseFloat(rhr);
		
		thr80=(parseFloat(mhr) - parseFloat(rhr)) * 0.8 + parseFloat(rhr);
		
		thr85=(parseFloat(mhr) - parseFloat(rhr)) * 0.85 + parseFloat(rhr);
		
		thr90=(parseFloat(mhr) - parseFloat(rhr)) * 0.9 + parseFloat(rhr); 
		
		var strHTML;
		strHTML= "<br>";
		strHTML=strHTML + "<b>";
		strHTML=strHTML +  "THR 60% = " + thr60.toFixed(2);
		strHTML=strHTML + "</b>";
		strHTML= strHTML + "<br>";
		strHTML=strHTML + " Fat burning and develope oxygen transport system.";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "<b>";
		strHTML=strHTML + "THR 75% = " + thr75.toFixed(2);
		strHTML=strHTML + "</b>";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + " Fat burning and develope oxygen transport system.";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "<b>";
		strHTML=strHTML + "THR 80% = " + thr80.toFixed(2);
		strHTML=strHTML + "</b>";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "Improve lactic acid threshold."
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "<b>";
		strHTML=strHTML + "THR 85% = " + thr85.toFixed(2);
		strHTML=strHTML + "</b>";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "Lactic threshold.";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "<b>";
		strHTML=strHTML + "THR 90% = " + thr90.toFixed(2);
		strHTML=strHTML + "</b>";
		strHTML=strHTML + "<br>";
		strHTML=strHTML + "Speed.";
		
		
		document.getElementById("THRCalcRes").innerHTML=strHTML;
		
	
	}
	
	/*
	function validateForm(theForm)
	{
		
		if (isEmpty(theForm.first_name.value)) {
			return warnInvalid(theForm.first_name, ifirst_name);
		}
		
		if (isEmpty(theForm.last_name.value)) {
			return warnInvalid(theForm.last_name, ilast_name);
		} 
		
		if (isEmpty(theForm.email.value)) {
			return warnInvalid(theForm.email, iemail);
		} 
		
		if (!isEmail(theForm.email.value)) {
			return warnInvalid(theForm.email, iemailinvalid);
		} 
		
		if (theForm.phone.value != "") {
			if (!isInteger(theForm.phone.value)) {
				return warnInvalid(theForm.phone, iphone);
			} 			
		}
		
		if (isEmpty(theForm.comment.value)) {
			return warnInvalid(theForm.comment, icomment);
		}
		
		
		return true;
	}
	*/

function validateFilesExtensions(formName) {

	
	var theForm = document.forms[formName];

	
	for (i=0;i<theForm.elements.length;i++) {
		
		if (theForm.elements[i].type == 'file') {				
			var fileOK = false;
			var fileName;
			fileName = theForm.elements[i].value;
			fileName = fileName.substr(fileName.lastIndexOf('\\') + 1);
			if (fileName != '') {	
				fileOK = ExtensionsOkay(fileName.toLowerCase())
				if (fileOK == false) {
					theForm.elements[i].focus()
					return false;
				}
			}
		}
	}
	
	return true;
	
}


function ExtensionsOkay(FileName) {
	var extension = new Array();
	
	var fieldvalue = FileName;

	extension[0] = ".jpg";
	extension[1] = ".jpeg";
	/*
	extension[0] = ".tiff";	
	extension[1] = ".tif";
	extension[2] = ".jpg";
	extension[3] = ".jpeg";
	extension[4] = ".gif";	
	extension[5] = ".png";
	extension[6] = ".pdf";	
	extension[7] = ".doc";	
	extension[8] = ".docx";
	extension[9] = ".mdi";	
	extension[10] = ".mdi";		
	extension[11] = ".bmp";			
	*/
	// No other customization needed.
	var thisext = fieldvalue.substr(fieldvalue.lastIndexOf('.'));
	for(var i = 0; i < extension.length; i++) {
		
		if(thisext == extension[i]) { return true; }
	}
	msg = "Invalid file format. Please upload photos in .jpg format only.";
	//msg = 'At least one file you have selected is not in a format that we support. You must remove this document in order to save your claim.  Acceptable file formats include jpg, jpeg, tif, tiff, gif, png, pdf, doc, docx, mdi and bmp.';
	alert(msg);
	return false;
}

function setGoldie()
{
	document.cookie="goldie=1";
	document.getElementById("goldie1").innerHTML='<span id="goldie" name="goldie" onClick="javaScript:resetGoldie();" style="cursor:pointer">Set default Cursor</span> ';	



		browser = navigator.appName;
		
		if (browser == 'Netscape') 
		{
			document.body.setAttribute("class","body2");	
			
			//setInterval(window.location.reload(true),1000);					
		}
		else
		{
			document.body.style.cursor = "cursor/cursor.cur";	
		}
	
	//alert("cursor set");
}

function resetGoldie()
{
	document.body.setAttribute("class","body1");
	document.body.style.cursor = "default";	
	document.cookie="goldie=0";
	document.getElementById("goldie1").innerHTML='<span id="goldie" name="goldie" onClick="javaScript:setGoldie();" style="cursor:pointer">Set Goldie as Cursor</span> ';	
	//alert("cursor set");
}

function getcookie()
{
	var cdata=(document.cookie.substring(7,8));
	if(cdata=="1")
	{
	
		browser = navigator.appName;
		
		if (browser == 'Netscape') 
		{
			document.body.setAttribute("class","body2");
		}
		else
		{
			document.body.style.cursor = "cursor/cursor.cur";	
		}
	
		
	}
	else
	{
		document.body.setAttribute("class","body1");
		document.body.style.cursor = "default";			
	}
}
