<!-- 
/*
 * generic ajax code
 * copy right Healthcommunities.com 2008
 *
 * This code may not be used by anyone or entity without written consent from Healthcommunities.com
 */
//Browser Support Code
function ajaxFunction(theForm, writeto, submiturl, loading_url){

	var ajaxRequest;  // The variable that makes Ajax possible!
  var forumParam='';
	
	try{
		// Opera 8.0+, Firefox, Safari
		ajaxRequest = new XMLHttpRequest();
	} catch (e){
		// Internet Explorer Browsers
		try{
			ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			try{
				ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e){
				// Something went wrong
				alert("Your browser broke!");
				return false;
			}
		}
	}
	// Create a function that will receive data sent from the server
	ajaxRequest.onreadystatechange = function(){
			if(ajaxRequest.readyState == 1 && loading_url){
        document.getElementById(div_id_write).innerHTML ='<div class="loading_img"><img src="'+loading_url+'" /></div>';
      } else if(ajaxRequest.readyState == 4){
			//document.myForm.time.value = ajaxRequest.responseText;
        document.getElementById(writeto).innerHTML = ajaxRequest.responseText;
      
		}
	}
  forumParam=enumerateFormLoop(theForm);
  /*
  forumParam.replace('[', '%5B');
  forumParam.replace(']', '%5D');
  */


  ajaxRequest.open('POST', submiturl, true);
  ajaxRequest.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
  ajaxRequest.setRequestHeader("Content-length", forumParam.length);
  ajaxRequest.setRequestHeader("Connection", "close");
  ajaxRequest.send(forumParam);
/* get
	ajaxRequest.open("GET", submiturl + forumParam, true);
	ajaxRequest.send(null); 
*/
}


function enumerateFormLoop(theForm){
  //var theForm = document.forms[myForm]
  //var queryString = '?sumbitted=' + theForm.name + '&';
  var queryString='';
/*
   for(i=0; i<theForm.elements.length; i++){
     queryString += "Element Type: " + theForm.elements[i].type + "\n"
     queryString += "Element Name: " + theForm.elements[i].name + "\n"
     queryString += "Element Value: " + escape(theForm.elements[i].value) +"\n---------\n"
 
   }
 alert(queryString);
*/   
   for(i=0; i<theForm.elements.length; i++){


      if(theForm.elements[i].type == "text" 
        || theForm.elements[i].type == "textarea" 
        || theForm.elements[i].type == "hidden" 
        //|| theForm.elements[i].type == "button"
      ){
        queryString += theForm.elements[i].name
          + "="
          + escape(theForm.elements[i].value)
          + "&"
      } else if(theForm.elements[i].type == "checkbox"){
        //queryString += "Element Checked? " + theForm.elements[i].checked + "\n"
        queryString += theForm.elements[i].name
          + "="
          + escape(theForm.elements[i].checked)
          + "&"
      } else if(theForm.elements[i].type == "select-one"){
        //queryString += "Selected Option's Text: " + theForm.elements[i].options[theForm.elements[i].selectedIndex].text + "\n"
        queryString += theForm.elements[i].name
          + "="
          + escape(theForm.elements[i].text)
          + "&"
      }
   }
   return queryString;

}

//-->
