﻿   //JavaScript for Guest List Signup
   
   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) {
          document.getElementById('messagespan').innerHTML = '<img src="graphics/ajax-loader.gif"> Please wait...';
      }
      if (http_request.readyState == 4) {
         if (http_request.status == 200) {
            //alert(http_request.responseText);
            result = http_request.responseText;
            document.getElementById('messagespan').innerHTML = result;            
         } else {
            alert('There was a problem with the request.');
         }
      }
   }   
   function get(obj) {
      var poststr = "Name_REQ=" + encodeURI( document.getElementById("Name_REQ").value ) +
      				"&company_REQ=" + encodeURI( document.getElementById("company_REQ").value ) +
      				"&address=" + encodeURI( document.getElementById("address").value ) +
					"&city=" + encodeURI( document.getElementById("city").value ) +
					"&state=" + encodeURI( document.getElementById("state").value ) +
					"&zip=" + encodeURI( document.getElementById("zip").value ) +
					"&phone=" + encodeURI( document.getElementById("phone").value ) +
					"&email=" + encodeURI( document.getElementById("email").value ) +
					"&fax=" + encodeURI( document.getElementById("fax").value ) +
					"&quantity_min=" + encodeURI(document.getElementById("quantity_min").value) +
                    "&quantity_max=" + encodeURI(document.getElementById("quantity_max").value) +
                    "&company_type=" + encodeURI(document.getElementById("company_type").value) +
					"&Describe_Problem=" + encodeURI(document.getElementById("Describe_Problem").value) +
					"&drawing_upload=" + encodeURI(document.getElementById("drawing_upload").value) +
					"&eau=" + encodeURI( document.getElementById("eau").value ) +
					"&material_specs_available=" + encodeURI(document.getElementById("material_specs_available").value) +
					"&color_match_required=" + encodeURI(document.getElementById("color_match_required").value) +
					"&closest_stock_part=" + encodeURI(document.getElementById("closest_stock_part").value) +
					"&closest_stock_dimension=" + encodeURI(document.getElementById("closest_stock_dimension").value) +
					"&papp_required=" + encodeURI(document.getElementById("papp_required").value) +
					"&domestic=" + encodeURI(document.getElementById("domestic").value) +
					"&itar_ddtc_required=" + encodeURI(document.getElementById("itar_ddtc_required").value) +
					"&someone_contact=" + encodeURI(document.getElementById("someone_contact").value) +
                    "&comments=" + encodeURI(document.getElementById("comments").value);
      makePOSTRequest('includes/sendmail.asp?', poststr);
   }

