function submit_ajax_form(form_object, extraData, callback) {
	if (!extraData) extraData = new Array();
    	var options = { 
		//target:        '#output1',   // target element(s) to be updated with server response 
		//beforeSubmit:  showRequest,  // pre-submit callback 
		success:       function(responseText, statusText, xhr, $form){
			if(typeof responseText != 'undefined' && responseText != 'null')
			{
				parsed_response = json_parse(responseText);
				$(form_object).replaceWith(parsed_response.form_html);
				$.triggerReady();
				if (typeof callback !== 'undefined')
				{	
					callback($(form_object));
				}
			}
		},  // post-submit callback 
			 
		// other available options: 
		url:       'ajax.php',    // override for form's 'action' attribute 
		data: extraData
		//type:      type        // 'get' or 'post', override for form's 'method' attribute 
		//dataType:  null        // 'xml', 'script', or 'json' (expected server response type) 
		//clearForm: true        // clear all form fields after successful submit 
		//resetForm: true        // reset the form after successful submit 
			 
		// $.ajax options can be used here too, for example: 
		//timeout:   3000 
   	};
	$(form_object).ajaxSubmit(options); 
}

function wj_preload_multi_cities(state_selector, city_selector)
{	
	selected_states = $(state_selector+":checked").map(function () {
		return this.value;
	}).get();
	ajax_url = "ajax.php?page=search&action=load_cities_list&state_list="+(encodeURI(selected_states));
	jQuery.ajax({	
		url: ajax_url,
  		success: function(responseText) {
			parsed_response = json_parse(responseText);
			currently_selected_city = $(city_selector).val();
			$(city_selector).html(parsed_response.city_list);
			$(city_selector).val(currently_selected_city);
	  	}
  	});

}

function initiate_search_form(previous_form) {
	$('div.search_results_left_tab_search legend').bind('click', function() {
		wj_search_tab_click($(this));
	});
	if (typeof previous_form !== 'undefined')
	{	
		previous_form.find('legend').each(function() {
			if ($(this).hasClass('search_tab_closed'))
			{
				$('div.search_results_left_tab_search fieldset.'+($(this).parent().attr('class'))+' legend').click();
			}
		});
	}
}

function wj_search_tab_click(target) {
	if (target.hasClass("search_tab_closed"))
	{
		//open section
		target.removeClass("search_tab_closed");
		target.parent().find('div').css('display', 'block');
	}
	else
	{
		//close section
		target.addClass("search_tab_closed");
		target.parent().find('div').css('display', 'none');
	}
}

$.getReadyList = function() {
	if(this.readyList != null) { this.myreadylist = [].concat(this.readyList); }
	return this.myreadylist;
};

$(document).ready(function() {
	readylist = $.getReadyList();
});

$.triggerReady = function() {
	$(readylist).each(function(){this();});
}


function process_delete_entry(link, refresh_table, custom_callback_f) {
	ajax_link = link.href;
	base_link = $('base').attr('href');
	ajax_link = ajax_link.replace(base_link, '');
	$.ajax({
	        method: "get", 
		url: "ajax.php", 
		data: "_seo_url="+ajax_link,
		success: function(responseText) {
			parsed_response = json_parse(responseText);
			if (refresh_table)
			{
				$(refresh_table).replaceWith(parsed_response['refresh_table']);
			}
			if (custom_callback_f)
			{
				custom_callback_f();
			}
		}
	});	
}

function profileSubsectionDeleteCallback() {
	is_profile_subsection_enabled("div.register_seeker2_div_experience", "div.experience_entries_list table.search_res tbody", "#display_position");
	is_profile_subsection_enabled("div.register_seeker2_div_education", "div.education_entries_list table.search_res tbody", "#display_education");
	if($('div.experience_entries_list table.search_res tbody').length==0)
	{
		$('div.experience_entries_list').css('display', 'none');
	}
	if($('div.education_entries_list table.search_res tbody').length==0)
	{
		$('div.education_entries_list').css('display', 'none');
	}
}




