  var owr = {
  startTimer: null,
  endTimer: null,
   init: function(){
     if($("oneWaySelection")) {
       owr.toggleHome();
       $("oneWaySelection").onclick =  function() {owr.toggleHome(); }
     }
     if($("pickupSection")){
       
       // Temp Variables to stop firefox from firing when tabbed away from field
       
       var tempP = $("pickupList").getValue();
       var tempR = $("returnList").getValue();
       $("pickupList").observe('change', function() {
          if($("pickupList").getValue() == tempP) return false;           
          else {
            tempP = $("pickupList").getValue();
            owr.timer("pickupSection");          
          }
        });
       $("returnList").observe('change', function() { 
         if($("returnList").getValue() == tempR) return false;
         else{
           tempR = $("returnList").getValue();
           owr.timer("returnSection");       
          }
        });
       
       if(!document.all){
         $("pickupList").observe('keyup', function(e) { 
           if(e.keyCode != 9 && e.keyCode != 16) {
           tempP = $("pickupList").getValue();
           owr.timer("pickupSection") }
           });
         $("returnList").observe('keyup', function(e) { 
          if(e.keyCode != 9 && e.keyCode != 16) {
            tempR = $("returnList").getValue();
            owr.timer("returnSection"); 
          }
          });
       }

     }     
     
   },
   toggleHome: function(){   
     if($("oneWaySelection").checked){
       $("standardTab").hide();  
       $("oneWayDetails").setStyle({ display: 'inline' });
       $("oneWayTab").setStyle({ display: 'block' });

     }
     else{
       $("standardTab").setStyle({ display: 'block' });
       $("oneWayDetails").setStyle({ display: 'none' });
       $("searchCriteria").focus();
       $("oneWayTab").setStyle({ display: 'none' });   
       
     }
     
    },
    timer: function(type){
      var t = type;

      $(t).innerHTML = "";
      $(t).addClassName("loading");
      
      if(t == "pickupSection"){
       if($("startError")) $("startError").hide();
       clearTimeout(owr.startTimer);
       owr.startTimer = setTimeout( "owr.doAjax('pickupSection')" , 1200);
      }
      else{
       if($("endError")) $("endError").hide();
        clearTimeout(owr.endTimer);
        owr.endTimer = setTimeout( "owr.doAjax('returnSection')" , 1200);
       }
      
      
      
    },
    doAjax: function(type){

      if(type == "pickupSection"){
         var pre = "start";
         var list = "pickupList";
      }
      else{
        var pre = "end";
        var list = "returnList";
      }
      var loc = $(type);
       
      // Params for Ajax
      var location = $(list).getValue();
      var month = $(pre + "DateMonth").getValue();
      var day = $(pre + "DateInput").getValue();
      var time = $(pre + "DateTime").getValue();
      var section = type.split("S")[0];
      
    

     new Ajax.Updater(loc, 'branchHours.do', { method: 'get', 
        onSuccess: function(){
          $(type).removeClassName("loading");
        },
       onComplete: function() {
          if($("endError").getStyle("display") == "none" && $("startError").getStyle("display") == "none" ){
            $$("p.error")[0].hide();
          }
          
          
          if($("serverError")) { 
            $$("p.error")[0].show();
            if(pre == "start") {
              $("startError").innerHTML = $("serverError").innerHTML;
              $("startError").show();              
            }
            else{
             $("endError").innerHTML = $("serverError").innerHTML;
             $("endError").show();
            }     
          }
          
        },
        parameters: {loc: location, startDateMonth: month, startDateInput: day, startTime: time, type: section}
       });
       
      
     
    }
  
  }
document.observe("dom:loaded", owr.init);

