

function movepic(img_name,img_src) {
document[img_name].src=img_src;

}

function new_window(url) {
	var w = 350;
	var h = 200;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=0,resizable=0';
	features = features + ',width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
	mywin = window.open(url,"popWin",features);
}

function NewWindow(page) {
OpenWin = this.open(page, "CtrlWindow", "width=550,height=500,toolbar=no,menubar=no,location=no,scrollbars=yes,resizable=yes,status=no");
}

function RoachWindowOpener(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function pop_window(url,w,h,s) {
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0';
	features = features + ',scrollbars=' + s + ',width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
	mywin = window.open(url,"popWin",features);
}

function pop_window2(url,w,h,s) {
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,resizable=0';
	features = features + ',scrollbars=' + s + ',width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
	mywin = window.open(url,"popWin2",features);
}


function popupForm(url, w, h, scroll, resize) {
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0';
	features = features + ',width=' + w + ',height=' + h + ',left=' + l + ',top=' + t + ',scrollbars=' + scroll + ',resizable=' + resize;
	mywin = window.open(url,"popWin",features);
}

function checkNumeric(inField)
{
	var strpin= inField.value;
	var strname = inField.name;

	for (var i = 0;i < strpin.length;i++)
	{
		if ((strpin.substring(i,i+1)!="1") && (strpin.substring(i,i+1)!= "2") &&
(strpin.substring(i,i+1)!="3") && (strpin.substring(i,i+1)!="4") &&
(strpin.substring(i,i+1)!="5") && (strpin.substring(i,i+1)!="6") &&
(strpin.substring(i,i+1)!="7") && (strpin.substring(i,i+1)!="8") &&
(strpin.substring(i,i+1)!="9") && (strpin.substring(i,i+1)!="0") &&
(strpin.substring(i,i+1)!="-") && (strpin.substring(i,i+1)!="(") &&
(strpin.substring(i,i+1)!=")") && (strpin.substring(i,i+1)!="+") &&
(strpin.substring(i,i+1)!=" "))
		{
			alert('The new food ' + strname + ' must be a numeric value.');
			return false;
		}
	}

	return true;
}

function checkForm()
{
	/* Lets make sure that the age is entered */
	if (document.form1.restPulseBase.value == "")
	{
		document.form1.restPulseBase.focus();
		document.form1.restPulseBase.select();
		alert('We need your Pulse Rate at Rest so that we can customize your exercise plan.');
		return false;
	}

	/* Lets make sure that the age is a number */
	if (checkNumFields(document.form1.restPulseBase) == false)
	{
		document.form1.restPulseBase.focus();
		document.form1.restPulseBase.select();
		return false;
	}
}

function checkForm2()
{
	var cardioChecked = 0;
	for (i=0;i<document.form1.cardioList.length;i++)
	{
		if (eval('document.form1.cardioList[' + i + '].checked') ==1)
		{
			var cardioChecked =1;
		}
	}
	if (cardioChecked ==1)
		{

		var cardioDaysChecked = 0;
		for (i=0;i<document.form1.cardioDayList.length;i++)
			{
				if (eval('document.form1.cardioDayList[' + i + '].checked') ==1)
			{
				var cardioDaysChecked = cardioDaysChecked + 1;
			}
		}
		if (cardioDaysChecked == document.form1.cardiodays.value)
			{

			var strengthDaysChecked = 0;
			for (i=0;i<document.form1.strengthDayList.length;i++)
			{
				if (eval('document.form1.strengthDayList[' + i + '].checked') ==1)
				{
					var strengthDaysChecked = strengthDaysChecked + 1;
				}
			}
			if (strengthDaysChecked == document.form1.strengthdays.value)
				{
					return true;
				}
			else
				{
					var url = 'dsp_check1strengthday.cfm?numDays=' + document.form1.strengthdays.value;
					pop_window(url,300, 200,0,0);
					return false;
				}
			}
		else
			{
				var url = 'dsp_check1cardioday.cfm?numDays=' + document.form1.cardiodays.value;
				pop_window(url,300, 200,0,0);
				return false;
			}
		}
	else		
	{
		pop_window('dsp_check1cardio.cfm',300, 200,0,0);
		return false;
	}
}

	
function checkNumFields(inField)
{
	var strpin= inField.value;
	var strname = inField.name;

	for (var i = 0;i < strpin.length;i++)
	{
		if ((strpin.substring(i,i+1)!="1") && (strpin.substring(i,i+1)!= "2") &&
(strpin.substring(i,i+1)!="3") && (strpin.substring(i,i+1)!="4") &&
(strpin.substring(i,i+1)!="5") && (strpin.substring(i,i+1)!="6") &&
(strpin.substring(i,i+1)!="7") && (strpin.substring(i,i+1)!="8") &&
(strpin.substring(i,i+1)!="9") && (strpin.substring(i,i+1)!="0") &&
(strpin.substring(i,i+1)!="-") && (strpin.substring(i,i+1)!="(") &&
(strpin.substring(i,i+1)!=")") && (strpin.substring(i,i+1)!="+") &&
(strpin.substring(i,i+1)!=" "))
		{
			alert('You must enter a number for your Heart Rate at Rest.');
			return false;
		}
	}

	return true;
}

 function putFocus(formInst, elementInst) {
  if (document.forms.length > 0) {
   document.forms[formInst].elements[elementInst].focus();
   document.forms[formInst].elements[elementInst].select();
  }
 }
// The second number in the "onLoad" command in the body
// tag determines the form's focus. Counting starts with '0'

function ConfirmDelete(){
		return confirm("Do you really want to delete this item?");
	}

function newWindow(URL,xSize,ySize,scrollBars){
	if (URL != "none")
	{
		var WindOptions = new String("'toolbar=no,directories=no,status=no,menubar=no,scrollbars=" + scrollBars + ",resizable=yes,width=" + xSize + ",height=" + ySize +"'")
		var newWind = window.open(URL,'popWin',WindOptions)	
		if (newWind.opener == null)
		{
			newWind.opener = self;
		}	
	}
}	

function exportChecked(currday)
{
//A variable that will hold the index number of the selected radio button
	var exportlist1 = '1,2,3,4,5,6,7';
		
	var url = 'export/index.cfm?fuseaction=exportForm&currentDay=' + currday +'&exportlist=' + exportlist1;
	var w = 422;
	var h = 324;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1';
	features = features + ',width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
	mywin = window.open(url,'popWin',features);
}

function exportChecked2(currday)
{
//A variable that will hold the index number of the selected radio button
	var exportlist1 = '';
	for (i=0;i<document.form2.exportlist.length;i++)
	{
		if (i==0 && document.form2.exportlist[i].checked==true) exportlist1=exportlist1 + document.form2.exportlist[i].value;
		else if (document.form2.exportlist[i].checked==true) exportlist1=exportlist1 + ',' + document.form2.exportlist[i].value;
	}
	if (exportlist1=="") return;
	
	var url = 'export/index.cfm?fuseaction=exportForm&currentDay=' + currday +'&exportlist=' + exportlist1;
	var w = 450;
	var h = 250;
	var l = (screen.width - w) / 2;
	var t = (screen.height - h) / 2;
	var features = 'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1';
	features = features + ',width=' + w + ',height=' + h + ',left=' + l + ',top=' + t;
	mywin = window.open(url,'popWin',features);
}





function textCount(maxLen,formName,errorMessage){
	var formString = "document.forms[0]." + formName;
	//alert(formString);
	if (eval(formString).value.length > maxLen){
		eval(formString).value = eval(formString).value.substring(0, maxLen);
		alert("Your "+errorMessage+" may not be more then "+maxLen+" characters in length");
	}
}


