﻿function do_submit(myval)
{
    if (document.getElementById("message").value == "")
    {
        alert("You must enter a message");
    }
    else if (document.getElementById("from").value == "")
    {
        alert("You must enter a reply email address");
    }
    else
    {
        var xmlHttp;
        
        try 
        {    
            xmlHttp = new XMLHttpRequest();    
        }
        catch (e)
        {    
            try
            {      
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch (e)
            {      
                try
                {        
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");        
                }
                catch (e)
                {        
                    alert("Your browser does not support AJAX");        
                    return false;        
                }
            }
         }
         xmlHttp.onreadystatechange = function() {
             if (xmlHttp.readyState == 4) {
                 var xml_response = xmlHttp.responseText;

                 var split01 = xml_response.split("<response>");
                 var split02 = split01[1].split("</response>");
                 var response = split02[0];

                 if (response == 0) {
                     var split01 = xml_response.split("<data>");
                     var split02 = split01[1].split("</data>");
                     var response = split02[0];

                     alert(response);
                 }
                 else if (response == 1) {
                     var split01 = xml_response.split("<data>");
                     var split02 = split01[1].split("</data>");
                     var response = split02[0];

                     alert(response);

                     if (myval == 0) {
                         window.location.href = "faq.aspx";
                     }
                     if (myval == 1) {
                         window.location.href = "contact.aspx";
                     }

                 }

             }
         }
        
        xmlHttp.open("GET", noCache("question_email.aspx?message=" + encodeURI(document.getElementById("message").value) + "&from=" + document.getElementById("from").value), true);
        xmlHttp.send(null);  
    }
}
function noCache(uri)
{
    return uri.concat( /\?/.test(uri)?"&":"?", "noCache=",(new Date).getTime(),".", Math.random()*1234567 )
}
