var http_request = false;

function makeHttpRequest(url, callback_function, return_xml)
{
   //var http_request = false;

   if (window.XMLHttpRequest) { // Mozilla, Safari,...
       http_request = new XMLHttpRequest();
       if (http_request.overrideMimeType) {
           http_request.overrideMimeType('text/xml');
       }
   } 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('Unfortunatelly you browser doesn\'t support this feature.');
       return false;
   }
   http_request.onreadystatechange = function() {
       if (http_request.readyState == 4) {
           if (http_request.status == 200) {
               if (return_xml) {
                   eval(callback_function + '(http_request.responseXML)');
               } else {
                   eval(callback_function + '(http_request.responseText)');
               }
           } else {
               alert('There was a problem with the request.(Code: ' + http_request.status + ')');
           }
       }
   }
   http_request.open('POST', url, true);
   http_request.send('');
}

function alertInfoFormContents(text) {
    if (text.indexOf("success") >= 0) {
		alert("Thank you very much for your feedback! We will respond quickly.");
	} else {
		alert("We are sorry, but the data failed to send for some reason. Please send us an e-mail at info@maphazards.com and we will get this problem resolved quickly." + result);
	}
}

function alertAddressCallbackContents(text) {
    if (text.indexOf("goodsuccess") >= 0) {
	} else {
		alert("There is a problem talking to the server" + http_request.status);
	}
}
   
   function get(obj) {
      var getstr = "";
      for (i=0; i<obj.childNodes.length; i++) {
         if (obj.childNodes[i].tagName == "INPUT" || obj.childNodes[i].tagName == "TEXTAREA") {
            if (obj.childNodes[i].type == "text" || obj.childNodes[i].type == "textarea") {
               getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
            }
            if (obj.childNodes[i].type == "checkbox") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               } else {
                  getstr += obj.childNodes[i].name + "=&";
               }
            }
            if (obj.childNodes[i].type == "radio") {
               if (obj.childNodes[i].checked) {
                  getstr += obj.childNodes[i].name + "=" + obj.childNodes[i].value + "&";
               }
            }
         }   
         if (obj.childNodes[i].tagName == "SELECT") {
            var sel = obj.childNodes[i];
            getstr += sel.name + "=" + sel.options[sel.selectedIndex].value + "&";
         }
         
      }
      makeHttpRequest('contactform.aspx?' + getstr, 'alertInfoFormContents', false);
   }
