
/*div_id_difine*/
var div_title_id = "titlebar";
var div_notice_id = "noticebar";
var div_nav_id = "navbar";
var div_query_id = "query_bar";
var div_login_id = "loginbar";
var div_doc_list_id = "doc_list_bar";
var div_foot_id = "footbar";
var div_name_front_itemList_main = "front_itemList_main";
var div_name_help = "help";
var div_name_introduce = "introduce";
var div_name_itemList = "itemList";
var div_name_additionItemList = "additionItemList";
Index = function () {
	return {init:function () {
		//Index.reloadTitle();
		Index.reloadNotice();
		Index.reloadNavigator();
		Index.reloadLoginForm();
		Index.reloadDocList();
	}, reloadTitle:function (nav) {
		return;
		var _nav = "";
		if (nav == undefined) {
			nav = _nav;
		}
		$.get("title.html", {"randomNum":Math.random(), "nav":nav}, function (_html) {
			$("#" + div_title_id).html(_html);
		});
	}, reloadNotice:function () {
		Index.block();
		$.get("notice_list.html", {"randomNum":Math.random()}, function (_html) {
			$("#" + div_notice_id).html(_html);
			Index.unblock();
		});
	}, reloadNavigator:function () {
		Index.block();
		$.get("nav.htm", {"randomNum":Math.random()}, function (_html) {
			$("#" + div_nav_id).html(_html);
			Index.unblock();
			Navigator.init();
		});
	}, reloadQuery:function () {
		Index.block();
		$.get("query.htm", {}, function (_html) {
			$("#" + div_query_id).html(_html);
			Index.unblock();
		});
	}, reloadMain:function () {
		Index.block();
		$.get("main.htm", {}, function (_html) {
			$("#" + div_name_front_itemList_main).html(_html);
			Index.unblock();
			setTimeout("Index.showMainFlash()", 2700);
		});
	}, reloadMainQuery:function () {
		Index.block();
		$.get("mainquery.htm", {}, function (_html) {
			$("#" + div_name_front_itemList_main).html(_html);
			Index.unblock();
			setTimeout("Index.showMainFlash()", 2700);
		});
	}, showMainFlash:function () {
		$("#main_flash_layer").hide();
		$("#main_image_layer").show();
	}, reloadLoginForm:function () {
		Index.block();
		$.get("register_loginForm.html", {"randomNum":Math.random()}, function (_html) {
			$("#" + div_login_id).html(_html);
			Index.unblock();
		});
	}, reloadDocList:function () {
		Index.block();
		$.get("attachmentList_all.html", {"randomNum":Math.random()}, function (_html) {
			$("#" + div_doc_list_id).html(_html);
			Index.unblock();
		});
	}, reloadPolicyFiles:function () {
		Index.block();
		$.get("policyFiles.htm", {}, function (_html) {
			$("#" + div_name_front_itemList_main).html(_html);
			Index.unblock();
		});
	}, reloadDeparmentList:function () {
		Index.block();
		$.get("departmentList.htm", {}, function (_html) {
			$("#" + div_name_front_itemList_main).html(_html);
			Index.unblock();
		});
	}, changeMainImg:function (imgPath) {
		$("#main_big_img").attr("src", imgPath);
	}, block:function () {
		$("#pageContent").block();
	}, unblock:function () {
		$("#pageContent").unblock();
	}};
}();
Navigator = function () {
	return {init:function () {
		$("#nav_item_table").find("tr").each(function () {
			$(this).click(function () {
				$("#nav_item_table").find("tr").each(function () {
					$(this).attr("class", "");
				});
				$(this).attr("class", "nav_selected");
			});
		});
	}};
}();
ItemListTab = function () {
	var clearTabClass = function () {
		$("#TabPage").find("li").each(function () {
			$(this).attr("class", "");
		});
	};
	return {loadHelp:function () {
		Index.block();
		$.get("itemList_help.htm", {}, function (_help) {
			$("#" + div_name_help).html(_help);
			Index.unblock();
		});
	}, hideAll:function () {
		$("#" + div_name_help).hide();
		$("#" + div_name_itemList).hide();
		$("#" + div_name_additionItemList).hide();
	}, showHelp:function () {
		ItemListTab.hideAll();
		$("#" + div_name_help).show("slow");
		clearTabClass();
		$("#itemList_help").attr("class", "Selected");
	}, showAuditList:function () {
		ItemListTab.hideAll();
		$("#" + div_name_itemList).show("slow");
		clearTabClass();
		$("#itemList_audit").attr("class", "Selected");
	}, showOtherList:function () {
		ItemListTab.hideAll();
		$("#" + div_name_additionItemList).show("slow");
		clearTabClass();
		$("#itemList_other").attr("class", "Selected");
	}};
}();
ItemGuide = function () {
	var loadIntroduce = function () {
		Index.block();
		$.get("itemGuide_introduce.html", {"randomNum":Math.random()}, function (_introduce) {
			$("#" + div_name_introduce).html(_introduce);
			Index.unblock();
		});
	};
	var loadAuditItemList = function () {
		Index.block();
		$.get("itemGuide_auditList.html", {"randomNum":Math.random()}, function (_itemList) {
			$("#" + div_name_itemList).html(_itemList);
			Index.unblock();
		});
	};
	var loadOtherItemList = function () {
		Index.block();
		$.get("itemGuide_otherList.html", {"randomNum":Math.random()}, function (_itemList) {
			$("#" + div_name_additionItemList).html(_itemList);
			Index.unblock();
		});
	};
	return {index:function () {
		Index.block();
		Index.reloadQuery();
		$.get("itemGuide_main.html", {"randomNum":Math.random()}, function (_main) {
			$("#" + div_name_front_itemList_main).html(_main);
			loadIntroduce();
			loadAuditItemList();
			loadOtherItemList();
			ItemListTab.loadHelp();
			ItemListTab.showHelp();
			Index.unblock();
		});
	}, listByParent:function (typeId) {
		Index.reloadQuery();
		Index.unblock();
		$.get("itemGuide_itemListByParent.html", {"typeId":typeId, "randomNum":Math.random()}, function (_html) {
			$("#" + div_name_front_itemList_main).html(_html);
		});
		Index.block();
	}, detail:function (typeId) {
		Index.block();
		$.get("itemDetail_detail.html", {"typeId":typeId, "randomNum":Math.random()}, function (_detail) {
			$("#" + div_name_front_itemList_main).html(_detail);
		});
		Index.unblock();
	}};
}();
ItemManager = function () {
	var loadIntroduce = function () {
		Index.block();
		$.get("itemList_introduce.html", {"randomNum":Math.random()}, function (_introduce) {
			$("#" + div_name_introduce).html(_introduce);
			Index.unblock();
		});
	};
	var loadAuditItemList = function () {
		Index.block();
		$.get("itemList_auditList.html", {"randomNum":Math.random()}, function (_itemList) {
			$("#" + div_name_itemList).html(_itemList);
			Index.unblock();
		});
	};
	var loadOtherItemList = function () {
		Index.block();
		$.get("itemList_otherList.html", {"randomNum":Math.random()}, function (_itemList) {
			$("#" + div_name_additionItemList).html(_itemList);
			Index.unblock();
		});
	};
	return {index:function () {
		Index.block();
		Index.reloadQuery();
		$.get("itemList_main.html", {"randomNum":Math.random()}, function (_main) {
			$("#" + div_name_front_itemList_main).html(_main);
			$("#" + div_name_front_itemList_main).html(_main);
			loadIntroduce();
			loadAuditItemList();
			loadOtherItemList();
			ItemListTab.loadHelp();
			ItemListTab.showAuditList();
			Index.unblock();
		});
	}, listByParent:function (typeId) {
		Index.reloadQuery();
		Index.block();
		$.get("itemList_itemListByParent.html", {"typeId":typeId, "randomNum":Math.random()}, function (_html) {
			$("#" + div_name_front_itemList_main).html(_html);
			Index.unblock();
		});
	}, queryBySerialNum:function (_serialNum) {
		var _type = $("#query_type").fieldValue();
		var serialNum = "";
		if (_serialNum && _serialNum != "") {
			serialNum = _serialNum;
		} else {
			serialNum = $("#consultation_item_serialNum").fieldValue();
		}
		if ("2" == _type) {
			if (serialNum.length != 12) {
				alert("\u67e5\u8be2\u7801\u957f\u5ea6\u5fc5\u987b\u4e3a12\u4f4d");
			} else {
				self.location = "http://124.74.193.52/mjzz/toWebAppQuery.do?app_no=" + serialNum;
			}
		} else {
			Index.reloadQuery();
			Index.block();
			$.get("itemQuery_query.html", {"serialNum":serialNum, "randomNum":Math.random()}, function (_result) {
				$("#" + div_name_front_itemList_main).html(_result);
				Index.unblock();
			});
		}
	}, clearQueryNum:function () {
		$("#consultation_item_serialNum").val("");
	}, statusQuery:function () {
		Index.block();
		$.getJSON("register_checkSession.html", {"randomNum":Math.random()}, function (result) {
			if (result.success == "true") {
				Index.reloadQuery();
				$.get("itemQuery_statusQuery.html", {"randomNum":Math.random()}, function (_result) {
					$("#" + div_name_front_itemList_main).html(_result);
				});
			} else {
				alert("\u60a8\u5c1a\u672a\u767b\u5f55,\u8bf7\u5148\u767b\u5f55!");
			}
			Index.unblock();
		});
	}, resultQuery:function () {
		Index.block();
		$.getJSON("register_checkSession.html", {"randomNum":Math.random()}, function (result) {
			if (result.success == "true") {
				Index.reloadQuery();
				$.get("itemQuery_resultQuery.html", {"randomNum":Math.random()}, function (_result) {
					$("#" + div_name_front_itemList_main).html(_result);
				});
			} else {
				alert("\u60a8\u5c1a\u672a\u767b\u5f55,\u8bf7\u5148\u767b\u5f55!");
			}
			Index.unblock();
		});
	}};
}();
AttachmentList = function () {
	var loadIntroduce = function () {
		Index.block();
		$.get("itemGuide_introduce.html", {"randomNum":Math.random()}, function (_introduce) {
			$("#" + div_name_introduce).html(_introduce);
			Index.unblock();
		});
	};
	var loadAuditList = function () {
		Index.block();
		$.get("attachmentList_auditList.html", {"randomNum":Math.random()}, function (_html) {
			$("#" + div_name_itemList).html(_html);
			Index.unblock();
		});
	};
	var loadOtherList = function () {
		Index.block();
		$.get("attachmentList_otherList.html", {"randomNum":Math.random()}, function (_html) {
			$("#" + div_name_additionItemList).html(_html);
			Index.unblock();
		});
	};
	return {index:function () {
		Index.block();
		Index.reloadQuery();
		$.get("itemList_main.html", {"randomNum":Math.random()}, function (_main) {
			$("#" + div_name_front_itemList_main).html(_main);
			loadIntroduce();
			loadAuditList();
			loadOtherList();
			ItemListTab.loadHelp();
			ItemListTab.showAuditList();
			Index.unblock();
		});
	}};
}();
ItemConsultation = function () {
	var div_recordFormTab_id = "recordFormTab";
	//var street_selector = {"\u6d66\u4e1c":{"WF":"\u6f4d\u574a\u8857\u9053", "MT":"\u5357\u7801\u5934\u8857\u9053", "ZC":"\u5468\u5bb6\u6e21\u8857\u9053", "TQ":"\u5858\u6865\u8857\u9053", "BC":"\u5317\u8521\u9547","MY":"\u9646\u5BB6\u5634\u8857\u9053"}, "\u95f8\u5317":{"LF":"\u4e34\u6c7e\u8def\u8857\u9053", "BS":"\u5b9d\u5c71\u8def\u8857\u9053", "TM":"\u5929\u76ee\u897f\u8857\u9053"}, "\u5f90\u6c47":{"LU":"\u51CC\u7389\u8857\u9053", "TB":"\u5929\u5e73\u8857\u9053", "XV":"\u5f90\u5bb6\u6c47\u8857\u9053",  "KA":"\u5eb7\u5065\u65b0\u6751\u8857\u9053",  "FL":"\u67ab\u6797\u8857\u9053"}, "\u5b9d\u5c71":{"MH":"\u5e99\u884c\u9547","YG":"\u53CB\u8C0A\u8857\u9053"}, "\u95f5\u884c":{"HQ":"\u8679\u6865\u9547","XZ":"\u8398\u5E84\u9547"}, "\u9ec4\u6d66":{"DX":"\u5C0F\u4E1C\u95E8\u8857\u9053"}, "\u5362\u6E7E":{"HH":"\u6DEE\u6D77\u4E2D\u8DEF\u8857\u9053"}};
	var street_selector = {"\u6d66\u4e1c":{"WF":"\u6f4d\u574a\u8857\u9053", "ZC":"\u5468\u5bb6\u6e21\u8857\u9053", "TQ":"\u5858\u6865\u8857\u9053", "BC":"\u5317\u8521\u9547","MY":"\u9646\u5BB6\u5634\u8857\u9053"}, "\u95f8\u5317":{"LF":"\u4e34\u6c7e\u8def\u8857\u9053", "BS":"\u5b9d\u5c71\u8def\u8857\u9053", "TM":"\u5929\u76ee\u897f\u8857\u9053"}, "\u5f90\u6c47":{"LU":"\u51CC\u7389\u8857\u9053","XV":"\u5F90\u5BB6\u6C47\u8857\u9053","KA":"\u5EB7\u5065\u65B0\u6751\u8857\u9053"}, "\u5b9d\u5c71":{"MH":"\u5e99\u884c\u9547"}, "\u95f5\u884c":{"HQ":"\u8679\u6865\u9547","XZ":"\u8398\u5E84\u9547"}, "\u9ec4\u6d66":{"DX":"\u5C0F\u4E1C\u95E8\u8857\u9053"}, "\u5362\u6E7E":{"HH":"\u6DEE\u6D77\u4E2D\u8DEF\u8857\u9053"}};
	var changeTabClass = function () {
		$("#TabPage").find("li").each(function () {
			$(this).click(function () {
				$("#TabPage").find("li").each(function () {
					$(this).attr("class", "");
				});
				$(this).attr("class", "Selected");
			});
		});
	};
	return {index:function (typeId) {
		Index.reloadQuery();
		Index.block();
		$.getJSON("register_checkSession.html", {"randomNum":Math.random()}, function (result) {
			if (result.success == "true") {
				$.get("recordForm_main.html", {"randomNum":Math.random(), "typeId":typeId}, function (_result) {
					$("#" + div_name_front_itemList_main).html(_result);
					changeTabClass();
					ItemConsultation.loadForm(typeId);
				});
			} else {
				alert("\u60a8\u5c1a\u672a\u767b\u5f55,\u8bf7\u5148\u767b\u5f55!");
			}
			Index.unblock();
		});
	}, loadHelp:function () {
		Index.block();
		$.get("itemList_help.htm", {}, function (_result) {
			$("#" + div_recordFormTab_id).html(_result);
		});
		Index.unblock();
	}, loadGuide:function (typeId) {
		Index.block();
		$.get("recordForm_loadGuide.html", {"randomNum":Math.random(), "typeId":typeId}, function (_result) {
			$("#" + div_recordFormTab_id).html(_result);
		});
		Index.unblock();
	}, loadForm:function (typeId) {
		Index.block();
		$.get("recordForm_loadForm.html", {"randomNum":Math.random(), "typeId":typeId}, function (_result) {
			$("#" + div_recordFormTab_id).html(_result);
			Validator.prepare("record_sumbit_form");
		});
		Index.unblock();
	}, attachmentForm:function (typeId) {
		var win = window.open("attachmentUpload.jsp?typeId=" + typeId, "attachmentUpload", "scrollbars=no,width=400,height=140,status=no");
	}, submit:function () {
		if (Validator.validate("record_sumbit_form")) {
			//var win = window.open("_blank", "sernum_win", "scrollbars=no,width=350,height=350,status=no");
			var bespeakDateStr = $("#bespeakDate").fieldValue();
			if (bespeakDateStr) {
				var bespeakDateStr = bespeakDateStr.substr(0, 10);
				var current = new Date();
				var beginDate = new Date(current.setDate(current.getDate() + 2));
				var endDate = new Date(current.setDate(current.getDate() + 5));
				var beginDateStr = beginDate.getFullYear() + "-" + (beginDate.getMonth() + 1) + "-" + beginDate.getDate() < 10 ? ("0" + beginDate.getDate()) : beginDate.getDate();
				var endDateStr = endDate.getFullYear() + "-" + (endDate.getMonth() + 1) + "-" + endDate.getDate() < 10 ? ("0" + endDate.getDate()) : endDate.getDate();
				if (bespeakDateStr < beginDateStr || bespeakDateStr > endDateStr) {
					alert("\u65e5\u671f\u8303\u56f4\u4e0d\u6b63\u786e,\u6b63\u786e\u8303\u56f4:'" + beginDateStr + "'-'" + endDateStr + "'!");
					return;
				}
			}
			$("#record_sumbit_form").submit();
			Index.reloadMain();
		}
	}, reset:function () {
	}, initCountySelector:function (selectorId) {
		var county = $("#" + selectorId);
		var options = "<option></option>";
		for (var key in street_selector) {
			options += "<option value='" + key + "'>";
			options += key + "</option>";
		}
		county.html(options);
	}, initStreetSelector:function (parentId, selectorId) {
		var county = $("#" + parentId);
		if (county.fieldValue() == "undefined" || county.fieldValue() == "") {
			return;
		}
		var streetOption = street_selector[county.fieldValue()];
		if (streetOption == "undefined") {
			return;
		}
		var options = "<option></option>";
		for (var key in streetOption) {
			options += "<option value='" + key + "'>";
			options += streetOption[key] + "</option>";
		}
		$("#" + selectorId).html(options);
	}, setSelectedOption:function (selectorId) {
		var selector = $("#" + selectorId).get(0);
		$("#" + selectorId + "_display").attr("value", (selector.options[selector.selectedIndex].text));
	}};
}();
Register = function () {
	var field_register_loginName_id = "register_loginName";
	var field_register_password_id = "register_password";
	var field_register_imageCode_id = "register_imageCode";
	var div_register_imageCode_img_id = "register_imageCode_img";
	return {checkSession:function () {
		Index.block();
		$.getJSON("register_checkSession.html", {"randomNum":Math.random()}, function (result) {
			if (result.success == "true") {
				Index.reloadTitle();
			} else {
				alert("\u60a8\u5c1a\u672a\u767b\u5f55,\u8bf7\u5148\u767b\u5f55!");
			}
		});
		Index.unblock();
	}, login:function () {
		var register_loginName = $("#" + field_register_loginName_id).fieldValue();
		var register_password = $("#" + field_register_password_id).fieldValue();
		var register_imageCode = $("#" + field_register_imageCode_id).fieldValue();
		var user_type = $("#user_type").fieldValue();
		if (register_loginName == "undefined" || register_loginName == "") {
			alert("\u8bf7\u586b\u5199\u767b\u5f55\u540d!");
			return;
		}
		if (register_password == "undefined" || register_password == "") {
			alert("\u8bf7\u586b\u5199\u767b\u5f55\u5bc6\u7801!");
			return;
		}
		if (register_imageCode == "undefined" || register_imageCode == "") {
			alert("\u8bf7\u586b\u5199\u9a8c\u8bc1\u7801!");
			return;
		}
		if (1 == user_type) {
			Index.block();
			$.getJSON("register_login.html", {"loginName":register_loginName, "password":register_password, "imageCode":register_imageCode, "randomNum":Math.random()}, function (result) {
				if (result.success == "true") {
					//alert("u767bu5f55u6210u529f");
					//Index.reloadTitle();
					//CookieManager.createCookie("pippo.govOnline.last.login.time", (new Date()).toLocaleString(), 9999);
				} else {
					alert("\u767b\u5f55\u5931\u8d25!");
				}
				Index.reloadLoginForm();
			});
			Index.unblock();
		} else {
			if (2 == user_type) {
				window.self.location = "http://124.74.193.52/mjzz/weblogin.do?netflag=internet&loginType=loginOrg&userName=" + register_loginName + "&password=" + register_password + "&fromorgan=mz";
			}
		}
	}, loadRegistForm:function () {
		Index.reloadQuery();
		Index.block();
		$.get("registForm.htm", {}, function (_result) {
			$("#front_itemList_main").html(_result);
			Index.unblock();
			Validator.prepare("registForm");
		});
	}, checkLoginNameCanUse:function () {
		var loginName = $("#regist_new_loginName").fieldValue();
		if ("" == loginName) {
			alert("\u8bf7\u8f93\u5165\u767b\u5f55\u540d");
			return;
		}
		Index.block();
		$.post("register_checkLoginNameCanUse.html", {"loginName":loginName}, function (result) {
			if ("true" == JSONstring.toObject(result).success) {
				alert("\u767b\u5f55\u540d[" + loginName + "]\u53ef\u4ee5\u4f7f\u7528!");
			} else {
				alert("\u767b\u5f55\u540d[" + loginName + "]\u5df2\u88ab\u4f7f\u7528!");
			}
			Index.unblock();
		});
	}, registNew:function () {
		var loginName = $("#regist_new_loginName").fieldValue();
		var password = $("#regist_new_password").fieldValue();
		var repeat = $("#regist_repeat_password").fieldValue();
		if (password != repeat) {
			alert("\u4e24\u6b21\u8f93\u5165\u7684\u5bc6\u7801\u4e0d\u5339\u914d!");
			return;
		}
		if (!Validator.validate("registForm")) {
			return;
		}
		if (password != password) {
			alert("\u4e24\u6b21\u8f93\u5165\u7684\u5bc6\u7801\u4e0d\u5339\u914d!");
			return;
		}
		Index.block();
		$.post("register_regist.html", {"loginName":loginName, "password":password, "rank":$("#regist_rank").fieldValue(), "realName":$("#regist_realName").fieldValue(), "uuidType":$("#regist_uuid_type").fieldValue(), "uuid":$("#regist_uuid").fieldValue(), "address":$("#regist_address").fieldValue(), "zipcode":$("#regist_zipcode").fieldValue(), "telnum":$("#regist_telnum").fieldValue(), "mobilenum":$("#regist_mobilenum").fieldValue(), "fax":$("#regist_fax").fieldValue(), "email":$("#regist_email").fieldValue()}, function (result) {
			if ("true" == JSONstring.toObject(result).success) {
				alert("\u6ce8\u518c\u6210\u529f");
				Index.reloadMain();
			} else {
				alert("\u6ce8\u518c\u5931\u8d25,\u7528\u6237\u5df2\u5b58\u5728!");
			}
			Index.unblock();
		});
	}, resetRegistForm:function () {
		Validator.reset("registForm");
	}};
}();

