function QOJDialogCallback( d ) {
	// error van
	if (typeof d.error!="undefined") {
		alert( d.error );
		return;
	}
	// van dialog
	if (typeof d.dlg!="undefined") {
		$("#dlg_quote_of_job_handler").html( d.dlg );
	}
	var dlg = {};
	if (typeof d.dlg_ttl!="undefined") dlg.title = d.dlg_ttl;
	dlg.modal = true;
	dlg.width = 400;
	dlg.height = 250;
	if (typeof d.buttons!="undefined") {
		var btns = {};
		for (var i in d.buttons) {
			if (d.buttons[i]!=false) {
				$("#dlg_quote_of_job_handler").data( "submitparams" , d.buttons[i] );
				btns[i] = function() { QOJSubmitDialog( ); }
			} else {
				btns[i] = function() { QOJCancelDialog(); }
			}
			dlg.buttons = btns;
		}
	}
	$("#dlg_quote_of_job_handler").dialog( dlg );
}

function QOJSubmitDialog() {
	var d = $("#dlg_quote_of_job_handler").data( "submitparams" );
	if (typeof document.frm_job_quote_comment.jqcomment != "undefined")
		d["jqcomment"] = document.frm_job_quote_comment.jqcomment.value;
	QOJSendRequest( d , QOJSimpleEval );
}

function QOJSimpleEval( e ) {
	eval( e.evaluate );
}

function QOJCancelDialog() {
	$("#dlg_quote_of_job_handler").dialog( "close" );
	$("#dlg_quote_of_job_handler").dialog( "destroy" );
}

function QOJSendRequest( d , cb ) {
	d["inajax"]=1;
	$.ajax(
		{
			type: "POST",
			cache: false,
			data: d,
			success: cb
		}
	);
}

function QOJAcceptJobQuote( job_quote_id ) {
	var d = {
		"ajaxevent" : "dlg_accept_job_quote",
		"job_quote_id" : job_quote_id
	};
	QOJSendRequest( d , QOJDialogCallback );
}

function QOJDeclineJobQuote( job_quote_id ) {
	var d = {
		"ajaxevent" : "dlg_decline_job_quote",
		"job_quote_id" : job_quote_id
	};
	QOJSendRequest( d , QOJDialogCallback );
}
