var oldPregStatus;

function checkgender() {
	var gender_dd = document.getElementById('gender');
	var ispreg_div = document.getElementById('pregnancy_select');
	var preg_weeks_div = document.getElementById('pregnancy_weeks');
	var waist_row = document.getElementById('waist_row');
	var hips_row = document.getElementById('hips_row');
	var bodyfat_row = document.getElementById('bodyfat_row');
	var ispregnant = getcheckedvalue(document.forms['healthAssessmentForm'].elements['ispregnant']);
	var preg_curr_weight = document.getElementById('preg_curr_weight');
	var chol_and_lipids = document.getElementById('chol_and_lipids_row');
	var chol_and_lipids1 = document.getElementById('chol_and_lipids_row1');
	var chol_and_lipids2 = document.getElementById('chol_and_lipids_row2');
	var chol_and_lipids3 = document.getElementById('chol_and_lipids_row3');
	var chol_and_lipids4 = document.getElementById('chol_and_lipids_row4');
	
	if (oldPregStatus == "" || oldPregStatus == null) {oldPregStatus = ispregnant;}
	
	toggleweighttext('Weight');
	
	if (gender_dd.value == 'f') {
		if (ispreg_div.style.display == 'none') {
			ispreg_div.style.display = "";
		}
		if (ispregnant == 'n') {
			//oldPregStatus = 'n';
			preg_weeks_div.style.display = "none";
			preg_curr_weight.style.display = "none";
			chol_and_lipids.style.display = "";
			chol_and_lipids1.style.display = "";
			chol_and_lipids2.style.display = "";
			chol_and_lipids3.style.display = "";
			chol_and_lipids4.style.display = "";
			waist_row.style.display = '';
			hips_row.style.display = '';
			bodyfat_row.style.display = '';
		} else if (ispregnant == 'y') {
			//oldPregStatus = 'y';
			toggleweighttext('Pre-Pregnancy Weight');
			preg_weeks_div.style.display = "";
			preg_curr_weight.style.display = "";
			chol_and_lipids.style.display = "none";
			chol_and_lipids1.style.display = "none";
			chol_and_lipids2.style.display = "none";
			chol_and_lipids3.style.display = "none";
			chol_and_lipids4.style.display = "none";
			waist_row.style.display = 'none';
			hips_row.style.display = 'none';
			bodyfat_row.style.display = 'none';
		}
	} else {
		ispreg_div.style.display = "none";
		preg_weeks_div.style.display = "none";
		preg_curr_weight.style.display = "none";
	}
	
	setTimeout('checkgender();', 100);
}

function getcheckedvalue(radioObj) {
	if(!radioObj)
		return "";
	var radioLength = radioObj.length;
	if(radioLength == undefined)
		if(radioObj.checked)
			return radioObj.value;
		else
			return "";
	for(var i = 0; i < radioLength; i++) {
		if(radioObj[i].checked) {
			return radioObj[i].value;
		}
	}
	return "";
}


function toggleweighttext(thetext) {
	var weighttext = document.getElementById('weight_text');
	if (weighttext.innerHTML != thetext) {
		weighttext.innerHTML = thetext;
	}
}

function showgoaloverview(goal) {
	var loc;
	var mywin;
	if (goal != '' && goal != null) {
		loc = 'include/goaloverview.php?goal='+goal;
	} else {
		loc = 'include/goaloverview.php';
	}
	mywin = window.open(loc,'goaloverview','left=20,top=20,width=600,height=350,toolbar=0,resizable=1,scrollbars=1');
	mywin.focus();
}

function continuetosignup() {
	window.location = "http://www.nutrigoals.com/signup";
}

function continuetoamiready() {
	window.location = "http://www.nutrigoals.com/secure/amiready.php";
}