function tuichu()
{
	exitUI();
	if(confirm("确实要退出吗？")){
		window.location.href="/pub/loginOut.jsp?url=/blog";
	}else{
		exitUI_();
	}
}

function showLeaveWord(id1,pic){
	//alert("typeof id2");
	if(typeof id1!='undefined')
		vis(id1);
	if(id1.style.display=='none')
		pic.src=picPath+"sort_asc.gif";
	else
		pic.src=picPath+"sort_desc.gif";
}
function getBlogTop(isVisAll,onclick){
	if(typeof isVisAll =='undefined')isVisAll=true;
	if(!onclick)onclick="visAll('"+picPath+"')";
	//alert(onclick);
return  "<table height=\"25\" cellSpacing=0 cellPadding=0 width=\"100%\" align=center border=\"0\" class='FaBuTB'>" +
		   "<TR><td align='right'>"+(isVisAll?
			   "<span style=\"cursor:hand\" align='right' onclick="+onclick+" ><img id='visAllPic' src='"+picPath+"light-on.gif' align='absmiddle' height='25'>&nbsp;&nbsp;&nbsp;</span>":"&nbsp;")+
	   "</TD><TD width=\"87\" background=\""+picPath+"dim.gif\" class=\"FaBu\"" +
	   " onclick=\"newBlog()\" >发布文章</TD><td width='15'></td></TR></TABLE>";
}
function showComment()
{
	visAll(picPath);
}
function showBlog(id1,id2,pic){
	//alert("typeof id2");
	try{
	if(typeof id1!='undefined')
		vis(id1);
	if(typeof id2!='undefined')
		vis(id2);
	if(id1.style.display=='none')
		pic.src=picPath+"sort_asc.gif";
	else
		pic.src=picPath+"sort_desc.gif";
	}catch(e){}
}


function proessHttpRequest(){
	//alert("处理请求："+action);
	if (http_request.readyState == 4) {
		if (http_request.status == 200)
		{
			var result=trim(http_request.responseText);
			//alert(result);
			if(action=="getBlogWithComment" || action=='getLeaveWord' || action=="namecard"){
				allHide=trim(result.substring(0,result.indexOf("#")));
				result=trim(result.substring(result.indexOf("#")+1));
			}
			//alert(allHide);
			//alert(result);
			if(action=="namecard"){
				var BID="";
				BID=trim(result.substring(0,result.indexOf("#")));
				result=trim(result.substring(result.indexOf("#")+1));
				showNamecardDiv(allHide,result,BID);
			}else if(action=="getblogdata"){
				//alert(result);
				MyPageContent.innerHTML=getBlogTop()+result+"</TABLE>";
				//processNullPic(document.chkPicForm);
			}else if(action=="getblogtitledata"){
				//alert(result);
				MyPageContent.innerHTML=getBlogTop(false)+result+"</TABLE>";
				//processNullPic(document.chkPicForm);
			}else if(action=="getBlogWithComment"){
				//alert(result);
				MyPageContent.innerHTML=getBlogTop(true,"myVisAll('"+picPath+"','trC','picC')")+result;
				//processNullPic(document.chkPicForm);
			}else if(action=="getLeaveWord"){
				//alert('pp');
				MyPageContent.innerHTML=result+getLeaveWordEnd()+"</TABLE>";
				//alert(result);
				//alert(getLeaveWordEnd());
				//document.getElementById("LeaveWord").focus();
				//processNullPic(document.chkPicForm);
			}else if(action=="yanzheng"){
				if(result.indexOf("正确")>=0){
					if(nowFunc=='LeaveWord')
						saveLeaveForm1();
					else if(nowFunc=='Comment')
						saveCommentForm1();
				}else{
					alert(result);
					if(nowFunc=='LeaveWord')
						changePic(document.LeaveForm.yzm,"fjmbindex");
					else if(nowFunc=='Comment')
						changePic(document.CommentForm.yzm,"fjmbindex");
				}

			}else if(action=='intro'){
				alert(result);
				window.location.reload();
			}else if(action=='FlowerEgg'){
				if(result.indexOf("！")<0 || result.indexOf("！")==result.length-1){
				
				}else{
					var c=result.substring(result.indexOf("！")+1);
					var result=result.substring(0,result.indexOf("！")+1);
					FlowerEggObj.innerText=c;
				}
				alert(result);
			}
			/*else if(action=='saveComment')
			{
				reviewBlogComment(BlogID,from,'1')
				alert(result);
				刷新左边评论();
			}*/else if(action=='saveBlogFavour')
			{
				alert(result);
				isSubmit=false;
			}
			//alert(action);
		} else {
			alert('请求有错误:'+action+":"+http_request.status);
		}
	}
	//alert("ok");
	//processNullPic(document.chkPicForm);
}


function resetLeaveForm()
{
	var form=document.LeaveForm;
	form.LeaveWord.value='';
	//alert(form.UserName)
	try{form.UserName.value='';}catch(e){}
	form.IsOpen.checked='';
}
function yanzheng(form)
{
	//alert(action);
	var yanzhengma=form.yanzhengma;
	if(yanzhengma.value=='')
	{
		alert("验证码不能为空！");
		return false;
	}
	if(chknum(yanzhengma.value,false)==false)
	{
		alert("验证码必须是数字！");
		return false;
	}
	if(yanzhengma.value.length!=4)
	{
		alert("验证码必须是4位数字！");
		return false;
	}
	//groupDiv.innerHTML="";
	action='yanzheng';
	makeRequest('func/yanzheng.jsp?yanzhengma='+yanzhengma.value);
}
function saveSMS()
{
	if(!isLogin){
		if(confirm("需要登录才可以发送站内短信，是否要跳转到博客首页登录？")){
			window.location.href="/blog";
		}
		return false;
	}
	var form=document.CommentForm_;
	var newComment=form.newComment;
	form.newComment.value=trim(form.newComment.value);
	if(form.newComment.value==''){
		alert("短信内容不能为空！");
		form.newComment.focus();
		return false;
	}
	form.action="save/SMS.jsp";
	form.method="post";
	form.submit();
}
function saveLeaveForm()
{
	var form=document.LeaveForm;
	if(!isLogin)
	{
		form.UserName.value=trim(form.UserName.value);
		if(form.UserName.value==''){
			alert("您的名字不能为空！");
			form.UserName.focus();
			return false;
		}
	}
	form.LeaveWord.value=trim(form.LeaveWord.value);
	if(form.LeaveWord.value==''){
		alert("留言内容不能为空！");
		form.LeaveWord.focus();
		return false;
	}

	//yanzhengmaMSG='submit';
	//yanzheng(form);
	saveLeaveForm1()
}
	function getTop(e){
	var offset=e.offsetTop;
	if(e.offsetParent!=null) offset+=getTop(e.offsetParent);
	return offset;
}
//获取元素的横坐标
function getLeft(e){
	var offset=e.offsetLeft;
	if(e.offsetParent!=null) offset+=getLeft(e.offsetParent);
	return offset;
}
function sms(myid)
{
	opensetwin('/sms/modifysms.jsp?from=update&readonly=readonly&id='+myid,'查看短信','450','350','0');
}
function reqIn(bid,circleid){
	opensetwin("/blog/q/pub/WinAddInCircle.jsp?IsAdd=0&ID="+circleid+"&ReqLoginID="+bid, 1, 400, 300);
}
function setMenu(obj,id){
	var isR=obj.innerHTML=='';
	if(isR){
		obj.innerHTML='请稍等，正在读取数据......';
		//vis(obj);
		if(id==0){
			makeRequest0("ajax/indexLeftGroup.jsp"+leftUrl,p_0);	
		}else if(id==1){
			makeRequest1("ajax/indexLeftComment.jsp"+leftUrl,p_1);
		}else if(id==2){
			makeRequest2("ajax/indexLeftLeaveWord.jsp"+leftUrl,p_2);	
		}else if(id==3){
			makeRequest3("ajax/indexLeftBlogFavour.jsp"+leftUrl,p_3);
		}else if(id==4){
			makeRequest4("ajax/indexLeftMyFavour.jsp"+leftUrl,p_4);
		}
	}else{
		vis(obj);
	}
}
function goPhoto(id){
	opensetwin_1('/photo/2index.jsp?m='+id,'','800','576');
}
function goFile(id){
	opensetwin_1('/share/pub/oneDetail.jsp?m='+id,'','800','576');
}
function setProessFont()
{
	MyPageContent.innerHTML="<br><br><br><span style='font-size:12px;color:green;' class='Color'>请稍等，正在读取数据......</span>";
}

function readBlog(id)
{
	alert(id);
}
function opensetwin(url, winName, width, height,scroll)
{
	if(typeof scroll=="undefined") scroll="0";
	xposition=0; yposition=0;
	if ((parseInt(navigator.appVersion) >= 4 ))
	{
	xposition = (screen.width - width) / 2;
	yposition = (screen.height - height) / 2;
	}
	theproperty= "width=" + width + ","
	+ "height=" + height + ","
	+ "location=0,"
	+ "menubar=0,"
	+ "resizable=0,"
	+ "scrollbars="+scroll+","
	+ "status=0,"
	+ "titlebar=0,"
	+ "toolbar=0,"
	+ "hotkeys=0,"
	+ "screenx=" + xposition + "," //仅适用于Netscape
	+ "screeny=" + yposition + "," //仅适用于Netscape
	+ "left=" + xposition + "," //IE
	+ "top=" + yposition; //IE
	return window.open(url,winName,theproperty );
}
function login()
{
	//alert("login");
	//winLogin=opensetwin("win/login.jsp?w=false",'登录',400,155);
	//window.location.href="/login.jsp?U=2";
	window.location.href="/sm.jsp?ID=6";
}
function p_0()
{
	pp(http_request0,leftTbGroup,0);
}
function p_1()
{
	leftTbComment.innerHTML="<span style='font-size:12px' class='Color'>请稍等，正在读取数据......</span><span id=mycommenttr>";
	//alert("receieve");
	pp(http_request1,leftTbComment,1);
	//alert(leftTbComment.innerHTML);
}
function p_2()
{
	pp(http_request2,leftTbLeaveWord,2);
}
function p_3()
{
	pp(http_request3,leftTbBlogFavour,3);
}
function p_4()
{
	pp(http_request4,leftTbMyFavour,4);
}
function pp(r,id,no)
{
	if (r.readyState == 4) {
		if (r.status == 200)
		{
			var result=trim(r.responseText);
			id.innerHTML=result;
			//if(no==2)alert(result);
		} else {
			//alert('请求有错误:'+no);
			alert("服务器繁忙，请稍候再试(No."+no+")！");
		}
	}
}
function goToBlog(id)
{
	var urlBuff='/blog/myIndex.jsp?page=1&u=' +id + '&isA=y';
	//alert(urlBuff);
	opensetwin_1(urlBuff,'','700','460');
}


function Intro(blogID){
	winIntro=opensetwin("win/intro.jsp?b="+blogID,'',400,125);
}

function _Intro(blogID){
	if(confirm("取消推荐吗？")){
		action="intro";
		makeRequest("save/intro.jsp?BlogID="+blogID);		
	}
}

function  MyTime(){  
	var  now  =  new  Date();  
	var  yy  =  now.getYear();  
	var  mm  =  now.getMonth();  
    return(yy+"-"+(mm+1)+"-"+now.getDate());
}
function FlowerEgg(BlogID,BlogInfoID,IsFlower){
	action="FlowerEgg";
	FlowerEggObj=document.getElementById((IsFlower==1?"FlowerNum":"EggNum")+BlogID);
	makeRequest("/blog/save/flowerEgg.jsp?BlogID="+BlogID+"&BlogInfoID="+BlogInfoID+"&IsFlower="+IsFlower);
}
