function service_chooser() {
this.name = "service_chooser";

//dynamic overlay loading turned on by default
this.dynamic = true;

this.current_gen_cat_id    = document.getElementById("gen_cat_id").value;
this.current_ser_cat_id    = document.getElementById("ser_cat_id").value;
this.current_sub_cat_id    = document.getElementById("sub_cat_id").value;
 
	if ( typeof service_chooser._initialized == "undefined" ) {

		service_chooser.prototype.build = function() {
  	  if (document.getElementById("chooser_general")) {
  	    //setup links
  	    var general_links = document.getElementById("chooser_general").getElementsByTagName("a");
        YAHOO.util.Event.addListener(general_links, "click", this.general_selected, this);
  	    //setup overlay
        this.chooser_general = new YAHOO.widget.Overlay("chooser_general", { visible: false, effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} });
        this.chooser_general.render();
        this.chooser_general.show();
      }
		  if (document.getElementById("chooser_service")) {
		    //setup links
  	    var service_links = document.getElementById("chooser_service").getElementsByTagName("a");
        YAHOO.util.Event.addListener(service_links, "click", this.service_selected, this);
  	    //setup overlay
        this.chooser_service = new YAHOO.widget.Overlay("chooser_service", { visible: false, effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} });
        this.chooser_service.render();
        if (document.getElementById("chooser_service_ul")) this.chooser_service.show();
      }
      if (document.getElementById("chooser_sub")) {
        //setup links
    	  var sub_links = document.getElementById("chooser_sub").getElementsByTagName("a");
        YAHOO.util.Event.addListener(sub_links, "click", this.sub_selected, this);
        //setup overlay
        this.chooser_sub = new YAHOO.widget.Overlay("chooser_sub", { visible: false, effect:{effect:YAHOO.widget.ContainerEffect.FADE,duration:0.25} });
        this.chooser_sub.render();
        if (document.getElementById("chooser_sub_ul")) this.chooser_sub.show();
      }
		}
	
		
		service_chooser.prototype.show_service_chooser = function() {
		  this.chooser_general.show();
		  if (document.getElementById("chooser_service_ul")) this.chooser_service.show();
		  if (document.getElementById("chooser_sub_ul")) this.chooser_sub.show();
		}
		
		/*
		*
		* Get the full chooser
		* int gen_cat_id, int ser_cat_id, int sub_cat_id
		*
		*/
		service_chooser.prototype.get_full_chooser = function(gen_cat_id, ser_cat_id, sub_cat_id) {
		  if (typeof(this.fc_send_call) == "undefined") this.fc_send_call = new send_call(this, "servicechooser");
  		this.fc_send_call.set_call("full_chooser");
  		var pass_vars = new Array();  		
  		if (gen_cat_id > 0) {pass_vars["gen_cat_id"] = gen_cat_id; }else{ pass_vars["gen_cat_id"] = 0;}
  		if (ser_cat_id > 0) {pass_vars["ser_cat_id"] = ser_cat_id; }else{ pass_vars["ser_cat_id"] = 0;}
  		if (sub_cat_id > 0) {pass_vars["sub_cat_id"] = sub_cat_id; }else{ pass_vars["sub_cat_id"] = 0;}
  		this.fc_send_call.set_url_vars(pass_vars);
  	  this.fc_send_call.send(dash_loader.ajax.ajax_support);
		}
		
		
		service_chooser.prototype.set_general_function = function(func, obj) {
		  this.general_function = func;
		  this.general_function_obj = obj;
		}
		service_chooser.prototype.set_service_function = function(func, obj) {
		  this.service_function = func;
		  this.service_function_obj = obj;
		}
		service_chooser.prototype.set_sub_function = function(func, obj) {
		  this.sub_function  = func;
		  this.sub_function_obj  = obj;
		}
		
		
		/**
		*
		* Set the currently selected General category ID and load the corresponding service categories
		* Event e, Object object
		*
		*/
		service_chooser.prototype.general_selected = function(e, obj) {
		  if (obj.dynamic){ //check if loading is dynamic
  		  //get id of category that was clicked
  		  var selected_id = this.id.replace(/gen_/,""); 
  		  obj.process_general_selected(selected_id);
		  }
		}
		service_chooser.prototype.process_general_selected = function(selected_id) {
		  //process if the click is different from the current general category
		  if (selected_id != this.current_gen_cat_id) {
		    //turn off link
    		if (elem = document.getElementById("gen_"+this.current_gen_cat_id)) {	elem.className = ''; 	}
		    //hide sub overlay
		    this.chooser_sub.hide();
  		  //set the current general cat id
  		  this.current_gen_cat_id = selected_id; 
  		  //turn ON link
    		if (elem = document.getElementById("gen_"+this.current_gen_cat_id)) {	elem.className = 'bohld'; }
        //send call to get new service_cats
  		  if (typeof(this.general_send_call) == "undefined") this.general_send_call = new send_call(this, "servicechooser");
    		this.general_send_call.set_call("create_chooser_service");
    		var pass_vars = new Array();  		
    		pass_vars["gen_cat_id"] = this.current_gen_cat_id;
    		this.general_send_call.set_url_vars(pass_vars);
    	  this.general_send_call.send(dash_loader.ajax.ajax_support);
    	  //set document vars
    	  document.getElementById('gen_cat_id').value = this.current_gen_cat_id;
    		document.getElementById('ser_cat_id').value = 0;
    		document.getElementById('sub_cat_id').value = 0;
    	  //run a passed in general function
    	  if (typeof(this.general_function) != "undefined") {
    	    eval("this.general_function_obj."+this.general_function+"();");
    	  }
		  }
		}
		
		
		/**
		*
		* Set the currently selected Service category ID and load the corresponding sub categories
		* Event e, Object object
		*
		*/
		service_chooser.prototype.service_selected = function(e, obj) {
		  if (obj.dynamic){ //check if loading is dynamic
  		  //get id of category that was clicked
  		  var selected_id = this.id.replace(/ser_/,"");
  		  obj.process_service_selected(selected_id);
  		}
		}
		service_chooser.prototype.process_service_selected = function(selected_id) { 
		  //process if the click is different from the current general category
		  if (selected_id != this.current_ser_cat_id) { 
		    //turn off link
    		if (elem = document.getElementById("ser_"+this.current_ser_cat_id)) {	elem.className = ''; 	}
		    //set current service cat id
  		  this.current_ser_cat_id = selected_id; 
  		  //turn ON link
    		if (elem = document.getElementById("ser_"+this.current_ser_cat_id)) {	 elem.className = 'bohld'; }
        //send call to get new sub cats
  		  if (typeof(this.service_send_call) == "undefined") this.service_send_call = new send_call(this, "servicechooser");
    		this.service_send_call.set_call("create_chooser_sub");
    		var pass_vars = new Array();  		
    		pass_vars["gen_cat_id"] = this.current_gen_cat_id;
    		pass_vars["ser_cat_id"] = this.current_ser_cat_id;
    		this.service_send_call.set_url_vars(pass_vars);
    	  this.service_send_call.send(dash_loader.ajax.ajax_support);
    	  //set document vars
    		document.getElementById('ser_cat_id').value = this.current_ser_cat_id;
    		document.getElementById('sub_cat_id').value = 0;
    	  //run a passed in service function
    	  if (typeof(this.service_function) != "undefined") {
    	    eval("this.service_function_obj."+this.service_function+"();");
    	  }
		  }
		}
		
		
		/** 
		*
		* Set the currently selected sub category ID
		* Event e, Object object
		*
		*/
		service_chooser.prototype.sub_selected = function(e, obj) {
		  if (obj.dynamic){ //check if loading is dynamic
  		  //get id of category that was clicked
  		  var selected_id = this.id.replace(/sub_/,""); 
  		  obj.process_sub_selected(selected_id);
		  }
		}
		service_chooser.prototype.process_sub_selected = function(selected_id) { 
		  //process if the click is different from the current general category
		  if (selected_id != this.current_sub_cat_id) { 
		    //turn off link
    		if (elem = document.getElementById("sub_"+this.current_sub_cat_id)) {	elem.className = ''; 	}
    		//set current sub cat id
  		  this.current_sub_cat_id = selected_id;   
  		  //turn ON link
    		if (elem = document.getElementById("sub_"+this.current_sub_cat_id)) {	elem.className = 'bohld'; }
  		  //set document vars
    		document.getElementById('sub_cat_id').value = this.current_sub_cat_id;
      	//run a passed in sub function
      	if (typeof(this.sub_function) != "undefined") {
    	    eval("this.sub_function_obj."+this.sub_function+"();");
    	  }
		  }
		}
		
			
		/**
		*
		* Receives an Ajax or onload based response from the ServiceChooser Library 
		* string response_text, string call
		*
		*/
		service_chooser.prototype.return_call = function (response_text, call) {
		  switch(call){ 
        case "full_chooser":
          document.getElementById("chooser_list").innerHTML = response_text; 
          this.build();
        break;
        case "create_chooser_service":
          document.getElementById("chooser_service").innerHTML = "";
    		  this.chooser_service.setBody(response_text);
    			this.chooser_service.render();
    			//show overlay
    			this.chooser_service.show(); 
    			//setup links
  	      var service_links = document.getElementById("chooser_service").getElementsByTagName("a");
          YAHOO.util.Event.addListener(service_links, "click", this.service_selected, this);
        break; 
        case "create_chooser_sub": 
          document.getElementById("chooser_sub").innerHTML = "";
    		  this.chooser_sub.setBody(response_text);
    			this.chooser_sub.render(); 
    			//show overlay
    			this.chooser_sub.show(); 
    		  //setup links
    	    var sub_links = document.getElementById("chooser_sub").getElementsByTagName("a");
          YAHOO.util.Event.addListener(sub_links, "click", this.sub_selected, this);
        break; 
		  }
		}
		
		
		service_chooser.prototype.process_history = function(history_obj) {
		  if (this.dynamic){ //check if loading is dynamic
		    if (typeof history_obj == "object" && history_obj != null){ 
  		    if (typeof history_obj.search_ids["gen_cat_id"] == "undefined") history_obj.search_ids["gen_cat_id"] = 0;
  		    if (typeof history_obj.search_ids["ser_cat_id"] == "undefined") history_obj.search_ids["ser_cat_id"] = 0;
  		    if (typeof history_obj.search_ids["sub_cat_id"] == "undefined") history_obj.search_ids["sub_cat_id"] = 0;
  		    //code used to determin if there is a change
  		    var chooser_code = history_obj.search_ids["gen_cat_id"]+"_"+history_obj.search_ids["ser_cat_id"]+"_"+history_obj.search_ids["sub_cat_id"];
  		    //if code matches the current id then don't send refresh
  		    if (chooser_code != this.current_gen_cat_id+"_"+this.current_ser_cat_id+"_"+this.current_sub_cat_id){
  		      this.get_full_chooser(history_obj.search_ids["gen_cat_id"], history_obj.search_ids["ser_cat_id"], history_obj.search_ids["sub_cat_id"]);
  		    }
  		  } else {
  		    //get an empty chooser
  		    this.get_full_chooser(0,0,0);
  		  }
		  }
    }
    		
    
    service_chooser.prototype.un_load = function() {	
      this.chooser_general.hide();
      this.chooser_service.hide();
      this.chooser_sub.hide();
		};
		
    		
		service_chooser._initialized = true;
	} 
}