var xmlHttp;

function EnableCriteria(q)
{ 
  document.Search.AmountFrom.disabled=q;
  document.Search.AmountTo.disabled=q;
}

function ShowSearchResult(page)
{ 
  xmlHttp=GetXmlHttpObject();
  if (xmlHttp==null)
  {
    alert ("Your browser does not support AJAX!");
    return;
  } 

  document.Search.Search.disabled=true;
  document.body.style.cursor='wait';
  document.getElementById("txtPleaseWait").innerHTML= "<font color='#FF0000'><b>Please wait...</b></font>";

  var url="SearchUnclaimedFunds.asp";
  var last_name = document.Search.LastName.value;
  var first_name = document.Search.FirstName.value;
  var creditor = document.Search.CreditorName.value;

  last_name = last_name.toLowerCase();
  first_name = first_name.toLowerCase();
  creditor = creditor.toLowerCase();

  last_name = last_name.replace(/[^a-z]+/g,'');
  first_name = first_name.replace(/[^a-z]+/g,'');
  creditor = creditor.replace(/[^a-z]+/g,'');

  url=url + "?LastName=" + last_name;
  url=url + "&FirstName=" + first_name;
  url=url + "&CreditorName=" + creditor;
  url=url + "&CaseNumber=" + document.Search.CaseNumber.value;
  url=url + "&AmountFrom=" + document.Search.AmountFrom.value;
  url=url + "&AmountTo=" + document.Search.AmountTo.value;
  url=url + "&page=" + page;

  if (Search.elements['Op'][0].checked)
  {
    url=url + "&Op=or";
  }
  else
  {
    url=url + "&Op=and";
  }

  if (document.Search.PaidStatus.checked)
  {
    url=url + "&PaidStatus=" + document.Search.PaidStatus.value;
  }

  url=url+"&sid="+Math.random();

  xmlHttp.onreadystatechange=stateChanged;
  xmlHttp.open("GET",url,true);
  xmlHttp.send(null);
}

function stateChanged() 
{ 
  if (xmlHttp.readyState==4)
  {
    var resultText = xmlHttp.responseText;
    document.getElementById("txtSearchResult").innerHTML=resultText.replace(/[+]+/g,'&');
    document.Search.Search.disabled=false;
    document.getElementById("txtPleaseWait").innerHTML= "";
    scroll(0,480);
    document.body.style.cursor='auto';
  }
}


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;
}

function InitControls()
{
  document.Search.AmountFrom.disabled=true;
  document.Search.AmountTo.disabled=true;

  try
  {
    document.Search.Search.setAttribute('type', 'button');
  }

  catch (e)
  {
   
  }
}

window.onload=InitControls;


