function menu() {
this.states = new Array("Alabama","Alaska ","Arizona","Arkansas","California","Colorado","Connecticut","DC","Delaware","Florida","Georgia","Hawaii","Idaho","Illinois","Indiana","Iowa","Kansas","Kentucky","Louisiana","Maine","Maryland","Massachusetts","Michigan","Minnesota","Mississippi","Missouri","Montana","Nebraska","Nevada","New Hampshire","New Jersey","New Mexico","New York","North Carolina","North Dakota","Ohio","Oklahoma","Oregon","Pennsylvania","Rhode Island","South Carolina","South Dakota","Tennessee","Texas","Utah","Vermont","Virginia","Washington","West Virginia","Wisconsin","Wyoming");

this.states_urls = new Array("alabama","alaska","arizona","arkansas","california","colorado","connecticut","district-of-columbia","delaware","florida","georgia","hawaii","idaho","illinois","indiana","iowa","kansas","kentucky","louisiana","maine","maryland","massachusetts","michigan","minnesota","mississippi","missouri","montana","nebraska","nevada","new-hampshire","new-jersey","new-mexico","new-york","north-carolina","north-dakota","ohio","oklahoma","oregon","pennsylvania","rhode-island","south-carolina","south-dakota","tennessee","texas","utah","vermont","virginia","washington","west-virginia","wisconsin","wyoming");

    
  if (typeof menu._initialized == "undefined") {
     
    menu.prototype.build = function () {
      YAHOO.util.Event.addListener("state_select", "mousedown", this.select_state_drop, this, true);
      YAHOO.util.Event.addListener("select_state_home", "mousedown", this.select_state_home_drop, this, true);
      YAHOO.util.Event.addListener("username", "click", this.clear_email, this, true);
      YAHOO.util.Event.addListener("login_button", "click", this.check_vals, this, true);
    }
  
    menu.prototype.select_state_drop = function () {
      YAHOO.util.Event.removeListener("state_select", "mousedown", this.select_state_drop);
      this.state_select = document.getElementById("state_select");
       
      for (i=0;i<50;i++){
        new_op = new Option(this.states[i],this.states_urls[i])
        this.state_select.options[i+1] = new_op;
      } 
      YAHOO.util.Event.addListener("state_select", "change", this.select_state_redirect);
    }
    
    menu.prototype.select_state_home_drop = function () {
      YAHOO.util.Event.removeListener("select_state_home", "mousedown", this.select_state_home_drop);
      this.state_select_home = document.getElementById("select_state_home");
         
      for (i=0;i<50;i++){
        new_op = new Option(this.states[i],this.states_urls[i])
        this.state_select_home.options[i+1] = new_op;
      } 
      YAHOO.util.Event.addListener("select_state_home", "change", this.select_state_redirect);
    }
 
    menu.prototype.select_state_redirect = function () {
      selected_state = this.options[this.selectedIndex].value;
      if (selected_state != -1){
        window.location.href = "/"+selected_state+"/";
      }
    }
    
    
    /*
      Login Code
    */
    menu.prototype.clear_email = function () {
      YAHOO.util.Event.removeListener("username", "click", this.clear_email);
      this.username = document.getElementById("username");
      this.username.value = "";
    }
    
    menu.prototype.check_vals = function () {
      this.email = document.getElementById("username");
      this.pass  = document.getElementById("password"); 
      this.login_form  = document.getElementById("login_form"); 
      this.focus_set = false;
      
     if (this.email.value.length == 0){
       this.error_message = "Enter your email address.";
       this.error_div     = "username";
       if(!this.focus_set) { this.email.focus(); this.focus_set = true; }
       this.passed = false;
     } else if (this.email.value == "Email"){
       this.email.value = "";
       this.error_message = "Enter your email address.";
       this.error_div     = "username";
       if(!this.focus_set) { this.email.focus(); this.focus_set = true; }
       this.passed = false;
     } else if (this.pass.value.length == 0){
       this.error_message = "Enter a password.";
       this.error_div     = "password";
       if(!this.focus_set) { this.pass.focus(); this.focus_set = true; }
       this.passed = false;
     } else {
       this.passed = true;
     }
     
     if (this.passed){ 
       this.login_form.submit(); 
     } else { 
       this.error_tip = new YAHOO.widget.Overlay("error_tip", {context:[this.error_div,"tl","bl"], visible:false, width:"200px", zIndex:1500 });
       this.error_tip.setBody("<div class='error_message'>"+this.error_message+"</div>"); 
       this.error_tip.render(document.body); 
       this.error_tip.show();
       YAHOO.util.Event.addListener(this.error_div, "keypress", this.hide_error, this, true);
       YAHOO.util.Event.addListener(this.error_div, "blur", this.hide_error, this, true);
     }
    }
    
     menu.prototype.hide_error = function () {
       YAHOO.util.Event.removeListener(this.error_div, "keypress", this.hide_error);
       YAHOO.util.Event.removeListener(this.error_div, "blur", this.hide_error);
       this.error_tip.hide();
     }
     
    menu._initialized = true;
  } 
}