function isLegal(ch)
{
	if(ch >= '0' && ch <= '9')return true;
	if(ch >= 'a' && ch <= 'z')return true;
	if(ch >= 'A' && ch <= 'Z')return true;
	if(ch == '-' || ch == '_' || ch == '@' || ch == '.') return true;
	return false;
}
function isNum(ch)
{
	if(ch >= '0' && ch <= '9')return true;
	return false;
}
function isChar(ch)
{
	if(ch >= 'a' && ch <= 'z')return true;
	if(ch >= 'A' && ch <= 'Z')return true;
	return false;
}
function isAllNum(str1)
{
	for (i=0; i<str1.length; i++) {
		if (!isNum(str1.charAt(i)))
		{
			return false;
		}
	}
	return true;
}

function isAllLegal(str1)
{
	for (i=0; i<str1.length; i++) {
		if (!isLegal(str1.charAt(i)))
		{
			return false;
		}
	}
	return true;
}


function isNum(ch)
{
	if(ch >= '0' && ch <= '9')return true;
	return false;
}

function transferViewIdToShort(viewerId){
	//alert(viewerId.length);
	var pre= '';
	var v = null;
	
	if(viewerId!=null && viewerId.length>=5){  	
	  	if(typeof getLabelByName != 'undefined'){
  			pre = getLabelByName('msgGuest');
	  	}else{
  			pre = "\u6765\u5bbe";
  		}
	    v= pre+viewerId.charCodeAt(0)+viewerId.charCodeAt(1)+viewerId.charCodeAt(2)+viewerId.charCodeAt(3)+viewerId.charCodeAt(4)
    	if(v.length>7){
    	 	 v = v.substring(0,7);
   		}  
	    return v;
  	}
	return viewerId;
 }
  function transferViewIdToShort2(vId,l){
  	
  	var v  = null;
  	if(vId != null && vId.length > l){
  		if(typeof getLabelByName != 'undefined'){
  			v = getLabelByName('msgGuest');
  		}else{
  			v = "\u6765\u5bbe";
  		}
  		var i = 0;
		while(i<l){
			var r = Math.ceil(vId.length*(Math.random()));
			var c = vId.charAt(r);
			if(isChar(c)||isNum(c)){
				v  += vId.charCodeAt(r);
				i++
			}
		}


  		return v.substring(0,l+2);
  	}
  	return vId;

 }

function replaceHtml(msg)
{
	var string = msg+"";
	
	string = string.replaceAll("&", "&amp;" );
	string = string.replaceAll("<", "&lt;" );
	string = string.replaceAll(">", "&gt;" );
	string = string.replaceAll("\r", "" );
	string = string.replaceAll("\n", "<br>" );
	string = string.replaceAll("\"", "&quot;" );
	
	return string;
}
String.prototype.replaceAll = stringReplaceAll;

function stringReplaceAll(AFindText,ARepText){
raRegExp = new RegExp(AFindText,"g")
return this.replace(raRegExp,ARepText)
}
function getTimeString(){
	var now = new Date();
	var year = now.getFullYear();
	var mon = now.getMonth() + 1;
	if (mon <10)
		mon = '0' + mon;
	var day = now.getDate();
	if(day < 10)
		day = '0' + day;
	var hour = now.getHours();
	if(hour < 10)
		hour = '0' + hour;
	var min = now.getMinutes();
	if(min < 10)
		min = '0' + min;
	var sec = now.getSeconds();
	if(sec < 10)
		sec = '0' + sec;
	var sep = '-';
		
	var rtn = year + sep + mon + sep + day + ' ';
	rtn += hour + ':' + min + ':' + sec;
	return rtn;
}
function getLocalTimeString(tm){
	if(tm == null)
		return null;
		
	var showTimeStr = "" + tm.getYear() + "\u5e74" + (tm.getMonth()+1) +"\u6708" + tm.getDate() + "\u65e5"
                        + "&nbsp;" + tm.getHours() + "\u65f6" + tm.getMinutes() + "\u5206" + tm.getSeconds() + "\u79d2";
                        
	return showTimeStr;
					
}
function getShortId(vId,rtnName,role) {
	
	var temp = "" +vId;
	if(role==6){
		return temp.substring(temp.length-3)+'会议室';
	}
	
    if (getRole(vId) == 1) {
        return rtnName==null?vId:rtnName;
    } else {
        return transferViewIdToShort(vId);
    }
}
function $(itemID) {
	if (document.getElementById) {
		return document.getElementById(itemID);
	} else {
		return document.all(itemID);
	}
}
function getRole(vId) {
    var idLength = vId.length;
    if (idLength > 30) {
        return 2;
    } else {
        return 1;
    }
}
Sys = function(){;}
Sys.NS = (document.layers) ? true : false;
Sys.IE = (document.all) ? true : false;
Sys.DOM = (document.getElementById) ? true : false;
if (Sys.IE) Sys.DOM = false;
Sys.MAC = (navigator.platform) && (navigator.platform.toUpperCase().indexOf('MAC') >= 0);
if (Sys.NS) Sys.MAC = false;
Sys.getObject = function(objId){if (document.getElementById)return document.getElementById(objId);else if (document.all)return document.all(objId);};


