   var http_request = false;
   function makePOSTRequest(url, parameters) {
      http_request = false;
      if (window.XMLHttpRequest) { // Mozilla, Safari,...
         http_request = new XMLHttpRequest();
         if (http_request.overrideMimeType) {
         	// set type accordingly to anticipated content type
            //http_request.overrideMimeType('text/xml');
            http_request.overrideMimeType('text/html');
         }
      } else if (window.ActiveXObject) { // IE
         try {
            http_request = new ActiveXObject("Msxml2.XMLHTTP");
         } catch (e) {
            try {
               http_request = new ActiveXObject("Microsoft.XMLHTTP");
            } catch (e) {}
         }
      }
      if (!http_request) {
         alert('Cannot create XMLHTTP instance');
         return false;
      }
      
      http_request.onreadystatechange = alertContents;
      http_request.open('POST', url, true);
      http_request.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
      http_request.setRequestHeader("Content-length", parameters.length);
      http_request.setRequestHeader("Connection", "close");
      http_request.send(parameters);
   }

   function alertContents() {
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            result = http_request.responseText;
            document.getElementById('div_calc').innerHTML = result;
         } else {
            alert('There was a problem with the request.');
         }
      }else{
		  document.getElementById('div_calc').innerHTML = "<img src='images/ajax-loading.gif' width='32' height='32' />";
	  }
   }
   
   function risk_calc(obj) {
      var poststr = "gender=" + encodeURI( document.getElementById("gender").value ) +
	  				"&age=" + encodeURI( document.getElementById("age").value ) +
					"&tc=" + encodeURI( document.getElementById("tc").value ) +
					"&smoker=" + encodeURI( document.getElementById("smoker").value ) +
					"&sbp=" + encodeURI( document.getElementById("sbp").value ) +
					"&treated=" + encodeURI( document.getElementById("treated").value ) +
                    "&hdlc=" + encodeURI( document.getElementById("hdlc").value );
      makePOSTRequest('make_cal.php', poststr);
   }
   
   function bmi_calc(obj) {
      var poststr = "txt_weight=" + encodeURI( document.getElementById("txt_weight").value ) +
					"&list_weight=" + encodeURI( document.getElementById("list_weight").value ) +
					"&txt_height=" + encodeURI( document.getElementById("txt_height").value ) +
                    "&list_height=" + encodeURI( document.getElementById("list_height").value );
      makePOSTRequest('makeb_cal.php', poststr);
   }