
	function strLen(str) {
		var charset = document.charset; 
		var len = 0;
		for(var i = 0; i < str.length; i++) {
			len += str.charCodeAt(i) < 0 || str.charCodeAt(i) > 255 ? (charset == "utf-8" ? 3 : 2) : 1;
		}
		return len;
	}
	
	function getStrbylen(str, len) {
		var num = 0;
		var strlen = 0;
		var newstr = "";
		var obj_value_arr = str.split("");
		for(var i = 0; i < obj_value_arr.length; i ++) {
			if(i < len && num + byteLength(obj_value_arr[i]) <= len) {
				num += byteLength(obj_value_arr[i]);
				strlen = i + 1;
			}
		}
		if(str.length > strlen) {
			newstr = str.substr(0, strlen);
		} else {
			newstr = str;
		}
		return newstr;
	}
	
	function textCounter(obj, showid, maxlimit) {
		var len = strLen(obj.value);
		var showobj = $("#"+showid);
		if(len > maxlimit) {
			obj.value = getStrbylen(obj.value, maxlimit);
			showobj.html('0');
		} else {
			showobj.html(maxlimit - len);
		}
		if(maxlimit - len > 0) {
			showobj.parentNode.style.color = "";
		} else {
			showobj.parentNode.style.color = "red";
		}
	}
	
	function isEmail(str){
		var reg = /^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/;
		return reg.test(str);
	}
	
	/**
	 / THIRD FUNCTION
	 * getPageScroll() by quirksmode.com
	 *
	 * @return Array Return an array with x,y page scroll values.
	 */
	function ___getPageScroll() {
		var xScroll, yScroll;
		if (self.pageYOffset) {
			yScroll = self.pageYOffset;
			xScroll = self.pageXOffset;
		} else if (document.documentElement && document.documentElement.scrollTop) {	 // Explorer 6 Strict
			yScroll = document.documentElement.scrollTop;
			xScroll = document.documentElement.scrollLeft;
		} else if (document.body) {// all other Explorers
			yScroll = document.body.scrollTop;
			xScroll = document.body.scrollLeft;	
		}
		arrayPageScroll = new Array(xScroll,yScroll);
		return arrayPageScroll;
	};
	
	/**
	 / THIRD FUNCTION
	 * getPageSize() by quirksmode.com
	 *
	 * @return Array Return an array with page width, height and window width, height
	 */
	function ___getPageSize() {
		var xScroll, yScroll;
		if (window.innerHeight && window.scrollMaxY) {	
			xScroll = window.innerWidth + window.scrollMaxX;
			yScroll = window.innerHeight + window.scrollMaxY;
		} else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
			xScroll = document.body.scrollWidth;
			yScroll = document.body.scrollHeight;
		} else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
			xScroll = document.body.offsetWidth;
			yScroll = document.body.offsetHeight;
		}
		var windowWidth, windowHeight;
		if (self.innerHeight) {	// all except Explorer
			if(document.documentElement.clientWidth){
				windowWidth = document.documentElement.clientWidth; 
			} else {
				windowWidth = self.innerWidth;
			}
			windowHeight = self.innerHeight;
		} else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
			windowWidth = document.documentElement.clientWidth;
			windowHeight = document.documentElement.clientHeight;
		} else if (document.body) { // other Explorers
			windowWidth = document.body.clientWidth;
			windowHeight = document.body.clientHeight;
		}	
		// for small pages with total height less then height of the viewport
		if(yScroll < windowHeight){
			pageHeight = windowHeight;
		} else { 
			pageHeight = yScroll;
		}
		// for small pages with total width less then width of the viewport
		if(xScroll < windowWidth){	
			pageWidth = xScroll;		
		} else {
			pageWidth = windowWidth;
		}
		arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight);
		return arrayPageSize;
	};
	
	function ringfoxPopWin(title,html,withgray,wait_sec,in_width){
		var div_popup;
		if (withgray)
			div_popup='<div id="ringfox-overlay" style="z-index:90;top:0;left:0;position:absolute"></div>';
		div_popup = div_popup + '<div class="popupmenu_centerbox" id="ringfoxPopContent" style="z-index:100"><h1>'+title+'</h1><a title="关闭" id="ringfoxClose" class="float_del">关闭</a><div class="popupmenu_inner">'+html+'</div></div>';
			
		$(document.body).append(div_popup);
		var arrPageScroll = ___getPageScroll();
		var arrPageSizes = ___getPageSize();
		
		$('#ringfox-overlay').css({
			backgroundColor:	"#000",
			opacity:			0.2,
			width:				arrPageSizes[0],
			height:				arrPageSizes[1]
		}).fadeIn();
		$("#ringfoxPopContent").css({
			width:	in_width,
			position:	"absolute",
			top:	arrPageScroll[1] + 100,
			left:	arrPageScroll[0] + (1000-in_width)/2
		}).show();
		$("#ringfoxClose").bind("click", function(){ringfoxCloseConfirm(wait_sec)});
		$("#ringfoxCancel").bind("click", function(){ringfoxCloseConfirm(wait_sec)});
	}
	
	function ringfoxCloseConfirm(waitSeconds)
	{
		s = parseInt(waitSeconds);
		var timeout = (s>0)?s*1000:0;
		setTimeout(function(){$('.popupmenu_centerbox').remove();$('#ringfox-overlay').remove();},timeout);
	}
	
	function getx(e)
	{
	  var l=e.offsetLeft;
	  while(e=e.offsetParent)
	  {
		l+=e.offsetLeft;
	  }
	  return(l);
	}

	function gety(e)
	{
	  var t=e.offsetTop;
	  while(e=e.offsetParent)
	  {
		t+=e.offsetTop;
	  }
	  return(t);
	}

	function ShowConfirm(windowName, obj, text)
	{
		//移除相关DOM对象
		$('#'+windowName).remove();
		
		//生成新的DOM对象并放进文档里
		var html = '<div id="'+windowName+'" class="dialog-1" style="position:absolute;"><div class="bd">';
		html += "<h3>"+text+"</h3>";
		html += "<div class=\"ft\"><p class=\"act\"><input id=\"ConfirmEnter\" name=\"ConfirmEnter\" class=\"f-button btn-confirm\" type=\"button\" value=\"确定\" /><input id=\"ConfirmClose\" name=\"ConfirmClose\" class=\"f-button f-alt btn-cancel\" type=\"button\" value=\"取消\" /></p></div>";
		html += "<div class=\"decor\"></div></div>";
		$("body").append(html);
		
		//绑定关闭事件
		$("#ConfirmClose").bind("click", function(){CloseConfirm()});
		//设置窗口坐标
		$('#'+windowName)[0].style.top = gety(obj) - $('#'+windowName)[0].offsetHeight;
		$('#'+windowName)[0].style.left = getx(obj) + (obj.offsetWidth/2) - ($('#'+windowName)[0].offsetWidth/1.25);
	}

	function ResetDialogXY(exp)
	{
		$(document).ready(function(){
			//设置窗口坐标
			$(exp)[0].style.width = 500;
			$(exp)[0].style.top =  ((document.documentElement.clientHeight - $(exp)[0].offsetHeight) / 2) + document.documentElement.scrollTop;
			$(exp)[0].style.left = ((document.documentElement.clientWidth  - $(exp)[0].offsetWidth)  / 2) + document.documentElement.scrollLeft;
			
			//
			$('.dialog-close')[0].style.top =  10;
			$('.dialog-close')[0].style.left = $(exp)[0].offsetWidth - 20;
			
			//设置背景半透明层大小
			$(".underlay")[0].style.width = $(exp)[0].offsetWidth;
			$(".underlay")[0].style.height = $(exp)[0].offsetHeight;
			$(".underlay")[0].style.padding = 8;
			$(".underlay")[0].style.top = -8;
			$(".underlay")[0].style.left = -8;
			
			$(".dialogBgDiv")[0].style.top = -$(exp)[0].offsetTop;
			$(".dialogBgDiv")[0].style.left = -$(exp)[0].offsetLeft;
			
			if(document.body.clientWidth > document.documentElement.clientWidth)
			{
				$(".dialogBgDiv")[0].style.width = document.body.clientWidth;
			}
			else
			{
				$(".dialogBgDiv")[0].style.width = document.documentElement.scrollWidth;
			}
			//alert($(".dialogBgDiv")[0].style.width);
			
			if(document.body.clientHeight > document.documentElement.clientHeight)
			{
				$(".dialogBgDiv")[0].style.height = document.body.clientHeight;
			}
			else
			{
				$(".dialogBgDiv")[0].style.height = document.documentElement.offsetHeight;
			}
		});
	}

	function CloseConfirm(waitSeconds)
	{
		var timeout = 1000;
		s = parseInt(waitSeconds);
		if(s > 0)timeout = s * 1000;
		else timeout = 0;
		setTimeout(function(){$('.dialog-1').remove();},timeout);
	}

	function ShowDialog(id,classname,content)
	{
		//
		if(classname == null || classname == "") classname = "dialog-2-c";
		
		//移除相关DOM对象
		$('.' + classname).remove();
		
		//替换button
		content=content.replace('$EnterButton','<input id="dialogEnter" name="dialogEnter" class="f-button" type="button" value="确定" />');
		content=content.replace('$CancelButton','<input id="dialog-end" class="f-button f-alt" name="cancel" type="button" value="取消" />');
		
		var html = '<div ';
		if(id != null && id != "") html += 'id="' + id + '" ';
		html += 'class="'+classname+'" style="Z-INDEX: 2; LEFT: 269px; VISIBILITY: visible; POSITION: absolute; TOP: 98px">';
		html += content;
		html += '<div class="underlay"></div><div class="dialog-close close" style="POSITION: absolute"></div>'
		html += '<div class="dialogBgDiv" style="background: #000000;position: absolute;opacity: 0.2;filter: alpha(opacity=20);z-index: 11;"></div>';
		$("body").append(html);
		
		//绑定关闭事件
		$("#dialog-end").bind("click", function(){CloseDialog(0,classname)});
		$(".dialog-close").bind("click", function(){CloseDialog(0,classname)});
		
		//调整xy坐标
		ResetDialogXY('.' + classname);
		$('.' + classname).resize(function(){ResetDialogXY('.' + classname);});
	}
	function CloseDialog(waitSeconds,classname)
	{
		//
		if(classname == null || classname == "") classname = "dialog-2-c";
		
		//
		var timeout = 1000;
		s = parseInt(waitSeconds);
		if(s > 0)timeout = s * 1000; else timeout = 0;
		
		//
		setTimeout(function(){$('.' + classname).remove();$('.underlay').remove();},timeout);
	}

	function ShowDialog2c(id,title,content)
	{
		var html = '<div '
		if(id != null && id != "") html += 'id="' + id + '" ';
		html += 'class="dialog-2" style="Z-INDEX: 2; POSITION: relative">';
		if(title != '') html += '<div class="hd"><h3>'+title+'</h3></div>';
		html += '<div class="bd">'+content+'</div><div class="ft">$EnterButton$CancelButton</div></div>';
		ShowDialog(null,"dialog-2-c",html);
	}

	function ShowAdvancedDialog(title, content)
	{
		var html = '<div class="dialog-content">';
		if(title != '') html += '<h3>'+title+'</h3>';
		html += '<div class="dialog-content">'+content;
		html += '<form><input id=\"dialogEnter\" name=\"dialogEnter\" class=\"f-button\" type=\"button\" value=\"确定\" /><input id="dialog-end" class="f-button f-alt" name="cancel" type="button" value="取消" /></form></div></div>';
		ShowDialog(null,"dialog-advanced",html);
	}

	function CloseAdvancedDialog(waitSeconds)
	{
		CloseDialog(waitSeconds, "dialog-advanced")
	}
	function ShowAdvancedDialog2(title, leftimage, content)
	{
		var html = "<p class=\"image\"><table><tr><td><img src=\""+leftimage+"\" /></td></tr></table></p><div class=\"info\"><p>"+content+"</p></div>";
		ShowAdvancedDialog(title, html);
	}

	function register_user_preview(){
		$("#dogs-profile").bind("mouseenter",function(){
			console.log("dog");
		});
		var onUserPreview = false;
		var closewaiter;
		function onShowUserPanel(){
				clearTimeout(closewaiter);
				$(".user_preview").remove();
				var div_preview = '<div class="user_preview"><ul><li><a href="/wo/'+$(this).attr("rel")+'">空间</a></li><li><a href="/albumlist/'+$(this).attr("rel")+'">相册</a></li><li><a href="/laodaolist/'+$(this).attr("rel")+'">唠叨</a></li><li><a href="/bloglist/'+$(this).attr("rel")+'">日记</a></li><li><a href="/actlist/'+$(this).attr("rel")+'">动态</a></li><li><a href="/friendslist/'+$(this).attr("rel")+'">好友</a></li><li><a href="/wall/'+$(this).attr("rel")+'">留言</a></li></ul></div>';
				$(document.body).append(div_preview);
				$(".user_preview").hide();
				$(".user_preview").animate({
                        height: 'show'
                }, 500);
				var offset = $(this).offset();
				$(".user_preview").css("left",offset.left+$(this).width()+2);
				$(".user_preview").css("top",offset.top);
				$(".user_preview").bind("mouseenter",function(){
					onUserPreview = true;
				});
				$(".user_preview").bind("mouseleave",function(){
					onUserPreview = false;
					$(".user_preview").remove();
				});
		}
		
		$(".small_user_avatar").each(function(){
			$(this).bind("mouseenter",onShowUserPanel);
			$(this).bind("mouseleave",function(){
				closewaiter=setTimeout(function(){
					if (!onUserPreview)
						$(".user_preview").remove();
				},1000);
			});
		});
	}
	
	function show_space_magic_album(aid,show){
		if (show){
			$("#space_magic_area").html('<div style="width:400px;height:298px;"><embed src="/widgets/magic_album.swf" flashvars="aid='+aid+'" type="application/x-shockwave-flash" width="400" height="298"></embed><div align="right"><a href="javascript:void(0)" onclick="show_space_magic_album(0,false)">隐藏</a></div></div>');
			$("#space_magic_area").hide();
			$("#space_magic_area").animate({
                        height: 'show'
                }, 800);
		}
		else
			$("#space_magic_area").html("");
	}
	
	function register_slide_vote_bar(){
		//$(".vote_bar_mid").css("width","0px");
		$(".vote_bar_left").hide();
		$(".vote_bar_right").hide();
		$(".vote_bar_mid").hide();
		$(".vote_bar_mid").animate({ 
		        width:'show'
      		}, 1000,function(){
				$(".vote_bar_left").show();
				$(".vote_bar_right").show();
				$(".vote_bar_mid").css("display","inline");
			} );
	}
	function register_label_image(){
		var xStart=60;
		var yStart=150;
		var rectW=50;var rectH=50;
		$("#mainpic").click(function(e){
					var offset = $(this).offset();
					$("#crop_border").show();
					$("#crop_border").css("left",e.pageX);
					$("#crop_border").css("top",e.pageY);
					//$("#crop_border").html("x:"+e.pageX+",y:"+e.pageY+"<br />");
		});
		function isInRect(pointx,pointy,rectx,recty,rectw,recth){
			return ((pointx>rectx)&&(pointx<rectx+rectw)&&(pointy>recty)&&(pointy<recty+recth));
		}
		$("#mainpic").mousemove(function(e){
			var offset = $(this).offset();
			if (isInRect(e.pageX,e.pageY,xStart+offset.left,yStart+offset.top,rectW,rectH)){
				$("#name_label").remove();
				var div_name_label = '<div id="name_label">阿牧</div>';
				$(document.body).append(div_name_label);
				$("#name_label").css("left",xStart+offset.left);
				$("#name_label").css("top",yStart+offset.top+rectH);
			}else{
				$("#name_label").remove();
			}
		});
	}
	
	function on_del_blog(bid,obj) {
		ShowConfirm('del_blog',obj,'确定要删除这篇日记么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			location.href="/blog.php?a=deleteb&bid="+bid;
			$('.dialog-1').remove();
		});
	}
	
	function on_del_blog_review(rid,obj) {
		ShowConfirm('del_blog_review',obj,'确定要删除这条日志评论么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			location.href="/blog.php?a=deletereview&rid="+rid;
			$('.dialog-1').remove();
		});
	}
	
	function on_del_laodao_review(lid,rid,obj) {
		ShowConfirm('del_laodao_review',obj,'确定要删除这条唠叨评论么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			location.href="/laodao.php?a=del_review&lid="+lid+"&rid="+rid;
			$('.dialog-1').remove();
		});
	}
	
	function on_del_photo_review(rid,pid,obj) {
		ShowConfirm('del_photo_review',obj,'确定要删除这条照片评论么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			location.href="/photo.php?a=del_review&rid="+rid+"&pid="+pid;
			$('.dialog-1').remove();
		});
	}
	
	function on_del_topic(eid,gid,obj) {
		ShowConfirm('del_topic',obj,'确定要删除这个话题么，这样会导致对这个话题的所有话题被移除？')
		$("#ConfirmEnter").bind("click", function()
	    {
			location.href="/group.php?a=del_topic&eid="+eid+"&gid="+gid;
			$('.dialog-1').remove();
		});
	}
	
	/* *************************** ajax area start **************************************/
	function ajx_approve_request(rid){
		$.post("/inc/jq_ajax_server.php?a=accept_req&p1="+rid,
			function(data){
				var obj = eval('('+data+')') ;
				if (obj.type==3)
					$("#request_"+rid).html('<div class="success">你加入了圈子 <a href="/group/'+obj.gid+'">'+obj.groupname+'</a></div> ');
				else
					$("#request_"+rid).html('<div class="success">你和<a href="/wo/'+obj.dest_pid+'">'+obj.dest_pname+'</a>成为好友了，去看看TA吧</div>');
			}
			,"json"
		); 
	}
	
	function ajx_ignore_request(rid){
		$.post("/inc/jq_ajax_server.php?a=ignore_req&p1="+rid,
			function(data){
				if (data&&(data=="ok"))
					$("#request_"+rid).hide();
			}
			,"text"
		); 
	}
	
	function ajx_space_fav_dog(pid,did){
		$.post("/inc/jq_ajax_server.php?a=fav_dog&p1="+pid+"&p2="+did,
			function(data){
				if (data&&(data=="ok"))
					$("#request_fav_dog_"+did).html("谢谢支持");
			}
			,"text"
		); 
	}
	
	function ajx_space_auth_trueman(pid){
		$.post("/inc/jq_ajax_server.php?a=auth_trueman&p1="+pid,
			function(data){
				if (data&&(data=="ok"))
					$("#btn_auth_trueman").html("通过认证");
			}
			,"text"
		); 
	}
	
	function ajx_quiz_is_right(qid,right){
		$.post("/inc/jq_ajax_server.php?a=set_quiz_right&p1="+qid+"&p2="+right,
			function(data){
				if (data){
					if (data==1)
						$("#area_is_quiz_right").html("你觉得这个测试准确");
					else if (data==0)
						$("#area_is_quiz_right").html("你觉得这个测试不准确");
					else
						$("#area_is_quiz_right").html("请求错误");
				}
			}
			,"text"
		); 
	}
	
	function add_to_friend(dest_pid) {
		ringfoxPopWin('申请成为Ta的好友？','<table class="form-layout"><tbody><tr><th>申请附言：</th><td><textarea name="share_desc" id="share_desc" style="width:420px" rows="4"></textarea></td></tr></tbody></table><div align="right"><button id="ringfoxEnter" class="submit">加为好友</button></div>',1,0,500);
		$("#ringfoxEnter").bind("click",function(){
			var desc = $("#share_desc").attr("value");
			if (typeof(desc)=='undefined') desc='';
			xajax_add_to_friend(dest_pid,desc);
			$("#ringfoxPopContent").html("<img src='/img/loading1.gif' />正在发送请求，请稍候...");
			ringfoxCloseConfirm(2);
		});
	}
	
	function popAddLaodao() {
		ringfoxPopWin('唠叨一句','<table class="form-layout"><tbody><tr><th>内容</th><td><textarea name="share_desc" id="share_desc" style="width:420px" rows="4"></textarea></td></tr></tbody></table><div align="right"><button id="ringfoxEnter" class="submit">发出</button></div>',1,0,500);
		$("#ringfoxEnter").bind("click",function(){
			var desc = $("#share_desc").attr("value");
			if (typeof(desc)=='undefined') desc='';
			xajax_append_laodao_pop(desc);
			$("#ringfoxPopContent").html("<img src='/img/loading1.gif' />正在发送请求，请稍候...");
			ringfoxCloseConfirm(2);
		});
	}
	
	function ajx_bind_msn() {
		ringfoxPopWin('绑定MSN','<table class="form-layout"><tbody><tr><th>MSN邮箱：</th><td><input name="share_desc" id="share_desc" style="width:220px" /></td></tr></tbody></table><div align="right"><button id="ringfoxEnter" class="submit">绑定</button></div>',1,0,500);
		$("#ringfoxEnter").bind("click",function(){
			var desc = $("#share_desc").attr("value");
			if (typeof(desc)=='undefined') desc='';
			xajax_bind_msn(desc);
			$("#ringfoxPopContent").html("<img src='/img/loading1.gif' />正在提交请求，请稍候...");
			ringfoxCloseConfirm(2);
		});
	}
	
	function reply_wall(wid) {
		ringfoxPopWin('回复留言','<table class="form-layout"><tbody><tr><th>内容：</th><td><textarea name="pop_content" id="pop_content" style="width:420px" rows="4"></textarea></td></tr></tbody></table><div align="right"><button id="ringfoxEnter" class="submit">回复</button></div>',1,0,500);
		$("#ringfoxEnter").bind("click",function(){
			var pop_content = $("#pop_content").attr("value");
			xajax_reply_wall(wid,pop_content);
			$("#ringfoxPopContent").html("<img src='/img/loading1.gif' />正在发送请求，请稍候...");
			ringfoxCloseConfirm(2);
		});
	}
	function post_wall(pid) {
		ringfoxPopWin('发表留言','<table class="form-layout"><tbody><tr><th>内容：</th><td><textarea name="pop_content" id="pop_content" style="width:420px" rows="4"></textarea></td></tr></tbody></table><div align="right"><button id="ringfoxEnter" class="submit">回复</button></div>',1,0,500);
		$("#ringfoxEnter").bind("click",function(){
			var pop_content = $("#pop_content").attr("value");
			xajax_append_wall("insert",pid,pop_content);
			$("#ringfoxPopContent").html("<img src='/img/loading1.gif' />正在发送请求，请稍候...");
			ringfoxCloseConfirm(2);
		});
	}
	
	function show_poke(pid,name,thumb) {
		ringfoxPopWin('给'+name+'打招呼','<table class="form-layout"><tbody><tr><th><img src="'+thumb+'" /></th><td valign="top"><a href="/wo/'+pid+'">'+name+'</a>将会在新鲜事中看到你给他打招呼</td></tr></tbody></table><div align="right"><button id="ringfoxCancel" class="submit">知道了</button></div>',1,0,500);
	}
	
	function set_impression(pid,iid){
		$("#lbl_status").html("正想TA发送你的评价，请稍候...");
		$.post("/inc/jq_ajax_server.php?a=set_impression&p1="+pid+"&p2="+iid,
			function(data){
				if (data&&(data=="ok"))
					location.href="/impression.php?a=all";
			}
			,"text"
		); 
	}
	/* *************************** ajax area end   **************************************/
	
	function delete_activity(pid,aid,obj){
		ShowConfirm('del_activity',obj,'确定要删除这条动态么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			xajax_del_activity(pid,aid);
			$('.dialog-1').remove();
		});
	}
	
	function copy_music(musicid,obj){
		ShowConfirm('copy_music',obj,'确定要把这首歌添加进我的音乐盒么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			xajax_copy_music_to_box(musicid);
			$('.dialog-1').remove();
		});
	}
	
	function check_submit(){
		if(document.f.nickname.value=="")
		{
			alert("对不起，请输入昵称")
			document.f.nickname.focus()
			return false;
		}
		if (document.f.email.value=="")
		{
			alert("对不起，邮箱地址还没有输入")
			document.f.email.focus()
			return false;
		}else if (!isEmail(document.f.email.value)){
			alert("对不起，邮箱格式有误，请检查一下")
			document.f.email.focus()
			return false;
		}
		if(document.f.password.value=="")
		{
			alert("对不起，密码没有输入")
			document.f.password.focus()
			return false;
		}
		return true;
	}
	
	function playvideo(areaid){
		if ($("#video_player_"+areaid).css("display")=="none"){
			$("#video_player_"+areaid).css("display","block");
			$("#video_control_"+areaid).css("display","none");
		}else{
			$("#video_player_"+areaid).css("display","none");
			$("#video_control_"+areaid).css("display","block");
		}
	}
	
	function expand_laodao_replies(areaid){
		if ($("#laodao_replies_"+areaid).css("display")=="none"){
			$("#laodao_replies_"+areaid).css("display","block");
			xajax_laodao_replies('get',areaid,0);
		}else{
			$("#laodao_replies_"+areaid).css("display","none");
		}
	}
	
	function append_wall(action,pid) {
		if (action == "insert"){
			var content = $('#wallcontent').val();
			if ((content=="")||(content.indexOf("过滤内容")>0)||(content.indexOf("url=")>0)){
				alert("内容不合法!");
				return;
			}
			$('#btn_append_wall').val("正在提交...");
			xajax_append_wall(action,pid,content);
		}else{
			$('#btn_append_wall').val("正在加载...");
			xajax_append_wall(action,pid,"0");
		}
	}
	
	function save_laodao_reply(lid){
		var replyto = $('#laodao_replyto_'+lid).val();
		var content = $('#input_laodao_reply_'+lid).val();
		xajax_laodao_replies('insert',lid,replyto,content);
	}
	
	function del_wall(pid,wid,obj) {
		ShowConfirm('del_laodao',obj,'确定要删除这条留言么？')
		$("#ConfirmEnter").bind("click", function()
	    {
			xajax_del_wall(pid,wid);
			$('.dialog-1').remove();
		});
	}
	
	function reply_photo_review(rid,pid,pname){
		$("#txt_reply2_area").css("display","block");
		$("#txt_reply2_pname").html(pname);
		$("#reply2_rid").val(rid);
		$("#reply2_pid").val(pid);
		$("#reply2_pname").val(pname);
	}
	
	function reply_blog_review(pid,nickname,content){
		$("#txt_reply2_area").html('<div class="quote"><span class="q"><b>'+nickname+'：</b>'+content+'</span></div>');
		$("#input_reply_quote").val('<b>'+nickname+'：</b>'+content);
		$("#reply2_pid").val(pid);
	}
	
	function reply_laodao_review(pid,nickname,content){
		$("#txt_reply2_area").html('<div class="quote"><span class="q">回复：<b>'+nickname+'</b></span></div>');
		$("#reply2_pid").val(pid);
	}
	
	function set_review_reminder(){
		$(".reply2").each(function(){
			$(this).mouseover(function(){
				$("#post"+$(this).attr("id")).css("border","1px dashed #F00");
			});
			$(this).mouseout(function(){
				$("#post"+$(this).attr("id")).css("border","");
			});
		});
	}
	function on_del_album(eid,obj) {
		ShowConfirm('del_album',obj,'确定要删除这个相册么？（注意：相册里的相片也会被同时删除）')
		$("#ConfirmEnter").bind("click", function()
	    {
			location.href="/album.php?a=deletea&eid="+eid;
			$('.dialog-1').remove();
		});
	}
	function register_faces_preview(){
		$(".facebutton").each(function(){
			$(this).mouseover(function(){
				var faceprv = '<div class="facepreview"><img src="/thumbs/faces_set1/'+$(this).attr("id")+'.gif" /></div>';
				$(document.body).append(faceprv);
				var offset = $(this).offset();
				$(".facepreview").css("left",offset.left);
				$(".facepreview").css("top",offset.top - 80);
			});
			$(this).mouseout(function(){
				$(".facepreview").remove();
			});
		});
	}
	function addFace(objname,face)
	{
		/*if (window.ActiveXObject){  //ie
			$('#'+objname).focus();
			document.execCommand('paste','',face);
		}else{*/
			$('#'+objname).val($('#'+objname).val()+face);
		//}
	}
	
	//************** 拖动 start *****************
	//定义移动对象和移动坐标
	var Mouse_Obj="none",_x,_y;
	//拖动对象函数(自动)
	document.onmousemove=function()
	{
		if(Mouse_Obj!=="none")
		{
		//document.getElementById(Mouse_Obj).style.left=_x+event.x;
		//document.getElementById(Mouse_Obj).style.top=_y+event.y;
		$("#"+Mouse_Obj).css("left",_x+event.x);
		$("#"+Mouse_Obj).css("top",_y+event.y);
		$("#"+Mouse_Obj+"_msg").css("left",$("#"+Mouse_Obj).css("left") );
		$("#"+Mouse_Obj+"_msg").css("top",parseInt($("#"+Mouse_Obj).css("top"))-40);
		event.returnValue=false;
		}
	}
	//停止拖动函数(自动)
	document.onmouseup=function()
	{
		Mouse_Obj="none";
	}
	//确定被拖动对象函数 o为被拖动对象
	function m(o)
	{
		Mouse_Obj=o;
		_x=parseInt(document.getElementById(Mouse_Obj).style.left)-event.x;
		_y=parseInt(document.getElementById(Mouse_Obj).style.top)-event.y;
	}
	function petSay(str){
		//if (!canSkip)&&($("#video_player_"+areaid).css("display")=="block"){
		//clearTimeOut
		$('#mypet_msg').show();
		$("#_petMsgBox").html(str);
		setTimeout(function(){$('#mypet_msg').hide();},5000);
	}
	function petConfirm(str){
//		var answer=window.confirm(str);
//		return "test";
		alert(str);
	}
	//************** 拖动 end   *****************

	function newpm() {
		var obj = $('#span_newpm');
		if(obj.css("color")=="red") {
			obj.css("color","");
			document.title = document.title.replace(/○/g,"");
			document.title="⊙⊙⊙"+document.title;
		} else {
			obj.css("color","red");
			document.title = document.title.replace(/⊙/g,"○");
		}
		setTimeout("newpm();", 1000);
	}
	
	function local_play_music_eee(url){
		var html = '<embed src="'+url+'" align="baseline" border="0" width="350" height="68" 					type="application/x-mplayer2" pluginspage="" name="MediaPlayer1" showcontrols="1" showpositioncontrols="0" showaudiocontrols="1" showtracker="1" showdisplay="0" showstatusbar="1" autosize="0" showgotobar="0" showcaptioning="0" autostart="1" autorewind="0" animationatstart="0" transparentatstart="0" allowscan="1" enablecontextmenu="1" clicktoplay="0" 					defaultframe="datawindow" invokeurls="0"></embed>';
		alert(html);
		$("#area_music_preview").html(html);
	}
	function local_play_music(musicurl){
		var html = '<object width="350" height="68" classid="CLSID:6BF52A52-394A-11d3-B153-00C04F79FAA6" id="wmp10"><param name="PlayCount" value="30"><param NAME="autostart" VALUE="1"><param NAME="clicktoplay" VALUE="0"><param name="AutoStart" value="1"><param name="url" value="'+musicurl+'" /><embed width="350" height="68" autostart="1" showdisplay="0" clicktoplay="0" type="application/x-mplayer2" src="'+musicurl+'" AutoStart="1" PlayCount="30"></embed></object>';
		$("#area_music_preview").html(html);
	}
	
	function preview_upload_pic(txtName)
	{
		var txtValue = $("#"+txtName).val();
		if (txtValue){
			var fileext=txtValue.substring(txtValue.lastIndexOf("."),txtValue.length)
		  fileext=fileext.toLowerCase()
		  if ((fileext!='.jpg') && (fileext!='.gif') && (fileext!='.jpeg') && (fileext!='.png'))
			{
			  alert("对不起，系统仅支持标准格式的照片，请您调整格式后重新上传，谢谢 ！");
			  //document.form1.UpFile.focus();
			}
			else
			{
				document.getElementById("div_preview_upload_pic").innerHTML="<img src='"+txtValue+"' width=120 style='border:1px solid #ccc;padding:2px;'>"
			}
		}
	}
	function on_del_friend(dest_id,obj) {
		ShowConfirm('del_laodao',obj,'确定要和TA脱离好友关系么？（注意：解除好友关系以后，TA的动态将不显示在你的新鲜事中）')
		$("#ConfirmEnter").bind("click", function()
	    {
			xajax_del_friendship(dest_id);
			$('.dialog-1').remove();
		});
	}