﻿// JScript File
var xmlHttp

function GetAppraisalFee()
{ 
    AppTypeFound = false;
    for(i=0; i < document.AppraisalOrder.AppType.length; i++){
        if(document.AppraisalOrder.AppType[i].checked == true ){               
                   AppTypeFound = true;
                                      }
                }

    if(AppTypeFound == true){
        if((document.AppraisalOrder.PropertyState.value == '')||(document.AppraisalOrder.PropertyCounty.value == '')){
           alert('You must select a property state and/or county to calculate the appraisal fee.');
           document.AppraisalOrder.PropertyState.focus();	
           document.getElementById("apprfee").innerHTML = "";
        }
          else{
          
                //alert("through");
                xmlHttp=GetXmlHttpObject();
                
                if (xmlHttp==null)
                  {
                  alert ("Your browser does not support AJAX!");
                  return;
                  } 
                var url="/onlineorder/getappraisalfee.asp";
                url=url+"?FormType=" + document.AppraisalOrder.FormType.value + "&JobType=" + document.AppraisalOrder.JobType.value + "&PropertyCounty=" + document.AppraisalOrder.PropertyCounty.value + "&PropertyState=" + document.AppraisalOrder.PropertyState.value + "&ClientCode=" + document.AppraisalOrder.ClientFeeSchedule.value;
                xmlHttp.onreadystatechange=stateChanged;
                xmlHttp.open("GET",url,true);
                xmlHttp.send(null);
                }
    } 
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==4){
		document.getElementById("apprfee").innerHTML = '$'+xmlHttp.responseText+'*';
	}
}

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)
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      }
    return xmlHttp;
}

