	function createLinkThisPagePopup(href, width, height) {
		popup=window.open(href, 'Printversion', 'height='+height+',width='+width+',status,resizable=yes,scrollbars=yes');
		popup.focus();
	}

	/**
	* isIE
	*
	* is there is a poor, buggy javascript implementation running?
	*/
	function isIE() {
		return document.all != null;
	}
	
	/**
	* goFromPageToPage
	*
	* set idxTo to the hidden field 'nextpage' and invoke a submit on the form
	* of the page idxFrom.
	*
	*/
	function goFromPageToPage(idxFrom, idxTo) {
		currentForm = $("form" + idxFrom);
		$("nextpage").value = idxTo;
		currentForm.submit();
	}
	
	/**
	* initCalciumCalc
	*
	* called from the html body's onload handler:
	* HTMLBody::addAttribute('onload="initCalciumCalc(2);"');
	* See the ZWAP PHP class: HTMLBody.class.php.
	*/
	function initCalciumCalc(page) {
		switch(page) {
			case 1:
				initPage1();
				break;
			case 2:
				initPage2();
				break;
		}
	}
	
	var html_ageselector_m = '<select id="sel_age" name="sel_age" onchange="calcRecommendedIntake();"><option value="0">Seçiniz...</option><option value="3">4-6</option><option value="4">7-9</option><option value="5">10-18</option><option value="7">19-65</option><option value="8">65+</option></select>';
	var html_ageselector_w = '<select id="sel_age" name="sel_age" onchange="calcRecommendedIntake();"><option value="0">Seçiniz...</option><option value="3">4-6</option><option value="4">7-9</option><option value="5">10-18</option><option value="6">19+</option></select>';
	var mg_intake_ages = new Array();
mg_intake_ages[3] = 600;
mg_intake_ages[4] = 700;
mg_intake_ages[5] = 1300;
mg_intake_ages[6] = 1000;
mg_intake_ages[7] = 1000;
mg_intake_ages[8] = 1300;
mg_intake_ages[9] = 1200;
mg_intake_ages[10] = 1000;
mg_intake_ages[11] = 1300;

	var mg_intake_pregnant = 1200;
	var mg_intake_breastfeeding = 1000;
	var mg_intake_postmenopausal = 1300;
	
	/**
	* initPage1
	*
	*
	*/
	function initPage1() {
		calcRecommendedIntake();
	}

	/**
	* setup
	*
	* adapt the layout of page 1 to the gender selected by the user.
	*
	*/
	function setup(gender) {
		if(gender == 'w') {
			$("age_selection").innerHTML = html_ageselector_w;
			$("women_only").style.display = '';
		}
		else {
			$("age_selection").innerHTML = html_ageselector_m;
			$("women_only").style.display = 'none';
		}
	}
	
	/**
	* calcRecommendedIntake
	*
	*
	*
	*/
	function calcRecommendedIntake() {
		value = 0;
		sel_age = $("sel_age");
		if(($("female").checked) && ($("pregnant").checked)) {
			value = mg_intake_pregnant;
		}
		else if(($("female").checked) && ($("breastfeeding").checked)) {
			value = mg_intake_breastfeeding;
		}
		else if(($("female").checked) && ($("postmenopausal").checked)) {
			value = mg_intake_postmenopausal;
		}
		else {
			id = Form.Element.Serializers.selectOne(sel_age)[1];
			if(id > 0) {
				value = mg_intake_ages[id];
			}
		}
		$("intake_display").innerHTML = value;
		$("recommendedintake").value = value;
		form1.deger.value = value;
		
		
	}
	
	/**
	* validatePage1
	*
	* test if the age slect box has a value greater than zero.
	*
	*/
	function validatePage1() {
		sel_age = $("sel_age");
		id = Form.Element.Serializers.selectOne(sel_age)[1];
		if(id > 0) {
			$("form1").submit();			
		}
		else {
			alert("Lütfen ilerlemeden önce yaş ve cinsiyet bilgilerinizi giriniz.");
		}
	}

	function createLinkThisPagePopup(href, width, height) {
		popup=window.open(href, 'Printversion', 'height='+height+',width='+width+',status,resizable=yes,scrollbars=yes');
		popup.focus();
	}
		/**
	* isIE
	*
	* is there is a poor, buggy javascript implementation running?
	*/
	function isIE() {
		return document.all != null;
	}
	
	/**
	* goFromPageToPage
	*
	* set idxTo to the hidden field 'nextpage' and invoke a submit on the form
	* of the page idxFrom.
	*
	*/
	function goFromPageToPage(idxFrom, idxTo) {
		currentForm = $("form" + idxFrom);
		$("nextpage").value = idxTo;
		currentForm.submit();
	}
	
	/**
	* initCalciumCalc
	*
	* called from the html body's onload handler:
	* HTMLBody::addAttribute('onload="initCalciumCalc(2);"');
	* See the ZWAP PHP class: HTMLBody.class.php.
	*/
	function initCalciumCalc(page) {
		switch(page) {
			case 1:
				initPage1();
				break;
			case 2:
				initPage2();
				break;
		}
	}