//--#start--Class CtrlUtil---------------------------------------------------
function Coordinate(nX, nY)
{
	this.x = nX;
	this.y = nY;
}

function CtrlUtil_GetAbsPosition(element, container)
{
	var nOffsetTop = element.offsetTop;
	var nOffsetLeft = element.offsetLeft;
	element = element.offsetParent;
	while (element != container && element != null) {
		nOffsetLeft += element.offsetLeft;
		nOffsetTop += element.offsetTop;
		element = element.offsetParent;
	}
	var coord = new Coordinate(nOffsetLeft, nOffsetTop);
	return coord;
}

function CtrlUtil_GetCheckedIndexArray(coll, validOnDisabled) {
	if (validOnDisabled == null) {
		validOnDisabled = true;
	}

	var arrChecked = new Array();
	var nLength = CtrlUtil_GetLength(coll);
	switch (nLength) {
		case 0:
			break;
		case 1:
			if (coll.checked && (!coll.disabled || validOnDisabled)) {
				arrChecked[0] = 0;
			}
			break;
		default:
		for (var i = 0, j = 0; i < nLength; i++) {
			if (coll.item(i).checked &&
				(!coll.item(i).disabled || validOnDisabled)) {
				arrChecked[j++] = i;
			}
		}
	}
	return arrChecked;
}

function CtrlUtil_GetAttributeMatchedIndexArray(coll, attrName, attrValue, validOnDisabled) {
	if (validOnDisabled == null) {
		validOnDisabled = true;
	}

	var arrChecked = new Array();
	var nLength = CtrlUtil_GetLength(coll);
	switch (nLength) {
		case 0:
			break;
		case 1:
			var value = coll.getAttribute(attrName);
			if (value == attrValue && (!coll.disabled || validOnDisabled)) {
				arrChecked[0] = 0;
			}
			break;
		default:
		for (var i = 0, j = 0; i < nLength; i++) {
			var value = coll.item(i).getAttribute(attrName);
			if (value == attrValue &&
				(!coll.item(i).disabled || validOnDisabled)) {
				arrChecked[j++] = i;
			}
		}
	}
	return arrChecked;
}

function CtrlUtil_SetCheckage(coll, bCheckage) {
	var nLength = CtrlUtil_GetLength(coll);
	switch (nLength) {
		case 0:
			break;
		case 1:
			coll.checked = bCheckage;
			break;
		default:
		for (var i = 0, j = 0; i < nLength; i++) {
			coll.item(i).checked  = bCheckage;
		}
	}
}

function CtrlUtil_SetAttribute(coll, attrName, attrValue, bInherit) {
	bInherit = (bInherit == true);
	var nLength = CtrlUtil_GetLength(coll);
	switch (nLength) {
		case 0:
			break;
		default:
			try {
				coll.setAttribute(attrName, attrValue);
				if (bInherit) {
					CtrlUtil_SetAttribute(coll.children, attrName, attrValue, bInherit);
				}
			}
			catch (ex) {
				for (var i = 0, j = 0; i < nLength; i++) {
					coll.item(i).setAttribute(attrName, attrValue);
					if (bInherit) {
						CtrlUtil_SetAttribute(coll.item(i).children, attrName, attrValue, bInherit);
					}
				}
			}
			break;
	}
}

function CtrlUtil_GetCheckedLength(coll, validOnDisabled) {
	var arr = CtrlUtil_GetCheckedIndexArray(coll, validOnDisabled);
	return arr.length;
}

function CtrlUtil_GetAttributeMatchedLength(coll, attrName, attrValue, validOnDisabled) {
	var arr = CtrlUtil_GetAttributeMatchedIndexArray(coll, attrName, attrValue, validOnDisabled);
	return arr.length;
}

function CtrlUtil_GetLength(coll)
{
	var nLength = 0;
	if (coll != null) {
		if (coll.length != null) {
			nLength = coll.length;
		}
		else {
			nLength = 1;
		}
	}
	return nLength;
}

function CtrlUtil_IndexOf(coll, element)
{
	var nIndex = -1;
	if (coll == element) {
		nIndex = 0;
	}
	else {
		for (var i = 0; i < coll.length; i++) {
			if (coll.item(i) == element) {
				nIndex = i;
				break;
			}
		}
	}
	return nIndex;
}

function CtrlUtil_IsCover(element_1, element_2) {
	var bIsCover = false;
	while (element_2 != null) {
		if (element_1 == element_2) {
			bIsCover = true;
		}
		element_2 = element_2.parentNode;
	}
	return bIsCover;
}

function CtrlUtil_IsMouseOn(element) {
	var coordElement = CtrlUtil_GetAbsPosition(element);
	var coordMouse = new Coordinate(
		event.x + document.body.scrollLeft, event.y + document.body.scrollTop);
	if (coordMouse.x >= coordElement.x
		&& coordMouse.x < coordElement.x + element.offsetWidth
		&& coordMouse.y >= coordElement.y
		&& coordMouse.y < coordElement.y + element.offsetHeight) {
		return true;
	}
	return false;
}

function CtrlUtil_SetReady(element) {
	element.focus();
	element.scrollIntoView();
}

function CtrlUtil_GetCheckedIndex(coll) {
	var arrCheckedAttrs = new Array();
	for (var i = 0; i < coll.length; i++) {
		if (coll.item(i).checked) {
			return i;
		}
	}
	return -1;
}

function CtrlUtil_Display(element, position, source) {
	if (source == null) {
		try {
			source = event.srcElement;
		}
		catch (ex) {}
	}
	switch(position) {
		case "event":	// according to event Object
			element.style.left = document.body.scrollLeft + event.x;
			element.style.top = document.body.scrollTop + event.y;
			break;
		case "ILTE":	// Inner-Left-Top of event.source
			var coord = CtrlUtil_GetAbsPosition(source);
			element.style.left = coord.x + source.clientLeft;
			element.style.top = coord.y + source.clientTop;
			break;
		case "IRTE":	// Inner-Right-Top of event.source;
			var coord = CtrlUtil_GetAbsPosition(source);
			element.style.right = document.body.clientWidth - coord.x - source.offsetWidth;
			element.style.top = coord.y + source.clientTop;
			break;
		case "center":
		default:
			element.style.left = document.body.scrollLeft
				+ (document.body.offsetWidth - element.offsetWidth) / 2;
			element.style.top = document.body.scrollTop
				+ (document.body.offsetHeight - element.offsetHeight) / 2;
	}
	element.style.display = "inline";
}

function CtrlUtil_GetParent(element, parentTagName) {
	while (element != null && element.tagName != parentTagName) {
		element = element.parentNode;
	}
	return element;
}

function CtrlUtil_SwitchDisplay(element) {
	element.style.display = (element.style.display == "none") ? "inline" : "none";
}

function CtrlUtil_GetArray(element) {
	var nLength = CtrlUtil_GetLength(element);
	var arr = new Array();
	if (nLength == 1) {
		arr.push(element);
	}
	else {
		for (var i = 0; i < nLength; i++) {
			arr.push(element.item(i));
		}
	}
	return arr;
}

function CtrlUtil() {
}

CtrlUtil.display                        = CtrlUtil_Display;
CtrlUtil.getAbsPosition                 = CtrlUtil_GetAbsPosition;
CtrlUtil.getArray                       = CtrlUtil_GetArray;
CtrlUtil.getAttributeMatchedIndexArray  = CtrlUtil_GetAttributeMatchedIndexArray;
CtrlUtil.getAttributeMatchedLength      = CtrlUtil_GetAttributeMatchedLength;
CtrlUtil.getCheckedIndex                = CtrlUtil_GetCheckedIndex;
CtrlUtil.getCheckedIndexArray           = CtrlUtil_GetCheckedIndexArray;
CtrlUtil.getCheckedLength               = CtrlUtil_GetCheckedLength;
CtrlUtil.getLength                      = CtrlUtil_GetLength;
CtrlUtil.getParent                      = CtrlUtil_GetParent;
CtrlUtil.indexOf                        = CtrlUtil_IndexOf;
CtrlUtil.isCover                        = CtrlUtil_IsCover;
CtrlUtil.isMouseOn                      = CtrlUtil_IsMouseOn;
CtrlUtil.setAttribute                   = CtrlUtil_SetAttribute;
CtrlUtil.setCheckage                    = CtrlUtil_SetCheckage;
CtrlUtil.setReady                       = CtrlUtil_SetReady;
CtrlUtil.switchDisplay                  = CtrlUtil_SwitchDisplay;

CtrlUtil.newHidden = function(name, value) {
	var oInputHidden = document.createElement("INPUT");
	oInputHidden.type = "hidden";
	oInputHidden.name = name;
	oInputHidden.value = value;
	return oInputHidden;
}

CtrlUtil.setDate = function(element) {
	CtrlUtil.setDatetime(element, "Y-m-d");
}

CtrlUtil.setDatetime = function(element, format) {
	var type = 2;

	var aHeights = new Array();
	aHeights[1] = 290;
	aHeights[2] = 316;

	var url = "/include/calendar.php?type=" + type;
	var prop = ""
		+ "status:no;"
		+ "center:yes;"
		+ "help:no;"
		+ "minimize:no;"
		+ "maximize:no;"
		+ "border:thin;"
		+ "statusbar:no;"
		+ "dialogWidth:218px;"
		+ "dialogHeight:" + aHeights[type] + "px";
	var d = window.showModalDialog(url, null, prop);
	if (d != null && d != "") {
		if (format == null) {
			element.value = d;
		}
		else {
			var date = new Date(d);
			var str = format;
			var Y = date.getYear();
			var m = date.getMonth() + 1;
			var d = date.getDate();
			var H = date.getHours();
			var i = date.getMinutes();
			var s = date.getSeconds();
			str = str.replace("Y", Y);
			str = str.replace("m", m >= 10 ? m : "0" +  m);
			str = str.replace("d", d >= 10 ? d : "0" +  d);
			str = str.replace("H", H >= 10 ? H : "0" +  H);
			str = str.replace("i", i >= 10 ? i : "0" +  i);
			str = str.replace("s", s >= 10 ? s : "0" +  s);
			element.value = str;
		}
	}
}
//--#end--Class CtrlUtil-------------------------------------------------------

//--#start--Object object------------------------------------------------------
//--#end--Object object--------------------------------------------------------

//--#start--window object------------------------------------------------------
window.popUp = function (URL, height, width, winName) {
	var sFeatures = "menubar=no, toolbar=no, resizable=yes, scrollbars=yes";

	var nHeight = parseInt(height);
	var nWidth = parseInt(width);
	if (!isNaN(nHeight)) {
		sFeatures += ", height=" + nHeight;
	}
	if (!isNaN(nWidth)) {
		sFeatures += ", width=" + nWidth;
	}

	var vName = winName;
	if (vName == null) {
		vName = "_blank";
	}

	window.open(URL, vName, sFeatures);
}

window.startScroll = function(x, y, milliSeconds) {
	if (x == null) {
		x = 1;
	}
	if (y == null) {
		y = 1;
	}
	if (milliSeconds == null) {
		milliSeconds = 50;
	}
	window.scrollID = window.setInterval("window.scrollBy(" + x + ", " + y + ")", milliSeconds);
}

window.endScroll = function() {
	if (window.scrollID != null) {
		window.clearInterval(window.scrollID);
		window.scrollID = null;
	}
}

window.switchScroll = function(x, y, milliSeconds) {
	if (window.scrollID != null) {
		window.endScroll();
	}
	else {
		window.startScroll(x, y, milliSeconds);
	}
}

window.onload = function() {
	if (typeof Init == "function") {
		Init();
	}
}

window.dialog = function(url, title, x, y, property) {
	// @todo
	var s = "/include/modal_dialog.php?title=" + title
		+ "&url=" + url.replace(/&/g, "%26");
	var sProperty = "center:yes; resizable:yes; scroll:no; status:no;"
		+ "dialogHeight:" + x + "px;"
		+ "dialogWidth:" + y + "px;";
	if ( property != null ) {
		sProperty = property + sProperty;
	}
	return window.showModalDialog(s, null, sProperty);
}
//--#end--window object--------------------------------------------------------

//--#start--document-----------------------------------------------------------
document.onselectstart = function() {
	return;
	switch(event.srcElement.tagName) {
		case "INPUT":
		case "TEXTAREA":
			return true;
	}
	return;
}
//--#end--document object------------------------------------------------------

//--#start--string-------------------------------------------------------------
var DATA_NAME=new Array();
DATA_NAME["letters"]="英文字母";
DATA_NAME["int"]="整数";
DATA_NAME["float"]="数字";
DATA_NAME["phone"]="电话";
DATA_NAME["phs"]="小灵通";
DATA_NAME["mobile"]="手机";
DATA_NAME["email"]="电子邮件";
DATA_NAME["postcode"]="邮政编码";
DATA_NAME["idcardno"]="身份证号码";
DATA_NAME["date"]="日期";
DATA_NAME["year"]="年份";

var REG=new Array();
REG["letters"]  = new RegExp("^[a-zA-Z]{0,}$", "g");
REG["int"]      = new RegExp("^[0-9]{0,}$", "g");
REG["float"]    = new RegExp("^[0-9]{0,}.?[0-9]{0,}$", "g");

REG["mobile"]   = new RegExp("^(13|15|18)[0-9]{9}$", "g");
REG["phs"]      = new RegExp("^[235689]{1}[0-9]{6,11}$", "g");
REG["phone"]    = new RegExp("^[23568]{1}[0-9]{6,7}$", "g");
// REG["phone"]    = new RegExp("^(([0-9]{1,}-)?[0-9]{1,}-)?[0-9]{1,}(#[0-9]{1,})?$", "g");

REG["email"]    = new RegExp("^([^(@|\.)]{1,})@([^(@|\.)]{1,})(\.[^(@|\.)]{1,}){0,}$", "g");
REG["postcode"] = new RegExp("^[0-9]{6}$", "g");
REG["idcardno"] = new RegExp("^([0-9]{15}|[0-9]{17}[a-z,A-Z,0-9]{1})$", "g");
REG["date"]     = new RegExp("^[0-9]{4}-((0?[13578]{1}|10|12)-(0?[1-9]{1}|[1-2]{1}[0-9]{1}|30|31)|(0?[469]{1}|11)-(0?[1-9]{1}|[1-2]{1}[0-9]{1}|30)|0?2-(0?[1-9]{1}|[1-2]{1}[0-9]{1}))$", "g");
/*
[0-9]{4}-
(
	(0?[13578]{1}|10|12)-(0?[1-9]{1}|[1-2]{1}[0-9]{1}|30|31)
	|
	(0?[469]{1}|11)-(0?[1-9]{1}|[1-2]{1}[0-9]{1}|30)
	|
	0?2-(0?[1-9]{1}|[1-2]{1}[0-9]{1})
)
*/

REG["year"]     = new RegExp("^(19|20)?[0-9]{2}$");

function String_IsSpace(){
	var reg = new RegExp("^ {0,}$", "g");
	return this.match(reg);
}

function String_ToBoolean() {
	var str = this.toLowerCase();
	return str == "true" || str == "t" || str == "1" || str == "yes" || str == "y";
}

// 检验字符串是否符合给定的数据类型
function String_Is(type)
{
	return this.match(REG[type.toLowerCase()]);
}

String.prototype.is = String_Is;
String.prototype.isSpace = String_IsSpace;
String.prototype.toBoolean = String_ToBoolean;

function IsTrue(arg) {
	switch (typeof arg)
	{
		case "undefinded":
			return false;
		case "string":
			return arg.toBoolean();
		case "number":
			return arg != 0;
		default:
			return false;
	}
}

function ObjectUtil() {
}

ObjectUtil.isTrue = IsTrue;
//--#end--string---------------------------------------------------------------

//--#start--FormUtil-----------------------------------------------------------
function FormUtil_Check(srcElement, bPrompt) {

	var value = srcElement.value;
	var type = srcElement.getAttribute("dataType");
	if (type == null) {
		return true;
	}
	else {
		type = type.toLowerCase();
	}
	if (value == srcElement.defaultValue) {
		return true;
	}
	if (value.isSpace()) {
		return true;
	}

	if(!value.is(type)){
		var sPrompt = "";
		if (srcElement.showName != null) {
			sPrompt = srcElement.showName;
		}
		sPrompt += "输入不正确。\n请正确填写" + DATA_NAME[type] + "。";
		alert(sPrompt);
		srcElement.select();
		return false;
	}

	switch(type)
	{
		case "year":
			var n = parseInt(value);
			if ( n < 100 ) {
				var s = ( n < 10 ) ? "20" : "19";
				srcElement.value = s.concat(value);
			}
			break;
		case "int":
		case "float":
			if (srcElement.max != null && value > parseFloat(srcElement.max)) {
				var sPrompt = "输入数字勿大于" + srcElement.max;
				alert(sPrompt);
				srcElement.select();
				return false;
			}
			if (srcElement.min != null && value < parseFloat(srcElement.min)) {
				var sPrompt = "输入数字勿小于" + srcElement.min;
				alert(sPrompt);
				srcElement.select();
				return false;
			}
			break;
		case "email":
			if(!value.match(REG["email"])) {
				var sPrompt = "邮件地址格式不符合规范";
				alert(sPrompt);
				srcElement.select();
				return false;
			}
			break;
	}

	return true;
}

function FormUtil_Inspect(oForm, bPrompt)
{
	if (bPrompt == null) {
		bPrompt = true;
	}

	var collText = oForm.getElementsByTagName("INPUT");
	var nLength = collText.length;
	for (var i = 0; i < nLength; i++) {

		// 跳过禁用的控件
		if (collText(i).disabled)
			continue;

		var bNoBlank = ObjectUtil.isTrue(collText(i).getAttribute("noblank"));
		var bNoZero = ObjectUtil.isTrue(collText(i).getAttribute("nozero"));
		var sShowName = collText(i).getAttribute("showName");

		switch(collText(i).type) {
			case "text":
			case "password":
				// 判断非空
				if (bNoBlank && collText(i).value.isSpace()) {
					if (bPrompt) {
						if (sShowName == null) {
							alert("请将信息填写完整。");
						}
						else {
							alert("请填写“" + sShowName + "”");
						}
						CtrlUtil.setReady(collText(i));
					}
					return false;
				}

				// 判断非零
				if (bNoZero && (collText(i).value.isSpace() || collText(i).value == "0")) {
					if (bPrompt) {
						if (sShowName == null) {
							alert("请将信息填写完整。");
						}
						else {
							alert("请填写“" + sShowName + "”");
						}
						CtrlUtil.setReady(collText(i));
					}
					return false;
				}

				// 判断是否符合类型
				if (!FormUtil.check(collText(i), false)) {
					return false;
				}

				// 判断长度
				var nMaxLength = parseInt(collText(i).getAttribute("maxlength"));
				if (!isNaN(nMaxLength) && nMaxLength < collText(i).value.length) {
					if (collText(i).showName != null)
						alert("“" + collText(i).showName + "”的长度不能超过" + nMaxLength + "!");
					return false;
				}

				break;
			case "radio":
				// 判断非空(已选择)
				if (bNoBlank) {
					if (CtrlUtil.getCheckedIndex(oForm.all(collText(i).name)) < 0) {
						if (bPrompt) {
							if (sShowName == null) {
								alert("请将信息填写完整。");
							}
							else {
								alert("请选择“" + sShowName + "”");
							}
							CtrlUtil.setReady(collText(i));
						}
						return false;
					}
				}
				break;
		}
	}

//	var collTextArea = oForm.tags("TEXTAREA");
	var collTextArea = oForm.getElementsByTagName("TEXTAREA");
	nLength = collTextArea.length;
	for (var i = 0; i < nLength; i++)
	{
		// 跳过禁用的控件
		if (collTextArea(i).disabled)
			continue;

		var bNoBlank = ObjectUtil.isTrue(collTextArea(i).getAttribute("noblank"));
		var bNoZero = ObjectUtil.isTrue(collTextArea(i).getAttribute("nozero"));
		var sShowName = collTextArea(i).getAttribute("showName");

		// 判断非空
		if (bNoBlank && collTextArea(i).value.isSpace()) {
			if (bPrompt) {
				if (sShowName == null) {
					alert("请将信息填写完整。");
				}
				else {
					alert("请填写“" + sShowName + "”");
				}
				CtrlUtil.setReady(collTextArea(i));
			}
			return false;
		}

		// 判断长度
		var nMaxLength = parseInt(collTextArea(i).getAttribute("maxlength"));
		if (!isNaN(nMaxLength) && nMaxLength < collTextArea(i).value.length) {
			if (collTextArea(i).showName != null)
				alert("“" + collTextArea(i).showName + "”的长度不能超过" + nMaxLength + "!");
			return false;
		}
	}

//	var collSelect = oForm.tags("SELECT")
	var collSelect = oForm.getElementsByTagName("SELECT");
	nLength = collSelect.length;
	for (var i = 0; i < nLength; i++)
	{
		// 跳过禁用的控件
		if (collSelect(i).disabled)
			continue;

		var bNoBlank = ObjectUtil.isTrue(collSelect(i).getAttribute("noblank"));
		var bNoZero = ObjectUtil.isTrue(collSelect(i).getAttribute("nozero"));
		var sShowName = collSelect(i).getAttribute("showName");

		if (bNoZero)
		{
			if (!(collSelect(i).selectedIndex > 0))
			{
				if (bPrompt) {
					if (sShowName != null) {
						alert("请选择“" + sShowName + "”!");
					}
					else {
						alert("请将信息填写完整!");
					}
					collSelect(i).focus();
				}
				return false;
			}
		}
	}
	return true;
}

function FormUtil_Clear(oForm)
{
//	var collText = oForm.tags("INPUT");
	var collText = oForm.getElementsByTagName("INPUT");
	var nLength = collText.length;
	for (var i = 0; i < nLength; i++) {

		// 跳过禁用的控件
		if (collText(i).disabled)
			continue;

		switch(collText(i).type) {
			case "text":
			case "password":
				collText(i).value = "";
				break;
			case "radio":
				collText(i).checked = false;
				break;
		}
	}

//	var collTextArea = oForm.tags("TEXTAREA");
	var collTextArea = oForm.getElementsByTagName("TEXTAREA");
	nLength = collTextArea.length;
	for (var i = 0; i < nLength; i++)
	{
		// 跳过禁用的控件
		if (collTextArea(i).disabled)
			continue;

		collTextArea(i).value = "";
	}

	var collSelect = oForm.tags("SELECT")
	var collSelect = oForm.getElementsByTagName("SELECT")
	nLength = collSelect.length;
	for (var i = 0; i < nLength; i++)
	{
		// 跳过禁用的控件
		if (collSelect(i).disabled)
			continue;
		collSelect(i).selectedIndex = 0;
	}
	return true;
}

function FormUtil() {
}
FormUtil.check = FormUtil_Check;
FormUtil.clear = FormUtil_Clear;
FormUtil.inspect = FormUtil_Inspect;

//--#end--FormUtil------------------------------------------------------------

//--#start--FileUtil----------------------------------------------------------
function LoadImage_New(targetImg, imageSrc, restrainedWidth, restrainedHeight) {
	var oImage = new Image();
	oImage.onload = function() {
		if (this.width / this.height > restrainedWidth / restrainedHeight ) {
			if (restrainedWidth >= 0) {
				targetImg.style.width = restrainedWidth + "px";
				targetImg.style.height = this.height * (restrainedWidth / this.width) + "px";
			}
		}
		else if ( restrainedHeight >= 0) {
			targetImg.style.height = restrainedHeight + "px";
			targetImg.style.width = this.width * (restrainedHeight / this.height) + "px";
		}
		targetImg.src = this.src;
	}
	oImage.src = imageSrc;
}


function LoadImage(targetImg, imageSrc, restrainedWidth, restrainedHeight) {
	var defaultPosition = targetImg.style.position;

	targetImg.style.visibility = "hidden";
	targetImg.style.display = "inline";
	targetImg.style.position = "absolute";

	targetImg.onload = function() {
		var nWidth = this.offsetWidth;
		var nHeight = this.offsetHeight;
		try
		{
			if (nWidth / nHeight > restrainedWidth / restrainedHeight ) {
				if (restrainedWidth >= 0) {
					this.style.width = restrainedWidth + "px";
					this.style.height = nHeight * (restrainedWidth / nWidth) + "px";
				}
			}
			else if ( restrainedHeight >= 0) {
				this.style.height = restrainedHeight + "px";
				this.style.width = nWidth * (restrainedHeight / nHeight) + "px";
			}
		}
		catch (ex) {
			this.style.width = restrainedWidth + "px";
			this.style.hegith = restrainedHeight + "px";
		}
		if (defaultPosition != null) {
			this.style.position = defaultPosition;
		}
		this.style.visibility = "visible";
		this.onload = null;
	}
	targetImg.src = imageSrc;
}

function FileUtil_GetFileName(path) {
	var name = path;
	name = name.substr(name.lastIndexOf("/") + 1);
	name = name.substr(name.lastIndexOf("\\") + 1);
	return name;
}

function FileUtil() {
}
FileUtil.getFileName = FileUtil_GetFileName;
//--#end--FileUtil------------------------------------------------------------


//--#start--PubUtil-----------------------------------------------------------
function PubUtil_SendMessage(login_id) {
	window.open(
		"http://onlinemsg.focus.cn/onlinemsg/sendmessage_f.php?senduser_id=" + login_id,
		"_blank",
		"resizable=1, scrollbars=1, status=no, toolbar=no, location=no, menu=no, width=380, height=300"
	);
}

function PubUtil_SendSMS(login_id, group_id) {
	window.open(
		"http://admin.house.focus.cn/sms/sendsms.php?senduser_id=" + login_id + "&group_id=" + group_id,
		"_blank",
		"resizable=1, scrollbars=1, status=no, toolbar=no, location=no, menu=no, width=380, height=320"
	);
}

function PubUtil() {
}
PubUtil.sendMessage    = PubUtil_SendMessage;
PubUtil.sendSMS        = PubUtil_SendSMS;
//--#end--PubUtil-------------------------------------------------------------

//--#start--兼容Netscape----------------------------------------------------
if ( navigator.appName == "Netscape" ) {
	HTMLElement.prototype.__defineGetter__(
		"runtimeStyle",
		Netscape_HTMLElement_Get_RuntimeStyle
		);

	window.constructor.prototype.__defineGetter__(
		"event",
		Netscape_window_Get_Event
		);

	Event.prototype.__defineGetter__(
		"srcElement",
		Netscape_Event_Get_srcElement
		);
}

function Netscape_HTMLElement_Get_RuntimeStyle() {
	return this.style;
}

// Netscape内核的浏览器在函数的第一个参数中存放事件句柄
function Netscape_window_Get_Event() {
	var f = Netscape_window_Get_Event.caller;
	while (f) {
		if (f.arguments[0] && f.arguments[0].constructor == Event) {
			return f.arguments[0];
		}
		f = f.caller;
	}
	return null;
}

// Netscape中的事件没有srcElement等属性。与srcElement相应的是target属性
function Netscape_Event_Get_srcElement() {
	return this.target;
}
//--#end--兼容Netscape------------------------------------------------------

function InitNamespace(namespace) {
	var aNames = namespace.split(".");
	var sScript = "if (typeof " + aNames[0] + " == 'undefined') { var " + aNames[0] + " = new function(){}; }";
	namespace = aNames[0];
	for (var i = 1; i < aNames.length; i++ ) {
		namespace += "." + aNames[i];
		sScript += "if (typeof " + namespace + " == 'undefined') { " + namespace + " = new function(){}; }";
	}
	return sScript;
}

function parseCookie() {
	var cookies = new Array();
	var cookie = document.cookie;
	var i = 0;
	while (i >= 0 && i < cookie.length) {
		j = cookie.indexOf("=", i);
		var name = cookie.substring(i, j);
		i = cookie.indexOf(";", j);
		j++;
		if (i > 0) {
			var value = cookie.substring(j, i);
			i += 2;
		}
		else {
			var value = cookie.substr(j);
		}
		cookies[name] = value;
	}
	return cookies;
}


function Cookie(document,name,hours,path,domain,secure){this.$document=document;this.$name=name;this.$expiration=hours?new Date((new Date()).getTime()+hours*3600000):null;this.$path=path?path:null;this.$domain=domain?domain:null;this.$secure=secure;};Cookie.prototype.store=function (){var cookieval="";for(var prop in this){if((prop.charAt(0)=='$')||((typeof this[prop])=='function')) continue;if(cookieval!="") cookieval+='&';cookieval+=prop+':'+escape(this[prop]);}var cookie=this.$name+'='+cookieval;if(this.$expiration)cookie+='; expires='+this.$expiration.toGMTString();if(this.$path) cookie+='; path='+this.$path;if(this.$domain) cookie+='; domain='+this.$domain;if(this.$secure) cookie+='; secure';this.$document.cookie=cookie;};Cookie.prototype.load=function(){var allcookies=this.$document.cookie;if(allcookies=="") return false;var start=allcookies.indexOf(this.$name+'=');if(start==-1) return false;start+=this.$name.length+1;var end=allcookies.indexOf(';',start);if(end==-1) end=allcookies.length;var cookieval=allcookies.substring(start,end);var a=cookieval.split('&');for(var i=0; i<a.length; i++) a[i]=a[i].split(':');for(var i=0; i<a.length; i++) this[a[i][0]]=unescape(a[i][1]);return true;};Cookie.prototype.remove = function(){var cookie;cookie = this.$name + '=';if (this.$path) cookie += '; path=' + this.$path;if (this.$domain) cookie += '; domain=' + this.$domain;cookie += '; expires=Fri, 02-Jan-1970 00:00:00 GMT';this.$document.cookie = cookie;};
