// 横幅模板  begin
KindEditor.plugin('nsybanner', function(K) {
			var self = this, name = 'nsybanner',lang = self.lang(name + '.');
			self.plugin.nsybanner = {
	            edit : function() {
		            var html = [
			            '<div style="padding:20px;">',
			            //width //height
			            '<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="600" maxlength="4" /> &nbsp; ',
			            '<label for="keHeight" style="width:30px;">'+lang.height+'</label>',
			            '<input type="text" id="keHeight" class="ke-input-text ke-input-number" name="height" value="30" maxlength="4" /> &nbsp; ',
			            '<label style="width:60px;">'+lang.random+'</label>',
			            '<select id="randomtype" name="randomtype">',
				        '<option value="0">' +lang.no+ '</option>',
				        '<option value="1">' +lang.yes+ '</option>',
				        '</select> &nbsp; ',
			            '</div>',
			            //横幅模板选择加载
			            '<div class="ke-dialog-row">',
			            '<label>'+lang.banner+'</label><iframe id="d_nsybanner" name="d_nsybanner" frameborder="0" src="../Wpedt/WpdccEditor/plugins/nsybanner/nsyItemBanner.aspx" width="100%" height="50px" scrolling="no" ></iframe>',
			            '</div>',
			            '</div>'
		            ].join('');
		            var dialog = self.createDialog({
			            name : name,
			            width : 450,
			            title : self.lang(name),
			            body : html,
			            yesBtn : {
				            name : self.lang('yes'),
				            click : function(e) {
        						var width = widthBox.val(),height = heightBox.val();
        						var random=K('#randomtype').val();
					            if (!/^\d*$/.test(width)) {
						            alert(self.lang('invalidWidth'));
						            widthBox[0].focus();
						            return;
					            }
					            if (!/^\d*$/.test(height)) {
						            alert(self.lang('invalidHeight'));
						            heightBox[0].focus();
						            return;
					            }
					            var bannerid=1;
					            var groupid=1;
					            var bannername="";
					            var groupname="";
					            try {
					                bannerid = frames['d_nsybanner'].myform.d_banner.value;
					                bannername=frames['d_nsybanner'].myform.d_banner.options[frames['d_nsybanner'].myform.d_banner.selectedIndex].text;//选中栏目的text
                                    groupid = frames['d_nsybanner'].myform.d_grouping.value;
                                    groupname=frames['d_nsybanner'].myform.d_grouping.options[frames['d_nsybanner'].myform.d_grouping.selectedIndex].text;//选中栏目的text
                                }catch(e){
                                    alert("error");
                                }
                                
					            var html = "<button id=\"QXNSY2005\" name=\"001?width="+width+"@height="+height+"@random="+random+"@bannerId="+bannerid+"@groupingId="+groupid+"\" style=\"WIDTH: "+width+"px; HEIGHT: "+height+"px\" >"+lang.show+"="+bannername+" "+groupname+" "+lang.width+"="+width+" "+lang.height+"="+height+"</button>";
					            self.insertHtml(html).hideDialog().focus();
				            }
			            }
		            }),
		            div = dialog.div,
		            widthBox = K('[name="width"]', div),
		            heightBox = K('[name="height"]', div),
		            randomtypeBox = K('[name="randomtype"]', div);
		            //加载右键菜单
		            var img = self.plugin.getSelectedNsybanner();
		            
			        if (img) {
				        widthBox.val(K.removeUnit(img.css('width')) ||  0);
				        heightBox.val(K.removeUnit(img.css('height')) || 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 random=URLParams["random"];
				        var bannerid=URLParams["bannerId"];
				        var groupid=URLParams["groupingId"];
				        randomtypeBox.val(random);
				        //修改加载iframe选中功能待完善
                        
			        }
			        widthBox[0].focus();
			        widthBox[0].select();
		            
	            }
	            
            };
	    self.clickToolbar(name, self.plugin.nsybanner.edit);
		});

// 横幅模板  end