// JScript source code
 // <script language="javascript"  type="text/javascript">
    var url = "quoteSend.php?"; // The server-side script
    function handleHttpResponse() {
    if (http.readyState == 4) {
    if (http.responseText.indexOf('invalid') == -1) {
    // Use the XML DOM to unpack the city and state data
    var xmlDocument = http.responseXML;

    var message = xmlDocument.getElementsByTagName('message').item(0).firstChild.data;
    var success = xmlDocument.getElementsByTagName('success').item(0).firstChild.data
    //var city = 'Tom';

    //var state = xmlDocument.getElementsByTagName('state').item(0).firstChild.data;
    if(success = "true")
    {
    document.getElementById('quoteRequest').style.display = "none";
    document.getElementById('quoteMessage').style.display = "none";
    document.getElementById('txt').innerHTML = message;
    document.getElementById("txt").style.display = "block";
    //document.getElementById('state').value = state;
    }
    
    isWorking = false;
    }
    }
    }
    var isWorking = false;

    var x;
    
    function ShowAddition()
    {
        var addition = document.getElementById("addition");
        
        if(addition.style.display == 'none')        
        {
            document.getElementById("addition").style.display = "block";
        }
        else
        {
            document.getElementById("addition").style.display = "none";
        }
    }
    
    function quoteSend() {
    var Param = "";
    var projectValue = "";
    var additionValue = "";
    var addonValue = "";
    var workdescValue = "";
    var homeageValue = "";
    var timeValue = "";
    var budgetValue = "";
    var investmentValue = "";
    var nameValue = "";
    var addressValue = "";
    var locationValue = "";
    var phoneValue = "";
    var emailValue = "";
    if (!isWorking && http) {

for (x = 1; x <=6; x++)
                       {
    if (document.getElementById("project"+x).checked)
    {
        Param = document.getElementById("project"+x).value;
        if(projectValue == '')
        {
            projectValue = Param;
        }
        else
        {
            projectValue = projectValue +"^"+ Param;
        }
    }
    
}

Param = "" ;
for(x = 1; x <=4; x++)
{
    if (document.getElementById("addition"+x).checked)
    {
    Param = document.getElementById("addition"+x).value;    
    if(additionValue == '')
        {
            additionValue = Param;
        }
        else
        {
            additionValue = additionValue +"^"+ Param;
        }
    }
}

Param = "";
for(x = 1; x <=4; x++)
{    
    if(document.getElementById("addon"+x).checked)
    {
      addonValue = document.getElementById("addon"+x).value;  
    }
}

workdescValue = document.getElementById("workdesc").value;

Param = "";
for(x = 1; x <=4; x++)
{    
    if(document.getElementById("homeage"+x).checked)
    {
      homeageValue = document.getElementById("homeage"+x).value;  
    }
}

Param = "";
for(x = 1; x <=4; x++)
{    
    if(document.getElementById("time"+x).checked)
    {
      timeValue = document.getElementById("time"+x).value;  
    }
}

Param = "";
for(x = 1; x <=5; x++)
{    
    if(document.getElementById("budget"+x).checked)
    {
      budgetValue = document.getElementById("budget"+x).value;  
    }
}

Param = "";
for(x = 1; x <=3; x++)
{    
    if(document.getElementById("investment"+x).checked)
    {
      investmentValue = document.getElementById("investment"+x).value;  
    }
}

nameValue = document.getElementById("name").value;
addressValue = document.getElementById("address").value;
locationValue = document.getElementById("location").value;
phoneValue = document.getElementById("phone").value;
emailValue = document.getElementById("email").value;

if(nameValue != '' && addressValue != '' && locationValue != '' && phoneValue != '' && emailValue != '' && projectValue != '')
{
    if(document.getElementById("project1").checked == true && (additionValue == '' || addonValue == ''))
    {
         document.getElementById('txt').innerHTML = "<span style='color:red;'>Please make sure the type and size of addition is selected.</span>";
    }
    else
    {
        document.getElementById("process").style.display = "block";  
        http.open("GET", url +"project="+ escape(projectValue) +"&addition="+ escape(additionValue) +"&addon="+ escape(addonValue) +"&workdesc="+ escape(workdescValue) +"&homeage="+ escape(homeageValue) +"&time="+ escape(timeValue) +"&budget="+ escape(budgetValue) +"&investment="+ escape(investmentValue) +"&name="+ escape(nameValue) +"&address="+ escape(addressValue) +"&location="+ escape(locationValue) +"&phone="+ escape(phoneValue) +"&email="+ escape(emailValue) , true);
        http.onreadystatechange = handleHttpResponse;
        isWorking = true;
        http.send(null);
    }
}
else
{
    var errorMessage = ''
    if(projectValue == '')
    {
        errorMessage = errorMessage + "<span style='color:red;'>Please select a project.<br></span>"   
        document.getElementById('projectText').style.color = 'red';       
        document.getElementById('projectText').style.fontWeight = 'bold';     
    }
    
    if(nameValue == '')
    {
        errorMessage = errorMessage + "<span style='color:red;'>Please enter your Name.<br></span>"   
        document.getElementById('nameText').style.color = 'red'; 
        document.getElementById('nameText').style.fontWeight = 'bold';         
    }
    
    if(addressValue == '')
    {
        errorMessage = errorMessage + "<span style='color:red;'>Please enter your address.<br></span>"      
        document.getElementById('addressText').style.color = 'red';   
        document.getElementById('addressText').style.fontWeight = 'bold';     
    }
    
    if(locationValue == '')
    {
        errorMessage = errorMessage + "<span style='color:red;'>Please enter your location.<br></span>"     
        document.getElementById('locationText').style.color = 'red';   
        document.getElementById('locationText').style.fontWeight = 'bold';      
    }
    
    if(phoneValue == '')
    {
        errorMessage = errorMessage + "<span style='color:red;'>Please enter your phone number.<br></span>"     
        document.getElementById('phoneText').style.color = 'red';    
        document.getElementById('phoneText').style.fontWeight = 'bold';     
    }
    
    if(emailValue == '')
    {
        errorMessage = errorMessage + "<span style='color:red;'>Please enter your email.<br></span>"   
        document.getElementById('emailText').style.color = 'red';   
        document.getElementById('emailText').style.fontWeight = 'bold';        
    }
    
    document.getElementById('txt').innerHTML = "<span style='color:red;'><b>Please enter information for all the highlighted fields</b><br><br></span>";
}
    
    }
    }

    function updateData() {
    if (!isWorking && http) {
    var zipValue = document.getElementById("divtxt").innerHTML;
    http.open("GET", url + escape(zipValue), true);
    http.onreadystatechange = handleHttpResponse;
    isWorking = true;
    http.send(null);
    }
    }
    function getHTTPObject() {
    var xmlhttp;
    /*@cc_on
    @if (@_jscript_version >= 5)
    try {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try {
    xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (E) {
    xmlhttp = false;
    }
    }
    @else
    xmlhttp = false;
    @end @*/
    if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
    try {
    xmlhttp = new XMLHttpRequest();
    xmlhttp.overrideMimeType("text/xml");
    } catch (e) {
    xmlhttp = false;
    }
    }
    return xmlhttp;
    }
    var http = getHTTPObject(); // We create the HTTP Object
 // </script>
 
 function initialState()
 {
    for (x = 1; x <=6; x++)
    {
        
        document.getElementById("project"+x).checked = false;
    }
    for(x = 1; x <=4; x++)
    {
        document.getElementById("addition"+x).checked = false;    
        
    }
    for(x = 1; x <=4; x++)
    {
         document.getElementById("addon"+x).checked = false;
    }

    workdescValue = document.getElementById("workdesc").value = '';

    Param = "";
    for(x = 1; x <=4; x++)
    {
        document.getElementById("homeage"+x).checked = false;  
    }

    Param = "";
    for(x = 1; x <=4; x++)
    {
          document.getElementById("time"+x).checked = false;
    }

    Param = "";
    for(x = 1; x <=5; x++)
    {
          document.getElementById("budget"+x).checked = false;
    }

    Param = "";
    for(x = 1; x <=3; x++)
    {
          document.getElementById("investment"+x).checked = false; 
    }

nameValue = document.getElementById("name").value = '';
addressValue = document.getElementById("address").value = '';
locationValue = document.getElementById("location").value = '';
phoneValue = document.getElementById("phone").value = '';
emailValue = document.getElementById("email").value = '';
 }