﻿// 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 setOutputSupport() {		
// Change the value of the outputText field function setOutputQuote(){
    if (httpObject.readyState == 4) {
        var responseString = httpObject.responseText;
        var answer = responseString.substring(0, 1);
        //radalert(answer);
        if (answer == "1") {
            radalert("<strong>Thank you for your support 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 doWorkSupport(nameValue, organizationValue, address1Value, address2Value, cityValue, stateValue, zipValue, emailValue, phoneValue, applicationValue, reasonValue, TTCValue) {

    // Instantiate the HTTP Object   
    httpObject = getHTTPObject();
    if (httpObject != null) {
        //alert("not_null");
        httpObject.open("GET", "contact_support.aspx?cname=" + nameValue + "&org=" + organizationValue + "&addr1=" + address1Value + "&addr2=" + address2Value + "&city=" + cityValue + "&state=" + stateValue + "&zip=" + zipValue + "&email=" + emailValue + "&phone=" + phoneValue + "&app=" + applicationValue + "&reason=" + reasonValue + "&ttc=" + TTCValue, true);
        httpObject.send(null);
        // Call the setOutput function if the state changes, ie if there is a response.
        httpObject.onreadystatechange = setOutputSupport;
    }
}