﻿var bc_confirmMessage = "Are you sure you want to delete this info?";

function BC_ConfirmDelete() {
	return confirm(bc_confirmMessage);
}

function BC_DeleteObject(obj, deleteField, id) {
	var form = $(obj).parents("form:first");

	if (BC_ConfirmDelete()) {
		BC_ChangeFormFieldValue(form, deleteField, id);
		$(form).submit();
	}
}

function BC_ChangeFormFieldValue(theform, fieldName, value) {
	$(theform).find("input[name=" + fieldName + "]").attr("value", value);
}

function BC_GotoPage(obj, page) {
	var form = $(obj).parents("form:first");

	BC_ChangeFormFieldValue(form, "bc_currentPage", page);
	$(form).submit();
}

function BC_AjaxSubmitForm(theform, options) {
	$(theform).ajaxSubmit(options);
}

function BC_ReportError(request, status, error) {
	alert(status);
}

function BC_CopySelectValueToTextBox(selectList, textBox) {
	$(textBox).val($(selectList).val());
}

function BC_GetItemDetail(options) {
	$.ajax({
		type: "GET",
		url: options.postUrl,
		cache: false,
		async: false,
		error: BC_ReportError,
		success: function(html) {
			if (options.width != null) {
				$("#bc_detailDialog")
					.dialog("option", "width", options.width)
					.dialog("option", "height", options.height)
					.dialog("option", "position", "center")
					.html(html)
					.dialog("open");
			} else {
				$("#bc_dialogContent").html(html);
				var width = $("#bc_resultContentData").width() + 20;
				var height = $("#bc_resultContent").height() + 50;

				$("#bc_detailDialog")
					.dialog("option", "width", width)
					.dialog("option", "height", height)
					.dialog("option", "position", "center");

				$("#bc_dialogContent").html("");
				$("#bc_detailDialog")
					.html(html)
					.dialog("open");
			}
		}
	});
}

function BC_AjaxPost(options) {
	if (options.type == null)
		options.type = "POST";

	if (options.dataType == null)
		options.dataType = "xml";

	$.ajax({
		type: options.type,
		url: options.postUrl,
		data: options.data,
		cache: false,
		async: false,
		dataType: options.dataType,
		success: function(xml) {
			options.successFunc(xml, options);
		}
	});
}


function BC_CancelUpdate() {
	$("#bc_detailDialog").dialog("close");
}

function FCKeditor_OnComplete(editorInstance) {
	var editorStyle = editorInstance.EditorWindow.parent.frameElement.style;
	editorStyle.height = '400px';
}
