function showImg() {
	if ($("#captcha").css("display") == "none") {
		$("#captcha").show("slow");
		// $("#captcha").css("display","block");
	}
};
function hidenImg() {
	if ($("#captcha").css("display") != "none") {
		$("#captcha").hide("slow");
		// $("#captcha").css("display","none");
	}

}

function refreshCaptcha() {
	$('#captchaImg').hide().attr('src',
			'../../security/jcaptcha.jpg?' + Math.floor(Math.random() * 100))
			.fadeIn();
	$("#captcha").css("display", "block");
}

// 注册回车登录事件
//if (document.addEventListener) {
//	document.addEventListener("keypress", fireFoxHandler, true); // firefox
//} else {
//	document.attachEvent("onkeypress", ieHandler); // ie
//}

function fireFoxHandler(evt) {
	if (evt.keyCode == 13) {
		document.getElementById('logo_btn').click();
	}
}

function ieHandler(evt) {
	if (document.getElementById('logo_btn') == null
			|| document.getElementById('logo_btn') == "") {
		return;
	} else {

		if (evt.keyCode == 13) {

			document.getElementById('logo_btn').click();
		}
	}
}

function login(formObj) {
	var userName = document.getElementById('j_username').value;
	if (userName == '' || userName == '用户名') {
		alert('请填写用户名.')
		document.getElementById('j_username').focus();
		return false;
	}
	var passWord = document.getElementById('j_password').value;
	if (passWord == '' || passWord == '密码') {
		alert('请填写密码.')
		document.getElementById('j_password').focus();
		return false;
	}
	var passWord = document.getElementById('j_captcha').value;
	if (passWord == '' || passWord == '验证码') {
		alert('请填写验证码.')
		document.getElementById('j_captcha').focus();
		return false;
	}
//	formObj.action = "../../j_spring_security_check";
//	formObj.submit();
}
// function linkComposition(){
// document.getElementById("indexForm").action="../../front-page/composition/composition!list.action";
// }
function linkSection() {
	document.getElementById('moveMentCode').value = Strings.trim(document
			.getElementById('moveMentCode').value);
	var moveMentCode = document.getElementById('moveMentCode').value;
	$.get("../section/section!processMovementClickingByCode.action", {
				moveMentCode : moveMentCode
			}, function(data) {
				if (data != "") {
					alert(data);
				} else {
					var formName = document.indexForm;
					formName.action = "../../front-page/section/section!list.action";
					formName.submit();
				}
			});
};

function userInter(eventHandle, control, obj) {
	if (control == 'user') {
		if (eventHandle == "F") {
			obj.style.color = "#000";
			if (obj.value == "用户名")
				obj.value = "";
		} else if (eventHandle == "B") {
			if (obj.value == "") {
				obj.value = "用户名";
				obj.style.color = "#909090";
			}
		}
	} else if (control == 'pwd') {
		if (eventHandle == "F") {
			var pNode = obj.parentNode;
			pNode.removeChild(obj);
			var pwdObj = document.createElement("INPUT");
			pwdObj.id = 'j_password';
			pwdObj.name = 'j_password';
			pwdObj.type = "password";
			// pwdObj.className = "pwd";
			pwdObj.style.color = "#000";
			pwdObj.tabIndex = 2;
			pwdObj.onblur = function() {
				userInter('B', 'pwd', this)
			}
			pNode.appendChild(pwdObj);
			pwdObj.focus();

			if (window.ActiveXObject) { // ie
				var rng = pwdObj.createTextRange();
				rng.select();
				rng.collapse();
			}
		} else if (eventHandle == "B") {
			if (obj.value == "") {
				var pNode = obj.parentNode;
				pNode.removeChild(obj);
				var pwdObj = document.createElement("INPUT");
				pwdObj.id = 'j_password';
				pwdObj.name = 'j_password';
				pwdObj.type = "text";
				pwdObj.value = "密码";
				// pwdObj.className = "pwd";
				pwdObj.tabIndex = 2;
				pwdObj.onfocus = function() {
					userInter('F', 'pwd', this);
				}
				pNode.appendChild(pwdObj);
			}
		}
	} else if (control == 'img') {
		if (eventHandle == "F") {
			obj.style.color = "#000";
			if (obj.value == "验证码")
				obj.value = "";
		} else if (eventHandle == "B") {
			if (obj.value == "") {
				obj.value = "验证码";
				obj.style.color = "#909090";
			}
		}
	}
}

