/**
 * @描述：业务基础Js库
 * @开发人员：moshco zhu
 * @开发日期：2010-1-15 上午10:18:35
 * @参数：
 * @返回值：any
 * @return
 */
function FHBusiUtils() {
	// 扩展基础组件对象
	var oComponentClass = {};
	$.extend(oComponentClass, FHUtils);
	$.extend(oComponentClass, FHBusiUtils);
	$.extend(FHBusiUtils, oComponentClass);
	var oComponent = {};
	$.extend(oComponent, FHUtils);
	$.extend(oComponent, FHUTILS);
	$.extend(oComponent, this);
	$.extend(this, oComponent);
}

/**
 * @描述:刷新安全码的图片
 * @开发人员:moshco zhu
 * @开发时间:2011-5-24 下午12:05:07
 * @param oComponent
 */
FHBusiUtils.refreshSecurityCodeImg = function(oComponent, strImgUrl) {
	oComponent.fadeOut(1500, function() {
		oComponent.css({
			display : "none"
		});
		$(this).css({
			display : "",
			"background-image" : "url(" + strImgUrl + "&p=" + Math.random() + ")",
			"background-position" : "left top",
			"background-repeat" : "no-repeat"
		});
	});
};

/**
 * @描述:验证手机安全验证码
 * @开发人员:moshco zhu
 * @开发时间:2011-5-28 上午10:24:17
 * @param strActionUrl
 * @param strMPhone
 * @param oSecurityCode
 */
FHBusiUtils.verifyMPhoneSecurityCode = function(strActionUrl, strMPhone, oSecurityCode) {
	// 异步函数
	var fn = function(strMsg) {
		// strJs不能为空
		if (strMsg == null) {
			msg("请求发送失败！");
		} else if (strMsg != "") {
			// 有错误提示
			// msg(strMsg);
			// 显示信息
			$(".mphone_security_verify .row_mphone_verify .msg").html(strMsg).fadeIn(1000, function() {
				$("#showWrong").show();
				$(this).fadeOut(8000);
			});
		} else {
			// 表单提示
			$(".mphone_security_verify").html("手机号验证成功！").fadeOut(0, function() {
				$(this).parent().attr('name', 'true');
				$("#mphoneVerifyAll").hide();
				$("#lastShowRight").show();
				$("#showMp").html(strMPhone);
				//$(this).parent().empty();

			});

			// if(strFn != null && $.isFunction(strFn)){
			// strFn();
			// }
		}
	};
	// 发出请求
	doAction(strActionUrl, {
		mphone : strMPhone,
		code : oSecurityCode.val()
	}, fn);
	// 返回函数值
	return;
};

/**
 * @描述:验证页面安全验证码 发送手机安全验证码
 * @开发人员:moshco zhu
 * @开发时间:2011-5-28 上午10:24:30
 * @param strActionUrl
 * @param strMPhone
 * @param strBusiness
 * @param strBusinessId
 * @param oSecurityCode
 */
FHBusiUtils.sendMPhoneSecurityCode = function(strActionUrl, strMPhone, strBusiness, strBusinessId, oSecurityCode) {
	// 异步函数
	var fn = function(strMsg) {
		//清空手机验证码输入框
		$(".mphone_security_verify .code").attr('value',"");
		//隐藏错误
		$("#showWrong").hide();
		$("#mmm").hide();
		// strJs不能为空
		if (strMsg == null) {
			msg("请求发送失败！");
			$(".security_code_img").click();
		} else if (strMsg == "手机安全验证码发送成功！") {
			// 显示手机验证表单
			$(".mphone_security_verify .row_mphone_verify").fadeIn(1000);
			$(".mphone_security_verify .row_mphone_text").fadeIn(1000);

		} else if (strMsg == "请不要频繁发送!") {
			// 显示手机验证表单
			$(".mphone_security_verify .row_mphone_verify").fadeIn(1000);
			$(".mphone_security_verify .row_mphone_text").fadeIn(1000);
			$(".security_code_img").click();
		} else {
			// 隐藏手机验证表单
			$(".mphone_security_verify .row_mphone_verify").fadeOut(0);
			$(".mphone_security_verify .row_mphone_text").fadeOut(0);
			$(".security_code_img").click();
		}
		// 显示信息
		$(".mphone_security_verify .row_page_verify .msg").html(strMsg).fadeIn(1000, function() {
			$(this).fadeOut(8000);
		});
	};
	// 发出请求
	doAction(strActionUrl, {
		phoneNum : strMPhone,
		securityCode : oSecurityCode.val(),
		business : strBusiness,
		businessId : strBusinessId
	}, fn);
	// 返回函数值
	return;
};

/**
 * @描述:显示手机安全验证表单
 * @开发人员:moshco zhu
 * @开发时间:2011-5-28 上午09:48:59
 * @param strUrl
 * @mphone:手机号码 business:业务 businessId:业务Id
 * @param oRefreshSection
 * @returns
 */
FHBusiUtils.showMPhoneSecurityForm = function(strUrl, oRefreshSection) {
	// 表单HTML数据
	var strFormHtml = "";
	// 异步函数
	var fn = function(strHtml) {
		// 刷新区域
		oRefreshSection.html(strHtml);
	};
	// 发出请求
	doAction(strUrl, {}, fn);
	// 返回函数值
	return;
};

/**
 * @描述：热门查询
 * @开发人员：zhoudan
 * @开发日期：2011-06-22 12:02:40
 */
FHBusiUtils.hotQuery = function(oContainer) {
	var word = oContainer.attr("business");
	var strUrl = oContainer.attr("actionUrl") + "&hotTitle=" + encodeURI(word);
	strUrl = encodeURI(strUrl);
	$("#hot_queryresult").load(strUrl);
};

/**
 * @描述:显示消息对话框
 * @开发人员:moshco zhu
 * @开发时间:2011-6-15 上午11:28:28
 * @param strMsg
 * @param strTitle
 * @returns
 */
FHBusiUtils.msg = function(strMsg, strTitle, lHideTime) {
	// 后台调用
	if (window.BaseUI != null) {
		return BaseUI.msg(strMsg, strTitle, lHideTime);
	}
	// 对话框容器
	var oDialogContainer = $(".dialog");
	// 创建对话框
	var oDialog = nmdialog("<br>" + strMsg, "关闭", null, oDialogContainer, null);
	oDialog.setTitleIcon("FHBaseUIDialogTitleMidIcon1");
	// oDialog.hideButton();
	// oDialog.setMarginLeft(($(window).width() / 2) + 220);
	oDialog.setMarginTop($(window).scrollTop() + 200);
	if (strTitle != null) {
		oDialog.setTitle(strTitle);
	} else {
		oDialog.setTitle("提示信息");
	}
	var oDialogContainer = oDialog.Container;
	oDialogContainer.fadeOut(0);
	oDialogContainer.fadeIn(200);
	if (lHideTime != null) {
		oDialogContainer.fadeTo(lHideTime, 0.95, function() {
			$(this).fadeOut(200);
		});
	}
	// 返回函数值
	return oDialog;
};

/**
 * @描述:显示一个对话框
 * @开发人员:moshco zhu
 * @开发时间:2011-7-2 上午09:48:46
 * @param strHtml
 * @param strTitle
 * @param bIsModal
 * @returns
 */
FHBusiUtils.showDialog = function(strHtml, strTitle, bIsModal) {
	// 后台调用
	if (window.BaseUI != null) {
		return BaseUI.showDialog(strHtml, strTitle, bIsModal);
	}
	// 对话框容器
	var oDialog = null;
	// 对话框容器对象
	var oDialogContainer = $(".dialog");
	// Url 或 html内容
	if (isUrl(arguments[0])) {
		strHtml = readHtml(arguments[0]);
	}
	if (bIsModal != null && bIsModal) {
		oDialog = mdialog(strHtml, null, null, oDialogContainer, null);
	} else {
		oDialog = nmdialog(strHtml, null, null, oDialogContainer, null);
	}
	// 设置对话框的属性
	oDialog.hideButton();
	// oDialog.hideClose();
	oDialog.setWidth(460, false);
	oDialog.setTitleIcon("FHBaseUIDialogTitleMidIcon1");
	oDialog.setMarginLeft(($(window).width() / 2));
	oDialog.setMarginTop($(window).scrollTop() + 200);
	oDialog.setTitle(strTitle);
	// 初始化组件
	initBaseUIComponent(oDialogContainer, true);
	// 设置默认标题
	setDefaultTitle($(oDialogContainer));
	// 返回函数值
	return oDialog;
};

/**
 * @描述:初始化数据表格
 * @开发人员:moshco zhu
 * @开发时间:2011-6-7 上午11:25:20
 */
FHBusiUtils.initTableData = function() {
	if (BaseUI == null) {
		alert("BaseUI为空！");
		return false;
	}
	try {
		var oSize = BaseUI.getTabGroupContainerSize();
		var iNewWidth = oSize.width - 30;
		$(".table_data").width(iNewWidth + 10);
		$(".table_data_row2_2_content").width(iNewWidth);
		$(".table_data_row2_2_content .table_data_tb").width(iNewWidth);
		$(".table_data_row2_2_content .table_data_tb td").each(function() {
			if ($(this).html() == "") {
				$(this).html("&nbsp;");
			}
		});
		$(".table_data_row2_2_content .table_data_tb_cell").each(function() {
			var iTdWidth = $(this).outerWidth();
			var oInputViews = $(this).find(".input_view");
			if (oInputViews != null && oInputViews.length == 1) {
				oInputViews.width(iTdWidth - 4);
			}
			oInputViews.each(function() {
				if ($(this).val() == "null" || trim($(this).val()) == "null") {
					$(this).val("");
				}
			});
		});

		$(".table_data_row2_2_content .table_data_tb .td_table").each(function() {
		// $(this).width($(this).parent().width());
		});
	} catch (e) {
		alert(e.message);
	}
};

/**
 * @描述:后台面板对象初始化代码
 * @开发人员:moshco zhu
 * @开发时间:2011-5-30 上午03:26:37
 */
FHBusiUtils.PanelInit = function() {
	if (BaseUI != null) {
		// 事件函数：当页面尺寸发生改变时运行
		var fnResize = function() {
			initTableData();
		};
		// 设置页面尺寸
		fnResize();
		// 当外部框架改变尺寸时运行
		BaseUI.setResizeFn(FHLayout.REGION_CENTER, function(iWidth, iHeight) {
			fnResize();
			var oPageUI = BaseUI.getPage();
			if (oPageUI.resizeComponent != null) {
				oPageUI.resizeComponent(iWidth, iHeight);
			}
		});
		// 设置默认标题
		setDefaultTitle(BaseUI.getPageView());
	}
};

// 业务基础对象
var FHBUSI = new FHBusiUtils();

// 实例化基础库对象
if (window.FHBUSI == null) {
	window.FHBUSI = FHBUSI;
}

// 将Web26311Utils0Base静态方法扩展到window对象
if (window.isExtendFHBusiUtils == null || !window.isExtendFHBusiUtils) {
	$.extend(window, FHBusiUtils);
	window.isExtendFHBusiUtils = true;
}

