// JavaScript Document
var fileSite = "http://ftp.zjtzg.com";// 文件系统域名


/*-------------------基本工具类----------------------*/
String.prototype.trim = function() {
	return this.replace(/(^\s*)|(\s*$)/g, "");
};
String.prototype.ltrim = function() {
	return this.replace(/(^\s*)/g, "");
};
String.prototype.rtrim = function() {
	return this.replace(/(\s*$)/g, "");
};
var dealStr = function(v) {
	v = v.replace(/(')/g, "");
	return v.trim();
};
var replacebranch = function(v) {
	return v.replace(/(;)/g, "/");
};
String.prototype.isNumber = function() {
	var patrn = /^([0-9])+(.)?([0-9])*$/;
	if (!patrn.exec(this))
		return false;
	return true;
};
String.prototype.delwave = function() {
	return this.replace(/(~|～)/g, "-");
}
var delwave = function(v) {
	v = v.replace(/(;)/g, "；");
	v = v.replace(/(~)/g, "～");
	v = v.replace(/(')/g, "‘");
	v = v.replace(/(")/g, "“");
	v = v.replace(/(<p>|<\/p>)/g, "");
	return v;
}
var delwave2 = function(v) {
	v = v.replace(/(')/g, "‘");
	return v;
}
var del_space = function(v) {
	if ((v || "") != "") {
		var temp = encodeURI(v);
		v = temp.replace(/(%C2%A0)/g, "");
		return decodeURI(v);
	} else
		return " ";

};
var trim = function(txt) {
	if (txt)
		return txt.replace(/(^\s*)|(\s*$)/g, "");
};
var replacedot = function(v) {
	if ((v || "") != "") {
		v = v.replace(/(')/g, "")
		return v.replace(/(")/g, "")
	}
}
var getE = function(id) {
	return document.getElementById(id);
};
var getN = function(ename) {
	return document.getElementsByName(ename);
};
var getV = function(id) {
	var obj = getE(id);
	if (obj)
		return obj.value;
	else
		return "";
}
var getT = function(obj, tagname) {
	return obj.getElementsByTagName(tagname);
};
var encode = function(txt) {
	return encodeURI(txt);
}
var decode = function(txt) {
	return decodeURI(txt);
}
var getArgs = function(sHref, sArgName) {
	var args = sHref.split("?");
	var retval = "";
	if (args[0] == sHref) {
		return retval;
	}
	var str = args[1];
	var spec = str.indexOf("#");
	if (spec != -1)
		str = str.substring(0, spec)
	args = str.split("&");
	var len = args.length;
	for (var i = 0; i < len; i++) {
		str = args[i];
		var arg = str.split("=");
		if (len < 1)
			continue;
		if (arg[0] == sArgName)
			retval = arg[1];
	}
	return retval;
}
function getCurArgs(argName) {
	var args = new Object();
	var query = location.search.substring(1); // Get query string
	var pairs = query.split("&"); // Break at ampersand
	for (var i = 0; i < pairs.length; i++) {
		var pos = pairs[i].indexOf('='); // Look for "name=value"
		if (pos == -1)
			continue; // If not found, skip
		var argname = pairs[i].substring(0, pos); // Extract the name
		var value = pairs[i].substring(pos + 1); // Extract the value
		value = decodeURIComponent(value); // Decode it, if needed
		args[argname] = value; // Store as a property
	}
	if ((argName || "") == "")
		return args; // Return the object,you can use it by this method:
						// "getCurArgs()["xx"]" or "getCurArgs().xx"
	else
		return args[argName]; // return the element,you can use it by this
								// method: getCurArgs("xx")
}
var setMenu = function(index) {
	var obj = getE("navmenus");
	var menus = obj.getElementsByTagName("a");
	var len = menus.length;
	for (var j = 0; j < len; j++) {
		menus[j].className = "indexnav";
	}
	menus[index - 1].className = "currnav";
}

var addAttribute = function(obj, styleClass) {
	if (obj) {
		if (document.all)
			obj.setAttribute("className", obj.getAttribute("className") + " "
							+ styleClass);
		else
			obj.setAttribute("class", obj.getAttribute("class") + " "
							+ styleClass);

	}
}

var removeAttribute = function(obj, styleClass) {
	if (obj) {
		if (document.all)
			obj.setAttribute("className", obj.getAttribute("className")
							.replace(styleClass, ""));
		else
			obj.setAttribute("class", obj.getAttribute("class").replace(
							styleClass, ""));

	}

}
var selectAllCheck = function(checkName) {
	var obj = document.getElementsByName(checkName);
	if (obj) {
		var len = obj.length;
		for (var i = 0; i < len; i++) {
			if (!obj[i].checked)
				obj[i].checked = true;
			else
				obj[i].checked = false;
		}
	}
};
var unSelectAllCheck = function(checkName) {
	var obj = document.getElementsByName(checkName);
	if (obj) {
		var len = obj.length;
		for (var i = 0; i < len; i++) {
			obj[i].checked = false;
		}
	}
};
var getRadioValue = function(radioName) {
	var txt = "";
	var obj = getN(radioName);
	if (obj) {
		var objlen = obj.length;
		for (var i = 0; i < objlen; i++) {
			if (obj[i].checked) {
				txt = obj[i].value;
				break;
			}
		}
	}
	return txt;
};

var resetSelectByValue = function(selectId, optionValue) {
	var obj = getE(selectId);
	var option = "";
	if (obj) {
		var len = obj.options.length;
		for (var i = 0; i < len; i++) {
			option = obj.options[i];
			if (option.value == optionValue)
				option.selected = true;
		}
	}
};
var resetSelectByText = function(selectId, optionText) {
	var obj = getE(selectId);
	var option = "";
	if (obj) {
		var len = obj.options.length;
		for (var i = 0; i < len; i++) {
			option = obj.options[i];
			if (option.text == optionText)
				option.selected = true;
		}
	}
};
var getSelectText = function(selectId) {
	var obj = getE(selectId);
	if (obj) {
		var len = obj.options.length;
		for (var i = 0; i < len; i++) {
			if (obj.options[i].selected == true)
				return obj.options[i].text;
		}
	}
};
function Cookie() {
}
Cookie.prototype.setCookie = function(name, value, option) {
	var str = name + "=" + encodeURIComponent(value);
	if (option) {
		if (option.expireDays) {
			var date = new Date();
			var ms = option.expireDays * 24 * 3600 * 1000;
			date.setTime(date.getTime() + ms);
			str += "; expires=" + date.toGMTString();
		}
		if (option.path)
			str += "; path=" + option.path;
		if (option.domain)
			str += "; domain" + option.domain;
		if (option.secure)
			str += "; true";
	}
	document.cookie = str;
};
Cookie.prototype.getCookie = function(name) {
	var cookieArray = document.cookie.split("; ");
	var cookie = new Object();
	for (var i = 0; i < cookieArray.length; i++) {
		var arr = cookieArray[i].split("=");
		if (arr[0] == name)
			return decodeURIComponent(arr[1]);
	}
	return "";
}

Cookie.prototype.deleteCookie = function(name) {
	this.setCookie(name, "", {
				expireDays : -1
			});
};
Array.prototype.inArray = function(value) {
	var i;
	for (i = 0; i < this.length; i++) {
		if (this[i] === value) {
			return true;
		}
	}
	return false;
};

String.prototype.gblen = function() {
	var len = 0;
	var txt = this.replace(/(^\s*)|(\s*$)/g, "");
	txt = txt.replace(/(^\s*)/g, "");
	txt = txt.replace(/(\s*$)/g, "");
	var templen = "";
	var temptype = 1;
	for (var i = 0; i < txt.length; i++) {
		if (txt.charCodeAt(i) > 127 || txt.charCodeAt(i) == 94) {
			len += 2;

		} else {
			len++;
		}
	}
	return len;

};
String.prototype.gbtrim = function(len, s) {
	var txt = this.replace(/(^\s*)|(\s*$)/g, "");
	txt = txt.replace(/(^\s*)/g, "");
	txt = txt.replace(/(\s*$)/g, "");
	var str = '';
	var sp = s || '';
	var len2 = 0;
	for (var i = 0; i < txt.length; i++) {
		if (txt.charCodeAt(i) > 127 || txt.charCodeAt(i) == 94) {
			len2 += 2;
		} else {
			len2++;
		}
	}
	if (len2 <= len) {
		return txt;
	}
	len2 = 0;
	len = (len > sp.length) ? len - sp.length : len;
	for (var i = 0; i < txt.length; i++) {
		if (txt.charCodeAt(i) > 127 || txt.charCodeAt(i) == 94) {
			len2 += 2;
		} else {
			len2++;
		}
		if (len2 > len) {
			str += sp;
			break;
		}
		str += txt.charAt(i);
	}
	return str;
};

//判断非空
function isEmpty(v){
	if((v||"")!="")
		return true;
	else
		return false;
};
