$(document).ready(function() {

$.fn.event_search = function(){
$("div.ss_results").addClass("searching").show().html("searching");
				qry = {
					"criteria" : $(this).val()
				};
				
				$.ajax({
				   type: "POST",
				   url: "/ajax/tn_event_search.asp",
				   data: qry,
				   success: function(msg){

				   		$("div.ss_results").removeClass("searching").html(msg);
				   }
				 });
}

$("input.search_input").keyup(function(){
if($(this).val().length >= 2){
wait(function(){
$("input.search_input").event_search();
}, 500 );
}
});

$close_suggest = function(){
$("div#localesearchresults").hide().empty();
}

$.mouse_out = function(event, fn, str){if($(event.target).parents().index(str) == -1) {setTimeout($close_suggest,2500);}}

$("div#localesearchresults").live("mouseout",function(event){
$.mouse_out(event, "", "div#localesearchresults");
});

$.show_locale_results = function(str){$("div#localesearchresults").html(str);}

$.fn.locale_search = function(){
locale_search = $(this).val();
$("div#localesearchresults").hide().empty();
if(locale_search.length >= 2){
$("div#localesearchresults").show().html("searching for: " + locale_search);

qry = {"locale": locale_search};
$.ajax({
   type: "POST",
   url: "/ajax/locale_search.asp",
   data: qry,
   success: function(msg){
$.show_locale_results(msg);
 }
 });

}
}

$("input.citytext").keyup(function(){$(this).locale_search();});
$("input.citytext").focus(function(){$(this).locale_search();});


});
