$(function() {

	// Make headers clickable
	
	$('.career_listing table th a').css('cursor', 'pointer');

	/* ---------------------------------------------------------------------- */
	/* add sorting to careers table
	/* ---------------------------------------------------------------------- */

	// init vars
	var orig_sort_by = $('.sort_by').html();
	var orig_sort_dir = $('.sort_dir').html();
	
	// add links for sorting columns of careers table
	$('.dataGrid th').each(function() {
		var type = $(this).attr('class');
		type = type.replace(/_header$/, '');
	
		var inner_link = $(this).find('a:first');
		var sort_by    = inner_link.html();	
		
		// flip direction if necessary
		if (orig_sort_by == sort_by && orig_sort_dir == 'asc') {
			var sort_dir = 'desc';
		} else {
			var sort_dir = 'asc';
		}

		// add href
		inner_link.attr('href', '?sort=' + inner_link.html() + '&dir=' + sort_dir)
	})
	
	$(".career_listing table th:nth-child(1)").addClass('job_title_header');
	$(".career_listing table th:nth-child(2)").addClass('company_header');
	$(".career_listing table th:nth-child(3)").addClass('industry_header');
	$(".career_listing table th:nth-child(4)").addClass('location_header');
	
})

