function updatePane(dom_id, action) {
	$("#" + dom_id).load(action);
}

function replaceAll( str, searchTerm, replaceWith, ignoreCase )	{
	var regex = "/"+searchTerm+"/g";
	if( ignoreCase ) regex += "i";
	return str.replace( eval(regex), replaceWith );
}

function ajaxRequest(url, data_params, javascript) {
  if (!javascript) {javascript = '';}

  $.ajax({
    type: "POST",
    url: url,
    data: data_params,
    dataType: 'script',
    success: function(js){js; eval(javascript);}
  });
};

function getLocationSlug(data) {
  location_slug = replaceAll( data + '', ' ', '-', true );
  location_slug = replaceAll( location_slug, ',', '', true );
  return location_slug;
}

function goToDirectoryRegion(event, data, formatted) {
  window.location.href = "/" + getLocationSlug(data);
}

function goToClassifiedRegion(event, data, formatted) {
  window.location.href = "/classifieds/" + getLocationSlug(data);
}

function goToEventRegion(event, data, formatted) {
  window.location.href = "/events/" + getLocationSlug(data);
}

function goToDealRegion(event, data, formatted) {
  window.location.href = "/deals/" + getLocationSlug(data);
}

function setSessionLocation(event, data, formatted) {
  window.location.href = "/set_location/" + getLocationSlug(data);
}

function setRegionToSearch(event, data, formatted) {
  $('#location_slug').attr("value", getLocationSlug(data));
  $('#region_query').attr("value", data);
}

/*
 * Written by Rob Schmitt, The Web Developer's Blog
 * http://webdeveloper.beforeseven.com/
 */
 
var active_color = '#000'; // Colour of user provided text
var inactive_color = '#999'; // Colour of default text
 
$(document).ready(function() {
  $("input.default-value").css("color", inactive_color);
  var default_values = new Array();
  $("input.default-value").focus(function() {
    if (!default_values[this.id]) {
      default_values[this.id] = this.value;
    }
    if (this.value == default_values[this.id]) {
      this.value = '';
      this.style.color = active_color;
    }
    $(this).blur(function() {
      if (this.value == '') {
        this.style.color = inactive_color;
        this.value = default_values[this.id];
      }
    });
  });
});

$.fn.hoverClass = function(c) {
	return this.each(function(){
		$(this).hover( 
			function() { $(this).addClass(c);  },
			function() { $(this).removeClass(c); }
		);
	});
}