function getXmlHttpObject() {
    var xmlHttp = null;
    
    try {
        // Firefox, Opera 8.0+, Safari
        xmlHttp = new XMLHttpRequest();
    }
    catch (e) {
        // Internet Explorer
        try {
            xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
        }
        catch (e) {
            try {
                xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
            }
            catch (e) { }
        }
    }
    
    return xmlHttp;
}

function ajaxLoading(e) {
    e.className = "ajaxLoading";
}

function ajaxDone(e, txt) {
    e.className = "ajaxDone";
    setHtml(e, txt);
}

function setHtml(e, txt) {
    e.innerHTML = txt;
}

function escapeVal(txt) {
    // txt is reference to that object value
    txt = encodeURIComponent(txt); // encode text string's carriage returns

    // replace new line character
    var newLine = "%0D%0A";
    if (txt.indexOf("%0D%0A") > -1) {
        // Windows encodes returns as \r\n hex
        txt = txt.replace(/%0D%0A/g, newLine);
    } else if (txt.indexOf("%0A") > -1) {
        // Unix encodes returns as \n hex
        txt = txt.replace(/%0A/g, newLine);
    } else if (txt.indexOf("%0D") > -1) {
        // Macintosh encodes returns as \r hex
        txt = txt.replace(/%0D/g, newLine);
    }
    
    return txt;
}