﻿// Get the HTTP Object
function getHTTPObject(){
	if (window.ActiveXObject){
		return new ActiveXObject("Microsoft.XMLHTTP");
	}
	else if (window.XMLHttpRequest){
		return new XMLHttpRequest();
	}
	else {
		radalert("Your browser does not support AJAX.");
		return null;
	}
}
function setOutputContact() {		
// Change the value of the outputText field function setOutputQuote(){
    if (httpObject.readyState == 4) {
        var responseString = httpObject.responseText;
        var answer = responseString.substring(0, 1);
//        alert(answer);
        if (answer == "1") {
            radalert("<strong>Thank you for your contact request. We will respond shortly.</strong>"); 
	    }
	    else {
	        radalert("<font color='#FF0000'>Email Error</font><br><br>Please check your information and try again.");
	    }
	}
}
			
// Implement business logic
function doWorkContact(cName, cEmail, cPhone, cComments) {
    
	// Instantiate the HTTP Object   
	httpObject = getHTTPObject();
	if (httpObject != null) {
		//alert("not_null");
	    httpObject.open("GET", "contact2.aspx?cname=" + cName + "&cemail=" + cEmail + "&cphone=" + cPhone + "&ccomments=" + cComments, true);
		httpObject.send(null); 
		// Call the setOutput function if the state changes, ie if there is a response.
		httpObject.onreadystatechange = setOutputContact;
	}
}

