$(function() {
    $(".addJob").button('enable');

    $(".addJob").click(function() {
	$(".addJob").button('disable');
	addJob();
    });



    $( "#jobAddedDialog" ).dialog({
	autoOpen: false,
	modal: true,
	buttons: {
	    Ok: function() {
		$( this ).dialog( "close" );
	    }
	},
	close: function(event,ui) {
	    window.location.href = '/jobs';
	}
    });


    function addJob() {

	var enquiryID = $(".addJob").attr("id");

	$.post('/jobs/ajax_add/'+enquiryID, function(data) {
	    $( "#jobAddedDialog" ).dialog('open');
	});

    }

});