function search_obj() {
	if (typeof search_obj._initialized == "undefined") {
    search_obj.prototype.build = function () {  
      if ( $( "search_button" ) ) {
        $ev("search_button", "click", this.check_process_search, this, true);
				$ev("search_change", "click", this.change_location_popup, this, true);
      }
    }

		search_obj.prototype.check_change_zipcode = function() {
			if (typeof(this.send_call) == "undefined") this.send_call = new send_call(this, "locationchooser");
			this.send_call.set_call( "check_change_zipcode" );
			var pass_vars = new Array();
			pass_vars['zipcode'] = $F("near");
			this.send_call.set_url_vars(pass_vars);
			this.send_call.send(dash_loader.ajax.ajax_support);
		}

    search_obj.prototype.check_process_search = function () {
      var passed = true;
			if ($F("searchterm").length < 4 && $F("searchterm").length > 0 ) {
				dash_loader.tooltip.create( "Your search term is too short", "searchterm" );
				passed = false;
			}

			if ( $F("near") ) {
				this.check_change_zipcode();
				passed = false; // zipcode needs to be checked
			}
			
			if ( passed ) {
				this.process_search();
			}
		}

		search_obj.prototype.process_search = function() {
			if (  $F("pid") == "hire" ) {
				dash_loader.passed_in_url_vars = "&searchterm="+$F("searchterm")+"&near="+$F("near");
				dash_loader.reload_tab();
			} else {
				$redirect_link = "/hire/?";
				if ($F("searchterm").length > 0) $redirect_link += "searchterm="+$F("searchterm");
				if( $("near").value.length > 0 ) $redirect_link  += "&near="+$F("near");
				window.location.href = $redirect_link; 
			}
    }

    /*
    * Check if a zipcode is valid
    */
    search_obj.prototype.is_valid_zip = function(zip) {
      if ( typeof( zip ) == "object" ) zip = zip.value;
      zip = trim(zip);
      var reZip = /^\d{5}?$/;
      return reZip.test( zip );
    }
    
		search_obj.prototype.return_call = function( response, call ) {
    	var m = YAHOO.lang.JSON.parse( response );

			if ( m.passed ) {
				switch( call ) {
				case "check_change_zipcode":
					$("neartext_hj").innerHTML = " near "+m.near;
					this.process_search();
					break;
				}
			} else {
				switch( call ) {
				case "check_change_zipcode":
					dash_loader.tooltip.create( "Please enter a valid zipcode", "near" );
					break;
				}
			}
		}

		search_obj._initialized = true;
  } 
}

