
// Submits the page with an anchor to ensure the browse returns to that position.
function submitWithAnchor(obj, anchor)
{
	
	setFormAnchor(obj, anchor);
	obj.form.submit();
}

function setFormAnchor(obj, anchor)
{
	var action = obj.form.action;
	action = action.replace(/#.+$/, "");
	obj.form.action = action + anchor;
}

function confirmAndSetAnchor(obj, question, anchor)
{
	if (confirm(question))
	{
		setFormAnchor(obj, anchor);
		return true;
	}
	else
	{
		return false;
	}
}

jQuery.fn.fadeToggle = function(speed, easing, callback) {
  return this.animate({opacity: 'toggle'}, speed, easing, callback);  
};

$(document).ready(function() {
  $('#country-select').change(function(e) {
    $('#state-select').load('/service/widgets.php', {
      action: 'LocationSelectOpts',
      parent_location_id: e.currentTarget.value,
      blank_option: $('#state-select').children('option:eq(0)').text()
    });
  });
  $('#state-select').change(function(e) {
    $('#city-select').load('/service/widgets.php', {
      action: 'LocationSelectOpts',
      parent_location_id: e.currentTarget.value,
      blank_option: $('#city-select').children('option:eq(0)').text()
    });
  });
  $('#industry-select').change(function(e) {
    $('#subindustry-select').load('/service/widgets.php', {
      action: 'IndustrySelectOpts',
      parent_industry_id: e.currentTarget.value,
      blank_option: $('#subindustry-select').children('option:eq(0)').text()
    });
  });

  if (typeof jQuery.fn.facebox == 'function')
    $('.facebox').facebox();

  $('#partner-reload').click(function (e) {
    $('#partner-results').load('/service/partners.php', null, function() {  $('.roundcorner').corner('10px'); });
  });

  $('#partner-results').load('/service/partners.php', null, function() {  $('.roundcorner').corner('10px'); });
});
