Lookup={};
Lookup.initialize=function(session,formID,table,selectID,selectID2,valueToGet,textToGet)
{
   Lookup.currentSession=session;
   Lookup.currentSelector=selectID;
   Lookup.currentSelector2=selectID2;
   Lookup.currentValueToGet=valueToGet;
   Lookup.currentTextToGet=textToGet;
   Lookup.currentTable=table;
   Lookup.formID=formID;
   Utilities.addListener(Utilities.getElement(Lookup.currentSelector),'change',Lookup.callLookup);
}
Lookup.callLookup=function()
{
   Lookup.lookup(Lookup.currentSelector,Utilities.getElement(Lookup.currentSelector).value,Lookup.currentSelector2,Lookup.currentValueToGet,Lookup.currentTextToGet,"outofstate!='1'");
}
Lookup.lookup=function(selector,value,selector2,optionval,optionsee,morecriteria)
{
   if(selector!='' && value!='' && selector2!='' && optionval!='' && optionsee!='')
   {
      Lookup.currentSelector=selector;
      Lookup.currentSelector2=selector2;
      var url="/phpclasses/serviceConnector.php?object=LookupManager&method=lookup&params="+ selector +","+ value +","+ optionval +","+ optionsee +","+ Lookup.currentTable +","+ morecriteria;
      AjaxUpdater.Update("GET",url,Lookup.onLookup);
   }
}
Lookup.onLookup = function()
{
    if(Ajax.checkReadyState('loading') == "200")
    {
	var response=Ajax.getResponse();
        var results=response.split("<result>");
        for(var i=0;i<results.length;i++)
        {
	   var details=results[i].split("<detail>");
	   Utilities.getElement(Lookup.currentSelector2).options[i]=new Option(details[1],details[0],true,false);
        }        
        Utilities.getElement(Lookup.currentSelector2).disabled=false;
    }   
    else
    {
       Utilities.getElement(Lookup.currentSelector2).options[0]=new Option("Loading Class...","",true,false);
       Utilities.getElement(Lookup.currentSelector2).disabled='true';
    }
}

