$(function(){
    $(":text, :password").focus(function(){
		$(this).attr("class","input_focus");
	}).blur(function(){
        $(this).removeClass("input_focus");
	});
	$("textarea").focus(function(){
		$(this).attr("class","textarea_focus");
	}).blur(function(){
        $(this).removeClass("textarea_focus");
	});
	$(":radio").attr("class","radio");
	//nav切换
	$('.nav li').hover(function(){
		$(this).addClass('hover');
    },function(){
		$(this).removeClass('hover');
	});
	$('.nav li a').focus(function(){
		this.blur();
	});
	//单行切换公告
	$("#announcement li:not(:first)").hide();
	setInterval(function(){
		var on = $("#announcement li:visible");
		var next = $("#announcement li:last").is(':visible')?$("#announcement li:first"):on.next();
		next.fadeIn(600);
		on.hide();
	}, 3000); //每3秒钟切换一条，你可以根据需要更改
});
function change_captcha(id){
	$('#'+id).attr('src', function(){return $(this).attr('src').split('?')[0] + '?' + Math.random()});
}
function redirect(url){
	if(url.lastIndexOf('/.') > 0){
		url = url.replace(/\/(\.[a-zA-Z]+)([0-9]+)$/g, "/$2$1");
	} else if(url.match(/\/([a-z]+).html([0-9]+)$/)) {
		url = url.replace(/\/([a-z]+).html([0-9]+)$/, "/$1-$2.html");
	} else if(url.match(/-.html([0-9]+)$/)) {
		url = url.replace(/-.html([0-9]+)$/, "-$1.html");
	}

	if(url.indexOf('://') == -1 && url.substr(0, 1) != '/' && url.substr(0, 1) != '?') url = $('base').attr('href')+url;
	location.href = url;
}
function loginSubmit(login){
	var usernameObj = $('#pass_loginLite_input_username');
	var username = $.trim(usernameObj.val());
	var passwordObj = $('#pass_loginLite_input_password');
	var password = $.trim(passwordObj.val());
	var captchaObj = $('#pass_loginLite_input_verifycode');
	var captcha = $.trim(captchaObj.val());
	if(username == '') {
		usernameObj.focus();
		$('#pass_loginLite_info').html(usernameObj.attr('msg'));
		return false;
	}
	if(password == '') {
		passwordObj.focus();
		$('#pass_loginLite_info').html(passwordObj.attr('msg'));
		return false;
	}
	$.post(login.action, 'username='+username+'&password='+password+'&captcha='+captcha+'&submit=1', function(data){
		usernameObj.val('');
		passwordObj.val('');
		if(data[0] == 1){
			var go = login.forward.value;
			if (go == '') {
				go = login.defalut_forward.value;
			}
			redirect(go);
		} else {
			$('#pass_loginLite_info').html(data[1]);
		}
	}, 'json');
}