	var statusHtml ="<img src=\""+jspicpath+"loading.gif\">&nbsp;&nbsp;&nbsp;&nbsp;载入中，请稍后......";
	var statusHtml2 ="<img src=\""+jspicpath+"loading.gif\">&nbsp;&nbsp;请求执行中，请稍后......";
				var infoform;
				var ff = "";
				var user_id,user_name,letters;
				function show_login(hf){
					if(typeof hf=="undefined"){
						ff="";
					}
					var searchOrder = rootPath+"components/login_box.jsp";
					infoform=alert("&nbsp;");
					infoform.setURL(searchOrder);
					infoform.setTitle("登录豆勺网");
				}
				function login(user_name,user_pass,remember){
					var searchOrder = "user_name="+user_name+"&user_pass="+user_pass;
					if(remember){
						searchOrder +="&rememeber=1";
					}
					var statuinfo = statusInfo(statusHtml);
					new Ajax.Request(rootPath+"LoginServlet",{
						method:'post',
						encoding:"UTF-8",
						postBody:searchOrder,
						onSuccess: function(originalRequest){
							var res = originalRequest.responseText;
							if(res.trim() == "no"){
								showErr('login_err_span','用户名或密码错误');
								statuinfo.closeAfter(0.1);
								return;
							}else if(res.trim() == "status_err"){
								showErr('login_err_span','该帐号违反豆勺条例，已被封锁');
								statuinfo.closeAfter(0.1);
								return;
							}else{
								var   strArray=new   Array();
								strArray=res.trim().split("&"); 
								user_id = strArray[0].split("=")[1];
								user_name = strArray[1].split("=")[1];
								letters = strArray[2].split("=")[1];
								var htmls = "您好，<span style='color: #f60;margin:0px'>"+user_name+"</span>&nbsp;|&nbsp;";
								if(letters >0){
									htmls += "<a  class='link_04' href='"+rootPath+"my/my_msg.jsp'><img src='"+staticPath+"img/help/has_msg.gif' alt='您有"+letters+"封站内信'/></a>"
								}else{
									htmls += "<a class='link_04' href='"+rootPath+"my/my_msg.jsp'>站内信</a>	"
								}
								htmls +="&nbsp;|&nbsp;<a class='link_04' href='"+rootPath+"my/'>个人中心</a>&nbsp;|&nbsp;"+
								"<a class='link_04' href='javascript:out_login();'>安全退出</a>";
								$("usin").innerHTML=htmls;
								if(ff != ""){ 
									infoform.closeAfter(0.1)
									setTimeout(ff,300);
									ff = "";
								}else{
									infoform.closeAfter(0.1)
									document.location.href=document.location.href;
							 	}
							 	statuinfo.closeAfter(0.1);
							}
						}
					});
					
				}
				function out_login(b){
					htmls ="<font class='floatL' style='margin-right: 141px'>你好，欢迎来到豆勺网</font>&nbsp;&nbsp;&nbsp;&nbsp;<font class='floatL'>"+
								"请先</font><a href='/reg/register.jsp' class='link_01 line18 textC floatL marginL5 marginR5 marginT5 jpg_01'"+
								">注册</a><font class='floatL'>或</font><a href='javascript:show_login();' class='link_01 line18 textC floatL"+
								" marginL5 marginT5 jpg_01'>登录</a>";
					$("usin").innerHTML=htmls;
					var searchOrder = rootPath+"reg/login_out.jsp";
					new Ajax.Request(searchOrder,{
						method:'post',
						encoding:"UTF-8",
						postBody:searchOrder,
						onSuccess: function(originalRequest){
							if(b){
								document.location.href=document.location.href;
							}
						}
					});
				}
				function is_login(f){
					var searchOrder = rootPath+"reg/is_login.jsp";
					new Ajax.Request(searchOrder,{
						method:'post',
						encoding:"UTF-8",
						postBody:searchOrder,
						onSuccess: function(originalRequest){
							var res = originalRequest.responseText;
							if(res.trim() == "true"){
								setTimeout(f,100);
							}else{
								ff = f;
								setTimeout("show_login('hf')",100);
							}
						}
					});
				}
				var ss;
				function show_send_msg(name,title,uid,rep_id){
					ss = alert("&nbsp;");
					ss.setTitle("发送留言");
					if(title != null ){
						ss.setTitle("回复留言");	
					}
					var url = rootPath+"my/comp/send_msg_div.jsp";
					if(typeof(name)!="undefined"){
						url += "?user_name=";
						url += name;
					}
					if(typeof(title)!="undefined" && title != null){
						url += "&msg_title=";
						url += title;
					}
					if(typeof(uid)!="undefined"){
						url += "&user_id=";
						url += uid;
						url += "&rep_id=";
						url += rep_id;
					}
					ss.setURL(encodeURI(url));
				}
				function send_msg(f){
					var statuinfo = statusInfo(statusHtml,1);
					new Ajax.Request(rootPath+"SendMsgServlet",{
						method:'post',
						encoding:"UTF-8",
						parameters: Form.serialize(f),
						onSuccess: function(originalRequest){
							var res = originalRequest.responseText;
							statuinfo.closeAfter(0.1);
							if(res.trim() == "login_err"){
								_alert("请先登陆");
								ss.closeAfter(0.1);
								show_login();
							}
							if(res.trim() == "rec_ismy"){
								showErr('send_user_err','不能给自己发送消息');
							}else if(res.trim()=="user_err"){
								showErr('send_user_err','没有找到该用户');
							}else if(res.trim()=="title_err"){
								showErr('send_title_err','标题不能少于4个字或超过32字');
							}else if(res.trim()=="content_err"){
								showErr('send_content_err','内容不能少于4个字或超过1000字');
							}else if(res.trim()=="send_succ"){
								alert("发送成功");
								ss.closeAfter(0.1);
							}else if(res.trim()=="send_fail"){
								alert("发送失败");
							}	
							
						}
					});
				}
				function showErr(id,cont){//显示错误信息
					if($(id)!=null){
						$(id).innerHTML=cont;
						$(id).style.display="";
					}
				}
				function hiddErr(id){//隐藏错误信息
					if($(id)!=null){	
						$(id).innerHTML="";
						$(id).style.display="none";
					}
				}
				function show(im){
					im.src=rootPath+"CheckCodeServlet?"+new Date;
					//注意这里的new Date一定要加上，否则只会生成一次验证码
				}
				
				var add_coll;
				function add_collection(b,t,reload){
					param="";
					if(b){
						param = "url="+encodeURIComponent(document.location.href);
						param +="&title="+document.title;
						param +="&type="+t;
						param +="&reload="+reload;
					}else{
						param += "reload="+reload;
					}
					new Ajax.Request(rootPath+"my/comp/add_collection.jsp",{
						method:'post',
						encoding:"UTF-8",
						parameters:param,
						onSuccess: function(originalRequest){
							var res = originalRequest.responseText;
							add_coll = alert("");
							add_coll.setContent(res.trim());
							add_coll.setTitle("添加到我的收藏");
						}
					});
				}
				function add_url(f){
					if(f.c_title.value==""){
						_alert("标题不能为空");
						return false;
					}
					if(f.c_url.value==""){
						_alert("链接地址不能为空");
						return false;
					}
					new Ajax.Request(rootPath+"my/comp/add_coll.jsp",{
						method:'post',
						encoding:"UTF-8",
						parameters: Form.serialize(f),
						onSuccess: function(originalRequest){
							var res = originalRequest.responseText;
							if(res.trim() == "no_login"){
								show_login()
							}else if(res.trim() == "true"){
								//document.location.reload();
								_alert("添加成功！！");
								add_coll.closeAfter(0.1);
								if(f.reload.value == "true"){
									document.location.href=document.location.href;
								}
							}else if(res.trim() == "false"){
								_alert("添加失败，请稍后再试");
							}else if(res.trim() == "title_long"){
								_alert("标题太长，请不要超过100字符");
							}else if(res.trim() == "url_long"){
								_alert("链接地址太长，请不要超过1000字符");
							}else if(res.trim() == "type_err"){
								_alert("请选择链接分类");
							}else if(res.trim() == "info_err"){
								_alert("链接描述太长，请不要超过5000字符");
							}else if(res.trim() == "label_err"){
								_alert("标签长度太长，请不要超过256字符");
							}else if(res.trim() == "add_err"){
								_alert("错误！请刷新后重新修改");
							}else{
								document.location.href = document.location.href ;
							}
							
						}
					});
				}