/**
 * 
 */
function newFormzb(url,fields,values,target){
	if(target==null||target==''||target==undefined){
		target = "_blank";
	}
	var form = document.createElement("form");
	form.action = url;
	form.target = target;
	form.method = "post";
	document.body.appendChild(form);
	var i;
	if(fields.length==values.length){
		for(i=0;i<fields.length;i++){
			var input = document.createElement("input");
			input.type = "hidden";
			input.name = fields[i];
			input.value = values[i];
			form.appendChild(input);
		}
		form.submit();
	}else{
		alert("传入参数错误！");
	}
}

var pubDialogBg = function(title,content){
	$('.pubDialogBg,.pubDialogCon_add').show();
	$("#tipTitle").html(title);
	$("#tipMsg").html(content);
}

//清除对话框
var clearPubDialogBg = function(){
	$('.pubDialogBg,.pubDialogCon_add').hide();
	$("#tipTitle").html("");
	$("#tipMsg").html("");
}

var doCallBackDialog = function(title,content,doCallBack){
	$('.pubDialogBg,.pubDialogCon_add').show();
	$("#okCallBack").show();	
	$("#cancelCallBack").hide();
	$("#dialogTitle").html(title);
	$("#dialogMsg").html(content);
	$("#doCallBackFun").attr("onclick",doCallBack);	
}

var cancelCallBack = function(title,content){
	$('.pubDialogBg,.pubDialogCon_add').show();
	$("#dialogTitle").html(title);
	$("#dialogMsg").html(content);
	$("#okCallBack").hide();	
	$("#cancelCallBack").show();	
}

var clearDoCallBackDialog = function (){
	$('.pubDialogBg,.pubDialogCon_add').hide();
	$("#dialogTitle").html("");
	$("#dialogMsg").html("");
	$("#doCallBackFun").remove("onclick");
}
function enterRoom(userId, userName, courseCode, liveKey, nowTime) {
	var url = "http://www.chinatet.com/zbapi/api/live/index_stud.shtm";
	var fields = [ "userId", "username", "coursecode", "key", "nowtime" ];
	var values = [ userId, userName, courseCode, liveKey, nowTime ];
	var target = "_blank"
	newFormzb(url, fields, values, target);
}
var errImgMap = new HashMap();
function onLoadImgErr(e,src){
	var times = 1;
	if(errImgMap.containsKey(e.id)){
		times = errImgMap.get(e.id);
		times++;
	}
	if(times > 1){
		return;
	}else{
		e.src = src;
	}
	errImgMap.put(e.id, times);
}
function CountCharsLength(words,type) {
	var sTotal = 0;//非单字节的字符，如中文标点、汉字
	var eTotal = 0;//单字节的字符，如数字、英文字母、英文标点
	var cnTotal = 0;//汉字
	var enTotal = 0;//英文字母
	var numTotal = 0;//数字
	
	for (i = 0; i < words.length; i++) {
		var c = words.charAt(i);
		if (c.match(/[^\x00-\xff]/)) {//非单字节的字符
			sTotal++;
		} else {
			eTotal++;
		}
		/**汉字*/
		if (c.match(/[\u4e00-\u9fa5]/)) {
			cnTotal++;
		}
		/**英文字母*/
		if (c.match(/[a-zA-Z]/)) {
			enTotal++;
		}
		if (c.match(/[0-9]/)) {
			numTotal++;
		}
	}
	switch(type){
		//中文字符个数
		case 1:{
			return cnTotal;
			break;
		}
		//英文字符个数
		case 2:{
			return enTotal;
			break;
		}
		//数字个数
		case 3:{
			return numTotal;
			break;
		}
		//中文标点个数
		case 4:{
			return sTotal - cnTotal;
			break;
		}
		//英文标点个数
		case 5:{
			return eTotal - enTotal - numTotal;
			break;
		}
		//标点个数
		case 6:{
			return sTotal - cnTotal + eTotal - enTotal - numTotal;
			break;
		}
		//字符个数，非单字节占两个字符
		default:{
			return sTotal * 2 + eTotal;
			break;
		}
	}
}
