OL.setOnLoadCallback(function(){
	$(".pngFix").pngFix();
	$(".dropdown").each(function() {
		new dropdown($(this));
	});

	if(User.PO.id){
		var f=$("#beenLogin");
		$("#displayName",f).html(User.PO.displayName);
		f.fadeIn("fast");
	}else{
		var f=$("#unLogin").fadeIn("fast");
		$("a.dropdown",f).addClass("hover");
	}
});

function QuickSearch(f)
{
	if(isEmpty($("#keyword",f).attr("value")))
	{
		OL.global.alert("请输入关键字!","失败");
		return false;
	}
	return true;
}
//GuestBook Action
function GuestBookDomReady()
{
	OL.load("jquery.cookie");
	OL.setOnLoadCallback(function(){
		$(document).keydown(function(e){
			if(e.ctrlKey && e.which == 13 || e.which == 10) {
				SubmitComment(null,$("#commentform"));
			} else if (e.shiftKey && e.which==13 || e.which == 10) {
				SubmitComment(null,$("#commentform"));
			}
		});

		var name=$.cookie('guestBook_name');
		var email=$.cookie('guestBook_email');
		var site=$.cookie('guestBook_site');
		if(User.PO.displayName)name=User.PO.displayName;
		if(User.PO.displayName)email=User.PO.email;
		if(User.PO.site)site=User.PO.site;
		if(!isEmpty(name))$("#commentform #name").attr("value",name);
		if(!isEmpty(email))$("#commentform #email").attr("value",email);
		if(!isEmpty(site))$("#commentform #site").attr("value",site);
	});
}
function SubmitComment(b,f)
{

	var name=$("#name",f);
	if(isEmpty(name.attr("value")))
	{
		OL.global.alert("请输入你的大名!","错误");
		name.focus();
		return false;
	}
	var input=$("#content",f);
	if(isEmpty(input.attr("value")))
	{
		input.focus();
		OL.global.alert("请输入内容!","错误");
		return false;
	}

	//cookie action
	var cookieOption={expires: 7};
	$.cookie('guestBook_name',name.attr("value"),cookieOption);
	input=$("#email",f).attr("value");
	if(!isEmpty(input))
	{
		$.cookie('guestBook_email',input,cookieOption);
	}
	input=$("#site",f).attr("value");
	if(!isEmpty(input))
	{
		$.cookie('guestBook_site',input,cookieOption);
	}

	new OL.ajax().submit({
			url:OL.global.ContextPath+'/GuestBook/Add.action',
			form:f,
			button:b,
			haveResult: true,
			loadingLayer:'#loadingMask',
			successFunction:function(json){
				if(OL.global.alert(json.msg,"成功"))
				{
					window.location="GuestBook.jsp";
				}
			}
	});
	return false;
}

function SubmitShareLib(b,f)
{

	var name=$("#name",f);
	if(isEmpty(name.attr("value")))
	{
		OL.global.alert("请输入你的大名!","错误");
		name.focus();
		return false;
	}
	var input=$("#content",f);
	if(isEmpty(input.attr("value")))
	{
		input.focus();
		OL.global.alert("请输入内容!","错误");
		return false;
	}

	input=$("#lib",f);
	if(isEmpty(input.attr("value")))
	{
		input.focus();
		OL.global.alert("请输入组件名称!","错误");
		return false;
	}


	new OL.ajax().submit({
			form:f,
			button:b,
			loadingLayer:'#loadingMask',
			haveResult: true,
			successFunction:function(json){
				if(OL.global.alert(json.msg,"成功"))
				{
					window.location="index.jsp";
				}
			}
	});
	return false;
}
function ReplyComment(id,rid)
{
	var c=$("#comment-id-"+id);
	var form=$("#commentform").remove();
	$("#CancelButton",form).css("display","inline");
	$("#rid",form).attr("value",rid);
	c.append(form);
}
//取消回复
function CancelReply()
{
	var form=$("#commentform").remove();
	$("#CancelButton",form).css("display","none");
	$("#rid",form).attr("value","");
	$("#content",form).attr("value","");
	$("#BodyContent").append(form);
}

var User={
	PO:{},
	Login:{
		To:function(op,returnToSoucePage){
			var url="";
			if(returnToSoucePage)
			{
				url=window.location;
			}
			switch(op)
			{
				case "Taobao":
					window.location="http://container.open.taobao.com/container?appkey=12104733";
					return;
				case "Google":
					window.location=OL.global.ContextPath+"/OpenID/Login.action?op=Google&url="+url;
					return;
				case "Yahoo":
					window.location=OL.global.ContextPath+"/OpenID/Login.action?op=Yahoo&url="+url;
					return;
			}

		},//Login.To End
		Out:function(){
			new OL.ajax().get({
				url:OL.global.ContextPath+"/Home/User/Logout.action",
				loadingLayer:'#loadingMask',
				haveResult: true,
				successFunction:function(){
					User.PO.id="";
					User.PO.displayName="";
					$("#beenLogin").css("display","none");
					$("#unLogin").css("display","block");
				}
			});
		},
		Submit:function(form,box,callBack){
			var f=$(form);
			var tmp;

			tmp=$("#name",f).val();
			if(isEmpty(tmp))
			{
				OL.global.alert("对不起，请输入用户名！");
				return false;
			}

			tmp=$("#password",f).val();
			if(isEmpty(tmp))
			{
				OL.global.alert("对不起，请输入密码！");
				return false;
			}

			new OL.ajax().submit({
				form:f,
				url:OL.global.ContextPath+"/User/Login.action",
				loadingLayer:'#loadingMask',
				haveResult: true,
				successFunction:function(){
					OL.load({uri:OL.global.ContextPath+'/User/U.action?r='+Math.random(),type:"js",charset:"utf-8",depend:false,onload:function(){
						$("#unLogin").css("display","none");
						var f=$("#beenLogin");
						$("#displayName",f).html(User.PO.displayName);
						f.fadeIn("fast");
					}});
					if(box)box.close();
					if(typeof(callBack)=='function')callBack();
				}
			});
			return false;
		},
		Check:function()//检查用户是否登录
		{
			var result=false;
			new OL.ajax().get({
				async:false,
				haveResult:false,
				url:OL.global.ContextPath+'/User/CheckLogin.action?r='+Math.random(),
				successFunction:function(json){
					result=json.success;
				}
			});
			return result;
		},
		ShowBox:function(callBack)
		{
			$.weeboxs.open(OL.global.ContextPath+"/template/Home/User/Login.html", {
				contentType:'ajax',
				cache:true,
				boxid:'_loginbox',
				title:'登录系统',
				width:350,
				onok:function(box)
				{
					User.Login.Submit(box.find("#loginBox"),box,callBack);
				}
			});
		}
	},//Login End
	Reg:{
		Submit:function(form,box){
			var f=$(form);
			var tmp,tmp2;

			tmp=$("#name",f).val();
			if(isEmpty(tmp))
			{
				OL.global.alert("对不起，请输入用户名！");
				return false;
			}

			tmp=$("#displayName",f).val();
			if(isEmpty(tmp))
			{
				OL.global.alert("对不起，请输入显示名称！");
				return false;
			}

			tmp=$("#password1",f).val();
			tmp2=$("#password2",f).val();
			if(isEmpty(tmp)||isEmpty(tmp2))
			{
				OL.global.alert("对不起，请输入密码！");
				return false;
			}
			if(!isEmpty(tmp)||!isEmpty(tmp2))
			{
				if(tmp!=tmp2)
				{
					OL.global.alert("对不起，两次输入的密码不一致！");
					return false;
				}
			}

			new OL.ajax().submit({
				form:f,
				url:OL.global.ContextPath+"/User/Reg.action",
				loadingLayer:'#loadingMask',
				haveResult: true,
				successFunction:function(){
					//OL.global.alert("恭喜，注册成功！");
					//if(box)box.close();
					window.location=OL.global.ContextPath+"/Home/User/Modify_Form.action";
				}
			});
			return false;
		},
		ShowBox:function()
		{
			$.weeboxs.open(OL.global.ContextPath+"/template/Home/User/Reg.html", {
				contentType:'ajax',
				boxid:'_regbox',
				title:'用户注册',
				width:350,
				onok:function(box)
				{
					User.Reg.Submit(box.find("#regBox"),box);
				}
			});
		}
	},
	Modify:function(form){
		var f=$(form);
		var tmp,tmp2;
		if(User.PO.openid && User.PO.openid==0)
		{
			tmp=$("#password1",f).val();
			tmp2=$("#password2",f).val();
			if(!isEmpty(tmp)||!isEmpty(tmp2))
			{
				//修改密码
				if(tmp!=tmp2)
				{
					OL.global.alert("对不起，两次输入的密码不一致！");
					return false;
				}
			}

		}

		tmp=$("#displayName",f).val();
		if(isEmpty(tmp))
		{
			OL.global.alert("对不起，请输入显示名称！");
			return false;
		}

		tmp=$("#email",f).val();
		if(!isEmpty(tmp)&&!isEmail(tmp))
		{
			OL.global.alert("对不起，EMAIL格式错误！");
			return false;
		}
		new OL.ajax().submit({
			form:f,
			url:"Modify.action",
			botton:$("#submitBotton",f),
			loadingLayer:'#loadingMask',
			haveResult: true,
			successFunction:function(){
				OL.global.alert("资料保存成功！");
				window.location="../Index.action";
			}
		});

		return false;
	}
};
var Favorites={
	Page:1,
	getUrl:function(type)
	{
		var url=OL.global.ContextPath+"/Home/Favorites/";
		switch(type)
		{
			case "article":
				return url+"Article";
				break;
		}
	},
	Add:function(id,type){
		if(!User.Login.Check())//未登录
		{
			User.Login.ShowBox(function(){
				Favorites.Add(id);
			});
			return;
		}//if end

		new OL.ajax().get({
			url:Favorites.getUrl(type)+"/Add.action?favorite.aid="+id,
			loadingLayer:'#loadingMask',
			haveResult: true,
			successFunction:function(json){
				OL.global.alert("恭喜，关注成功！");
			}
		});
	},
	Del:function(id,type,options){
		new OL.ajax().get({
			url:Favorites.getUrl(type)+"/Del.action?favorite.id="+id,
			loadingLayer:'#loadingMask',
			haveResult: true,
			successFunction:function(json){
				OL.global.alert("删除成功！");
				switch(type)
				{
					case "article":
						Favorites.ArticleListData();
						break;
				}

			}
		});
	},
	ArticleListData:function()
	{
		new OL.ajax().submit({
			form:"#SearchForm",
			url:OL.global.ContextPath+"/Home/Favorites/Article/ListData.action?page.page=" + Favorites.Page,
			loadingLayer:'#loadingMask',
			haveResult: false,
			successFunction:function(json){
				var html="";
				var po;
				for(var ii=0;ii<json.rows.length;ii++)
				{
					po=json.rows[ii];
					html+='<div class="ArticleItem">';
					html+='<div class="Name"><a href="'+OL.global.ContextPath+'/Lib/'+po.aid+'.jsp" targer="_blank">'+po.aname+'</a><span class="Type">[&nbsp;<a href="'+OL.global.ContextPath+'/Type/'+po.atid+'-1.jsp">'+po.atype+'</a>&nbsp;]</span></div>';
					html+='<div class="Summary">'+po.asummary+'</div>';
					html+='<div><span class="gray">收藏于：'+po.time+'</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="gray">'+po.abefavorite+'人收藏</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:Favorites.Del('+po.id+',\'article\');" class="green">删除</a></div>';
					html+='</div>';
				}
				$("#home #content.favorties #list").html(html);
				$("#pager").pager({ pageNumber: json.page, pageCount:json.totalPage,recordCount:json.total, callBack: function(opt){Favorites.Page=opt.pageNumber;Favorites.ArticleListData();} });
			}
		});
	}
};
var ForumAction={
	Loading:null,
	Type:{
		cache:{},
		get:function(id){
			return Forum[ForumH[id]];
		},
		getText:function(id){
			var node=ForumAction.Type.get(id);
			if(node)return node[2];
			return "";
		},
		getPath:function(id){
			var paths=[];
			var node=ForumAction.Type.get(id);
			while(node)
			{
				paths.push(node);
				node=ForumAction.Type.getParent(node[0]);
			}
			return paths;
		},
		getParent:function(id)
		{
			var node=ForumAction.Type.cache["getParent"+id];

			if(node)
			{
				return node;
			}
			var index=ForumH[id];
			node=Forum[index];
			for(var i=index-1;i>=0&&node[3]>0;i--)
			{
				var tmp=Forum[i];
				if(tmp[3]<node[3])
				{
					ForumAction.Type.cache["getParent"+id]=tmp;
					return tmp;
				}
			}
			return null;

		}
	},//Type end
	Location:{
		print:function(id,isPost){
			var random = window.location.search;
			if(!random)random="";


			var html="<a href='"+OL.global.ContextPath+"/Forum/index.jsp"+random+"'>讨论区</a>";
			var paths=ForumAction.Type.getPath(id);
			for(var i=paths.length-1;i>=0;i--)
			{
				html+='&nbsp;>>&nbsp;<a href="'+OL.global.ContextPath+'/Forum/Forum_'+paths[i][0]+'_1.action'+random+'">'+paths[i][2]+'</a>';
			}
			document.write(html);
		}
	},
	Permission:{
		Ready:function(){
			OL.setOnLoadCallback(function(){
				if(!User.PO.id)//未登录
				{
					return;
				}
				if(ForumAction.Permission.EDIT_OTHER)
				{
					$(".Permission_Edit_Other").show();
				}else{
					$(".Permission_Edit_"+User.PO.id).show();
				}
				if(ForumAction.Permission.DEL)
				{
					$(".Permission_Del").show();
				}
				if(ForumAction.Permission.CHANGE_LEVEL)
				{
					$(".Permission_ChangeLevel").show();
				}
				if(ForumAction.Permission.MOVE)
				{
					$(".Permission_Move").show();
				}
			});
		}
	},
	Post:{
		GetNewest:function(){
			new OL.ajax().get({
				url:OL.global.ContextPath+"/Forum/Forum_Newest.action",
				loadingLayer:'#loadingMask',
				haveResult: false,
				successFunction:function(json){
					var html="";
					var po;
					for(var ii=1;ii<4&&ii<json.rows.length;ii++)
					{
						po=json.rows[ii];
						html+='<div class="Item">';
						html+='<div class="Title"><a href="'+OL.global.ContextPath+'/Forum/Read_'+po.id+'_1.action">'+po.title+'</a></div>';
						html+='<div class="Ltime">'+po.lastReplyTime+'</div>';
						html+='</div>';
					}
					$("#Forum_Newest_List").html(html);
				}
			});
		},
		New:function(fid,tag){
			if(!User.Login.Check())//未登录
			{
				User.Login.ShowBox(function(){
					window.location.href=OL.global.ContextPath+"/Forum/Post/Add_"+fid+".action?tag="+tag;
				});
				return;
			}//if end

			window.location.href=OL.global.ContextPath+"/Forum/Post/Add_"+fid+".action?tag="+tag;
		},
		Add:function(form){
			tinyMCE.triggerSave();
			if(!User.PO.id)//未登录
			{
				ForumAction.Draft.Save("addPost");
				User.Login.ShowBox(function(){
					/*setTimeout(function(){
						ForumAction.Post.Add(form);
					},200);*/
				});
				return false;
			}//if end
			form=$(form);
			if(isEmpty($("#f_title",form).val()))
			{
				OL.global.alert("对不起,请输入标题！");
				return false;
			}
			if(isEmpty($("#f_content",form).val()))
			{
				OL.global.alert("对不起,请输入内容！");
				return false;
			}

			new OL.ajax().submit({
				url:"Add_Action.action",
				form:form,
				button:$("#submitBotton",form)[0],
				//loadingLayer:'#loadingMask',
				haveResult: true,
				beforeSendFunction:function(){ForumAction.Loading.show();},
				afterSendFunction:function(){ForumAction.Loading.hide();},
				successFunction:function(json){
					ForumAction.Draft.Clear("addPost");
					OL.global.alert("恭喜，发表成功！");
					window.location.href=OL.global.ContextPath+"/Forum/Read_"+json.id+"_1.action?r="+random(100000);
				}
			});
			return false;
		},
		Edit:function(form){
			tinyMCE.triggerSave();
			if(!User.PO.id)//未登录
			{
				ForumAction.Draft.Save("editPost");
				User.Login.ShowBox();
				return false;
			}//if end

			form=$(form);
			if(isEmpty($("#f_title",form).val()))
			{
				OL.global.alert("对不起,请输入标题！");
				return false;
			}
			if(isEmpty($("#f_content",form).val()))
			{
				OL.global.alert("对不起,请输入内容！");
				return false;
			}

			new OL.ajax().submit({
				url:"Edit_Action.action",
				form:form,
				button:$("#submitBotton",form)[0],
				//loadingLayer:'#loadingMask',
				haveResult: true,
				beforeSendFunction:function(){ForumAction.Loading.show();},
				afterSendFunction:function(){ForumAction.Loading.hide();},
				successFunction:function(json){
					ForumAction.Draft.Clear("editPost");
					OL.global.alert("恭喜，编辑成功！");
					window.location.href=OL.global.ContextPath+"/Forum/Read_"+json.id+"_1.action?r="+random(100000);
				}
			});
			return false;
		},
		Del:function(id){
			var value=OL.global.confirm("请确定是否需要删除该帖子?","删除");
			if(!value)return;
			new OL.ajax().get({
				url:"Post/Del_"+id+".action",
				loadingLayer:'#loadingMask',
				successFunction:function(json){
					OL.global.alert("恭喜，删除成功！");
					window.location.href=OL.global.ContextPath+"/Forum/Forum_"+json.fid+"_1.action?r="+random(100000);
				}
			});
		},
		ChangeLevel:function(id)
		{
			$.weeboxs.open(OL.global.ContextPath+"/template/Forum/Post/ChangeLevel.html", {
				contentType:'ajax',
				boxid:'_forum_changeLevel',
				title:'置顶',
				width:500,
				onok:function(box)
				{
					var form=box.find("#changelLevelBox");
					new OL.ajax().get({
						url:"Post/ChangeLevel_"+id+"_"+$("#forumPost_level",form).val()+".action",
						loadingLayer:'#loadingMask',
						successFunction:function(){
							OL.global.alert("置顶成功！");
							//window.location.reload();
							window.location.href=OL.global.ContextPath+"/Forum/Read_"+id+"_1.action?r="+random(100000);
						}
					});
				}
			});
		},
		Move:function(id)
		{
			$.weeboxs.open(OL.global.ContextPath+"/template/Forum/Post/Move.html", {
				contentType:'ajax',
				boxid:'_forum_move',
				title:'移动帖子',
				width:500,
				onok:function(box)
				{
					var form=box.find("#moveBox");
					new OL.ajax().get({
						url:"Post/Move_"+id+"_"+$("#forumPost_fid",form).val()+".action",
						loadingLayer:'#loadingMask',
						successFunction:function(){
							OL.global.alert("移动成功！");
							//window.location.reload();
							window.location.href=OL.global.ContextPath+"/Forum/Read_"+id+"_1.action?r="+random(100000);
						}
					});
				}
			});
		},
		EditorReady:function(){
			OL.setOnLoadCallback(function(){
				ForumAction.Loading=new ol.loading({id:"postForm"});
				$(".tag").autocomplete(OpenLib_API_Lib_Libs, {
					minChars: 1,
					max: 20,
					autoFill: false,
					mustMatch: false,
					matchContains: false,
					selectFirst:false,
					scrollHeight: 320,
					width:180
				});
				$('#tag_tab').tipsy({gravity: 'w'});
			});
			OL.load("jquery.cookie");
			OL.load("ol.loading","ajax");
			OL.load("jquery.autocomplete","ajax");
			OL.load({uri:OL.global.ContextPath+"/js/libs.js",type:"js",charset:"utf-8",depend:true,loadType:"ajax"});
			OL.load("tipsy","ajax");
		}
	},///Post end
	Reply:{
		New:function(pid){
			if(!User.Login.Check())//未登录
			{
				User.Login.ShowBox(function(){
					window.location.href=OL.global.ContextPath+"/Forum/Reply/Add_"+pid+".action";
				});
				return;
			}//if end

			window.location.href=OL.global.ContextPath+"/Forum/Reply/Add_"+pid+".action";
		},
		To:function(pid,rid,page){
			var uname=$("#name","#post_"+rid).html();
			var html='<div class="replyToUser mceNonEditable">回复：<a href="'+OL.global.ContextPath+'/Forum/Read_'+pid+'_'+page+'.action#post_'+rid+'">'+uname+'</a></div><p></p>';
			tinyMCE.get('f_content').execCommand('mceReplaceContent',false,html);
		},
		Quote:function(id,rid){
			if(!User.Login.Check())//未登录
			{
				User.Login.ShowBox(function(){
					window.location.href=OL.global.ContextPath+"/Forum/Reply/Quote_"+id+"_"+rid+".action";
				});
				return;
			}//if end

			window.location.href=OL.global.ContextPath+"/Forum/Reply/Quote_"+id+"_"+rid+".action";
		},
		Add:function(form){
			tinyMCE.triggerSave();
			if(!User.PO.id)//未登录
			{
				ForumAction.Draft.Save("addReply");
				User.Login.ShowBox(function(){
					/*setTimeout(function(){
						ForumAction.Reply.Add(form);
					},200);*/
				});
				return false;
			}//if end

			form=$(form);
			if(isEmpty($("#f_content",form).val()))
			{
				OL.global.alert("对不起,请输入内容！");
				return false;
			}

			new OL.ajax().submit({
				url:OL.global.ContextPath+"/Forum/Reply/Add_Action.action",
				form:form,
				button:$("#submitBotton",form)[0],
				//loadingLayer:'#loadingMask',
				haveResult: true,
				beforeSendFunction:function(){ForumAction.Loading.show();},
				afterSendFunction:function(){ForumAction.Loading.hide();},
				successFunction:function(json){
					ForumAction.Draft.Clear("addReply");
					OL.global.alert("恭喜，回复成功！");
					window.location.href=OL.global.ContextPath+"/Forum/Read_"+json.pid+"_1.action?r="+random(100000);
				}
			});
			return false;
		},
		Edit:function(form){
			tinyMCE.triggerSave();
			if(!User.PO.id)//未登录
			{
				ForumAction.Draft.Save("editReply");
				User.Login.ShowBox();
				return false;
			}//if end

			form=$(form);
			if(isEmpty($("#f_content",form).val()))
			{
				OL.global.alert("对不起,请输入内容！");
				return false;
			}

			new OL.ajax().submit({
				url:OL.global.ContextPath+"/Forum/Reply/Edit_Action.action",
				form:form,
				button:$("#submitBotton",form)[0],
				//loadingLayer:'#loadingMask',
				haveResult: true,
				beforeSendFunction:function(){ForumAction.Loading.show();},
				afterSendFunction:function(){ForumAction.Loading.hide();},
				successFunction:function(json){
					ForumAction.Draft.Clear("editReply");
					OL.global.alert("恭喜，编辑成功！");
					window.location.href=OL.global.ContextPath+"/Forum/Read_"+json.pid+"_1.action?r="+random(100000);
				}
			});
			return false;
		},
		Del:function(id){
			var value=OL.global.confirm("请确定是否需要删除该回帖?","删除");
			if(!value)return;
			new OL.ajax().get({
				url:"Reply/Del_"+id+".action",
				loadingLayer:'#loadingMask',
				successFunction:function(json){
					OL.global.alert("恭喜，删除成功！");
					window.location.reload();
					//window.location.href=OL.global.ContextPath+"/Forum/Read_"+json.pid+"_1.action?r="+random(100000);
				}
			});
		},
		EditorReady:function(){
			OL.setOnLoadCallback(function(){
				ForumAction.Loading=new ol.loading({id:"replyForm"});
			});
			OL.load("jquery.cookie");
			OL.load("ol.loading","ajax");
		}
	},//Reply end
	Draft:{//草稿箱
		_save:function(key,id,value,cookieOption)
		{
			if(typeof(value)=='undefined')return;
			$.cookie(key+'_'+id,value,cookieOption);
		},
		_get:function(key,id)
		{
			var tmp=$.cookie(key+"_"+id)
			if(!tmp)return "";
			return tmp;
		},
		Save:function(type)
		{
			var cookieOption={expires: 1};
			var id;
			var isPost=true;
			switch(type)
			{
				case "addPost":
					id="postFid#"+$("#f_fid").attr("value");
					break;
				case "editPost":
					id="postId#"+$("#f_id").attr("value");
					break;
				case "addReply":
					isPost=false;
					id="replyPid#"+$("#f_pid").attr("value");
					break;
				case "editReply":
					isPost=false;
					id="replyId#"+$("#f_id").attr("value");
					break;
				default:
					return;

			}
			if(isPost)
			{
				ForumAction.Draft._save("forum_title",id,$("#f_title").attr("value"),cookieOption);
				ForumAction.Draft._save("forum_tag1",id,$("#f_tag1").attr("value"),cookieOption);
				ForumAction.Draft._save("forum_tag2",id,$("#f_tag2").attr("value"),cookieOption);
				ForumAction.Draft._save("forum_tag3",id,$("#f_tag3").attr("value"),cookieOption);
				ForumAction.Draft._save("forum_tag4",id,$("#f_tag4").attr("value"),cookieOption);
			}
			ForumAction.Draft._save("forum_content",id,$("#f_content").attr("value"),cookieOption);
		},
		Load:function(type){
			var id;
			var isPost=true;
			switch(type)
			{
				case "addPost":
					id="postFid#"+$("#f_fid").attr("value");
					break;
				case "editPost":
					id="postId#"+$("#f_id").attr("value");
					break;
				case "addReply":
					isPost=false;
					id="replyPid#"+$("#f_pid").attr("value");
					break;
				case "editReply":
					isPost=false;
					id="replyId#"+$("#f_id").attr("value");
					break;
				default:
					return;
			}
			var tmp;
			if(isPost)
			{
				tmp=ForumAction.Draft._get('forum_title',id);
				if(tmp)$("#f_title").attr("value",tmp);
				tmp=ForumAction.Draft._get('forum_tag1',id);
				if(tmp)$("#f_tag1").attr("value",tmp);
				tmp=ForumAction.Draft._get('forum_tag2',id);
				if(tmp)$("#f_tag2").attr("value",tmp);
				tmp=ForumAction.Draft._get('forum_tag3',id);
				if(tmp)$("#f_tag3").attr("value",tmp);
				tmp=ForumAction.Draft._get('forum_tag4',id);
				if(tmp)$("#f_tag4").attr("value",tmp);
			}
			tmp=ForumAction.Draft._get('forum_content',id);
			if(tmp)$("#f_content").attr("value",tmp);
		},
		Clear:function(type){
			var id;
			var isPost=true;
			switch(type)
			{
				case "addPost":
					id="postFid#"+$("#f_fid").attr("value");
					break;
				case "editPost":
					id="postId#"+$("#f_id").attr("value");
					break;
				case "addReply":
					isPost=false;
					id="replyPid#"+$("#f_pid").attr("value");
					break;
				case "editReply":
					isPost=false;
					id="replyId#"+$("#f_id").attr("value");
					break;
				default:
					return;
			}
			if(isPost)
			{
				ForumAction.Draft._save("forum_title",id,null,null);
				ForumAction.Draft._save("forum_tag1",id,null,null);
				ForumAction.Draft._save("forum_tag2",id,null,null);
				ForumAction.Draft._save("forum_tag3",id,null,null);
				ForumAction.Draft._save("forum_tag4",id,null,null);
			}
			ForumAction.Draft._save("forum_content",id,null,null);
		}
	}//Draft end
};











function random(max)
{
	return Math.floor(Math.random()*max+1); //1-10
}
//下拉菜单
function dropdown(obj)
{
	this.t=null;

	this.bind=function(menu)
	{
		this.t=setTimeout(function() {
			menu.css("display","none");
			obj.removeClass("hover");
		}, 100);
	}

	obj.bind("mouseover",{E:this},function(v){
		var E=v.data.E;
		clearTimeout(E.t);
		$(this).next().css("display","block");
	});
	obj.bind("mouseout",{E:this},function(v){
		var E=v.data.E;
		E.bind($(this).next());
		obj.addClass("hover");
	});

	obj.next().bind("mouseover",{E:this},function(v){
		var E=v.data.E;
		clearTimeout(E.t);
		$(this).css("display","block");
	});
	obj.next().bind("mouseout",{E:this},function(v){
		var E=v.data.E;
		E.bind($(this));
	});
}
///////////////////////////////////////
OL.loader.libs["tinymce"] =[ {mark:"tinymce",uri: "../tinymce/jquery.tinymce.js",type: "js",	charset: "utf-8",depend:false}];
OL.loader.libs["jquery.autocomplete"] = [
	{uri: "../jquery.autocomplete/jquery.autocomplete.min.js",type:"js",charset: "utf-8"},
	"jquery.bgiframe",
	{uri: "../jquery.autocomplete/jquery.ajaxQueue.js",type:"js",	charset: "utf-8"},
	{uri: "../jquery.autocomplete/thickbox-compressed.js",type:"js",charset: "utf-8"},
	{uri: "../jquery.autocomplete/jquery.autocomplete.css",type:"css",charset: "utf-8"},
	{uri: "../jquery.autocomplete/thickbox.css",type:"css",	charset: "utf-8"}
];

OL.loader.libs["tipsy"] = [
	{uri: "../tipsy/javascripts/jquery.tipsy.js",type:"js",charset: "utf-8"},
	{uri: "../tipsy/stylesheets/tipsy.css",type:"css",	charset: "utf-8"}
];
OL.loader.libs["syntaxhighlighter"] = [
	{uri: "../syntaxhighlighter3.0.83/scripts/compress.js",type:"js",charset: "utf-8"},
	/*{uri: "../syntaxhighlighter3.0.83/scripts/shLegacy.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushAppleScript.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushAS3.js",type:"js",charset: "utf-8"},
	//{uri: "../syntaxhighlighter3.0.83/scripts/shBrushBash.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushColdFusion.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushCpp.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushCSharp.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushCss.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushDelphi.js",type:"js",charset: "utf-8"},
	//{uri: "../syntaxhighlighter3.0.83/scripts/shBrushDiff.js",type:"js",charset: "utf-8"},
	//{uri: "../syntaxhighlighter3.0.83/scripts/shBrushErlang.js",type:"js",charset: "utf-8"},
	//{uri: "../syntaxhighlighter3.0.83/scripts/shBrushGroovy.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushJava.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushJavaFx.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushJScript.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushPerl.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushPhp.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushPlain.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushPowerShell.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushPython.js",type:"js",charset: "utf-8"},
	//{uri: "../syntaxhighlighter3.0.83/scripts/shBrushRuby.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushSass.js",type:"js",charset: "utf-8"},
	//{uri: "../syntaxhighlighter3.0.83/scripts/shBrushScala.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushSql.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushVb.js",type:"js",charset: "utf-8"},
	{uri: "../syntaxhighlighter3.0.83/scripts/shBrushXml.js",type:"js",charset: "utf-8"},*/
	{uri: "../syntaxhighlighter3.0.83/styles/shCoreDefault.css",type:"css",charset: "utf-8"}
];
OL.loader.libs["ol.loading"] = [
	"jquery",
	"jquery.bgiframe",
	{uri: "../ol.loading/loading-min.js",type: "js",charset: "utf-8",depend:true},
	{uri: "../ol.loading/loading.css",type: "css",charset: "utf-8"}
];

