// 频道栏目  begin
KindEditor.plugin('nsychannel', function(K) {
			var self = this, name = 'nsychannel',lang = self.lang(name + '.');
			self.plugin.nsychannel = {
	            edit : function() {
		            var html = [
			            '<div style="padding:20px;">',
			            //频道栏目名称
			            '<div class="ke-dialog-row">',
			            '<label for="kechannelname" style="width:60px;">'+lang.channel+'</label>',
			            '<input type="text" id="kechannelname" class="ke-input-text" name="channelname" value="请输入栏目区名称" maxlength="100" /> &nbsp; ',
			            '<input type="text" id="kechannelid" class="ke-input-text" style="display:none;" name="channelid" value="" /> &nbsp; ',
			            '</div>',
			            //频道栏目选择加载//width
			            '<div class="ke-dialog-row">',
			            '<label for="keWidth" style="width:30px;">'+lang.width+'</label>',
			            '<input type="text" id="keWidth" class="ke-input-text ke-input-number" name="width" value="300" maxlength="4" /> &nbsp; ',
			            '<input type="checkbox" class="ke-inline-block" id="ckbAuto" name="isAuto" title="文字头条、图文翻动、图文滚动、滚动公告、滚动图片链接、文字链接组、列表链接、今日导读、留言本、自定义表单栏目必须设置宽度">&nbsp;'+ lang.autoWidth + '</input>',
			           // '<label style="width:120px;">'+lang.isArtDesign+'</label>',
			            '<select id="artdesign" name="artdesign" style="display:none;">',
				        '<option value="0">' +lang.no+ '</option>',
				        '<option value="1">' +lang.yes+ '</option>',
				        '</select> &nbsp; ',
			            '</div>',
			            '<div class="ke-dialog-row" style="color:red;">',
			            '注意：部分栏目必须设置宽度，否则默认宽度为200px',
			            '</div>',
			            '</div>'
		            ].join('');
		            var dialog = self.createDialog({
			            name : name,
			            width : 400,
			            title : self.lang(name),
			            body : html,
			            yesBtn : {
				            name : self.lang('yes'),
				            click : function(e) {
        						var width = widthBox.val(),artdesign = artDesignBox.val();
//        						ishot = ishotBox.val(),
//        						istop = istopBox.val(),
//        						ismore = ismoreBox.val(),
//        						isclick = isclickBox.val(),
//        						istime = istimeBox.val(),
//        						isdepartment = isdepartmentBox.val();
        						var channelname=K('#kechannelname').val();
        						//宽度不能为空
        						if(width=="" || width==null){
        						    alert(self.lang('invalidNull'));
        						    widthBox[0].focus();
        						    return ;
        						}
					            if (!/^\d*$/.test(width)) {
						            alert(self.lang('invalidWidth'));
						            widthBox[0].focus();
						            return;
					            }
					            if (channelname==""||channelname==null) {
						            alert(self.lang('invalidNull'));
						            channelnameBox[0].focus();
						            return;
					            }
                                
                                var itemid =K('#kechannelid').val();
                                //初始化生成itemid
                                if(itemid =="" || itemid==null){
                                    var time = new Date ();
                                    var years= time.getYear();
                                    var months=time.getMonth()+1;
                                    var days=time.getDate();
                                    var hours= time.getHours();
                                    var mins= time.getMinutes();
                                    var secs= time.getSeconds();
                                    if (hours<10)
                                    {
                                        hours="0"+hours;
                                    }
                                    if(mins<10)
                                    {
                                        mins="0"+mins;
                                    }
                                    if (secs<10)
                                    {
                                        secs="0"+secs;
                                    }
                                    //itemid规则
                                    itemid=""+years+months+days+hours+mins+secs;
                                }
                                //启用自适应宽度
                                if(isAutoBox[0].checked)
                                {
                                    var html = "<button id=\"QXNSY2005\" type=\"button\" name=\"300?isArtDesign="+artdesign+"@width=auto@itemId="+itemid+"@regionName="+channelname+"\" style=\"WIDTH: auto;\" >"+lang.channel+"="+channelname+" "+lang.width+"=auto</button>";
                                }
                                else
                                {
					                var html = "<button id=\"QXNSY2005\" type=\"button\" name=\"300?isArtDesign="+artdesign+"@width="+width+"@itemId="+itemid+"@regionName="+channelname+"\" style=\"WIDTH: "+width+"px;\" >"+lang.channel+"="+channelname+" "+lang.width+"="+width+"</button>";
					            }
//					            "@en="+isnew+"@eh="+ishot+"@et="+istop+"@em="+ismore+"@ec="+isclick+"@ert="+istime+"@ed="+isdepartment+"@width="+width+"@itemId="+itemid+"@regionName="+channelname+"\" style=\"WIDTH: "+width+"px;\" >"+lang.channel+"="+channelname+" "+lang.width+"="+width+"</button>";
					            self.insertHtml(html).hideDialog().focus();
				            }
			            }
		            }),
		            div = dialog.div,
		            widthBox = K('[name="width"]', div),
		            channelnameBox = K('[name="channelname"]', div),
		            artDesignBox = K('[name="artdesign"]', div),
		            channelidBox = K('[name="channelid"]', div);
//		            isnewBox = K('[name="isnew"]', div),
//		            ishotBox = K('[name="ishot"]', div),
//		            istopBox = K('[name="istop"]', div),
//		            ismoreBox = K('[name="ismore"]', div),
//		            isclickBox = K('[name="isclick"]', div),
//		            istimeBox = K('[name="istime"]', div),
//		            isdepartmentBox = K('[name="isdepartment"]', div);
		            isAutoBox=K('[name="isAuto"]',div);//自适应宽度参数
		            //加载右键菜单
		            var img = self.plugin.getSelectedNsychannel();
		            
		            
			        if (img) {
				        widthBox.val(K.removeUnit(img.css('width')) ||  0);
				        
				        //读取修改参数
				        var names=img[0].name.split('?');
				        var URLParams = new Object() ;
                        var aParams =names[1].split('@') ;
                        for (i=0 ; i < aParams.length ; i++) {
	                        var aParam = aParams[i].split('=') ;
	                        URLParams[aParam[0]] = aParam[1] ;
	                    }
				        var regionName=URLParams["regionName"];
				        var lsisArtDesign=URLParams["isArtDesign"];
				        var itemId=URLParams["itemId"];
				       if(URLParams["width"]=="auto")
				       {
				       isAutoBox[0].checked=true;
				       }
//				        var lsenableNews=URLParams["en"];
//				        var lsenableHot=URLParams["eh"];
//				        var lsenableTop=URLParams["et"];
//				        var lsenableMore=URLParams["em"];
//				        var lsenableClick=URLParams["ec"];
//				        var lsenableReleaseTime=URLParams["ert"];
//				        var lsenableDepartment=URLParams["ed"];
				        channelnameBox.val(regionName);
				        artDesignBox.val(lsisArtDesign);
				        channelidBox.val(itemId);
//				        isnewBox.val(lsenableNews);
//				        ishotBox.val(lsenableHot);
//				        istopBox.val(lsenableTop);
//				        ismoreBox.val(lsenableMore);
//				        isclickBox.val(lsenableClick);
//				        istimeBox.val(lsenableReleaseTime);
//				        isdepartmentBox.val(lsenableDepartment);
			        }
			        channelnameBox[0].focus();
			        channelnameBox[0].select();
		            
	            }
            };
	    //加载控件
	    self.clickToolbar(name, self.plugin.nsychannel.edit);
		});

// 频道栏目  end