function ajax(url, func, id){
	var url_arr = new Array();
	url_arr = url.split('?');
	xmlhttp=null;
	if (window.XMLHttpRequest){// code for all new browsers
		xmlhttp=new XMLHttpRequest();
	}
	else if (window.ActiveXObject){// code for IE5 and IE6
		xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
	}
	if (xmlhttp!=null){
		xmlhttp.onreadystatechange = function() { 
			if (xmlhttp.readyState==4)
				if (xmlhttp.status==200)
					func(xmlhttp, id);
		}

		//xmlhttp.open("GET",url,true);
		xmlhttp.open("POST",url_arr[0],true);
		//Send the proper header information along with the request
		xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhttp.setRequestHeader("Content-length", url_arr[1].length);
		xmlhttp.setRequestHeader("Connection", "close");
		xmlhttp.send(url_arr[1]);
		//xmlhttp.send(null);
	}
	else{
		alert("Your browser does not support XMLHTTP.");
	}
}

function submitcontact(){
	first = document.getElementById('firstname').value;
	last = document.getElementById('lastname').value;
	email = document.getElementById('email').value;
	reason = document.getElementById('reason').value;
	message = document.getElementById('message').value;

	if(first==""){
		alert("Please fill in your first name");
		return;
	}
	if(last==""){
		alert("Please fill in your last name");
		return;
	}
	if(email==""){
		alert("Please fill in your email address");
		return;
	}
	if(reason==""){
		alert("Please fill in a reason for contact");
		return;
	}
	if(message==""){
		alert("Please fill in a message");
		return;
	}

	url = "contactemail.php?first="+first+"&last="+last+"&email="+email+"&subject="+reason+"&body="+message;
	ajax(url, confirmsubmitcontact, 'contactform_mid');
}

function confirmsubmitcontact(req, id){
	response = req.responseText;
	if(response == "1"){
		document.getElementById(id).innerHTML= "<h1>Success!</h1>Your email was sent to our customer service department.<BR>You should receive a reply within 24 hours."
	}
	else{
		alert("Email failed to send.  Please try again.");
	}
}