function getHTTPObject() {
  var xmlhttp; 
  if (window.XMLHttpRequest) { // Mozilla, Safari,...
         xmlhttp = new XMLHttpRequest();
         if (xmlhttp.overrideMimeType) {
            xmlhttp.overrideMimeType('text/xml');
         }
  } else if (window.ActiveXObject) { // IE
         try {
            xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
            xmlhttp.preserveWhiteSpace = false;
         } catch (e) {
            try {
               xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
               xmlhttp.preserve = false;
            } catch (e) {}
         }
         
  }
    if (!xmlhttp) {
      alert('Cannot create XMLHTTP instance');
      return false;
    }
  return xmlhttp; 
} 

var http = getHTTPObject(); // We create the HTTP Object 

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}
function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function getQueryVariable(variable) {
  var query = window.location.search.substring(1);
  var vars = query.split("&");
  for (var i=0;i<vars.length;i++) {
    var pair = vars[i].split("=");
    if (pair[0] == variable) {
      return pair[1];
    }
  } 
  return false;
}

// Do this function on page load to see if there is a GET variable
function page_load() {
  
  show_div('');
  MM_preloadImages('images/trustee_r4_c2_f2.gif','images/prop_info_f2.gif','images/prop_tax_report_f2.gif','images/prop_tax_notice_f2.gif','images/prop_help_f2.gif','images/general_menu_f2.gif','images/detailed_menu_f2.gif','images/deed_menu_f2.gif','images/plat_menu_f2.gif','images/district_menu_f2.gif');
  if (varia = getQueryVariable('prop_id')) {
    document.getElementById('searchss').value = varia;
    document.getElementById('param').value = 'prop_id';
    get_info('general', 'general');
  } else if (varia = getQueryVariable('name')) {
    document.getElementById('searchss').value = varia;
    document.getElementById('param').value = 'name';
    get_info('general', 'general');
  } else if (varia = getQueryVariable('address')) {
    document.getElementById('searchss').value = varia;
    document.getElementById('param').value = 'address';
    get_info('general', 'general');
  } else if (varia = getQueryVariable('change')) {
    document.getElementById('info_box').style.visibility = 'visible';
  }
  //alert("Property Tax Detailed, Deed, and District information is offline for repair.");
}

// Show Property Information Menu
function show_menu() {
  MM_swapImage('Image37','','images/prop_info_f2.gif',1);
  document.getElementById('prop_menu').style.visibility = 'visible';
}

// Close Property Information Menu 
function close_menu() {
  MM_swapImgRestore();
  document.getElementById('prop_menu').style.visibility = 'hidden';
}

// Show different sections of Information
function show_div(sdiv) {
  document.getElementById('prop_menu').style.visibility = 'hidden';
  //get_info();
  //get_info();
  if (sdiv == 'general') {
    document.getElementById('general_info').style.visibility = 'visible';
  } else {
    document.getElementById('general_info').style.visibility = 'hidden';
  }
  if (sdiv == 'detailed') {
    document.getElementById('detailed_info').style.visibility = 'visible';
  } else {
    document.getElementById('detailed_info').style.visibility = 'hidden';
  }
  if (sdiv == 'deed') {
    document.getElementById('deed_info').style.visibility = 'visible';
  } else {
    document.getElementById('deed_info').style.visibility = 'hidden';
  }
  if (sdiv == 'plat') {
    document.getElementById('plat_info').style.visibility = 'visible';
  } else {
    document.getElementById('plat_info').style.visibility = 'hidden';
  }
  if (sdiv == 'district') {
    document.getElementById('district_info').style.visibility = 'visible';
  } else {
    document.getElementById('district_info').style.visibility = 'hidden';
  }
  if (sdiv == 'loading') {
    document.getElementById('loadings').style.visibility = 'visible';
  } else {
    document.getElementById('loadings').style.visibility = 'hidden';
  }
  if (sdiv == 'pay') {
    document.getElementById('payment_info').style.visibility = 'visible';
  } else {
    document.getElementById('payment_info').style.visibility = 'hidden';
  }
  if (sdiv == 'no_results') {
    document.getElementById('noResults').style.visibility = 'visible';
  } else {
    document.getElementById('noResults').style.visibility = 'hidden';
  }
  if (sdiv == 'change_owner') {
    document.getElementById('owner_change').style.visibility = 'visible';
  } else {
    document.getElementById('owner_change').style.visibility = 'hidden';
  }
  if (sdiv == 'change_mailing') {
    document.getElementById('mailing_change').style.visibility = 'visible';
  } else {
    document.getElementById('mailing_change').style.visibility = 'hidden';
  }
  if (sdiv == 'list_results' || document.getElementById('hold').value == 'yes') {
    document.getElementById('list_results').style.visibility = 'visible';
  } else {
    document.getElementById('list_results').style.visibility = 'hidden';
  }
  if (sdiv == 'validate_mailing_prechange_warning') {
    document.getElementById('mailing_change_prevalidate_content').style.visibility = 'visible';
  }
   else {
    document.getElementById('mailing_change_prevalidate_content').style.visibility = 'hidden';
  }
  if (sdiv == 'property_id_must') {
    document.getElementById('property_id_must').style.visibility = 'visible';
  }
   else {
    document.getElementById('property_id_must').style.visibility = 'hidden';
  }
}

// This function prints the tax report
function print_tax() {
  if (document.getElementById('prop_id').value != "") {
  window.open('reports/tax_report.php?prop_id='+document.getElementById('prop_id').value, 'report', 'width=700,height=400');
  } else {
    alert("You must search for property before using this function");
  }
}

// This function to print notice
function print_notice() {
  if (document.getElementById('prop_id').value != "") {
    window.open('reports/tax_notice.php?prop_id='+document.getElementById('prop_id').value, 'report', 'width=700,height=400');
  } else {
    alert("You must search for property before using this function");
  }
}

// This function to print reciept
function print_reciept() {
  window.open('reports/tax_reciept.php?prop_id='+document.getElementById('prop_id').value, 'report', 'width=700,height=400');
}

// This function determines if we should query KGIS again or not (takes very long to query KGIS)
function more_details(page) {
  if (document.getElementById('got_details').value == 'yes') {
    show_div(page);
  } else {
    get_info('no', page);
  }
}

// Function to check for proper selection of search
function properSearch(general, detail) {
  if (document.getElementById('param').value != "") {
    get_info(general, detail);
  } else {
    alert("Please choose an Option to Search By.");
  }
}

// This function is for changing the colors of rows in the Search Results table
function mouseOver(row) {
  row.bgColor="#b3d9ff";
  row.style.cursor = "pointer";
}


function getResults(prop) {
  document.getElementById('searchss').value = prop;
  document.getElementById('param').value = 'prop_id';
  document.getElementById('hold').value = 'yes';
  get_info('general', 'general');
}

// This function closes search results list and keeps it closed
function close_list() {
  document.getElementById('hold').value = 'no';
  document.getElementById('list_results').style.visibility = 'hidden';
}

// This function closes info box and keeps it closed
function close_info() {
  //document.getElementById('info_box').value = 'no';
  document.getElementById('info_box').style.visibility = 'hidden';
}

// This is the main function
function get_info(detail,page) {
  
  // Create object for retrieving information from tax lookup
  http = getHTTPObject();
  
  // Continue if successful in creating object
  if (http) { 
    
    // If just 'general' information just query database only else query database and KGIS
    if (detail == 'general') {
      var urls = "data/search.php?search="+document.getElementById('searchss').value+"&param="+document.getElementById('param').value;
      //alert(document.getElementById('searchss').value);
      http.open("GET", urls, true);
    } else {
      http.open("GET", "data/search.php?search="+document.getElementById('searchss').value+"&param="+document.getElementById('param').value+"&full=yes", true);
    }
    // Show loading section why getting information
    show_div('loading');
    
    // When inform
    http.onreadystatechange = function () {
      if (http.readyState == 4) {
        //alert("breakpoint");
        if (http.responseText.indexOf('invalid') == -1) {
          
          // Declare XMl Doc
          var xmlDocument = http.responseXML;
          xmlObj = xmlDocument.documentElement;
          
          //document.getElementById('debugging').innerHTML = http.responseText; //For testing purposes
          //alert(http.responseText);
          
          //##############################
          //### If there is more than one result returned then show list of properties
          //#############################
          if (xmlObj.firstChild.getAttribute('amount') > 1) {
            //alert(xmlObj.childNodes[1].childNodes.length);
            
            // Fill in search results div
            var listSearch = "<table width='230' cellpadding='0' cellspacing='0'>";
            //ialert("here 14");
            for (i=0;i<xmlObj.childNodes[1].childNodes.length;i++) {
              //alert(xmlObj.childNodes[1].childNodes[i].childNodes[2].firstChild.nodeValue);
              listSearch += "<tr onmouseover='mouseOver(this)' onmouseout='this.bgColor=\"white\"' onclick='getResults(\""+xmlObj.childNodes[1].childNodes[i].firstChild.firstChild.nodeValue.replace('|tt','')+"\")'><td valign='top' class='list_table_cell'>"+xmlObj.childNodes[1].childNodes[i].firstChild.firstChild.nodeValue.replace('|tt','')+"</td>";
              listSearch += "<td valign='top' class='list_table_cell'>"+xmlObj.childNodes[1].childNodes[i].childNodes[2].firstChild.nodeValue.replace('|tt','')+"</td></tr>";
              
            }
            
            document.getElementById('search_list').innerHTML = listSearch;
            
            show_div('list_results');
          
          // Else if no results are returned then show "No Results" div  
          } else if (xmlObj.firstChild.getAttribute('amount') == 0) {
            //alert(xmlObj.firstChild.getAttribute('amount'));
            show_div('no_results');
            
          // If there is only one property returned then fill in data
          } else {
            
            // Set cursor on prop id
            prop_info = xmlObj.childNodes[1].firstChild;
            
            // Set property ID
            document.getElementById('prop_id').value = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
            
            //####### Testing  ########
            
            //document.getElementById("plist_content").innerHTML = xmlDocument;
            //alert(http.responseText);
            //alert (prop_info.childNodes[1].firstChild.nodeValue);
            //alert (xmlDocument.getElementsByTagName('prop_id').item(0).firstChild.nodeValue);
            
            
            
            // Fill in General Information Page
            document.getElementById('nameTd').innerHTML = prop_info.childNodes[1].firstChild.nodeValue.replace('|tt','');
            document.getElementById('propaddrTd').innerHTML = prop_info.childNodes[2].firstChild.nodeValue.replace('|tt','');
            //document.getElementById('taxrateTd').innerHTML = prop_info.childNodes[6].firstChild.nodeValue;
            document.getElementById('taxlevyTd').innerHTML = prop_info.childNodes[7].firstChild.nodeValue.replace('|tt','');
            document.getElementById('totalTd').innerHTML = "$"+prop_info.childNodes[9].firstChild.nodeValue.replace('|tt','');
            document.getElementById('mailaddrTd').innerHTML = prop_info.childNodes[3].firstChild.nodeValue.replace('|tt','')+"<br \>"+prop_info.childNodes[56].firstChild.nodeValue.replace('|tt','')+", "+prop_info.childNodes[57].firstChild.nodeValue.replace('|tt','')+" "+prop_info.childNodes[58].firstChild.nodeValue.replace('|tt','');
            document.getElementById('appraisTd').innerHTML = "$"+prop_info.childNodes[4].firstChild.nodeValue.replace('|tt','');
            document.getElementById('assessTd').innerHTML = "$"+prop_info.childNodes[5].firstChild.nodeValue.replace('|tt','');
            
            // Fill in Change Owner / Property Forms
            document.getElementById('change_owner_prop').innerHTML = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
            document.getElementById('change_mailing_prop').innerHTML = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
            document.getElementById('change_owner_oldaddress').innerHTML = prop_info.childNodes[2].firstChild.nodeValue.replace('|tt','');
            document.getElementById('change_mailing_oldaddress').innerHTML = prop_info.childNodes[2].firstChild.nodeValue.replace('|tt','');
            document.getElementById('change_owner_oldowner').innerHTML = prop_info.childNodes[1].firstChild.nodeValue.replace('|tt','');
            document.getElementById('change_mailing_owner').innerHTML = prop_info.childNodes[1].firstChild.nodeValue.replace('|tt','');
            
            // Fill In Payment Information
            document.getElementById('address1').value = prop_info.childNodes[3].firstChild.nodeValue.replace('|tt','');
            document.getElementById('cityName').value = prop_info.childNodes[56].firstChild.nodeValue.replace('|tt','');
            document.getElementById('provinceCd').value = prop_info.childNodes[57].firstChild.nodeValue.replace('|tt','');
            document.getElementById('postalCd').value = prop_info.childNodes[58].firstChild.nodeValue.replace('|tt','');
            document.getElementById('paymentAmount').value = prop_info.childNodes[9].firstChild.nodeValue.replace('|tt','');
            
            // Create Uniq ID for payment transaction
            var d = new Date();
            var time = d.getDate()+"1"+d.getMonth()+"1"+d.getFullYear()+"1"+d.getSeconds();
            document.getElementById('cde-UniqID-0').value = document.getElementById('prop_id').value+"_"+time;
            document.getElementById('cde-ParcNumb-1').value = document.getElementById('prop_id').value+"_"+time;
            
            if (detail != 'general') {
              // Fill in details pages
              document.getElementById('detailId').innerHTML = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailType').innerHTML = prop_info.childNodes[10].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailDimen').innerHTML = prop_info.childNodes[11].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailRec').innerHTML = prop_info.childNodes[12].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailCalc').innerHTML = prop_info.childNodes[13].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailSysCalc').innerHTML = prop_info.childNodes[14].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailLand').innerHTML = prop_info.childNodes[15].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailDate').innerHTML = prop_info.childNodes[16].firstChild.nodeValue.replace('|tt','');
              document.getElementById('detailPrice').innerHTML = prop_info.childNodes[17].firstChild.nodeValue.replace('|tt','');
              
              // Fill in Deed Information
              document.getElementById('deedId').innerHTML = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
              document.getElementById('deedBook').innerHTML = prop_info.childNodes[18].firstChild.nodeValue.replace('|tt','');
              document.getElementById('deedPage').innerHTML = prop_info.childNodes[19].firstChild.nodeValue.replace('|tt','');
              document.getElementById('deedRec').innerHTML = prop_info.childNodes[20].firstChild.nodeValue.replace('|tt','');
              document.getElementById('deedSale').innerHTML = prop_info.childNodes[21].firstChild.nodeValue.replace('|tt','');
              document.getElementById('deedDate').innerHTML = prop_info.childNodes[22].firstChild.nodeValue.replace('|tt','');
              document.getElementById('deedType').innerHTML = prop_info.childNodes[23].firstChild.nodeValue.replace('|tt','');
              
              //Fill in Plat Information
              document.getElementById('platId').innerHTML = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platBook').innerHTML = prop_info.childNodes[24].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platPage').innerHTML = prop_info.childNodes[25].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platRec').innerHTML = prop_info.childNodes[26].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platType').innerHTML = prop_info.childNodes[27].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platLblock').innerHTML = prop_info.childNodes[28].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platHblock').innerHTML = prop_info.childNodes[29].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platLlot').innerHTML = prop_info.childNodes[30].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platHlot').innerHTML = prop_info.childNodes[31].firstChild.nodeValue.replace('|tt','');
              document.getElementById('platRecNum').innerHTML = prop_info.childNodes[32].firstChild.nodeValue.replace('|tt','');
              
              // Fill in District Information
              document.getElementById('districtId').innerHTML = prop_info.childNodes[0].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtcens').innerHTML = prop_info.childNodes[33].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtplann').innerHTML = prop_info.childNodes[34].firstChild.nodeValue.replace('|tt','');
              document.getElementById('district1990').innerHTML = prop_info.childNodes[35].firstChild.nodeValue.replace('|tt','');
              document.getElementById('district2000').innerHTML = prop_info.childNodes[36].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtjurco').innerHTML = prop_info.childNodes[37].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtjurci').innerHTML = prop_info.childNodes[38].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtZoneEl').innerHTML = prop_info.childNodes[39].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtZoneIn').innerHTML = prop_info.childNodes[40].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtZoneMi').innerHTML = prop_info.childNodes[41].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtZoneHi').innerHTML = prop_info.childNodes[42].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtVotpre').innerHTML = prop_info.childNodes[43].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtVotloc').innerHTML = prop_info.childNodes[44].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtVotadd').innerHTML = prop_info.childNodes[45].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtStaHou').innerHTML = prop_info.childNodes[46].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtStaSen').innerHTML = prop_info.childNodes[47].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtCoCom').innerHTML = prop_info.childNodes[48].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtCiCou').innerHTML = prop_info.childNodes[49].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtSchBo').innerHTML = prop_info.childNodes[50].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtStaHouMem').innerHTML = '<a href="javascript:void(0)" onclick="window.open(\''+prop_info.childNodes[59].firstChild.nodeValue.replace('|tt','')+'\',\'info\',\'width=600,height=400,scrollbars=yes\')">'+prop_info.childNodes[51].firstChild.nodeValue.replace('|tt','')+"</a>";
              document.getElementById('districtStaSenMem').innerHTML = '<a href="javascript:void(0)" onclick="window.open(\''+prop_info.childNodes[60].firstChild.nodeValue+'\',\'info\',\'width=600,height=400,scrollbars=yes\')">'+prop_info.childNodes[52].firstChild.nodeValue.replace('|tt','')+"</a>";
              document.getElementById('districtCoComMem').innerHTML = prop_info.childNodes[53].firstChild.nodeValue.replace('|tt','');
              document.getElementById('districtCiCouMem').innerHTML = '<a href="javascript:void(0)" onclick="window.open(\''+prop_info.childNodes[62].firstChild.nodeValue+'\',\'info\',\'width=600,height=400,scrollbars=yes\')">'+prop_info.childNodes[54].firstChild.nodeValue.replace('|tt','')+"</a>";
              document.getElementById('districtSchBoMem').innerHTML = '<a href="javascript:void(0)" onclick="window.open(\''+prop_info.childNodes[63].firstChild.nodeValue+'\',\'info\',\'width=600,height=400,scrollbars=yes\')">'+prop_info.childNodes[55].firstChild.nodeValue.replace('|tt','')+"</a>";
              
            } else {
              //Reset search
              document.getElementById('got_details').value = "no";
            }
            
            
            
            //Fill in the Payment Summary Table
            var payhistView = '<table width="100%" cellpadding="2" cellspacing="0"><tr><td class="cell_dec_title">Tax Year</td><td class="cell_dec_title">Status</td><td class="cell_dec_title">Date Paid</td><td class="cell_dec_title">Payment</td><td class="cell_dec_title">Balance Due</td></tr>';
            for (i=0;i<prop_info.childNodes[64].childNodes.length;i++) {
              
              payhistView += '<tr><td class="cell_dec">';
              payhistView += prop_info.childNodes[64].childNodes[i].childNodes[0].firstChild.nodeValue.replace('|tt','')+'</td><td class="cell_dec">';
              payhistView += prop_info.childNodes[64].childNodes[i].childNodes[1].firstChild.nodeValue.replace('|tt','')+'</td><td class="cell_dec">';      
              //alert("here");
              payhistView += prop_info.childNodes[64].childNodes[i].childNodes[2].firstChild.nodeValue.replace('|tt','')+'</td><td class="cell_dec">';
              
              payhistView += prop_info.childNodes[64].childNodes[i].childNodes[3].firstChild.nodeValue.replace('|tt','')+'</td><td class="cell_dec">';
              payhistView += prop_info.childNodes[64].childNodes[i].childNodes[4].firstChild.nodeValue.replace('|tt','')+'</td></tr>';
              
            }
            document.getElementById('payment_history').innerHTML = payhistView;
            
            // Show "Pay Taxes" or "Print Reciept"
            //alert(parseInt(prop_info.childNodes[9].firstChild.nodeValue));
            if (parseInt(prop_info.childNodes[9].firstChild.nodeValue.replace('|tt','')) > 0) {
              document.getElementById('payOrnot').innerHTML = '<a href="javascript:void(0)" onmouseout="close_menu()" onmouseover="MM_swapImage(\'Image40\',\'\',\'images/pay_taxes_f2.gif\',1)" onclick="show_div(\'pay\')"><img src="images/pay_taxes.gif" alt="Property Search" name="Image40" width="148" height="24" border="0" id="Image40" /></a>';
            } else {
              document.getElementById('payOrnot').innerHTML = '<a href="javascript:void(0)" onmouseout="close_menu()" onmouseover="MM_swapImage(\'Image40\',\'\',\'images/print_reciept_f2.gif\',1)" onclick="print_reciept()"><img src="images/print_reciept.gif" alt="Property Search" name="Image40" width="148" height="24" border="0" id="Image40" /></a>';
            }
            
            // After all work is done show general section
            show_div(page);
            //show_div('debug'); // For Debugging puproses
            
            // Set Info Variable
            if (detail != 'general') {
              document.getElementById('got_details').value = 'yes';
            }
          } //End If statement for more than property
          
        } else {
          alert("Problem retrieving data");
        }
      }
    }
    http.send(null);
  }
}

function send_mailing_changes() {
  
  //alert(document.getElementById('change_mailing_oldaddress').innerHTML);
  var poststr = "propid=" + encodeURI(document.getElementById('prop_id').value) +
          "&propAddr=" + encodeURI(document.getElementById('change_mailing_oldaddress').innerHTML) +
          "&newAddr=" + encodeURI(document.getElementById('change_mailing_newaddress').value) +
          "&city=" + encodeURI(document.getElementById('change_mailing_city').value) + 
          "&state=" + encodeURI(document.getElementById('change_mailing_state').value) +
          "&zip=" + encodeURI(document.getElementById('change_mailing_zip').value) +
          "&owner=" + encodeURI(document.getElementById('change_mailing_owner').innerHTML) +
          "&email=" + encodeURI(document.getElementById('change_mailing_email').value) +
          "&date=" + encodeURI(document.getElementById('change_mailing_date').value);
  if (http) { 
    http.open("POST", "data/change_mailing.php", true); 
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.send(poststr);
    http.onreadystatechange = function () {
      if (http.readyState == 4) {
        if (http.responseText.indexOf('invalid') == -1) {
          show_div('general');
        } else {
          alert(http.responseText);
        }
      }
    }
  }
}

function send_owner_changes() {
  //alert(document.getElementById('change_mailing_oldaddress').innerHTML);
  var poststr = "propid=" + encodeURI(document.getElementById('prop_id').value) +
          "&propAddr=" + encodeURI(document.getElementById('change_owner_oldaddress').innerHTML) +
          "&newAddr=" + encodeURI(document.getElementById('change_owner_newaddress').value) +
          "&city=" + encodeURI(document.getElementById('change_owner_city').value) + 
          "&state=" + encodeURI(document.getElementById('change_owner_state').value) +
          "&zip=" + encodeURI(document.getElementById('change_owner_zip').value) +
          "&preowner=" + encodeURI(document.getElementById('change_owner_oldowner').innerHTML) +
          "&newowner=" + encodeURI(document.getElementById('change_owner_owner').value) +
          "&email=" + encodeURI(document.getElementById('change_owner_email').value) +
          "&date=" + encodeURI(document.getElementById('change_owner_date').value);
  if (http) { 
    http.open("POST", "data/change_owner.php", true); 
    http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
    http.send(poststr);
    http.onreadystatechange = function () {
      if (http.readyState == 4) {
        if (http.responseText.indexOf('invalid') == -1) {
          show_div('general');
        } else {
          alert(http.responseText);
        }
      }
    }
  }
}

function mailing_change_prevalidate() {
  if (document.getElementById('prop_id').value == '') {
    show_div('validate_mailing_prechange_warning');
  } else {
    show_div('change_mailing');
  }
}

function validate_form(thisform) {
  if (document.getElementById('prop_id').value == '') {
    show_div('property_id_must');
    return false;
  } else {
    return true;
  }
}
