/*******************************************\
日期选择类：58版权所有 最坏是单飞 下载
\*******************************************/
function Dom()
{
	this.$ = function(){
		var elements = new Array();
		for (var i = 0; i < arguments.length; i++) {
		var element = arguments[i];
		if (typeof element == 'string') element = document.getElementById(element);
		if (arguments.length == 1) return element;
		elements.push(element);
		}return elements;
	}
	//获取元素的属性
	this.$B = function(args, attribute){
		if(args == null)return false;
		if(!attribute)return false;
		if(args.getAttribute(attribute) == null || args.getAttribute(attribute) == "" || args.getAttribute(attribute) == undefined)return false;
		return args.getAttribute(attribute);
	}

	//给元素增加属性
	this.$S = function(args, attribute, v){
		if(args == null)return false;
		if(!attribute)return false;
		if(args.getAttribute(attribute) == null || args.getAttribute(attribute) == "" || args.getAttribute(attribute) == undefined)return false;
		args.setAttribute(attribute, v);
	}

	//删除元素的属性
	this.$R = function(args, attribute){
		if(args == null)return false;
		if(!attribute)return false;
		if(args.getAttribute(attribute) == null || args.getAttribute(attribute) == "" || args.getAttribute(attribute) == undefined)return false;
		return args.removeAttribute(attribute, 0);
	}

	this.$A = function(iterable) {
		if (!iterable) return [];
		if (iterable.toArray) {
			return iterable.toArray();
		} else {
			var results = [];
			for (var i = 0; i < iterable.length; i++)
				results.push(iterable[i]);
			return results;
		}
	}

	this.$ReplaceA = function(){
		var elements = new Array();
		var str = arguments[0];
		for (var i = 1; i < arguments.length; i++) {
			var element = arguments[i];
			str = str.replace("{"+(i-1)+"}", element);
		}
		return str;
	}

	this.loadCss = function(file, id){
		var cssTag = document.getElementById(id);
		var head = document.getElementsByTagName("head").item(0);
		if(cssTag) head.removeChild(cssTag);
		css = document.createElement("link");
		css.href = file+".css";
		css.rel = "stylesheet";
		css.type = "text/css";
		if(id!=null){
			css.id = id;
		}
		head.appendChild(css);
	}

	this.$OH = function(objname, outHTML, isRW){
		if(isRW){
			this.$(objname).innerHTML += outHTML;
		}else{
			this.$(objname).innerHTML = outHTML;
		}
	}

	//根据浏览器判断高度是否为0
	this.$IsEH = function(h,m){
		var b = false;
		if(m==null){m=0;}
		var isIE = this.getPlatform().indexOf("ie") != -1;
		var isMoz = this.getPlatform() == "moz";
		var isOpera = this.getPlatform() == "opera";
		if(isIE){
			if(h == m){
				b = true;
			}
		}
		if(isMoz || isOpera){
			if(h == (m+8)){
				b = true;
			}
		}
		return b;
	}

	//获取当前浏览器
	this.getPlatform = function()
	{
		var _platform = null;
		if (_platform != null)
		{
			return _platform;
		}
		if (typeof(navigator) == "undefined")
		{
			return "not-browser";
		}
		var ua = navigator.userAgent.toLowerCase();
		if (/gecko/i.test(ua))
		{
			_platform = "moz";
		}
		else if (/opera/i.test(ua))
		{
			_platform = "opera";
		}
		else if (/msie/i.test(ua))
		{
			if (/msie 6/i.test(ua))
			{
				_platform = "ie6";
			}
			else if (/msie 5\.5/i.test(ua))
			{
				_platform = "ie5.5";
			}
			else if (/msie 5\.[^5]/i.test(ua))
			{
				_platform = "ie5";
			}
			else
			{
				_platform = "ie";
			}
		}
		else
		{
			_platform = "other";
		}
		return _platform;
	}
}
//if (!GGServer.Class.Dom) GGServer.Class.Dom = {};
if (!Dom) Dom = {};
Dom.String = function()
{
	this.isEmptyOrNull = function(str, isEmpty){
		if(str == null || str == undefined){
			return false;
		}
		if(isEmpty != undefined || isEmpty){
			if(str == ""){
				return false;
			}
		}
		return true;
	}
	this.keyRestrict = function(validchars) { // v3.0
		keychar = String.fromCharCode(key);
		keychar = keychar.toLowerCase();
		validchars = validchars.toLowerCase();
		if (validchars.indexOf(keychar) != -1)
			return true;
		if ( key==null || key==0 || key==8 || key==9 || key==13 || key==27 )
			return true;
		return false;
	}

	this.quanjiao2Banjiao = function(str) {
		var i;
		var result = '';
		for (i = 0; i < str.length; i++) {
			code = str.charCodeAt(i);
			if (code >= 65281 && code < 65373) {
				result += String.fromCharCode(str.charCodeAt(i) - 65248);
			}
			else {
				result += str.charAt(i);
			}
		}
		return result;
	}
}