$(document).ready(function(){
	var searchLabel ='请输入搜索的关键词';
	$('#KeywordsTextBox').addClass('keywordinputplace').val(searchLabel).focus(function(){
		if (this.value == searchLabel){
			$(this).removeClass('keywordinputplace').val('');
		};
	}).blur(function(){
		if (this.value == '') {
			$(this).addClass('keywordinputplace').val(searchLabel);
		};
	});
	
	$('#formsearch').submit(function(){
		if ($('#KeywordsTextBox').val() == searchLabel){
			$('#KeywordsTextBox').val('');			
			alert("请输入搜索的关键词");
			$('#keyword').focus;
			return false;
		}
	});

	$('#newspecial').mouseover(function(){
		setMenuPosition(this.id);
		MenuDivShow(this.id);		
	}).mouseout(function () { $('#' + this.id + '_menu').hide(); });
	
	$('#newspecialtmp').mouseover(function(){
		setMenuPosition(this.id);
		MenuDivShow('newspecial');	
	}).mouseout(function () { $('#newspecial_menu').hide(); });
		
	$('#filtertype').click(function(){
		setMenuPosition(this.id);
		MenuDivShow(this.id);
	}).mouseout(function () { $('#' + this.id + '_menu').hide(); });
	
	$('#filterorder').click(function(){
		setMenuPosition(this.id);
		MenuDivShow(this.id);
	}).mouseout(function () { $('#' + this.id + '_menu').hide(); });
	
	//所有版面列表的下拉
	$('#BoardDiv').mouseover(function(){
		BoardListDiv(1,this.id);
	}).mouseout(function () { $('#' + this.id + '_menu').hide(); });
		
});
/// ready end 



function expertrequest(ForumID,experturl,Bexperttitle){
	floatDiv(Bexperttitle,500,350);
	getajax(experturl,'messagebox_body');
	
}

//版规，管理团队等
function BMMenu(BMID,ForumID){
	for (var i=1;i<=5;i++){
		if (i==BMID){
			$('#BM_'+i).removeClass('normal');
			$('#BM_'+i).addClass('active');
		}
		else{
			$('#BM_'+i).removeClass('active');
			$('#BM_'+i).addClass('normal');
		}
	}
	
	$.ajax({
		url: "/ajaxTemplates/BMMenu.asp",
		cache: false,
		timeout:10000,
		data: 'BMID='+ BMID +'&ForumID='+ ForumID,
		beforeSend: function(XMLHttpRequest){
			Loadingstr=ShowLoading();
			$('#BM_Comtent').html(Loadingstr);
		},
		success: function(html){
			$('#BM_Comtent').html(html);
		},
		complete: function(){
			$('#loading').remove();
		},
		error: function(){
			$('#BM_Comtent').html('加载失败...');
		}
	}); 
}

//申请推荐专家
function CheckExpertsend(theform){
	var forumid=document.Expertform.forumid.value;
	var Recommend_Reason=document.Expertform.Recommend_Reason.value;
	var EType=document.Expertform.EType.value;
	
	if (EType == 'B'){
		Eusername=document.Expertform.Eusername.value;
		
		if (Eusername == ''){
			alert('请输入被推荐人账号');
			document.Expertform.Eusername.focus();
			return false
		}
	}else{
		Eusername ='';
	}
	
	if (Recommend_Reason == ''){
			alert('请输入理由');
			document.Expertform.Recommend_Reason.focus();
			return false
	}
	if (document.Expertform.Recommend_Reason.value.length > 200){
		alert('理由不能超过200个字符');
		document.Expertform.Recommend_Reason.focus();
		return false
	}
	
	ajaxpost_bbs(theform); 
	 
}


function CheckSort(theform){
	if (theform.SortName.value==''){
		alert("请输入子版名称");
		theform.SortName.focus();
		return false;
	}
	$('#waitID').empty(); 
	
	ajaxpost_bbs(theform);
}

function CheckForbid(theform){
	if (theform.username.value==''){
		alert("请输入处罚的用户名");
		theform.username.focus();
		return false;
	}
	
	
	$('#waitID').empty(); 
	
	ajaxpost_bbs(theform);
}

function CheckBoardRule(theform){
	if (theform.BoardRules.value==''){
		alert("请输入版规内容");
		theform.BoardRules.focus();
		return false;
	}
	
	ajaxpost_bbs(theform);
}

function Checklive(theform){
	if (theform.FL_Reason.value==''){
		alert("请输入理由");
		theform.FL_Reason.focus();
		return false;
	}
	
	ajaxpost_bbs(theform);
}

//删帖
function Checkdelthread(theform){

	if (theform.Reason_Del.value==''){
		alert("请输入理由");
		theform.Reason_Del.focus();
		return false;
	}
	
	if (theform.Reason_Del.value.length > 40){
		alert('理由不能超过40个字符');
		theform.Reason_Del.focus();
		return false;
	}
	
	theform.btndel.disabled = false;
	ajaxpost_bbs(theform);
	
}

//本版居民
function forumLive(ForumID,LiveType){
	 $.ajax({
	 	type:"POST",
		url: '/ajaxTemplates/ForumIDLiveAjax.asp?ForumID='+ ForumID +'&LiveType='+ LiveType,
		cache: false,
		
		beforeSend: function(XMLHttpRequest){
			Loadingstr=ShowLoading(); 
			$('#waitID').html(Loadingstr);
		},
		success: function(html){
			$('#messagebox_body').html(html);
			setTimeout(function(){ window.location.href=window.location.href}, 2000);
		},
		complete: function(){
			$('#loading').remove();
		},
		error: function(){
			$('#waitID').html('加载失败...');
		}
	}); 
}



//焦点话题
function BMFocusListShow(BFType,ForumID,FID){
	
	$.ajax({
			  url: "/ajax/BMFocus_info.asp",
			  cache: false,
			  data: 'ForumID='+ ForumID +'&BFType='+ BFType +'&FID='+ FID,
			  beforeSend: function(XMLHttpRequest){
				//ShowLoading();
				Loadingstr=ShowLoading();
				$('#tableBMFocus').html(Loadingstr);
			  },
			  success: function(html){
				$('#tableBMFocus').html(html);
			  },
			  complete: function(){
				 $('#loading').remove();
			  },
			  error: function(){
				$('#tableBMFocus').html('加载失败...');
			  }
		}); 
}

//保存焦点话题
function BMFocussend(){
	var FTitle=document.formFocus.FTitle.value;
	var FContent=document.formFocus.FContent.value;
	var BFType=document.formFocus.BFType.value;
	var ForumID=document.formFocus.ForumID.value;
	var FID=document.formFocus.FID.value;
	
	if (BFType == ''){
		alert('参数传递错误，请关闭对话框后重试');
		return false
	}
	
	if (BFType == 'Fediter'){
		if (FID ==''){
			alert('您需要修改的焦点话题的可能已经不存在了，请关闭对话框后重试');
			return false
		}	
	}
	
	if (FTitle == ''  || FContent == ''){
			alert('请输入完整的推荐焦点话题标题或内容');
			document.formFocus.FTitle.focus();
			return false
	}
	if (document.formFocus.FTitle.value.length > 100){
		alert('焦点话题标题不能超过100个字符');
		document.formFocus.FTitle.focus();
		return false
	}
	
	
	
	 $.ajax({
	 	type:"POST",
		url: "/ajax/BMFocus_Code.asp",
		cache: false,
		data:'forumid=' + ForumID +'&BFType='+ BFType+'&FID='+ FID +'&FTitle='+escape(FTitle)+'&FContent='+escape(FContent),
		beforeSend: function(XMLHttpRequest){
			Loadingstr=ShowLoading(); 
			$('#WaitIDshow').html(Loadingstr);
		},
		success: function(html){
			$('#tableBMFocus').html(html);
		},
		complete: function(){
			$('#loading').remove();
		},
		error: function(){
			$('#WaitIDshow').html('加载失败...');
		}
	}); 
	 
}
