function checkBlank(id){
	if ($("#" + id).val() == null | $("#" + id).val()==''){
		return false
	} else if (/^[\s]+$/.test($("#" + id).val())){
		return false;
	}
   return true;
}
$( function(e) {
	$.get('/user/ajax_login/' + Math.random(), {}, function(re){
		$('#user_info').html(re + '<li><a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=linrenling"><img src="http://s7.addthis.com/static/btn/sm-share-en.gif" width="83" height="16" alt="Bookmark and Share" style="border:0"/></a></li>');
		eval('<script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=linrenling"></script>');
	});
	$('#regnickname').blur( function() {
		$(".reg_username").css('display', 'none');
		if (!(/^[\w\d]{3,20}$/.test($('#regnickname').val()))) {
			$('#err_username_1').css('display', 'block');
			return false;
		} else {
			$.post('/user/check_nickname/', {
				nickname: $('#regnickname').val()
			}, function(re) {
				if (re == '0') {
					$('#err_username_2').css('display', 'block');
					return false;
				} else {
					$('#right_username').css('display', 'block');
					return true;
				}
			});
		}
	});
	$('#password').blur(function(){
		$(".reg_password").css('display', 'none');
		if (!(/^[\w\d]{3,20}$/.test($('#password').val()))) {
			$('#err_password_1').css('display', 'block');
			return false;
		} else if ($('#passwordconfirm').val() != ''){
			if ($('#password').val() != $('#passwordconfirm').val()){
				$('#err_password_2').css('display', 'block');
				return false;
			} else {
				$('#right_password').css('display', 'block');
				return true;
			}
		}
	});
	$('#passwordconfirm').blur(function(){
		$(".reg_password").css('display', 'none');
		if (!(/^[\w\d]{3,20}$/.test($('#password').val()))) {
			$('#err_password_1').css('display', 'block');
			return false;
		} else if ($('#password').val() != $('#passwordconfirm').val()){
			$('#err_password_2').css('display', 'block');
			return false;
		} else {
			$('#right_password').css('display', 'block');
			return true;
		}
	});
	$("#email").blur(function(){
		$(".reg_email").css('display', 'none');
		if (!(/^([\w-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([\w-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)$/.test($('#email').val()))) {
			$('#err_email_1').css('display', 'block');
			return false;
		} else {

			$.post('/user/check_email/', {
				email: $('#email').val()
			}, function(re) {
				if (re != '1') {
					$('#err_email_2').css('display', 'block');
					return false;
				} else {
					$('#right_email').css('display', 'block');
					return true;
				}
			});
		}
	});
	$('#theme_elite').click(function(){
		$.post('/thread/elite/', {
			theme_id: $(this).attr('theme_id'),
			elite: $(this).attr('elite')
		}, function(re) {
			if (re == '1') {
				$('#theme_elite').html('<img src="/files/img/onRight.gif" border="0">');
				return false;
			} else {
				$('#theme_elite').html('<img src="/files/img/onError.gif" border="0">');
				return true;
			}
	   });
	});
	$('#theme_delete').click(function(){
		$.post('/thread/delete/', {
			theme_id: $(this).attr('theme_id')
		}, function(re) {
			if (re == '1') {
				$('#theme_delete').html('<img src="/files/img/onRight.gif" border="0">');
				return false;
			} else {
				$('#theme_delete').html('<img src="/files/img/onError.gif" border="0">');
				return true;
			}
	   });
	});
	$("#check_code").blur(function(){
		$(".reg_check_code").css('display', 'none');
		$.post('/user/check_code/', {
			check_code: $('#check_code').val()
		}, function(re) {
			if (re != '1') {
				$('#err_check_code_1').css('display', 'block');
				return false;
			} else {
				$('#right_check_code').css('display', 'block');
				return true;
			}
	   });
	});
	$('#reload_btn').click( function() {
		var url = '/user/code/?rand=' + Math.random();
		$('#reload_img').attr('src', url);
	});
	$('#loginnickname').blur( function() {
		$(".login_username").css('display', 'none');
		if (!(/^[\w\d]{3,20}$/.test($('#loginnickname').val()))) {
			$('#err_username_1').css('display', 'block');
			return false;
		} else {
            return true;
		}
	});
	$("#reply_form").submit(function(){
		$(".error").css('display', 'none');
		if(!checkBlank('reply_title')){	
			$("#title_error").css('display', 'block');
			return false;
		} else if(!checkBlank('reply_content')){
			$("#content_error").css('display', 'block');
			return false;
		} else if (!checkBlank('reply_check_code')){
			$("#code_tr").css('display', '');
			$("#code_error").css('display', 'block');
			return false;
		}
		return true;
	});
})
document.writeln('<script type="text/javascript" src="http://js.tongji.linezing.com/1523246/tongji.js"></script><noscript><a href="http://www.linezing.com"><img src="http://img.tongji.linezing.com/1523246/tongji.gif" width="0" height="0"/></a></noscript>');