﻿function fullEscape(text){
	var encodedHtml = encodeURIComponent(text);
	return encodedHtml;
}
// 错误信息提示
function processError(e){
	// alert(e);
	
	if(!e){
		return;
	}
	
	var elem;
	if(e.indexOf("用户名")>=0 || e.indexOf("编号")>=0){
		elem = $("loginName");
	}
	else if(e.indexOf("密码")>=0){
		elem = $("loginPassword");
	}
	else if(e.indexOf("验证码")>=0){
		elem = $("verifyCode");
		$("verifyField").show();
	}
	else{
		// 其他提示信息放在用户名上
		elem = $("loginName");
	}
	
	elem.select();
	
	clearLoginErrors();
	var pos = fGetXY(elem);
	var resultDiv = createFloatDiv(e);
    
   	resultDiv.style.position = "absolute";
    document.body.appendChild(resultDiv);
    
	resultDiv.style.left = pos[0] + elem.clientWidth - (elem.clientWidth / 2);
    resultDiv.style.top = pos[1] + elem.clientHeight - resultDiv.clientHeight - 25;
   	resultDiv.style.display = "";
   	
   	elem.attachEvent("onclick",function(){clearLoginErrors()});	// 点击清除float提示
   	// window.setTimeout("clearLoginErrors()",3000);	// 3秒钟后，自动清除float提示
	
	return;
}

function createFloatDiv(str){
	var resultDiv = document.createElement("DIV");
	resultDiv.id = "floatLoginError";
	resultDiv.className= "FloatDiv";
	var html = "<div class=\"InnerBox\"><div class=\"Lt\"></div>";
	html += "<p style=\"font-size:12px;\"><strong>" + str +"</strong></p>";
	html += "<div class=\"Rb\"></div><div class=\"Bttm\"></div></div>";
	
	// alert(html);
	resultDiv.innerHTML = html;
	
	resultDiv.attachEvent("onclick",function(){
		clearLoginErrors();
	});
	
	return resultDiv;
}

// 清除页面上已有的浮动信息提示
function clearLoginErrors(){
 	var floatResultDiv = document.getElementById("floatLoginError");
    if(floatResultDiv){
   		floatResultDiv.removeNode(true);
    }
}


