function checkForm(f){
	return true
	}

function showUserHistory(id, type){
	//alert('Showing ' +type+' history for user '+id+'...')
	var url		= '../../members/mycheck/index.php?type=' + type
	var props	= 'width=650,height=550,status=yes'
	if(window.userWindow == undefined || userWindow.closed){
		userWindow	= window.open(url, '', props)
		}
	else{
		userWindow.location.href = url
		userWindow.focus()
		}
	}
	
function editUserDetails(id){
	var url		= '../../members/admin/index.php?userId=' +id+ '&action=edit&postEditAction=close'
	var props	= 'width=670,height=560,status=yes,scrollbars=yes'
	window.open(url, '', props)
//	window.open(url)
	}
	
function calculateWaistToHip(){
	var f			= document.forms['form-mycheck']
	var waist		= parseInt(f['measurement[waist_circumference]'].value)
	var hip			= parseInt(f['measurement[hip_circumference]'].value)
	
	var val			= waist / hip
	if(isNaN(val)) val = ''
	
	f['measurement[waist_to_hip_ratio]'].value = val
	}
	
	function getDateFromDateString(dateStr){
		
		var validDate	= /^\d{1,2}\/\d{1,2}\/(19|20)\d\d$/
		if(dateStr.search(validDate) == -1)return null
		
		var arr		= dateStr.split('/')
		var d		= parseInt(arr[0])
		var m		= parseInt(arr[1]) - 1
		var y		= parseInt(arr[2])
		var d		= new Date(y, m, d)
		
		if(d == "Invalid Date") return null
		else return d
		}


	
rxBloodPressure = new RegExp('[0-9]{2,3}//[0-9]{2,3}');
rxDate = new RegExp('[0-9]{1,2}//[0-9]{1,2}//[0-9]{4,4}');

function checkMyCheckValues(f){

	try{
		
		if(f.date.value != ''){
			var date = getDateFromDateString(f.date.value)
			if(!date){
				throw('Date must be entered as dd/mm/yyyy')
				}
			}
		
		if(isNaN(f.weight.value))				throw('Weight must be entered as numbers only')
		if(isNaN(f.bmi.value))					throw('BMI must be entered as numbers only')
		if(isNaN(f.body_fat.value))				throw('Body Fat must be entered as numbers only')
		
		var bp		= f.blood_pressure.value
		if(bp != ''){
			var bpArr	= bp.split('/')
			if(bpArr.length != 2)					throw('Blood pressure must be entered as "xx/yy"')

			if(parseInt(bpArr[0]) <= parseInt(bpArr[1]))
													throw('Blood Pressure must be entered as numbers, with the first measuerment being the greater value')
			}
		
		if(isNaN(f.heart_rate.value))			throw('Heart Rate must be entered as numbers only')
		if(isNaN(f.cholesterol.value))			throw('Cholesterol must be entered as numbers only')
		if(isNaN(f.glucose.value))				throw('Glucose must be entered as numbers only')
		if(isNaN(f.pef.value))					throw('PEF must be entered as numbers only')
		if(isNaN(f.waist_circumference.value))	throw('Waist Circumference must be entered as numbers only')
		if(isNaN(f.hip_circumference.value))	throw('Hip Circumference must be entered as numbers only')
		if(isNaN(f.waist_to_hip_ratio.value))	throw('Waist-to-Hip Ratio must be entered as numbers only')
		if(isNaN(f.recovery_heart_rate.value))	throw('Recovery Heart Rate must be entered as numbers only')
		
		}

	catch(e){
		alert(e)
		return false
		}

	return true
	}
