// JavaScript Document
var ctr = 0;

function setDate() {

  thisDate = new Date();

  var month = thisDate.getMonth();
  var day   = thisDate.getDate();
  var year  = thisDate.getFullYear(); 

  f = document.forms[0];
  
  f.BEGINMONTH.selectedIndex = month;
  f.BEGINDAY.selectedIndex   = day - 1;
  f.BEGINYEAR.selectedIndex  = year - 2010;

  f.ENDMONTH.selectedIndex   = month;
  f.ENDDAY.selectedIndex     = day - 1;
  f.ENDYEAR.selectedIndex    = year - 2010;  
  }
 
function doLookup(fromList) {
 
var xmlHttp;
 
// create the query object based on the browser
 
try {xmlHttp=new XMLHttpRequest();}  // Firefox, Opera 8.0+, Safari
catch (e){
  try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}     // Internet Explorer
    catch (e){
  try{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}
    catch (e) {alert("Your browser does not support AJAX!");return false;}
    }
  }


if(fromList == "1"){
  selection = document.getElementById("COUNTRY").value;
  query = "/cgi-bin/getstates?Country=" + selection + "&X=" + ctr;
  ctr++;
  }
 
if(fromList == "2"){
  query = "/cgi-bin/getcities?V=AZHISWCS&State=&X=" + ctr; 
  ctr++;
  }
 
if(fromList == "3"){
  selection = document.getElementById("CITY").value;
  query = "/cgi-bin/getnbds?V=AZHISWCS&Search=Global&&City=" + selection + "&X=" + ctr;
  ctr++;
  }
 
try {xmlHttp.open("GET",query,true);}
  catch (e) {alert(e)};
 
xmlHttp.onreadystatechange=function() {
 
if(xmlHttp.readyState==4) {
 
  // stuff the query results into an array
 
  var tmpArr = new Array();
  tmpArr = xmlHttp.responseText.split("\n");
 
  var lines = new Array();
 
  for(i=0;i<(tmpArr.length-1);i++) {
 
    if(tmpArr[i].match(/HTML/i)) {continue;}
    if(tmpArr[i].match(/NAME/i)) {continue;}
 
    if(tmpArr[i].match(/SELECT/i)) {tmpArr[i] = tmpArr[i].replace(/..SELECT./i,"");}
 
    lines = tmpArr[i].split('\"');
    var value = lines[1];
    var label = lines[2].replace(/\>/,"");
 
    if(fromList == "1"){document.getElementById('STATE').options[i-3] = new Option(label, value, true, false);}
       if(fromList == "2"){document.getElementById('CITY').options[i-3] = new Option(label, value, true, false);}
       if(fromList == "3"){document.getElementById('NEIGHBORHOOD').options[i-3] = new Option(label, value, true, false);}
       }
 
           /* if(fromList == "3"){document.getElementById("hoodDiv").style.display = "inline";}  */
       }
     }
     xmlHttp.send(null);
   }
 
function clearLists() {
  if(fromList == "1"){document.getElementById('STATE').options.length = 0;}
  if(fromList == "2"){document.getElementById('CITY').options.length = 0;}
  if(fromList == "3"){document.getElementById('NEIGHBORHOOD').options.length = 0;}
  }