JTK.require('JTK.Cookie');
JTK.require('JTK.Array');
JTK.require('JTK.String');

function bbs_layouts_main(){
	//主题管理下拉菜单
	$(".bblue_btn_box").mouseover(function(){
		$(this).find(".xiala").show();
		//$(".xialaParent")..removeClass("set");
	}).mouseout(function(){
		$(this).find(".xiala").hide();
		//$(this).css("background","#70A9CF");
	});
	//发帖按钮下拉菜单
	$(".bred_btn_box").mouseover(function(){
		$(this).find(".xiala").show();
		//$(".xialaParent")..removeClass("set");
	}).mouseout(function(){
		$(this).find(".xiala").hide();
		//$(this).css("background","#70A9CF");
	});
	//主题列表排序下拉
	$(".allthreadlist").mouseover(function(){
		$(this).find(".xiala").show();
		//$(".xialaParent")..removeClass("set");
	}).mouseout(function(){
		$(this).find(".xiala").hide();
		//$(this).css("background","#70A9CF");
	});
	
	//主题列表排序下拉
	$(".gobacklist").mouseover(function(){
		$(this).find(".backlist").show();
		//$(".xialaParent")..removeClass("set");
	}).mouseout(function(){
		$(this).find(".backlist").hide();
		//$(this).css("background","#70A9CF");
	});
	
	//下拉菜单
	$(document).ready(function(){
		$(".xialaParent").mouseover(function(){
			$(this).find(".xiala").show();
			$(this).addClass("xialaBg");
		}).mouseout(function(){
			$(this).find(".xiala").hide();
			$(this).removeClass("xialaBg");
		});
		$(".xiala ul").mouseover(function(){
			$(".xiala ul").removeClass("set");
			$(this).addClass("set");
		});
	});
	

	//风格切换
	$(".head_nav .skinchangebox").mouseover(function(){
		$(this).find(".selectskin").show();
		$(this).css("background"," ");
	}).mouseout(function(){
		$(this).find(".selectskin").hide();
		$(this).css("background"," ");
	});
	$(".head_nav .selectskin li").mouseover(function(){
		$(".head_nav .selectskin li").removeClass("set");
		$(this).addClass("set");
	});
	
	//个人设置
	
	
	
	
	
	$(".head_nav .xialaParent").mouseover(function(){
		$(this).find(".xiala").show();
		$(this).addClass("xialaBg");
	}).mouseout(function(){
		$(this).find(".xiala").hide();
		$(this).removeClass("xialaBg");
	});
	$(".nav_right2 .xiala ul").mouseover(function(){
		$(".nav_right2 .xiala ul").removeClass("set");
		$(this).addClass("set");
	});
	
	$(".caozuo_main .xialaParent").mouseover(function(){
		$(this).find(".youxiala").show();
		//$(".xialaParent")..removeClass("set");
		$(this).addClass("set");
	}).mouseout(function(){
		$(this).find(".youxiala").hide();
		//$(this).css("background","#70A9CF");
	});
	$(".caozuo_main ul").mouseover(function(){
		$(".caozuo_main ul").removeClass("set");
		$(this).addClass("set");
	});
	$(".youxiala ul li").mouseover(function(){
		$(".youxiala ul li").removeClass("set");
		$(this).addClass("set");
	});
	//后台管理常用操作
	$(".cycz").html(JTK.Cookie.getCookie("cyCookieListStr"));
	if(!JTK.Cookie.getCookie("cyCookieListStr")){
		var cyCookieListStr = '<ul><A href="/index.php?r=manage/threads/ThreadsManage&amp;t=1278574938">主题管理</A> </ul>,<ul><A href="/index.php?r=manage/default/FlinkManage&amp;t=1278574938">友情链接</A> </ul>,<ul><A href="/index.php?r=manage/forums/ForumsMerge&amp;t=1278574938">版块合并</A> </ul>,<ul><A href="/index.php?r=manage/forums/ForumsManage&amp;t=1278574938">版块管理</A> </ul>,<ul><A href="/index.php?r=manage/user/ListMemberUsergroup&amp;t=1278574938">用户组管理</A> </ul>';
		JTK.Cookie.setCookie("cyCookieListStr", cyCookieListStr);
	}else{
		var cyCookieListStr = JTK.Cookie.getCookie("cyCookieListStr");
	}
	var listShows = cyCookieListStr.split(",");
	listShows.splice(5,1000);
	var listShow = listShows.join("");
	$(".cycz").html(listShow);
	$(".caozuo_box li").mousedown(function(){
		if(!JTK.Cookie.getCookie("cyCookieListStr")){
			var cyCookieListStr = '';
		}else{
			var cyCookieListStr = JTK.Cookie.getCookie("cyCookieListStr");
		}
		if(!$(this).parent().hasClass("xialaParent") && !$(this).parents(".cycz").html()){
			if(cyCookieListStr){
				cyCookieLists = cyCookieListStr.split(",");
			}else{
				cyCookieLists = [];
			}
			var pushStr = "<ul>"+$(this).html()+"</ul>";
			var findStr = $(pushStr).text();
			if(cyCookieListStr.indexOf(findStr.trim()) <0 ){
				cyCookieLists.reverse();
				cyCookieLists.push(pushStr);
				cyCookieLists.reverse();
			}
			if(!JTK.Cookie.getCookie("cyCookieListStr")){
				var cyCookieListStr = '';
			}else{
				var cyCookieListStr = JTK.Cookie.getCookie("cyCookieListStr");
			}
			cyCookieLists.splice(5,1000);
			cyCookieListStr = cyCookieLists.join(",");
			JTK.Cookie.setCookie("cyCookieListStr", cyCookieListStr);
			var listShows = cyCookieListStr.split(",");
			var listShow = listShows.join("");
			$(".cycz").html(listShow);
			var href = $(this).find("a").attr("href");
			if(href != undefined){
				window.location=href;
			}
		}
	});

	//前台管理常用操作
	$(".qtcycz").html(JTK.Cookie.getCookie("frontcyCookieListStr"));
	if(!JTK.Cookie.getCookie("frontcyCookieListStr")){
		var qtcyCookieListStr = '';
		JTK.Cookie.setCookie("frontcyCookieListStr", qtcyCookieListStr);
	}else{
		var qtcyCookieListStr = JTK.Cookie.getCookie("frontcyCookieListStr");
	}
	var listShows = qtcyCookieListStr.split(",");
	listShows.splice(3,200);
	var listShow = listShows.join("");
	listShow = listShow.replace('dissettingguides=0','');//修改在ie下出现'dissettingguides=0'的问题。
	$(".qtcycz").html(listShow);
	$(".qtcy_box li").mousedown(function(){
		if(!JTK.Cookie.getCookie("frontcyCookieListStr")){
			var qtcyCookieListStr = '';
		}else{
			var qtcyCookieListStr = JTK.Cookie.getCookie("frontcyCookieListStr");
		}
		if(!$(this).parent().hasClass("xialaParent") && !$(this).parents(".qtcycz").html()){
			if(qtcyCookieListStr){
				qtcyCookieLists = qtcyCookieListStr.split(",");
			}else{
				qtcyCookieLists = [];
			}
			var picon = '';
			picon = $(this).prev(".pic").html();
			if(picon == null) picon = "<li class=\"pic\"><img src=\"/default/mutual/images/common/doth1.gif\" /></li>";
			var pushStr = "<ul>"+picon+$(this).html()+"</ul>";
			var findStr = $(pushStr).text();
			if(qtcyCookieListStr.indexOf(findStr.trim()) <0 ){
				qtcyCookieLists.reverse();
				qtcyCookieLists.push(pushStr);
				qtcyCookieLists.reverse();
			}
			if(!JTK.Cookie.getCookie("frontcyCookieListStr")){
				var qtcyCookieListStr = '';
			}else{
				var qtcyCookieListStr = JTK.Cookie.getCookie("frontcyCookieListStr");
			}
			qtcyCookieLists.splice(3,200);
			qtcyCookieListStr = qtcyCookieLists.join(",");
			JTK.Cookie.setCookie("frontcyCookieListStr", qtcyCookieListStr);
			var listShows = qtcyCookieListStr.split(",");
			var listShow = listShows.join("");
			$(".qtcycz").html(listShow);
			var href = $(this).find("a").attr("href");
			if(href != undefined){
				window.location=href;
			}
		}
	});
	//折叠左侧菜单
	$(".collapse_tb").click(function(){	
		$(this).parent(".caozuo_tit").next(".caozuo_main").slideToggle(8);
		if($(this).find("img").attr("src")==mutualImgPath+'/common/cate_open.gif'){
			$(this).find("img").attr("src",mutualImgPath+"/common/cate_fold.gif");
		}else{
			$(this).find("img").attr("src",mutualImgPath+"/common/cate_open.gif");
		}
	});
	
	//切换宽窄屏
	$("#chLayoutWidth").click(function(){
		
		/*
		 * 在这里配置存储程序路径
		 * 然后每次在layout里所有css打印之后打印如下css
		 * 窄屏
			#head, #foot {
				width: 80%;
			}
			#lay0, #lay1, #lay2, #lay3, #lay4, #lay5, #lay6, #lay7 {
				width: 78%;
			}
		 * 宽屏幕
		   #head, #foot {
				width: 100%;
			}
			#lay0, #lay1, #lay2, #lay3, #lay4, #lay5, #lay6, #lay7 {
				width: 98%;
			}
		 */
		var chLayoutUrl = "/index.php?r=forums/default/forumlayout";	
		
		var layoutWidthType = 1;	//1宽屏 2窄屏
		if($("#head").width() == $("body").width()){	//宽屏
			$("#head, #foot").width("80%");
			$("#lay0, #lay1, #lay2, #lay3, #lay4, #lay5, #lay6, #lay7").width("78%");
			var layoutWidthType = 2;
			$(this).html("切换到宽版");
		} else {
			$("#head, #foot").width("100%");
			$("#lay0, #lay1, #lay2, #lay3, #lay4, #lay5, #lay6, #lay7").width("98%");
			var layoutWidthType = 1;
			$(this).html("切换到窄版");
		}
		$.get(chLayoutUrl, { "layoutWidthType": layoutWidthType} ); 
	});
};

