/*
	author:zengyanglin
	lastdate:2009-11-17 17:00
	version:1.01
*/


function addfavorite() {
	if (document.all) {
		window.external.addFavorite(window.location.href, document.title);
	} else {
		if (window.sidebar) {
			window.sidebar.addPanel(document.title, window.location.href, "");
		}
	}
}

function setHomePage(url) {
	if (document.all) {
		document.body.style.behavior = "url(#default#homepage)";
		document.body.setHomePage(url);
	}
	if (window.netscape) {
		try {
			netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
		}
		catch (e) {
		}
	}
	var prefs = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefBranch);
	prefs.setCharPref("browser.startup.homepage", url);
}





function addmini(miniurl,obj){
				
				var offsetleft=$(obj).offset().left;
				var offsettop=$(obj).offset().top+$(obj).innerHeight();
				
	    		var content=$.trim($("#ctnt").val());
	    		var point=parseInt($("#point").val());
	    		if (content==''||content=='我在做什么……'){
	    			$.msgbox.confirmbox("","添加迷你博客,内容不能为空!",offsetleft,offsettop);
	    			$.msgbox.closemsgbox(2000);
	    			return false;
	    		}
	    		else if(point<=-100){
	    			$.msgbox.confirmbox("","添加迷你博客,你的银币数小于-100！不能发表！",offsetleft,offsettop);
	    			$.msgbox.closemsgbox(2000);
	    			return false;
	    		}
	    		else{
						$.ajax({
								url:miniurl+"?callback=?&content="+encodeURI(encodeURI(content)),
								dataType: "jsonp",
								cache:false,
								success:function(html){
									$.msgbox.confirmbox("","添加迷你博客,"+html.items,offsetleft,offsettop);
									$("#ctnt").val('');
								},
								error:function(){
										$.msgbox.confirmbox("","添加迷你博客,提交失败！",offsetleft,offsettop);
								},
								beforeSend:function(){
										$.msgbox.confirmbox("","添加迷你博客,提交中！",offsetleft,offsettop);
								},
								complete: function(){
								$.msgbox.closemsgbox(2000);
											return false;
								}					
							});
	    		}
}


			   //显示输入用户名的窗口
			   function showInputPopwin(cluburl){
				   $.ajax({
						  url:"common/forgetPassword.jsp",
						  cache:false,
						  success:function(html){
							  $forgetPasswordPopwin=$.msgbox.popupwin(250,100,"取回密码",html);
							  sendPassword($forgetPasswordPopwin,cluburl);
							  },
						  error:function(){$.msgbox.msgbox(150,100,"取回密码","页面读取失败！")},
						  beforeSend:function(){$.msgbox.msgbox(150,100,"取回密码","页面读取中！")},
						  complete: function(){}
						  })
				   }
				   
			   //发送密码
			   function sendPassword($obj,cluburl){
				   var $userNameObj=$obj.find("#username");
				   var $aSendPassword=$obj.find("#a_sendpassword");
				   var $sendPasswordMsg=$obj.find("#sendpasswordmsg");
				   
				   $aSendPassword.click(function(){
												 $sendPasswordMsg.html("");
												 if ($userNameObj.val()==""){
													 //$sendPasswordMsg.html("请输入需要取回密码的用户名！");
													 $aSendPassword.next().html("请输入需要取回密码的用户名！");
													 }else{ 
													 $aSendPassword.next().html("密码发送中！");
													 var $this=$(this);
													 $this.hide();
													 $.ajax({
															url:cluburl+"portlet/user/sendPassword.do?callback=?",
															data:"username="+$userNameObj.val(),
															cache:false,
															dataType: "jsonp",
															success:function(html){
															//alert(html);
																if (html.error == 1 ){
																	$aSendPassword.next().html("密码发送至您的邮箱！");
																	$.msgbox.closemsgbox(1000);
																	}else{
																	$aSendPassword.next().html("密码取回失败！");
																	$this.show();
																	}
																},
															error:function(){$aSendPassword.next().html("密码取回失败！");},
															beforeSend:function(){$aSendPassword.next().html("密码发送中！");},
															complete: function(){}
															})
													 }
												 })
				   }
			   