var xmlhttp=false;
/*@cc_on @*/
/*@if (@_jscript_version >= 5)
// JScript gives us Conditional compilation, we can cope with old IE versions.
// and security blocked creation of the objects.
  try {
  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  } catch (e) {
   try {
	xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
   } catch (E) {
	xmlhttp = false;
   }
  }
@end @*/
if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  xmlhttp = new XMLHttpRequest();
}

function Get_ZIP(zip) {
	//xmlhttp.open("GET", "?zip=" + zip, true);
	xmlhttp.open("GET", site_url + "/engine/support.php?zip=" + zip, true);
	xmlhttp.onreadystatechange = function() {
		if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
				xml = xmlhttp.responseXML;
				//xml = xmlhttp.responseText;
				if (xml.documentElement) {
					var city = xml.documentElement.getElementsByTagName("City")[0].firstChild.nodeValue; //.toLowerCase() make it lowercase, and capitalize first letter of each word using CSS
					//var city = xml.documentElement.getElementsByTagName("City");
					var state = xml.documentElement.getElementsByTagName("State")[0].firstChild.nodeValue;
					document.getElementById("city").value = city;
					document.getElementById("state").value = state;
				}
		}
	}
  xmlhttp.send(null);
}

function send_support_form(url, parameters) {
	xmlhttp.onreadystatechange = alertContents;
	xmlhttp.open('POST', url, true);
	xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	xmlhttp.setRequestHeader("Content-length", parameters.length);
	xmlhttp.setRequestHeader("Connection", "close");
	xmlhttp.send(parameters);
}

function alertContents() {
  if (xmlhttp.readyState == 4) {
	 if (xmlhttp.status == 200) {
		//alert(xmlhttp.responseText);
		result = xmlhttp.responseText;
		document.getElementById('quote').innerHTML = result;
	 } else {
		document.getElementById('quote').innerHTML = "There was a problem with the request.";
	 }
  }
}

function post(obj) {
  var poststr = "name=" + encodeURI( document.getElementById("name").value ) + 
				"&email=" + encodeURI( document.getElementById("email").value ) + 
				"&country=" + encodeURI( document.getElementById("country").value ) + 
				"&subject=" + encodeURI( document.getElementById("subject").value ) + 
				"&inquiry=" + encodeURI( document.getElementById("inquiry").value );
  document.getElementById('quote').innerHTML = '<span style="color: #fff; background-color: #0000FF; font-size: 1.5em; margin-left: 15px;">Loading...</span>';
  send_support_form(site_url + '/engine/support.php', poststr);
}