	function isAnonymous(){
		$('anonymous').checked ? $('username').disable() : $('username').enable();
	}
	function chgImg(){
		$('authimg').src='/auth/?action=init&t='+Math.random();
	}
	function addMsg(){
		if($F('username').trim().empty()){
			$('username').enable();
			$('anonymous').checked = false;
			ModalDialog.alert('<font color="red">用户名不能为空</font>',{callback:function(){$('username').focus();}});
			return false;
		}
		if($F('username').trim().size() > 16){
			$('username').enable();
			$('anonymous').checked = false;
			ModalDialog.alert('<font color="red">用户名也太长了吧！</font>',{callback:function(){$('username').focus();}});
			return false;
		}
		if($F('msgContent').trim().empty()) {
			ModalDialog.alert('<font color="red">留言内容不能为空</font>',{callback:function(){$('msgContent').focus();}});
			return false;
		}
		if($F('msgContent').trim().size() > 200) {
			ModalDialog.alert('<font color="red">留言内容不能超过200个字</font>',{callback:function(){$('msgContent').focus();}});
			return false;
		}
		if($F('yzm').trim().empty()){
			ModalDialog.alert('<font color="red">验证码不能为空</font>',{callback:function(){$('yzm').focus();}});
			return false;
		} else {
			$('addmsgFrm').action = '/space/guestbook/add?uid='+bloggerID;
			$('addmsgFrm').request({
				onSuccess: function(transport) {
					if (transport.responseText.match(/nopurview/i)){
						ModalDialog.alert('<font color="red">该用户已将留言功能关闭,暂不能给他留言</font>',{width:300,callback:function(){return}});
					}else if (transport.responseText.match(/noauth/i)){
						ModalDialog.alert('<font color="red">验证码输入有误</font>',{callback:function(){$('yzm').focus();}});
						return false;
					} else if (transport.responseText.match(/ok/i)){
						chgImg();
						new Module('modnewmsg');
						if ($('guestbook'))	scroll(0,$('guestbook').cumulativeOffset().top);
						$('addmsgFrm').reset();
						return false;
					} else if (transport.responseText.match(/keyword/i)){
						//ModalDialog.alert('<font color="red">您的留言中含有非法关键字！</font>');
						myArray=transport.responseText.split(":");
						ModalDialog.alert(myArray[1]);
						return false;
					} else {
						ModalDialog.alert('<font color="red">系统忙，请稍后发表你的留言！</font>');
						return false;
					}
			}});
		}
		return false;
	}
	/*用于按下回复时，改变表单状态的js*/
	function changeMsg(id,username){
		$('username').disable();
		$('anonymous').disable();
		$('addsubmit').hide();
		$('replysubmit').show();
		$('msgContent').value="回复"+username+":";
		$('reply_id').value = id;
	}
	/*回复完成后重置表单*/
	function resetform(){
		$('username').enable();
		$('anonymous').enable();
		$('addsubmit').show();
		$('replysubmit').hide();
		$('msgContent').value="";
		$('reply_id').value = "";
	}
	function replyMsg(){
		
		if($F('msgContent').trim().empty()) {
			ModalDialog.alert('<font color="red">留言内容不能为空</font>',{callback:function(){$('msgContent').focus();}});
			return false;
		}
		if($F('msgContent').trim().size() > 200) {
			ModalDialog.alert('<font color="red">留言内容不能超过200个字</font>',{callback:function(){$('msgContent').focus();}});
			return false;
		}
		if($F('yzm').trim().empty()){
			ModalDialog.alert('<font color="red">验证码不能为空</font>',{callback:function(){$('yzm').focus();}});
			return false;
		}
		//alert('ss');
		id = $('reply_id').value;
		//alert(id);
		$('addmsgFrm').action = '/space/guestbook/reply?uid='+bloggerID+'&id='+id;
			$('addmsgFrm').request({
				onSuccess: function(transport) {alert(transport.responseText);
					if (transport.responseText.match(/nopurview/i)){
						ModalDialog.alert('<font color="red">您已将留言功能关闭,暂不能回复</font>',{width:300,callback:function(){return}});
					}else if (transport.responseText.match(/noauth/i)){
						ModalDialog.alert('<font color="red">验证码输入有误</font>',{callback:function(){$('yzm').focus();}});
						return false;
					} else if (transport.responseText.match(/ok/i)){
						chgImg();
						new Module('modnewmsg');
						if ($('guestbook'))	scroll(0,$('guestbook').cumulativeOffset().top);
						$('addmsgFrm').reset();
						resetform();
						return false;
					} else {
						ModalDialog.alert('<font color="red">系统忙，请稍后发表你的留言！!!</font>');
						return false;
					}
				}
			})
		
	}
	function removeMsg(id,o){
		var oElem = o.parentNode.parentNode.parentNode;
		var orginBackground = oElem.style.background
		oElem.style.background = 'red';
		ModalDialog.confirm('你确定要删除该留言吗?',{callback:function(btn){
			if (1 != btn) {
				oElem.style.background = orginBackground;
				return false;
			}
			new Ajax.Request('/space/guestbook/remove?uid='+bloggerID+'&id='+id,{
				onSuccess:function(transport){
					if (transport.responseText.match(/ok/i)){
						oFadeElement = oElem;
						setOpacity();
					} else {
						oElem.style.background = orginBackground;
						ModalDialog.alert('<font color="red">系统忙,请稍后再试.</font>',{callback:function(){return;}});
						return false;
					}
				}
			});
		}});
		//if (!confirm('你确定要删除该留言吗?')) return;
	}
	//huamin
	function zhuanzai(blogid)
	{
		if(!isGuest)
		{
			ModalDialog.confirm("您确定要转载该博文吗?",{callback:function(btn){
			if ( 1 != btn ) return;
			var url = "/admin/friend/zhuanzai?blogid="+blogid;
			new Ajax.Request(url,{
				onSuccess:function(transport){
					if (transport.responseText.match('succes')){
						ModalDialog.alert('<font color="red">转载成功</font>',{callback:function(){return;}});
					} else if (transport.responseText.match('fail')) {
						ModalDialog.alert('<font color="red">转载失败！</font>',{width:400,callback:function(){return;}});
					}
						else if (transport.responseText.match('unable')) {
						ModalDialog.alert('<font color="red">不能转载自己博文</font>',{width:400,callback:function(){return;}});
					}
					else{
						ModalDialog.alert('<font color="red">系统忙,请稍后再试该功能</font>',{callback:function(){return;}});
					}
				}
				//parameters:new Hash({username: name})
				});
			}});
		}
		else{
			ModalDialog.confirm('未登录,暂不能使用该功能,您是否要现在登录',{width:300,callback:function(btn){
				if (1 != btn) return;
				window.location.href='http://passport.ccstock.cn/user/login?return='+encodeURIComponent(window.location);
			}});
		}
	}
	function addBuddy(name,uid){
		if(!isGuest) {
			ModalDialog.confirm("您确定要和 "+name+ " 交朋友吗?",{callback:function(btn){
			if ( 1 != btn ) return;
			var url = "/admin/friend/addfriend?ac=add&blogger_id="+bloggerID;
			//var url = 'http://passport.ccstock.com/Ifriends.php?fid='+bloggerID+'&uid='+uid+'&action=add';
			//alert(url);
			new Ajax.Request(url,{
				onSuccess:function(transport){
					if (transport.responseText.match('4')){
						ModalDialog.alert('<font color="red">添加朋友失败</font>',{width:300,callback:function(){return;}});
					} else if (transport.responseText.match('notaddself')) {
						ModalDialog.alert('<font color="red">虽然说自恋是正常的心理特征，但是我们也不推荐您将自己添加为好友</font>',{width:400,callback:function(){return;}});
					}  else if (transport.responseText.match('5')) {
						ModalDialog.alert('<font color="red">朋友用户不存在</font>',{width:400,callback:function(){return;}});
					}
						else if (transport.responseText.match('1')) {
						ModalDialog.alert('<font color="red">没有朋友被添加</font>',{width:400,callback:function(){return;}});
					}
						else if (transport.responseText.match('2')) {
						ModalDialog.alert('<font color="red">用户id错误</font>',{width:400,callback:function(){return;}});
					}
						else if (transport.responseText.match('3')) {
						ModalDialog.alert('<font color="red">该用户已经是您的好友了</font>',{width:400,callback:function(){return;}});
					}
						else if (transport.responseText.match('-1')) {
						ModalDialog.alert('<font color="red">参数错误</font>',{width:400,callback:function(){return;}});
					}
					else if (transport.responseText.match('0')) {
						ModalDialog.flash('好友添加成功',{callback:function(){return;}});
					}else{
						ModalDialog.alert('<font color="red">系统忙,请稍后再试该功能</font>',{callback:function(){return;}});
					}
				}
				//parameters:new Hash({username: name})
				});
			}});
		} else {
			ModalDialog.confirm('未登录,暂不能使用该功能,您是否要现在登录',{width:300,callback:function(btn){
				if (1 != btn) return;
				window.location.href='http://passport.zjt.com.cn/user/login?return='+encodeURIComponent(window.location);
			}});
		}
	}
	function addBlack(name){
		if(!isGuest) {
			ModalDialog.confirm("您确定要将 "+name+ " 加入黑名单吗?",{width:300,callback:function(btn){
			if ( 1 != btn ) return;
			var url = '/space/proxy/addblack?uid='+bloggerID;
			new Ajax.Request(url,{
				method: 'post',
				onSuccess:function(transport){
					if (transport.responseText.match('nouser')){
						ModalDialog.alert('<font color="red">该用户尚未加入财客的行列</font>',{callback:function(){return;}});
					} else if (transport.responseText.match('notaddself')) {
						ModalDialog.alert('<font color="red">虽然自残不受法律约束，但是我们也不推荐您将自己加入黑名单</font>',{width:400,callback:function(){return;}});
					} else if (transport.responseText.match('success')) {
						ModalDialog.flash('添加成功',{callback:function(){return;}});
					}else{
						ModalDialog.alert('<font color="red">系统忙,请稍后再试该功能</font>',{callback:function(){return;}});
					}
				},
				parameters:new Hash({username: name})
				});
			}});
		} else {
			ModalDialog.confirm('未登录,暂不能使用该功能,您是否要现在登录',{width:300,callback:function(btn){
				if (1 != btn) return;
				window.location.href='http://passport.zjt.com.cn/user/login?return='+encodeURIComponent(window.location);
			}});
		}
	}
	var Module = function(modname){
		var _mod = modname.substring(3);
		var _url = '/space/mod/'+_mod+'?uid='+bloggerID;
		new Ajax.Request(_url,{
				method : 'get',
				onSuccess:function(transport){
					$(modname).update(transport.responseText);
				},
				onCreate:function(){
					$(modname).innerHTML = '<p class="center">正在读取数据...</p>';
				},
				onLoading:function(){
					//$(modname).innerHTML = '<p class="center">正在读取数据...</p>';
				},
				onFailure:function(){
					$(modname).update('数据读取加载失败');
				}
		});
	}
	//初始化模块
	function initModule(){
		aLoadedModAbname.each(function(modname){
			new Module(modname);
		})
	}
	function onmodmusic() {
		ModalDialog.show({
			showBottomBar:false,
			iframePad:0,
			title: '我的音乐盒',
			width: 710,
			height: 220,
			url: '/admin/setting/music'
		});
	}
	//mmy83 -add start
	function onmodfriendlink() {
		ModalDialog.show({
			showBottomBar:false,
			iframePad:0,
			title: '友情链接',
			width: 510,
			height: 420,
			url: '/admin/setting/friendlink'
		});
	}
	function delfriendlink( id ,o) {
		var oElem = o.parentNode;
		var orginBackground = oElem.style.background
		oElem.style.background = 'red';
		ModalDialog.confirm("是否要删除？",{title:"删除友情链接",callback:function(btn){
			if(!btn) {
				oElem.style.background = orginBackground;
				return false;
			}
			else
			{
				new Ajax.Request("/admin/friendlink/delfriendlink?ac=delfriendlink&id="+id,
				{
					method: "get",
					onSuccess: function(transport){
					var json=transport.responseText.evalJSON(true);
						if(json[0]=="ok")
						{
							//location.reload();
							//new Module('modfriendlink');
							oFadeElement = oElem;
							setOpacity();
						}else{
							oElem.style.background = orginBackground;
							ModalDialog.alert('<font color="red">系统忙,请稍后再试.</font>',{callback:function(){return;}});
							return false;
						}
					}
				});
			}
		}});
	}

	//mmy83 -add end
	//添加回复留言
	function addreply(id){
		ModalDialog.show({
			showBottomBar:false,
			iframePad:0,
			title: '回复留言',
			width: 510,
			height: 420,
			url: '/admin/setting/addreply?uid='+bloggerID+'&id='+id+''
		});
	}
	//添加个性域名
	function onsetdomain(uid) {
		ModalDialog.show({
			showBottomBar:false,
			iframePad:0,
			title: '个性域名',
			width: 510,
			height: 120,
			url: '/admin/setting/setdomain'
		});
	}
	//修改博客名
	function onsetblogname() {
		ModalDialog.show({
			showBottomBar:false,
			iframePad:0,
			title: '个性域名',
			width: 510,
			height: 120,
			url: '/admin/setting/setblogname'
		});
	}
	function textLimitCheck(thisArea, maxLength){
    if (thisArea.value.length > maxLength){

      alert(maxLength + ' 个字限制. \r超出的将自动去除.');

      thisArea.value = thisArea.value.substring(0, maxLength);

      thisArea.focus();

    }
    document.getElementById('countwords').innerHTML = thisArea.value.length;
}