/**
 * TODO 小红花共用
 */
var xhhLvValue = 50;
var xhhLvAvd = 3;
var xhhLvStr = "";
var xhhLvImg = [];
var cImg;
var pt;
var myCheckPhone = /^(((13[0-9]{1})|(15[0-9]{1}))+\d{8})$/;
var personString;
var personPhones;
var addPhones = new Array();
var phoneArrayIndex;
var csendCul;

// 站点路径
function getUrl(d) {
	switch (d) {
		case 0 :
			return $(document).find("base").attr("href");
		case 1 :
			return $(document).find("base").attr("href") + "organ/";
		case 2 :
			return $(document).find("base").attr("href") + "person/";
	}

}

// 当前地址
function getLocation() {
	return window.location.href;
}

// toplink动作
function toplinkASelect() {
	$(".divTopLink a").mouseover(function() {
		$(this).addClass("topoverA");
		$(this).css("backgound-color", "#CCC");
	}).mouseout(function() {
		var obj = $(this);
		setTimeout(function() {
			obj.removeClass("topoverA");
		}, 300);
	});
	xhhLvImg = [
			"<img width='14px' height='14px' src='" + obtainUrl()
					+ "/image/xhhlv_1.png'' />",
			"<img width='14px' height='14px' src='" + obtainUrl()
					+ "/image/xhhlv_2.png'' />"];
}

// 登陆用户选择
function selectLoginButton() {
	$(".divSelectLogin a").mouseover(function() {
		$(this).addClass("voerA");
	}).mouseout(function() {
		$(this).removeClass("voerA");
	}).click(function() {
		$(this).addClass("selectA").siblings("a").removeClass("selectA");
		$("#login").attr("action", $(this).attr("sel"));
	});
}

// 超连接按钮，背景变换
function aButton() {
	$(".aButton").mouseover(function() {
		$(this).removeClass("aButton").addClass("bButton");
	}).mouseout(function() {
		$(this).removeClass("bButton").addClass("aButton");
	});
}

// 识别浏览器
function isfirfox() {
	if (navigator.userAgent.indexOf("Firefox") != -1) {
		return true;
	} else {
		return false;
	}
}

// 插入行
function insertRow(stab) {
	if (isfirfox()) {
		var tabIndex = stab.rows.length;
		var cellcount = stab.rows[0].cells.length;
		var newrow = stab.insertRow(stab.rows.length);// 添加行
		for (var i = 0; i < cellcount; i++) {
			newrow.insertCell(i);// 添加列
			newrow.cells[i].innerHTML = "&nbsp;";
		}
		return newrow;
	} else {
		var tab = stab.firstChild;
		var tabIndex = tab.lastChild.rowIndex;
		var cellcount = tab.firstChild.cells.length;
		var newrow = tab.insertRow(eval(tabIndex + 1));// 添加行
		for (var i = 0; i < cellcount; i++) {
			newrow.insertCell(i);// 添加列
			newrow.cells[i].innerHTML = "&nbsp;";
		}
		return newrow;
	}
}

// 删除表格内容 方法
function clearTable(stab) {
	if (isfirfox()) {
		// var tab = stab.firstChild;
		var tabIndex = stab.rows.length;
		for (var i = tabIndex; i > 0; i--) {
			// tab.deleteRow(i);
		}
	} else {
		var tab = stab.firstChild;
		var tabIndex = tab.lastChild.rowIndex;
		for (var i = tabIndex; i > 0; i--) {
			tab.deleteRow(i);
		}
	}
}

// 已经选中的不隐藏
function checkSel(selObj) {
	if (selObj.css("display") != "block") {
		selObj.addClass("blockDiv").siblings("div").removeClass("blockDiv")
				.addClass("hiddenDiv");
		return true;
	} else {
		return false;
	}
}

// 蒙板
function divBoard(str) {

	var pWidth = $(document).width();
	var pHeight = $(document).height();

	$(".divBoard").css("background-color", "#EEE");
	$(".divBoard").css("width", pWidth + "px");
	$(".divBoard").css("height", pHeight + "px");
	$(".divBoard").css("display", "block");
	$(".divBoard div").css("top", (pHeight / 2 - 50) + "px");
	$(".divBoard div").css("left", (pWidth / 2 - 150) + "px");
	$(".divBoard div").html(str);

}

// table效果
function tableChange() {
	$("td").mouseover(function() {
		$(this).parent().css("background-color", "rgb(160,240,255)");
	}).mouseout(function() {
		$(this).parent().css("background-color", "");
	});
}

// li效果
function liChange() {
	$("li").mouseover(function() {
		$(this).css("background-color", "rgb(220,220,250)");
	}).mouseout(function() {
		$(this).css("background-color", "");
	});
}

// a效果
function aChange() {
	$("a").unbind("mouseover").unbind("mouseout").mouseover(function() {
		$(this).css("text-decoration", "underline").css("color", "red");
	}).mouseout(function() {
		$(this).css("text-decoration", "none").css("color", "");
	});
}

function getUser() {
	return $(document).find("base").attr("user");
}

function getObu() {
	return $(document).find("base").attr("obu");
}

var t = 1;
// 小红花等级
function funXhhCount(count) {

	t = 1
	xhhLvStr = "";
	calcuXhhLv(count);
	return xhhLvStr;
	// xhhLvStr
}

// 产生分页
var pageDef = 6;
function createPaging(mdObj) {
	var pd = mdObj.length / pageDef;
	var re = /^[1-9]+[0-9]*]*$/;
	if (!re.test(pd)) {
		pd = parseInt(pd) + 1;
	}
	var pagingStr = "";
	for (var pi = 0; pi < pd; pi++) {
		pagingStr += "<a  style='width: 50px;' href='javascript:void(0)' pagePt="
				+ (pi + 1) + ">[第" + (pi + 1) + "页]</a>";
	}
	return pagingStr;
}

// 计算小红花等级
function calcuXhhLv(count) {
	var a = Math.floor(count / (xhhLvValue * t));
	if (a > xhhLvAvd) {
		var b = a - xhhLvAvd;
		xhhLvStr += xhhLvImg[1];
		t++;
		calcuXhhLv(xhhLvValue * b);
	} else {
		for (var i = 0; i < a - 1; i++) {
			xhhLvStr += xhhLvImg[0];
		}
	}
}

// 时间
function replaceTimeToDay(dat) {
	var year = dat.getYear();
	var month = dat.getMonth() + 1;
	if (year < 100) {
		year += 1900;
	}
	return year + "-" + month + "-" + dat.getDate();
}

function replaceTimeToMonth(dat) {
	var year = dat.getYear();
	var month = dat.getMonth() + 1;
	if (year < 100) {
		year += 1900;
	}
	return year + "-" + month;
}

function addyearStr() {
	var isDate = new Date();
	var isYear = isDate.getYear();
	var str = "";
	for (var i = 1970; i < isYear + 1; i++) {
		str += "<option value='" + i + "'>" + i + "</option>"
	}
	return str;
}

function addMonthStr() {
	var str = "";
	for (var i = 1; i < 13; i++) {
		str += "<option value='" + i + "'>" + i + "</option>"
	}
	return str;
}

// 输出空格
function getSpace(p) {
	var s = "";
	for (var i = 0; i < p; i++) {
		s += "&nbsp;";
	}
	return s;
}

// null返回
function returnNullIsSpace(property) {
	if (property == null) {
		return "";
	} else {
		return property;
	}
}

// 激励项目经验条
function disEmpValue() {
	$(".empValue").each(function() {
		var empObj = $(this);
		var siblingInputObj = $(this).siblings("input:text");
		empObj.css("top", siblingInputObj.offset().top).css("left",
				siblingInputObj.offset().left);
	});
}

// 用户类型(true: 个人, false:组织)
function checkUserSole() {
	switch (getObu()) {
		case "organ" :
			$("#sfyk").val("head");
			return;
		case "person" :
			$("#sfyk").val("log");
			return;
	}
}

/*
 * TODO 颜色方案
 */
var color000 = "rgb(255, 255, 255)";
var color001 = "rgb(255, 0, 0)";
var color002 = "rgb(125, 0, 255)";
var color003 = "rgb(0, 230, 255)";
var color004 = "rgb(255, 125, 0)";
var color005 = "rgb(255, 255, 0)";
var color006 = "rgb(255, 0, 125)";
var color007 = "rgb(255, 255, 125)";
var color008 = "rgb(125, 125, 255)";
var color009 = "rgb(255, 125, 255)";

function getColor(d) {
	switch (d) {
		case 0 :
			return color000;
		case 1 :
			return color001;
		case 2 :
			return color002;
		case 3 :
			return color003;
		case 4 :
			return color004;
		case 5 :
			return color005;
		case 6 :
			return color006;
		case 7 :
			return color007;
		case 8 :
			return color008;
		case 9 :
			return color009;

	}
}

/**
 * TODO 文化库
 */
var selFree = true; // 默认免费
var messStatus = false; // 默认短信
var speed = 90;
var cultype;
var selectType;
var fireCulture;
var userCuls = null;

$(window).scroll(function() {
	$(".divSeeBuy").css("top", ($(this).scrollTop() / 2) - 100);
	updateImgdetpx();
}).resize(function() {
	$(".divSeeBuy").css("top", ($(this).scrollTop() / 2) - 100);
	updateImgdetpx();
});

// 免费收费选择
function selectFree(sel) {
	switch (sel) {
		case "notfree" :
			selFree = false;
			break;
		case "free" :
			selFree = true;
			break;
		case "med" :
			messStatus = true;
			break;
		case "char" :
			messStatus = false;
			break;
	}
	var c;
	$(".freeMc").each(function() {
		c = "";
		if (selFree) {
			c += "免费的";
			if ($(this).attr("control") == "free") {
				$(this).css("color", "red").siblings("a").css("color", "");
			}
		} else {
			c += "收费的";
			if ($(this).attr("control") == "notfree") {
				$(this).css("color", "red").siblings("a").css("color", "");
			}
		}
		if (messStatus) {
			c += "彩信";
			if ($(this).attr("control") == "med") {
				$(this).css("color", "red").siblings("a").css("color", "");
			}
		} else {
			c += "短信";
			if ($(this).attr("control") == "char") {
				$(this).css("color", "red").siblings("a").css("color", "");
			}
		}
	});
	$(".isFreeType").each(function() {
		$(this).html(c);
	});
	cuteMess();
}

// 文化库实例
function newCultureType() {
	cImg = new Array();
	cImg[0] = "<img width='15px' height='15px' src='"
			+ $(document).find("base").attr("href") + "image/ok.gif'></img>";
	cImg[1] = "<img width='15px' height='15px' src='"
			+ $(document).find("base").attr("href") + "image/error.gif'></img>";
	obtainFireCultures();
	commonCall.obtainCultures(function(result) {
		cultype = result;
		selectFree("");
	});
	$(".freeMc").click(function() {
		selectFree($(this).attr("control"));
	});
}

// 输出文化库
function cuteMess() {
	var cultureStr = "";
	$(".divMessMatter").html("");
	for (var i = 0; i < cultype.length; i++) {
		var type = cultype[i];
		if (type.parentType == null) {
			pt = 0;
			$(".divMessMatter").append("<strong id='strongCultureType"
					+ type.id + "'>" + getCultureParentImg(type)
					+ "&nbsp;<a class='cultureType' typeId='" + type.id
					+ "' href='javascript:void(0);'>" + type.name
					+ "</a></strong>");
			var chilrenTypes = type.childreTypeSet;
			if (chilrenTypes.length > 0) {
				recurCultureType(chilrenTypes);
			}
			writeCulture(type);
		}
	}
	$(".divMessMatter").find("strong").each(function() {
		if ($(this).find("label").length <= 0) {
			$(this).attr("hid", true).hide();
		}
	});
	$(".divMessMatter strong img").click(function() {
		var thisAlt = $(this).attr("alt");
		var thisSrc = $(this).attr("src");
		if (thisAlt == "展开") {
			thisAlt = "收起";
			thisSrc = getUrl(0) + "image/button-.gif";
		} else {
			thisAlt = "展开";
			thisSrc = getUrl(0) + "image/button+.gif";
		}
		$(this).attr("alt", thisAlt).attr("src", thisSrc).siblings("strong")
				.each(function() {
					if ($(this).attr("hid")) {
						$(this).hide();
					} else {
						$(this).toggle(300);
					}

				});
	});
	$(".cultureType").click(function() {
		seeCultureType($(this).attr("typeId"));
			// $(this).siblings("label").toggle(300);
		});
	$(".culture").click(function() {
		var culId = $(this).attr("id");
		var type
		for (var i = 0; i < cultype.length; i++) {

		}
		seeCulture(culId);
	});
	aChange();
}

// 文化库组子组
function recurCultureType(types) {
	for (var i = 0; i < types.length; i++) {
		var type = types[i];
		var p = pt;
		$("#strongCultureType" + type.parentType.id)
				.append("<strong id='strongCultureType" + type.id
						+ "' style='display: block;'>" + getSpace(p)
						+ "|-&nbsp;" + getCultureParentImg(type)
						+ "&nbsp;<a class='cultureType' typeId='" + type.id
						+ "' href='javascript:void();'>" + type.name
						+ "</a></strong>");
		var chilrenTypes = type.childreTypeSet;
		if (chilrenTypes.length > 0) {
			recurCultureType(chilrenTypes);
		}
		writeCulture(type);
	}
}

// 文化库内容
function writeCulture(type) {
	var cultures = type.childrenCulture;
	for (var i = 0; i < cultures.length; i++) {
		var culture = cultures[i];
		if (selFree == culture.status) {
			if (messStatus == culture.messageStatus) {
				var p = pt;
				$("#strongCultureType" + culture.culturetype.id)
						.append("<label style='display: none;'>" + getSpace(p)
								+ "&nbsp;&nbsp;&nbsp;<a class='culture' id='"
								+ culture.id + "' href='javascript:void();'>"
								+ culture.name + "</a></label>");
			}
		}
	}
}

function getCultureParentImg(type) {
	if (type.childreTypeSet.length > 0) {
		return "<img width='9px' alt='收起' height='9px' src='" + getUrl(0)
				+ "image/button-.gif' />";
	} else {
		return "";
	}
}

// 查看文化库分组内容
function seeCultureType(typeId) {
	getCultureType(typeId, cultype);
	var userCulsStr = "";
	for (var i = 0; i < userCuls.length; i++) {
		userCulsStr += userCuls[i].id + ",";
	}
	if (userCulsStr.lastIndexOf(",") > 0) {
		userCulsStr = userCulsStr.substring(0, userCulsStr.lastIndexOf(","));
	}
	var reBlack = window.showModalDialog(getUrl(0)
			+ "home/xhh/cultureType.jsp?selFree=" + selFree + "&messStatus="
			+ messStatus + "&userCuls=" + userCulsStr, selectType,
			"dialogHeight=300px;status:no;scroll:auto;help:no;");
	returnFunction(reBlack);
}

// 查看单个文化库信息
function seeCulture(culId) {
	if (checkUserCulture(culId)) {
		var reBlack = window.showModalDialog(getUrl(0)
				+ "home/xhh/seeculture.jsp", culId,
				"dialogHeight=100px;status:no;scroll:no;help:no;");
		returnFunction(reBlack);
	} else {
		alert("此文化信息您已存在于您的文化库中");
	}
}

function seeCultureAr(culId, userCulAr) {
	for (var i = 0; i < userCulAr.length; i++) {
		if (culId == userCulAr[i]) {
			alert("此文化信息您已存在于您的文化库中");
			return;
		}
	}
	var reBlack = window.showModalDialog(getUrl(0) + "home/xhh/seeculture.jsp",
			culId, "dialogHeight=100px;status:no;scroll:no;help:no;");
	returnFunction(reBlack);
}

// 要打开的信息是否存在
function checkUserCulture(culId) {
	for (var i = 0; i < userCuls.length; i++) {
		if (culId == userCuls[i].id) {
			return false;
		}
	}
	return true;
}

// 选定分类
function getCultureType(typeId, types) {
	var type;
	for (var i = 0; i < types.length; i++) {
		type = types[i];
		if (type.id == typeId) {
			selectType = type;
		}
		if (type.childreTypeSet.length > 0) {
			getCultureType(typeId, type.childreTypeSet);
		}
	}
}

// 热门文化信息输出
function obtainFireCultures() {
	commonCall.fireCulture("10", function(result) {
		fireCulture = result;
		var culStr = "";
		for (var i = 0; i < 10; i++) {
			culStr += "<li><a href='javascript:seeCulture(" + result[i].id
					+ ");'>" + result[i].name
					+ "</a><label><img width='9px' height='9px' src='"
					+ getUrl(0) + "/image/fire.gif' />" + result[i].cuteCount
					+ "</label></li>";
		}
		$(".divFireCulture ul").html(culStr);
		aChange();
		slidupFireCulture();
	});
}

// 上传图片定位
function updateImgdetpx() {
	var thisTop = ($(window).height() / 2) - 100;
	var thisLeft = ($(window).width() / 2) - 150;
	$(".colseDivUpdateHead").unbind().mouseover(function() {
		$(this).attr("src", "image/closeButtonA.gif");
	}).mouseout(function() {
		$(this).attr("src", "image/closeButtonB.gif");
	}).click(function() {
		$(".divUpdateHead").hide(300);
	});
	checkUserSole();
	$(".divUpdateHead").css("top", thisTop).css("left", thisLeft);
}

// 预览上传图片
function showUpimg() {
	$("#addUphead").submit();
}

function writeImg(thisId) {
	$("#showUpimg").html("<img id='" + thisId
			+ "' width='100px' height='80px' src='" + getUrl(0)
			+ "mediaLoad.action?med=" + thisId + "' />");
}

// 保存用户头像
function saveHead() {
	var user = getUser();
	var img = $("#showUpimg img").attr("id");
	var obu = getObu();
	if (img == null || img == "") {
		alert("请选择上传图片");
		$("#upload").focus();
		return;
	}
	if (user == "" || obu == "") {
		window.location.href = getUrl(0);
		return;
	}
	commonCall.saveHead(user, img, obu, function(result) {
		$(".divUpdateHead").hide(300);
		returnFunction(result);
	});
}

// 滑动
function slidupFireCulture() {
	fire2.innerHTML = fire1.innerHTML;
	var MyMar = setInterval(Marquee, speed);
	divFireCulture.onmouseover = function() {
		clearInterval(MyMar);
	}
	divFireCulture.onmouseout = function() {
		MyMar = setInterval(Marquee, speed);
	}
}

function Marquee() {
	if (fire2.offsetTop - divFireCulture.scrollTop <= 0) {
		divFireCulture.scrollTop -= fire1.offsetHeight;
	} else {
		divFireCulture.scrollTop++;
	}
}

/**
 * TODO 站点加载
 */

// 加载站点
function loadstations(result, d) {
	var stationsStr = "";
	var oneStation = result[0];
	for (var i = 0; i < result.length; i++) {
		var s = result[i].name;
		switch (s.length) {
			case 2 :
				s = s.substring(0, 1) + "&nbsp;&nbsp;" + s.substring(1);
				break;
			case 3 :
				s = s.substring(0, 1) + "&nbsp;" + s.substring(1, 2) + "&nbsp;"
						+ s.substring(2);
				break;
		}
		stationsStr += "<label><button station='" + result[i].id + "' sfyk='"
				+ result[i].sfyk + "' href='" + getUrl(d) + "index.jsp?st="
				+ result[i].id + "&' >" + s + "</button></label>";
	}
	$(".divStation").html(stationsStr + "");
	$(".divStation button").click(function() {
		var hrefStr = $(this).attr("href");
		window.location.href = hrefStr;
	});
	// $(".divStation a").mouseover(function() {
	// $(this).css("text-decoration", "underline");
	// }).mouseout(function() {
	// $(this).css("text-decoration", "none");
	// });
	var isStationUrl = getLocation();
	if (isStationUrl.indexOf("?") > 0) {
		var st = isStationUrl.substring(isStationUrl.indexOf("st=") + 3,
				isStationUrl.indexOf("&"));
		commonCall.obtainStation(st, function(result) {
			// selectSatation(st);
			obtainChildreStations(result, d);
		});
	} else {
		// selectSatation(oneStation.id);
		obtainChildreStations(oneStation, d);
	}
	cs = "";
}

// 选定导航站点
function selectSatation(sel) {
	$(".divStation a").each(function() {
		if (sel == $(this).attr("station")) {
			$(this).addClass("navigationB");
		} else {
			$(this).addClass("navigationA");
		}
	});
}

// 加载子站点
function obtainChildreStations(parentStation, d) {
	var childrens = parentStation.childrenSet;
	if (childrens == "") {
		return;
	}
	cs = "";
	var oneChildren = childrens[0];
	for (var i = 0; i < childrens.length; i++) {
		cs += "<label><button station='" + childrens[i].id + "' sfyk='"
				+ childrens[i].sfyk + "' href='" + getUrl(d) + "index.jsp?st="
				+ parentStation.id + "&stc=" + childrens[i].id + "&' >"
				+ childrens[i].name + "</button></label>";
		if (childrens[i].childrenSet.length > 0) {
			obtainChildreStations(childrens[i], d);
		}
	}
	$(".divTools").html(cs);
	$(".divTools button").click(function() {
		var hrefStr = $(this).attr("href");
		window.location.href = hrefStr;
	});
	// $(".divTools a").mouseover(function() {
	// $(this).css("font-style", "italic");
	// }).mouseout(function() {
	// $(this).css("font-style", "normal");
	// });
	var isStationUrl = getLocation();
	var stc;
	if (isStationUrl.indexOf("stc=") > 0) {
		stc = isStationUrl.substring(isStationUrl.indexOf("stc=") + 4,
				isStationUrl.lastIndexOf("&"));
	} else {
		stc = oneChildren.id;
	}
	// selectChildrenStation(stc);

	// TODO 测试时关闭
	loadFunctions(stc);
}

// 选定子站点
// function selectChildrenStation(sel) {
// $(".divTools a").each(function() {
// if (sel == $(this).attr("station")) {
//			
// loadFunctions(sel);
// $(this).css("background-color", "#DDD");
// }
// });
// }

// 加载当前页功能
function loadFunctions(station) {
	commonCall.obtainStation(station, function(result) {
		var children = result.childrenSfSet;
		var funStr = "";
		for (var i = 0; i < children.length; i++) {
			var fun = children[i].functionmodules;
			funStr += "<div class='divCenterTableTopBG'><div><span style='width: 40px;'></span>"
					+ "<span style='background-color: #FFF;'><font style='width: 10px; background-color: #FFF;'></font>"
					+ fun.name
					+ "<font style='width: 10px; background-color: #FFFS;'></font></span></div><div class='divCenterTableBodyBG'><funt id='"
					+ fun.sfyk
					+ "' />"
					+ fun.cuteEvent
					+ "</div><div class='divCenterTableBottomBG'>&nbsp;</div>"
					+ "<div style='height: 1px; font-size: 1px;'>&nbsp;</div>";
		}
		$(".divCenter").html(funStr);
		loadMat();
	});
}

// 加载充值页面
var divSeeBuyTop = "";
var divSeeBuyLeft = "";
function loadMoneyRecord() {
	var userObj;
	switch ($(document).find("base").attr("obu")) {
		case "person" :
			userObj = person;
			break;
		case "organ" :
			userObj = organ;
			break;
	}
	if (userObj.xhhcount < 50) {
		$("#presentXhh").css("color", "red");
	} else {
		$("#presentXhh").css("color", "rgb(0,255,0)");
	}
	if (userObj.money < 20) {
		$("#presentMoney").css("color", "red");
	} else {
		$("#presentMoney").css("color", "rgb(0,255,0)");
	}
	$("#presentXhh").html(userObj.xhhcount);
	$("#presentMoney").html(userObj.money);
	$("#fillMoney").change(function() {
		var fillMoney = $(this).val();
		if (fillMoney == null || fillMoney == "") {
			$(this).val(0);
			$("#fillXhh").html(0);
			return;
		}
		if (checkInt(fillMoney)) {
			$("#fillXhh").html(parseFloat(fillMoney) * 10);
		} else {
			$(this).val(0);
			alert("请正确输入。(大于0的数字)");
		}
	});
	divSeeBuyTop = ($(window).height() / 2) - 100;
	divSeeBuyLeft = ($(window).width() / 2) - 150;
	$(".divSeeBuy").css("left", divSeeBuyLeft).css("top", divSeeBuyTop);
	$(window).scroll(function() {
		$(".divSeeBuy").css("top", divSeeBuyTop + $(this).scrollTop());
	});
}

// 验证充值框内容是否为数字
function checkInt(str) {
	var checkStr = /^\d+(\.\d+)?$/;
	return checkStr.test(str);
}

// 提交充值
function subFill() {
	var fillMoney = $("#fillMoney").val();
	if (ch(fillMoney)) {
		$(".divCenterTableBodyBG div strong label input:radio")
				.each(function() {
					if ($(this).attr("checked")) {
						var paytype = $(this).val();
						var fill = $("#fillMoney").val();
						var fillXhh = $("#fillXhh").html();

						$("#buyNumber").val(getBuyNumber());
						$("#fill").val(fill);
						$("#fillWay").val(paytype);

						$(".divSeeBuy").show();

						$("#fillMoney").val("0");
						$("#fillXhh").html("0");
					}
				});
	} else {
		$("#fillMoney").val("0");
		$("#fillXhh").html("0")
		$("#calculateMonay").html("0");
		alert("您的填写的充值内容不正确，请重新填写。");
	}
}

function ch(str) {
	if (checkInt(str)) {
		if (parseFloat(str) > 0) {
			return true;
		}
		return false;
	}
	return false;
}

// 获得订单号
function getBuyNumber() {
	var dt = new Date();
	var year = adstr(dt.getYear().toString());
	var month = adstr(dt.getMonth().toString());
	var da = adstr(dt.getDate().toString());
	var day = adstr(dt.getDay().toString());
	var hours = adstr(dt.getHours().toString());
	var minutes = adstr(dt.getMinutes().toString());
	var seconds = adstr(dt.getSeconds().toString());
	var recNumber = "xhh" + year + month + da + day + hours + minutes + seconds;
	return recNumber;
}

function adstr(str) {
	if (str.length > 1) {
		return str;
	} else {
		return "0" + str;
	}
}

// 关闭订单层
function closeDivSeeBuy() {
	$(".divSeeBuy").hide();
}

// 提交充值至服务器
function subFillajax(bol) {
	var buyNumber = $("#buyNumber").val();
	var balance = $("#presentMoney").html();
	var filllMoney = $("#fill").val();
	var fillWay = $("#fillWay").val();
	commonCall.fillMoney(buyNumber, $(document).find("base").attr("obu"),
			getUser(), balance, filllMoney, fillWay, bol, function(reslut) {
				returnFunction(reslut);
				$('.divSeeBuy').css('display', 'none');
			});
}

// 短信发送返回
function sendCallBlock(result) {
	switch (result) {
		case "successSend" :
			alert("短信发送成功");
			break;
		case "errorSend" :
			alert("短信发送失败");
			break;
	}
}

// 动作回调后处理
function returnFunction(funBlack) {
	funBlack += "";
	var chks = "";
	var culid = "";
	if (funBlack != null) {
		if (funBlack.indexOf("&") > 0) {
			chks = funBlack.substring(0, funBlack.indexOf("&"));
			culid = funBlack.substring(funBlack.indexOf("&") + 1,
					funBlack.length);
		} else {
			chks = funBlack;
		}
	}
	if (getUser() != null && getUser() != "") {
		switch (parseInt(chks)) {
			case 0 :
				alert("网站维护中，请稍后重试");
				window.close();
				break;
			case 1 :
				alert("发送请求用户不存在");
				window.location.href = getUrl(0);
				break;
			case 2 :
				alert("操作完成");
				switch ($(document).find("base").attr("obu")) {
					case "person" :
						obtainStations();
						break;
					case "organ" :
						loadOrganization();
						break;
				}
				obtainFireCultures();
				setTimeout(function() {
					if (culid != null && culid != "") {
						var matter = "";
						for (var i = 0; i < userCuls.length; i++) {
							if (parseInt(culid) == userCuls[i].id) {
								matter = userCuls[i].matter;
							}
						}
						if (matter != "") {
							$(".divCenter").find("funt").each(function() {
								var funS = $(this).attr("id");
								switch (funS) {
									case "organdisperson" :
										matter += "--" + organ.name + "--";
										break;
									case "messagesend" :
										matter += "--" + person.name + "--";
										break;
								}
							});
						}
						$("#matter").html(matter);
					}
				}, 1200);
				break;
			case 3 :
				alert("用户操作对象不存在");
				break;
			case 4 :
				alert("用户发送请求信息错误，请重试");
				break;
			case 5 :

				break;
			case 6 :
				alert("您操作的对象内还有子成员，请先删除子成员移动子成员");
				break;
			case 8 :
				alert("时间错误，请重新确认填写时间");
				break;
		}
	} else {
		if (funBlack != null && funBlack != "" && funBlack != "undefined") {
			window.returnValue = funBlack;
			window.close();
		}
	}
}

