function toggle_search_filter(filter_name)
{
	if ($('div#'+filter_name).hasClass('filter_title_enabled'))
	{
		//disable the filter
		$('div#'+filter_name).removeClass('filter_title_enabled');
		$('div#'+filter_name).addClass('filter_title_disabled');
		$('div#'+filter_name+'_contents').removeClass('filter_contents_enabled');
		$('div#'+filter_name+'_contents').addClass('filter_contents_disabled');
	}
	else if ($('div#'+filter_name).hasClass('filter_title_disabled'))
	{
		//enable the filter
		$('div#'+filter_name).removeClass('filter_title_disabled');
		$('div#'+filter_name).addClass('filter_title_enabled');
		$('div#'+filter_name+'_contents').removeClass('filter_contents_disabled');
		$('div#'+filter_name+'_contents').addClass('filter_contents_enabled');
	}
}


function expand_more_filters(filter_name)
{
	$('div#'+filter_name+'_contents div.extra_filter_entry').css('display', 'block');
	$('div#'+filter_name+'_contents div.filter_more_link').css('display', 'none');
}


function toggle_url_field()
{
	if ($('select#manage_applicants').val()==376)
	{
		$('div#post_single_job_apply_url').css('display', 'none');
	}
	else
	{
		$('div#post_single_job_apply_url').css('display', 'block');
	}
}


function gather_sort_ids(experience_selector, education_selector, experience_form_field, education_form_field)
{
	$(experience_form_field).val('');
	$(experience_selector).each(function() 
	{
		if ($(experience_form_field).val()!='')
		{
			$(experience_form_field).val($(experience_form_field).val()+'-'+$(this).val());
		}
		else
		{
			$(experience_form_field).val($(this).val());
		}
	});

	$(education_form_field).val('');	
	$(education_selector).each(function() 
	{
		if ($(education_form_field).val()!='')
		{
			$(education_form_field).val($(education_form_field).val()+'-'+$(this).val());
		}
		else
		{
			$(education_form_field).val($(this).val());
		}
	});
}


function process_fb_popup()
{
	var vars = [], hash;
	var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
	for(var i = 0; i < hashes.length; i++)
	{
		hash = hashes[i].split('=');
		vars.push(hash[0]);
		vars[hash[0]] = hash[1];
	}
	if (vars['page']=='register_seeker' && vars['action']=='import_profile' && vars['is_popup']=='1')
	{
		window.opener.location.href = window.location.href.replace("&is_popup=1", "");
	}
	window.close();
}


function is_profile_subsection_enabled(subform_container, entries_table, display_control_field)
{
	if($(entries_table).length==0)
	{
		//the subsection doesn't have entries, display its subform
		$(subform_container).css('display', 'block');
	}
	else
	{
		//the subsection has entries but still may need to be displayed
		if ($(display_control_field).val()==1)
		{
			//user is working with the subsection, display it
			$(subform_container).css('display', 'block');
		}
		else 
		{
			//hide the subsection
			$(subform_container).css('display', 'none');
		}
	}
}

