<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head><title><!--{$UUDEV_PAGE_TITLE}--></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!--{include file=elements/header.css.html}-->
<!--{include file=elements/header.js.html type=common}-->
<!--{include file=elements/header.js.html type=form}-->
<!--{include file=elements/header.js.html type=ubb}-->
<script src="js/jquery/ui/jquery-ui.min.js"></script>
<script src="js/jquery/jquery.query.js"></script>
<script src="js/jquery/jquery.contextmenu.js"></script>

<script src="js/jquery/jquery.blockUI.js" charset="utf-8"></script>

<link href="css/layoutcpanel.css" rel="stylesheet"/>
<style type="text/css">
#cpaneldiv{
	position:absolute;
	left:6px;
	width:353px;
	border:1px #24598b solid;
	background:#FFFFFF;
}
#rightdiv{
	position:absolute;
	left:368px;
	border:1px #24598b solid;
	background:#FFFFFF;
}
</style>
</head>
<body>
<div id="outside">
	<!--{include file=frame/top.html}-->
	<div id="mainareaContent">
		<!--{include file=frame/left.html}-->
		<div id="rightContent">
			<div id="secrightContent-cpanel" style="width:100%;height:100%; background:#689dcf; border:1px #24598b solid; padding:5px; margin-top:8PX;">
				<div id="cpaneldiv">
					<div class="UBBbuju_title">
						<!--{if $template.id == 1}-->用户中心页布局<!--{else}-->用户浏览页布局<!--{/if}-->
					</div>
					<div style="height:29px;line-height:34px;margin-top:5px;padding-left:5px;">
						<a class="ubb_button_ui" href="index.php?r=Layout.user&id=1">用户中心页布局</a>
						<a class="ubb_button_ui" href="index.php?r=Layout.user&id=2">用户浏览页布局</a>
					</div>
					<div id="cpanel-scroll" style="border:1px #bfd5e8 solid; background:#FFFFFF;overflow-y:auto; overflow-x:hidden;width:100%;">
						<div id="cpanelBox" style="boder:0;width:100%;height:100%;"><!--{$template.content}--></div>
					</div>
				</div>
				<div id="rightdiv">
					<div id="help-scroll" style="boder:0; overflow-y:auto; overflow-x:hidden;">
						<div id="helperBox" style="boder:0;width:100%;height:100%;">
							<div class="UBBbuju_title">编辑区</div>
							<div class="layoutEditor" style=" background:#FFFFFF; padding:0px 3px;">
								<div class="editorBody">
									<form id="userTemplateForm" action="index.php?r=layout.edit_user_template" method="post">
										<input type="hidden" name="data[UserTemplate][id]" value="<!--{$template.id}-->"/>
										<div class="ubbEditor" style="padding-top:3px; width:99%">
											<textarea id="content" name="data[UserTemplate][content]"><!--{$templateubb.content}--></textarea>
										</div>
										<div class="ubbAttr" style="padding:5px 0;">
											<button type="submit" class="butT">保存</button>
										</div>
									</form>
								</div>
								<div style="overflow-y:scroll;border:1px #bfd5e8 solid;" id="UBB_edit_navBox">
									<div class="showtool" style=" padding:2px; background:url(images/bgx.gif) 0px -199px; height:20px; line-height:20px; border-right:none; cursor:pointer">
										<span><b id="ubbmenu-status">基本功能</b><img src="images/jt.gif" alt=""></span>&nbsp;&nbsp;<span style="color:#FF0000; margin-left:8px;">[点击显示更多功能 <img src="images/new.gif" alt="">]</span>
									</div>
									<div class="ubbTool" style="background:#ffffff; border-top:1px #aedcfe solid;">
										<ul>
											<li><a class="ubbmenu" value="basic-function" href="javascript:void();">基本功能</a></li>
											<li><a class="ubbmenu" value="resources-call" href="javascript:void();">资源调用</a></li>
											<li><a class="ubbmenu" value="new-resources" href="javascript:void();">资源新增</a></li>
											<li><a class="ubbmenu" value="advertising-system" href="javascript:void();">广告系统</a></li>
											<li><a class="ubbmenu" value="links" href="javascript:void();">友情链接</a></li>
											<li><a class="ubbmenu" value="custom-search" href="javascript:void();">自定义搜索</a></li>
											<li><a class="ubbmenu" value="music-module" href="javascript:void();">音乐模块</a></li>
											<li><a class="ubbmenu" value="access-statistics" href="javascript:void();">访问统计</a></li>
											<li><a class="ubbmenu" value="personal-center-page" href="javascript:void();">个人中心页面</a></li>
											<li><a class="ubbmenu" value="member-display-page" href="javascript:void();">会员展示页面</a></li>
											<li><a class="ubbmenu" value="ubbtags" href="javascript:void();">自定义标签</a></li>
										</ul>
									</div>
									<div class="ubbBody" style="background:#f6f9fc; border-top:1px #bfd5e8 solid;">
										<div id="ubbArea" style="line-height:24px; color:#0c6500; padding-left:5px;">
										</div>
									</div>
								</div>
							</div>
						</div>
					</div>
				</div>
			</div>
		</div>
	</div>
</div>
</body>
<script>
_$.resize = function(){
	var tcHeight = $("#topOutside").height();
	var leftWidth = $("#leftContent").width();
	var sWidth = document.documentElement.clientWidth;
	var sHeight = document.documentElement.clientHeight;
	var tabcontentheight = $(".tabcontent").height() + 5;
	var sitmapHeight = $(".sitmap").height();
	var cpaneldiv = $("#cpaneldiv").width();
	
	$("#mainareaContent").css({
		height: sHeight - tcHeight - 4
	});
	$("#leftContent").css({
		height: sHeight - tcHeight - 4
	});
	$("#rightContent").css({
		height: sHeight - tcHeight - 4
	});
	$("#rightContent").css({
		width: sWidth - leftWidth - 10
	});
	$("#secrightContent").css({
		height: sHeight - sitmapHeight - tabcontentheight - tcHeight
	});
	
	$("#cpanel-scroll").css({
		height: sHeight - 85 - 21 -62
	});
	
	$("#help-scroll").css({
		height: sHeight - 85 - 21
	});
	
	$("#secrightContent-cpanel").css({
		height: sHeight - 85 - 21
	});
	$("#rightdiv").css({
		width: sWidth - 151 - 6 - cpaneldiv -30
	});
	
	var soc = 0;
	if(document.all)
	{
		if($("#cpanel-scroll").height()<$("#cpanelLayout").height())
		{
			soc+=18;
		}
		
		if($("#help-scroll").height()<$("#helperLayout").height())
		{
			soc+=18;
		}
	}
}

$(document).ready(function(){
	$("#userTemplateForm").submit(function(){
		$(this).ajaxSubmit({
			success: function(str){
				var data = eval('(' + str + ')');
				if (data.status == 1) {
					
					$.successUI({
						message:"保存成功！",
						showOverlay:true,
						confirm:function(){setTimeout($.unblockUI, 300);$("#cpanelBox").html(data.content);}
					});
					
				} else if (data.status == 0) {

					$.errorUI({
						message:"保存失败！",
						showOverlay:true
					});
				}
			}
		});
		return false;
	});

	var $Editor = $("#content").addClass("cleditorTextarea").cleditor({
		width: "100%",
		height: 120,
		controls: "bold italic underline break | undo redo | image link file |",
		customBind: function(editor){
			$.ajax({
				url:"index.php?r=Layout.getUbbTemplate",
				type:"get",
				data:{template:'basic-function'},
				cache:false,
				success:function(html){
					$("#ubbArea").empty();
					$(html).appendTo("#ubbArea");
					$(".ubbcode").bind('click',function(){
						$.cleditor.cRange(editor);
						$.cleditor.exec(editor,$(this).text());
					});
				}
			});
			
			$(".ubbmenu").click(function(){
				var btn_name = $(this).text();
				if($(this).attr("value")!=''){
					$.ajax({
						url:"index.php?r=Layout.getUbbTemplate",
						type:"get",
						data:{template:$(this).attr("value")},
						cache:false,
						success:function(html){
							$(".ubbTool").slideUp(1000);
							$("#ubbArea").empty();
							$("#ubbmenu-status").html(btn_name);
							$(html).appendTo("#ubbArea");
							$(".ubbcode").bind('click',function(){
								$.cleditor.cRange(editor);
								$.cleditor.exec(editor,$(this).text());
							});
							
							//绑定资源调用向导
							$(".useubbwizard").bind('click',function(){
								var channel_id=0,channel_text=$(this).attr("value");
								if(channel_text == '' || channel_text== undefined) return false;
								
								var isAll = false;
								var channels = new Array();
								
								switch(channel_text){
									case "article": channel_id = 1;break;
									case "software": channel_id = 2;break;
									case "theme": channel_id = 8;break;
									case "game": channel_id = 3;break;
									case "picture": channel_id = 9;break;
									case "forum": channel_id = 5;break;
									case "link": channel_id = 7;break;
									case "music": channel_id = 10;break;
								}
								
								$.ajax({
									url:"index.php?r=Layout.getChannelByModule",
									type:"get",
									data:{channel_module_id:channel_id},
									cache:false,
									success:function(ChannelResponseText){
										var fc = $.fn.firesbox.start(ChannelResponseText, {hideOnContentClick: false});
										//绑定checkall事件
										fc.find("#checkall").unbind("click").bind("click", function(){
											if($(this).attr("checked")){
												$(".channelbox").each(function(){
													$(this).attr("checked",true);
												});
												isAll = true;
											}else{
												$(".channelbox").each(function(){
													$(this).attr("checked",false);
												});
												isAll = false;
											}
										});
										//绑定单个选框事件
										fc.find(".channelbox").unbind("click").bind("click", function(){
											var channel_id = $(this).val();
											if($(this).attr("checked")){
												if($.inArray(channel_id,channels) == -1){
													channels.push(channel_id);
												}
											}else{
												if($.inArray(channel_id,channels) != -1){
													channels = $.grep(channels,function(n,i){return n!=channel_id;});
												}
												
												if(isAll){
													isAll = false;
													$("#checkall").attr("checked",false);
													$(".channelbox").each(function(){
														if($(this).attr("checked")){
															if($.inArray($(this).val(),channels) == -1){
																channels.push($(this).val());
															}
														}
													});
												}
											}
										});
										
										fc.find(".nextBtn").unbind("click").bind("click", function(){
											if(!isAll && channels.length<1){
												alert("请选择频道！");
												return false;
											}
											var channel = "";
											if(isAll){
												channel = "0";
											}else{
												$(channels).each(function(k,v){
													if(channel == ""){
														channel = v;
													}else{
														channel+="|"+v;
													}
												});
											}
											switch(channel_text){
												case "article": bindArticle(editor,channel);break;
												case "software": bindSoftware(editor,channel);break;
												case "theme": bindTheme(editor,channel);break;
												case "game": bindGame(editor,channel);break;
												case "picture": bindPicture(editor,channel);break;
												case "forum": bindForum(editor,channel);break;
												case "link": bindLink(editor,channel);break;
												case "music": bindMusic(editor,channel);break;
											}
										});
									}
								});
							});
							
							//绑定资源新增向导
							$(".useubbwizard-new").bind('click',function(){
								var channel_id=0,channel_text=$(this).attr("value");
								if(channel_text == '' || channel_text== undefined) return false;
								
								var isAll = false;
								var channels = new Array();
								
								switch(channel_text){
									case "article": channel_id = 1;break;
									case "software": channel_id = 2;break;
									case "theme": channel_id = 8;break;
									case "game": channel_id = 3;break;
									case "picture": channel_id = 9;break;
									case "bbs": channel_id = 5;break;
									case "link": channel_id = 7;break;
								}
								
								$.ajax({
									url:"index.php?r=Layout.getChannelByModule",
									type:"get",
									data:{channel_module_id:channel_id},
									cache:false,
									success:function(ChannelResponseText){
										var fc = $.fn.firesbox.start(ChannelResponseText, {hideOnContentClick: false});
										//绑定checkall事件
										fc.find("#checkall").unbind("click").bind("click", function(){
											if($(this).attr("checked")){
												$(".channelbox").each(function(){
													$(this).attr("checked",true);
												});
												isAll = true;
											}else{
												$(".channelbox").each(function(){
													$(this).attr("checked",false);
												});
												isAll = false;
											}
										});
										//绑定单个选框事件
										fc.find(".channelbox").unbind("click").bind("click", function(){
											var channel_id = $(this).val();
											if($(this).attr("checked")){
												if($.inArray(channel_id,channels) == -1){
													channels.push(channel_id);
												}
											}else{
												if($.inArray(channel_id,channels) != -1){
													channels = $.grep(channels,function(n,i){return n!=channel_id;});
												}
												if(isAll){
													isAll = false;
													$("#checkall").attr("checked",false);
													$(".channelbox").each(function(){
														if($(this).attr("checked")){
															if($.inArray($(this).val(),channels) == -1){
																channels.push($(this).val());
															}
														}
													});
												}
											}
										});
										
										fc.find(".nextBtn").unbind("click").bind("click", function(){
											if(!isAll && channels.length<1){
												alert("请选择频道！");
												return false;
											}
											var channel = "";
											if(isAll){
												channel = "0";
											}else{
												$(channels).each(function(k,v){
													if(channel == ""){
														channel = v;
													}else{
														channel+="|"+v;
													}
												});
											}
											bindResourcesNew(editor,channel,channel_text);
										});
									}
								});
							});
							
							//绑定广告
							$(".useubbADwizard").bind('click',function(){
								bindADWizard(editor);
							});
							
							$(".useubbsearchwizard").bind('click',function(){
								$.ajax({
									url:"index.php?r=Layout.getSearchInputWizard",
									type:"get",
									data:{},
									cache:false,
									success:function(HtmlResponseText){
										var fc = $.fn.firesbox.start(HtmlResponseText, {hideOnContentClick: false});
										
										 fc.find(".cancelBtn").unbind("click").bind('click',function(){
											$.fn.firesbox.close();
										});
										fc.find(".insertBtn").unbind("click").bind('click',function(){
											var input_name = $("#firesbox_content").find("#input-name").val();
											var input_size = $("#firesbox_content").find("#input-size").val();
											var input_value = $("#firesbox_content").find("#input-value").val();
											if(input_name == ""){
												alert("搜索框名不能为空！");
												return false;
											}
											$.cleditor.cRange(editor);
											$.cleditor.exec(editor,"[input name="+input_name+" size="+input_size+" value="+input_value+"]");
											
											$.fn.firesbox.close();
										});
									}
								});
							});
							
							$(".useubbsearchbuttonwizard").bind('click',function(){
								var channel_id=0,channel_text=$(this).attr("value");
								if(channel_text == '' || channel_text== undefined) return false;
								var $channel_id = 0;
								switch(channel_text){
									case "article": channel_id = 1;break;
									case "software": channel_id = 2;break;
									case "theme": channel_id = 8;break;
									case "game": channel_id = 3;break;
									case "picture": channel_id = 9;break;
									case "forum": channel_id = 5;break;
								}
								$.ajax({
									url:"index.php?r=Layout.getSearchChannelByModule",
									type:"get",
									data:{channel_module_id:channel_id},
									cache:false,
									success:function(ChannelResponseText){
										var fc = $.fn.firesbox.start(ChannelResponseText, {hideOnContentClick: false});
										//绑定checkall事件
										fc.find(".channelbox").unbind("click").bind("click", function(){
											if ($(this).attr("checked")) {
												$channel_id = $(this).val();
											}
										});
										fc.find(".nextBtn").unbind("click").bind("click", function(){
											switch(channel_text){
												case "article": bindSearchArticle(editor,$channel_id);break;
												case "software": bindSearchSoftware(editor,$channel_id);break;
												case "theme": bindSearchTheme(editor,$channel_id);break;
												case "game": bindSearchGame(editor,$channel_id);break;
												case "picture": bindSearchPicture(editor,$channel_id);break;
												case "forum": bindSearchForum(editor,$channel_id);break;
											}
										});
									}
								});
							});
						}
					});
				}
			});
		  }
      });
		
	$(".showtool").click(function(){
		if($(".ubbTool").is(":visible") !== false){
			$(".ubbTool").slideUp(300);
		}else{
			$(".ubbTool").slideDown(300);
		}
	});
		
	function bindArticle(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getArticleWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[article="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSoftware(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getSoftwareWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find("#ordering").unbind("change").bind('change',function(){
					if($(this).val() == 5){
						$("#firesbox_content").find("#show-ordering-day").fadeIn("slow");
					}else{
						$("#firesbox_content").find("#show-ordering-day").fadeOut("slow");
					}
				});
				
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					var ordering_day = $("#firesbox_content").find("#ordering-day").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					if(ordering == "5" && ordering_day==""){
						alert("请填写天数！");
						return false;
					}else if(ordering == "5" && ordering_day >0){
						ordering+= "|"+ordering_day;
					}
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[software="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindTheme(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getThemeWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find("#ordering").unbind("change").bind('change',function(){
					if($(this).val() == 5){
						$("#firesbox_content").find("#show-ordering-day").fadeIn("slow");
					}else{
						$("#firesbox_content").find("#show-ordering-day").fadeOut("slow");
					}
				});
				
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					var ordering_day = $("#firesbox_content").find("#ordering-day").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					if(ordering == "5" && ordering_day==""){
						alert("请填写天数！");
						return false;
					}else if(ordering == "5" && ordering_day >0){
						ordering+= "|"+ordering_day;
					}
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[theme="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindGame(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getGameWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find("#ordering").unbind("change").bind('change',function(){
					if($(this).val() == 5){
						$("#firesbox_content").find("#show-ordering-day").fadeIn("slow");
					}else{
						$("#firesbox_content").find("#show-ordering-day").fadeOut("slow");
					}
				});
				
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					var ordering_day = $("#firesbox_content").find("#ordering-day").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					if(ordering == "5" && ordering_day==""){
						alert("请填写天数！");
						return false;
					}else if(ordering == "5" && ordering_day >0){
						ordering+= "|"+ordering_day;
					}
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[game="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindPicture(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getPictureWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find("#ordering").unbind("change").bind('change',function(){
					if($(this).val() == 5){
						$("#firesbox_content").find("#show-ordering-day").fadeIn("slow");
					}else{
						$("#firesbox_content").find("#show-ordering-day").fadeOut("slow");
					}
				});
				
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					var ordering_day = $("#firesbox_content").find("#ordering-day").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					if(ordering == "5" && ordering_day==""){
						alert("请填写天数！");
						return false;
					}else if(ordering == "5" && ordering_day >0){
						ordering+= "|"+ordering_day;
					}
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[picture="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}

	function bindForum(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getForumWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[bbs="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindLink(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getLinkWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var title_length = $("#firesbox_content").find("#title-length").val();
					var show_br = $("#firesbox_content").find("#show-br").val();
					var br_count = $("#firesbox_content").find("#br-count").val();
					var spacer = $("#firesbox_content").find("#spacer").val();
					if(record_count == "") record_count = 20;
					if(title_length == "") title_length = 0;
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[link="+channel+"_"+record_count+"_"+ordering+"_"+title_length+"_"+show_br+"_"+br_count+"_"+spacer+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindResourcesNew(editor,channel,module){
		$.ajax({
			url:"index.php?r=Layout.getResourcesNewWizard",
			type:"get",
			data:{module:module},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					if(record_count == "") record_count = 20;
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"["+module+"="+channel+"_"+record_count+"_"+ordering+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindADWizard(editor){
		$.ajax({
			url:"index.php?r=Layout.getADWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				var fc = $.fn.firesbox.start(HttpResponseText, {hideOnContentClick: false});
				fc.find(".cancelBtn").unbind("click").bind('click',function(){
					//清空cookie
					$.cookie("ADCOOKIES",null);
					$.fn.firesbox.close();
				});
				fc.find(".insertBtn").unbind("click").bind('click',function(){
					var ad_cookies = $.cookie("ADCOOKIES");
					if(ad_cookies == "" ||　ad_cookies == undefined){
						alert("请先选择要投放的广告！");
						return false;
					}
					var record_count = $("#firesbox_content").find("#record-count").val();
					if(record_count == "") record_count = 20;
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ad]"+ad_cookies+"_"+record_count+"[/ad]");
					//清空cookie
					$.cookie("ADCOOKIES",null);
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindMusic(editor,channel){
		$.ajax({
			url:"index.php?r=Layout.getMusicWizard",
			type:"get",
			data:{},
			cache:false,
			success:function(HttpResponseText){
				$("#firesbox_content").empty();
				$(HttpResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var show_type = $("#firesbox_content").find("#show-type").val();
					var record_count = $("#firesbox_content").find("#record-count").val();
					var ordering = $("#firesbox_content").find("#ordering").val();
					var show_channel = $("#firesbox_content").find("#show-channel").val();
					if(record_count == "") record_count = 20;
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"["+show_type+"="+channel+"_"+record_count+"_"+ordering+"_"+show_channel+"]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSearchArticle(editor,$channel_id){
		$.ajax({
			url:"index.php?r=Layout.getSearchArticleWizard",
			type:"get",
			data:{channel_module_id:1},
			cache:false,
			success: function(HtmlResponseText){
				$("#firesbox_content").empty();
				$(HtmlResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var input_name = $("#firesbox_content").find("#input-name").val();
					var btn_name = $("#firesbox_content").find("#btn-name").val();
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ancho=article_"+$channel_id+" name="+input_name+"]"+btn_name+"[/ancho]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSearchSoftware(editor,$channel_id){
		$.ajax({
			url:"index.php?r=Layout.getSearchSoftwareWizard",
			type:"get",
			data:{channel_module_id:1},
			cache:false,
			success: function(HtmlResponseText){
				$("#firesbox_content").empty();
				$(HtmlResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var input_name = $("#firesbox_content").find("#input-name").val();
					var btn_name = $("#firesbox_content").find("#btn-name").val();
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ancho=software_"+$channel_id+" name="+input_name+"]"+btn_name+"[/ancho]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSearchTheme(editor,$channel_id){
		$.ajax({
			url:"index.php?r=Layout.getSearchThemeWizard",
			type:"get",
			data:{channel_module_id:1},
			cache:false,
			success: function(HtmlResponseText){
				$("#firesbox_content").empty();
				$(HtmlResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var input_name = $("#firesbox_content").find("#input-name").val();
					var btn_name = $("#firesbox_content").find("#btn-name").val();
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ancho=theme_"+$channel_id+" name="+input_name+"]"+btn_name+"[/ancho]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSearchGame(editor,$channel_id){
		$.ajax({
			url:"index.php?r=Layout.getSearchGameWizard",
			type:"get",
			data:{channel_module_id:1},
			cache:false,
			success: function(HtmlResponseText){
				$("#firesbox_content").empty();
				$(HtmlResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var input_name = $("#firesbox_content").find("#input-name").val();
					var btn_name = $("#firesbox_content").find("#btn-name").val();
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ancho=game_"+$channel_id+" name="+input_name+"]"+btn_name+"[/ancho]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSearchPicture(editor,$channel_id){
		$.ajax({
			url:"index.php?r=Layout.getSearchPictureWizard",
			type:"get",
			data:{channel_module_id:1},
			cache:false,
			success: function(HtmlResponseText){
				$("#firesbox_content").empty();
				$(HtmlResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var input_name = $("#firesbox_content").find("#input-name").val();
					var btn_name = $("#firesbox_content").find("#btn-name").val();
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ancho=picture_"+$channel_id+" name="+input_name+"]"+btn_name+"[/ancho]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	function bindSearchForum(editor,$channel_id){
		$.ajax({
			url:"index.php?r=Layout.getSearchForumWizard",
			type:"get",
			data:{channel_module_id:1},
			cache:false,
			success: function(HtmlResponseText){
				$("#firesbox_content").empty();
				$(HtmlResponseText).appendTo("#firesbox_content");
				$("#firesbox_content").find(".cancelBtn").unbind("click").bind('click',function(){
					$.fn.firesbox.close();
				});
				$("#firesbox_content").find(".insertBtn").unbind("click").bind('click',function(){
					var input_name = $("#firesbox_content").find("#input-name").val();
					var btn_name = $("#firesbox_content").find("#btn-name").val();
					$.cleditor.cRange(editor);
					$.cleditor.exec(editor,"[ancho=bbs_"+$channel_id+" name="+input_name+"]"+btn_name+"[/ancho]");
					
					$.fn.firesbox.close();
				});
			}
		});
	}
		
	var editorBody = $(".editorBody").height();
	var sHeight = document.documentElement.clientHeight;
	var tcHeight = $("#topOutside").height();
	var toph = $(".sitmap").height();
	$("#UBB_edit_navBox").css({
		height: sHeight - editorBody -tcHeight -toph -59
	});
		
});
</script>
</html>
