/**
 * @author jiangsj
 */
            
$(document).ready(function(){
            	$("#posteditor_cmd_createlink").click(function(){

            		var stxt = FT.txt();
					$("#pop-window").empty();
					$("#pop-window").load('cmd_link.html');
            		$("#posteditor_cmd_createlink_title").val(stxt);
            		if(stxt.substring(0, 7) == "http://"){
            			$("#posteditor_cmd_createlink_url").val(stxt);
            		}
            		
            		var y = $(this).offset().top;
            		var x = $(this).offset().left;
            		$("#pop-window").css({top:y+20,left:x});
            		$("#pop-window").fadeIn();
            	});
            	$("#posteditor_cmd_createlink_submit").live('click',function(){
            		if($("#posteditor_cmd_createlink_url").val()=="http://" || $("#posteditor_cmd_createlink_url").val()==""){
            			alert("请输入链接地址！");
            		}else{
            			if($("#posteditor_cmd_createlink_title").val()==""){
            				$("#posteditor_cmd_createlink_title").val($("#posteditor_cmd_createlink_url").val());
            			}
						var ubbtxt;
            			if($("#posteditor_cmd_createlink_type").val()==1){
							ubbtxt = '[url='+$("#posteditor_cmd_createlink_url").val()+']'+$("#posteditor_cmd_createlink_title").val()+'[/url]';
						}else{
							ubbtxt = '[anchor='+$("#posteditor_cmd_createlink_url").val()+']'+$("#posteditor_cmd_createlink_title").val()+'[/anchor]';
						}
            			FT.settxt(ubbtxt);
            			$("#pop-window").hide();
            		}
            	});
            	$("#posteditor_cmd_createlink_close").live('click',function(){
            		$("#pop-window").hide();
            	});
            
            	
            	$("#posteditor_cmd_insertimage").click(function(){
					var html = '<div unselectable="on" class="popupmenu_option">图片地址:<br><input type="text" value="" size="30" id="posteditor_cmd_image_url"><br><img scr="common/bb_sub.gif" width="20" height="20" id="m1" class="m1"><br><span id="uploadimg" class="button" style="margin-left:5px;">上传图片</span> <span id="upload_manager" class="button">图片管理</span><br>宽: <input value="" size="4" id="posteditor_cmd_image_width">高: <input value="" size="4" id="posteditor_cmd_image_height"><br><center><input type="button" value="提交" id="posteditor_cmd_image_submit">&nbsp; <input type="button" value="取消" id="posteditor_cmd_image_close"></center></div>';
					
					$("#pop-window").empty();
					//$("#pop-window").load('cmd_upload_image.html');
					$("#pop-window").append(html);
					newAjaxUpload('image');
					var y = $(this).offset().top;
            		var x = $(this).offset().left;
            		$("#pop-window").css({top:y+20,left:x});
            		$("#pop-window").fadeIn();
            		
            	});
            	
            	$("#posteditor_cmd_image_submit").live('click',function(){
            		var   r  = /^\+?[1-9][0-9]*$/;　　//正整数
            		if($("#posteditor_cmd_image_url").val()==""){
            			alert("请输入图片地址或本地上传图片！");
            		} if($("#posteditor_cmd_image_width").val()!="" && !r.test($("#posteditor_cmd_image_width").val())){
            			alert("宽度必须是正整数！");
            		}else if($("#posteditor_cmd_image_height").val()!="" && !r.test($("#posteditor_cmd_image_height").val())){
            			alert("高度必须是正整数！");
            		}else{
            			var w = parseInt($("#posteditor_cmd_image_width").val());
            			var h = parseInt($("#posteditor_cmd_image_height").val());
            			var ubbtxt;
						if(w>0 && h>0){
							ubbtxt = '[img width='+w+' height='+h+']'+$("#posteditor_cmd_image_url").val()+'[/img]';	
						}else{
							ubbtxt = '[img]'+$("#posteditor_cmd_image_url").val()+'[/img]';
						}
					
            			FT.settxt(ubbtxt);
            			$("#pop-window").hide();
            		}
            		
            	});
            	$("#posteditor_cmd_image_close").live('click',function(){
            		$("#pop-window").hide();
            	});
            	
            	$("#posteditor_popup_media").click(function(){
					var html = '<div unselectable="on" class="popupmenu_option">文件地址:<br><input type="text" value="" size="30" id="posteditor_cmd_file_url"><br><div id="uploadfile" class="button" style="margin-left:5px;">上传附件</div><br><center><input type="button" value="提交" id="posteditor_cmd_file_submit">&nbsp; <input type="button" value="取消" id="posteditor_cmd_file_close"></center></div>';
            		
					$("#pop-window").empty();
					//$("#pop-window").load('cmd_upload_file.html');
					$("#pop-window").append(html);
					newAjaxUpload('file');
            		var y = $(this).offset().top;
            		var x = $(this).offset().left;
            		$("#pop-window").css({top:y+20,left:x});
            		$("#pop-window").fadeIn();
            	});
            	$("#posteditor_cmd_file_submit").live('click',function(){
            		if($("#posteditor_cmd_file_url").val()==""){
            			alert("请输入文件地址！");
            		}else{
						var furl = $("#posteditor_cmd_file_url").val();
						furl = furl.substr(furl.lastIndexOf("/")+1);
            			var ubbtxt = '[url='+$("#posteditor_cmd_file_url").val()+']'+furl+'[/url]';
            			FT.settxt(ubbtxt);
            			$("#pop-window").hide();
            		}
            		
            	});
            	$("#posteditor_cmd_file_close").live('click',function(){
            		$("#pop-window").hide();
            	});
            	
            	$("#posteditor_cmd_undo").click(function(){
					$("#pop-window").hide();
            		FT.undo();
            	});
            	
            	$("#posteditor_cmd_redo").click(function(){
					$("#pop-window").hide();
            		FT.redo();
            	});
            	
            	$("#checklength").click(function(){
            		alert("已经输入："+FT.length()+" 字符");
            	});
            	
    $("#clearcontent").click(function(){
		$("#pop-window").hide();
        FT.clear();
    });
				
	$("#posteditor_cmd_bold").click(function(){
		$("#pop-window").hide();
        FT.cmd_bold();
    });
				
	$("#posteditor_cmd_italic").click(function(){
		$("#pop-window").hide();
        FT.cmd_italic();
    });
				
	$("#posteditor_cmd_underline").click(function(){
		$("#pop-window").hide();
        FT.cmd_underline();
    });
				
	$("#posteditor_cmd_br").click(function(){
		$("#pop-window").hide();
        FT.cmd_br();
	});
            	
	$("#posteditor_expand").click(function(){
		FT.height(40);
	});
				
	$("#posteditor_contract").click(function(){
		FT.height(-40);
	});
	$("#posteditor_cmd_more").click(function(){
		var y = $(this).offset().top;
        var x = $(this).offset().left;
		$("#pop-window").empty();
		
		var url = 'cmd_more.html';
		
		if(FT.tools()=='tags'){
			url = 'cmd_more_tags.html';
		}else if(FT.tools()=='all'){
			url = 'cmd_more_all.html';
		}
		$("#pop-window").load(url);
		
        $("#pop-window").css({top:y+20,left:x});
        $("#pop-window").fadeIn();
	});
	
	$("#upload_manager").live("click",function(){
		var l = (screen.width - 400) / 2; 
        var t = (screen.height - 380) / 2; 
		window.open ('../../index.php?r=upload.manager&parTags=posteditor_cmd_image_url','图片管理', 'height=380, width=420, top='+l+', left='+t+', toolbar=no, menubar=no,scrollbars=no, resizable=no,location=no, status=no');
	});
	
	/**
	 * cmd_more 更多操作
	 */
	$("#cmd_more_normal").live('click',function(){
		
		var y = $(this).offset().top;
        var x = $(this).offset().left;
		
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_normal.html');
		$("#pop-window").css({top:y+20,left:x});
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_data").live('click',function(){
		var y = $(this).offset().top;
        var x = $(this).offset().left;
		
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_data.html');
		$("#pop-window").css({top:y+20,left:x});
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_new").live('click',function(){
		var y = $(this).offset().top;
        var x = $(this).offset().left;
		
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_new.html');
		$("#pop-window").css({top:y+20,left:x});
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_search").live('click',function(){
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_search.html');
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_music").live('click',function(){
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_music.html');
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_ucenter").live('click',function(){
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_ucenter.html');
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_count").live('click',function(){
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_count.html');
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_ad").live('click',function(){
		var y = $(this).offset().top;
        var x = $(this).offset().left;
		
		$("#pop-window").empty();
		$("#pop-window").load('cmd_more_ad.html');
		$("#pop-window").css({top:y+20,left:x});
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	$("#cmd_more_tags").live('click',function(){
		$("#pop-window").empty();
		$("#pop-window").load('../../index.php?r=Tags.getTagsByEditor&rd='+Math.random());
		$("#pop-window").fadeIn();
		
		rewidth($(this));
	});
	
	
	/**
	 * tags 自定义标签操作
	 */
	$(".cmd_li_tags").live('click',function(){
		var tags = $(this).attr('tags');
		if(tags!=''){
			FT.settxt(tags);
            $("#pop-window").hide();
		}
	});
	
	/**
	 * 基本功能
	 */
	$("#cmd_more_normal_bold").live('click',function(){
		$("#pop-window").hide();
        FT.cmd_bold();
	});
	$("#cmd_more_normal_italic").live('click',function(){
		$("#pop-window").hide();
        FT.cmd_italic();
	});
	$("#cmd_more_normal_underline").live('click',function(){
		$("#pop-window").hide();
        FT.cmd_underline();
	});
	$("#cmd_more_normal_br").live('click',function(){
		$("#pop-window").hide();
        FT.cmd_br();
	});
	$("#cmd_more_normal_space").live('click',function(){
		$("#pop-window").hide();
        FT.settxt('[space]');
	});
	$("#cmd_more_normal_link").live('click',function(){
		var stxt = FT.txt();
		var html = '<div unselectable="on" class="popupmenu_option">链接文字<br><input id="posteditor_cmd_createlink_title" size="30" name="posteditor_cmd_createlink_title"><br>链接地址<br><input id="posteditor_cmd_createlink_url" size="30" name="posteditor_cmd_createlink_url" value="http://"><br>有无下划线<br><select id="posteditor_cmd_createlink_type" ><option value="1">有</option><option value="0">无</option></select><br><input type="button" value="提交" id="posteditor_cmd_createlink_submit"> &nbsp; <input id="posteditor_cmd_createlink_close" type="button" value="取消"></div>';
		
		$("#pop-window").empty();
		//$("#pop-window").load('cmd_link.html');
		$("#pop-window").append(html);
        $("#posteditor_cmd_createlink_title").val(stxt);
        if(stxt.substring(0, 7) == "http://"){
        	$("#posteditor_cmd_createlink_url").val(stxt);
        }
        $("#pop-window").fadeIn();
	});
	$("#cmd_more_normal_image").live('click',function(){
		var html = '<div unselectable="on" class="popupmenu_option">图片地址:<br><input type="text" value="" size="30" id="posteditor_cmd_image_url"><br><span id="uploadimg" class="button" style="margin-left:5px;">上传图片</span> <span id="upload_manager" class="button">图片管理</span><br>宽: <input value="" size="4" id="posteditor_cmd_image_width">高: <input value="" size="4" id="posteditor_cmd_image_height"><br><center><input type="button" value="提交" id="posteditor_cmd_image_submit">&nbsp; <input type="button" value="取消" id="posteditor_cmd_image_close"></center></div>';
		$("#pop-window").empty();
		//$("#pop-window").load('cmd_upload_image.html');
		$("#pop-window").append(html);
		newAjaxUpload('image');
        $("#pop-window").fadeIn();
	});
	$("#cmd_more_normal_file").live('click',function(){
		var html = '<div unselectable="on" class="popupmenu_option">文件地址:<br><input type="text" value="" size="30" id="posteditor_cmd_file_url"><br><div id="uploadfile" class="button" style="margin-left:5px;">上传附件</div><br><center><input type="button" value="提交" id="posteditor_cmd_file_submit">&nbsp; <input type="button" value="取消" id="posteditor_cmd_file_close"></center></div>';
        $("#pop-window").empty();
		//$("#pop-window").load('cmd_upload_file.html');
		$("#pop-window").append(html);
		newAjaxUpload('file');
        $("#pop-window").fadeIn();
	});
	$("#cmd_more_normal_undo").live('click',function(){
		//$("#pop-window").hide();
        FT.undo();
	});
	$("#cmd_more_normal_redo").live('click',function(){
		//$("#pop-window").hide();
        FT.redo();
	});
	$("#cmd_more_normal_search").live('click',function(){
		$("#pop-window").load('cmd_more_normal_search.html');
        $("#pop-window").fadeIn();
	});
	$("#cmd_more_normal_search_submit").live('click',function(){
        if($("#cmd_more_normal_search_name").val()==""){
        	alert("请输入name值！");
			return false;
        }else if(!isabc($("#cmd_more_normal_search_name").val())){
			alert("只能是英文字母组成！");
			return false;
		}else if($("#cmd_more_normal_search_key").val()!=''){
			var partten = /[^\u4E00-\u9FA50-9a-zA-Z,]/;
			var objExp=new RegExp(partten);
			if(objExp.test($("#cmd_more_search_key").val())){
				alert("默认关键字格式错误！");
				return false;
			}
			
		}
		if($("#cmd_more_normal_search_size").val()==''){
			$("#cmd_more_normal_search_size").val(6);
		}
		
		if($("#cmd_more_normal_search_key").val()!=''){
			var ubbtxt = '[input name='+$("#cmd_more_normal_search_name").val()+' size='+$("#cmd_more_normal_search_size").val()+' value='+$("#cmd_more_normal_search_key").val()+']';
		}else{
			var ubbtxt = '[input name='+$("#cmd_more_normal_search_name").val()+' size='+$("#cmd_more_normal_search_size").val()+']';
		}
		
       	FT.settxt(ubbtxt);
       	$("#pop-window").hide();
		
    });
    $("#cmd_more_normal_search_close").live('click',function(){
		$("#pop-window").hide();
    });
	//----------------------------
	$("#cmd_more_normal_call").live('click',function(){
		var stxt = FT.txt();
		var html = '<div unselectable="on" class="popupmenu_option">说明<br><input id="posteditor_cmd_call_title" size="30" name="posteditor_cmd_call_title"><br>手机号码<br><input id="posteditor_cmd_call_number" size="30" name="posteditor_cmd_call_number" value=""><br><input type="button" value="提交" id="posteditor_cmd_call_submit"> &nbsp; <input id="posteditor_cmd_call_close" type="button" value="取消"></div>';
		$("#pop-window").empty();
		//$("#pop-window").load('cmd_call.html');
		$("#pop-window").append(html);
        $("#posteditor_cmd_call_title").val(stxt);
		if(checkPhoneNumber(stxt)){
			$("#posteditor_cmd_call_number").val(stxt);
		}
		//document.getElementById("posteditor_cmd_call_title").value = stxt;
        $("#pop-window").fadeIn();
	});
    $("#posteditor_cmd_call_submit").live('click',function(){
        if($("#posteditor_cmd_call_number").val()==""){
        	alert("请输入手机号码！");
        }else if(!checkPhoneNumber($("#posteditor_cmd_call_number").val())){
			alert("输入手机号码不正确！");
		}else{
			var ubbtxt;
        	if($("#posteditor_cmd_call_title").val()==""){
            	ubbtxt = '[call]'+$("#posteditor_cmd_call_number").val()+'[/call]';
            }else{
				ubbtxt = '[call='+$("#posteditor_cmd_call_number").val()+']'+$("#posteditor_cmd_call_title").val()+'[/call]';
			}
            FT.settxt(ubbtxt);
            $("#pop-window").hide();
        }
    });
    $("#posteditor_cmd_call_close").live('click',function(){
		$("#pop-window").hide();
    });
	$("#cmd_more_normal_sms").live('click',function(){
		var stxt = FT.txt();
		var html = '<div unselectable="on" class="popupmenu_option">说明<br><input id="posteditor_cmd_sms_title" size="30" name="posteditor_cmd_sms_title"><br>手机号码<br><input id="posteditor_cmd_sms_number" size="30" name="posteditor_cmd_sms_number" value=""><br><input type="button" value="提交" id="posteditor_cmd_sms_submit"> &nbsp; <input id="posteditor_cmd_sms_close" type="button" value="取消"></div>';
		$("#pop-window").empty();
		//$("#pop-window").load('cmd_sms.html');
		$("#pop-window").append(html);
        $("#posteditor_cmd_sms_title").val(stxt);
		if(checkPhoneNumber(stxt)){
			$("#posteditor_cmd_sms_number").val(stxt);
		}
		//document.getElementById("posteditor_cmd_sms_title").value = stxt;
        $("#pop-window").fadeIn();
	});
    $("#posteditor_cmd_sms_submit").live('click',function(){
        if($("#posteditor_cmd_sms_number").val()==""){
        	alert("请输入手机号码！");
        }else if(!checkPhoneNumber($("#posteditor_cmd_sms_number").val())){
			alert("输入手机号码不正确！");
		}else{
			var ubbtxt;
        	if($("#posteditor_cmd_call_title").val()==""){
            	ubbtxt = '[sms]'+$("#posteditor_cmd_sms_number").val()+'[/sms]';
            }else{
				ubbtxt = '[sms='+$("#posteditor_cmd_sms_number").val()+']'+$("#posteditor_cmd_sms_title").val()+'[/sms]';
			}
            FT.settxt(ubbtxt);
            $("#pop-window").hide();
        }
    });
    $("#posteditor_cmd_sms_close").live('click',function(){
		$("#pop-window").hide();
    });
	$("#cmd_more_normal_back").live('click',function(){
		var stxt = FT.txt();
		var html = '<div unselectable="on" class="popupmenu_option">返回按钮文字<br><input id="posteditor_cmd_back_title" size="30" name="posteditor_cmd_back_title"><br><input type="button" value="提交" id="posteditor_cmd_back_submit"> &nbsp; <input id="posteditor_cmd_back_close" type="button" value="取消"></div>';
		$("#pop-window").empty();
		$("#pop-window").append(html);
        $("#posteditor_cmd_back_title").val(stxt);
		$("#pop-window").fadeIn();
	});
	$("#posteditor_cmd_back_submit").live('click',function(){
        if($("#posteditor_cmd_back_title").val()==""){
        	alert("请输入返回按钮文字！");
        }else{
			var ubbtxt = '[back]'+$("#posteditor_cmd_back_title").val()+'[/back]';
            FT.settxt(ubbtxt);
            $("#pop-window").hide();
        }
    });
    $("#posteditor_cmd_back_close").live('click',function(){
		$("#pop-window").hide();
    });
	$("#cmd_more_normal_login_register").live('click',function(){
		FT.settxt('[login/register]');
        $("#pop-window").hide();
	});
	$("#cmd_more_normal_login").live('click',function(){
		var stxt = FT.txt();
		var html = '<div unselectable="on" class="popupmenu_option">登陆可见内容<br><input id="posteditor_cmd_login_title" size="30" name="posteditor_cmd_login_title"><br><input type="button" value="提交" id="posteditor_cmd_login_submit"> &nbsp; <input id="posteditor_cmd_login_close" type="button" value="取消"></div>';
		$("#pop-window").empty();
		$("#pop-window").append(html);
        $("#posteditor_cmd_login_title").val(stxt);
		$("#pop-window").fadeIn();
	});
	$("#posteditor_cmd_login_submit").live('click',function(){
        if($("#posteditor_cmd_login_title").val()==""){
        	alert("请输入登陆可见内容！");
        }else{
			var ubbtxt = '[login]'+$("#posteditor_cmd_login_title").val()+'[/login]';
            FT.settxt(ubbtxt);
            $("#pop-window").hide();
        }
    });
    $("#posteditor_cmd_login_close").live('click',function(){
		$("#pop-window").hide();
    });
	$("#cmd_more_normal_member").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[total_member]');
	});
	$("#cmd_more_normal_online_member").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[member_online]');
	});
	$("#cmd_more_normal_online").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[total_online]');
	});
	//------------------------------------------------------------
	$("#cmd_more_normal_time_now").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[now]');
	});
	$("#cmd_more_normal_time_year").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[year]');
	});
	$("#cmd_more_normal_time_month").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[month]');
	});
	$("#cmd_more_normal_time_day").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[day]');
	});
	$("#cmd_more_normal_time_hour").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[hour]');
	});
	$("#cmd_more_normal_time_minute").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[minute]');
	});
	$("#cmd_more_normal_time_second").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[second]');
	});
	$("#cmd_more_normal_time_date").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[date]');
	});
	$("#cmd_more_normal_time_time").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[time]');
	});
	$("#cmd_more_normal_time_weekday").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[weekday]');
	});
	$("#cmd_more_normal_time_lunar").live('click',function(){
		//$("#pop-window").hide();
		FT.settxt('[ttcc]');
	});
	/**
	 * 基本功能结束
	 */
	
	/**
	 * 资源调用
	 */
	$("#cmd_more_data_submit").live('click',function(){
		if($("#cmd_more_data_chid").val()==''){
			alert("栏目ID不能为空！");
			return false;
		}else if($("#cmd_more_data_limit").val()==''){
			alert("显示条数 不能为空！");
			return false;
		}else if($("#cmd_more_data_sort").val()==''){
			alert("排序不能为空！");
			return false;
		}else if($("#cmd_more_data_length").val()==''){
			alert("标题字数不能为空！");
			return false;
		}
		var ubbtxt = '['+$("#cmd_more_data_module").val()+'='+$("#cmd_more_data_chid").val()+'_'+$("#cmd_more_data_limit").val()+'_'+$("#cmd_more_data_sort").val()+'_'+$("#cmd_more_data_length").val()+'_'+$("#cmd_more_data_c").val()+']';
       	FT.settxt(ubbtxt);
       	$("#pop-window").hide();
    });
    $("#cmd_more_data_close").live('click',function(){
		$("#pop-window").hide();
    });
	/**
	 * 资源调用结束
	 */
	
	/**
	 * 资源新增
	 */
	$("#cmd_more_new_submit").live('click',function(){
		if($("#cmd_more_new_chid").val()==''){
			alert("栏目ID不能为空！");
			return false;
		}else if($("#cmd_more_new_limit").val()==''){
			alert("日期 不能为空！");
			return false;
		}else if($("#cmd_more_new_sort").val()==''){
			alert("显示条数 不能为空！");
			return false;
		}
		var ubbtxt = '['+$("#cmd_more_new_module").val()+'='+$("#cmd_more_new_chid").val()+'_'+$("#cmd_more_new_limit").val()+'_'+$("#cmd_more_new_sort").val()+'_'+$("#cmd_more_new_c").val()+']';
       	FT.settxt(ubbtxt);
       	$("#pop-window").hide();
    });
    $("#cmd_more_new_close").live('click',function(){
		$("#pop-window").hide();
    });
	/**
	 * 资源新增结束
	 */
	
	/**
	 * 友情链接调用
	 */
	$("#cmd_more_link").live('click',function(){
		$("#pop-window").load('cmd_more_data_link.html');
        $("#pop-window").fadeIn();
	});
	$("#cmd_more_data_link_submit").live('click',function(){
		if($("#cmd_more_data_link_chid").val()==''){
			alert("栏目ID不能为空！");
			return false;
		}else if($("#cmd_more_data_link_limit").val()==''){
			alert("显示条数 不能为空！");
			return false;
		}else if($("#cmd_more_data_link_sort").val()==''){
			alert("排序不能为空！");
			return false;
		}else if($("#cmd_more_data_link_length").val()==''){
			alert("标题字数不能为空！");
			return false;
		}
		if($("#cmd_more_data_link_c").val()==1){
			if($("#cmd_more_data_link_brs").val()==''){
				alert("换行条数不能为空！");
				return false;
			}
		}
		var ubbtxt = '[link='+$("#cmd_more_data_link_chid").val()+'_'+$("#cmd_more_data_link_limit").val()+'_'+$("#cmd_more_data_link_sort").val()+'_'+$("#cmd_more_data_link_length").val()+'_'+$("#cmd_more_data_link_c").val()+'_'+$("#cmd_more_data_link_brs").val()+'_'+$("#cmd_more_data_link_tags").val()+']';
       	FT.settxt(ubbtxt);
       	$("#pop-window").hide();
    });
    $("#cmd_more_data_link_close").live('click',function(){
		$("#pop-window").hide();
    });
	/**
	 * 友情链接调用结束
	 */
	
	/**
	 * 自定义搜索
	 */
	/*
	$("#cmd_more_search_submit").live('click',function(){
		if($("#cmd_more_search_chid").val()==''){
			alert("栏目ID不能为空！");
			return false;
		}else if($("#cmd_more_search_title").val()==''){
			alert("按钮标题不能为空！");
			return false;
		}else if($("#cmd_more_search_key").val()!=''){
			var partten = /[^\u4E00-\u9FA50-9a-zA-Z,]/;
			var objExp=new RegExp(partten);
			if(objExp.test($("#cmd_more_search_key").val())){
				alert("默认关键字格式错误！");
				return false;
			}
			
		}
		if($("#cmd_more_search_size").val()==''){
			$("#cmd_more_search_size").val(6);
		}
		if($("#cmd_more_search_key").val()!=''){
			var ubbtxt = '[ancho='+$("#cmd_more_search_module").val()+'_'+$("#cmd_more_search_chid").val()+' size='+$("#cmd_more_search_size").val()+' value='+$("#cmd_more_search_key").val()+']'+$("#cmd_more_search_title").val()+'[/ancho]';
		}else{
			var ubbtxt = '[ancho='+$("#cmd_more_search_module").val()+'_'+$("#cmd_more_search_chid").val()+' size='+$("#cmd_more_search_size").val()+']'+$("#cmd_more_search_title").val()+'[/ancho]';
		}
		
		
       	FT.settxt(ubbtxt);
       	$("#pop-window").hide();
    });*/
	$("#cmd_more_search_submit").live('click',function(){
		if($("#cmd_more_search_chid").val()==''){
			alert("栏目ID不能为空！");
			return false;
		}else if($("#cmd_more_search_title").val()==''){
			alert("按钮标题不能为空！");
			return false;
		}else if($("#cmd_more_search_name").val()==''){
			alert("绑定搜索框不能为空！");
			return false;
		}else if(!isabc($("#cmd_more_search_name").val())){
			alert("绑定搜索框只能是英文字母组成！");
			return false;
		}
		var ubbtxt = '[ancho='+$("#cmd_more_search_module").val()+'_'+$("#cmd_more_search_chid").val()+' name='+$("#cmd_more_search_name").val()+']'+$("#cmd_more_search_title").val()+'[/ancho]';

       	FT.settxt(ubbtxt);
       	$("#pop-window").hide();
    });
    $("#cmd_more_search_close").live('click',function(){
		$("#pop-window").hide();
    });
	/**
	 * 自定义搜索结束
	 */
	
	/**
	 * 广告系统
	 */
	$("#cmd_more_ad_submit").live('click',function(){
		if($("#cmd_more_ad_chid").val()==''){
			alert("广告ID不能为空！");
			return false;
		}else if($("#cmd_more_ad_limit").val()==''){
			alert("展示条数不能为空！");
			return false;
		}
		
       	FT.settxt('[ad]'+$("#cmd_more_ad_chid").val()+'_'+$("#cmd_more_ad_limit").val()+'[/ad]');
       	$("#pop-window").hide();
    });
    $("#cmd_more_ad_close").live('click',function(){
		$("#pop-window").hide();
    });
	/**
	 * 广告系统结束
	 */
	
	/**
	 * 用户中心
	 */
	$(".cmd_ucenter").live("click",function(){
		var tags = $(this).attr("tags");
		if(tags!=''){
			FT.settxt(tags);
		}
	});
	/**
	 * 用户中心结束
	 */
	
	/**
	 * 访问统计
	 */
	$(".cmd_count").live("click",function(){
		var tags = $(this).attr("tags");
		if(tags!=''){
			FT.settxt(tags);
		}
	});
	/**
	 * 访问统计结束
	 */
	
	
	/**
	 * 2010-09-09
	 */
	$(".tags-data").live("click",function(){
		var tags = $(this).text();
		if(tags!=''){
			FT.settxt(tags);
			$("#pop-window").hide();
		}
	});
});




function newAjaxUpload(type)
{   
	if (type == 'image') {
		new AjaxUpload($("#uploadimg"), {
			action: '../../index.php?r=Upload.image',
			name: 'upload',
			onSubmit: function(file, ext){
				if (!(ext && /^(jpg|png|jpeg|gif)$/i.test(ext))) {
					alert(ext + '文件格式不支持 ，请重新上传！');
					return false;
				}
				
				this.disable();
				$("#uploadimg").html('<img src="images/ajax.gif"/>');
			},
			onComplete: function(file, response){
				var data = eval('(' + response + ')');
				if (data.flag == 1) {
					$("#posteditor_cmd_image_url").val(data.name);
					$("#m1").attr("src",data.name);
				}
				else {
					alert("图片上传失败");
				}
				$("#uploadimg").html('上传图片');
				this.enable();
			}
		});
	}
	else {
		new AjaxUpload($("#uploadfile"), {
			action: '../../index.php?r=Upload.file',
			name: 'upload',
			onSubmit: function(file, ext){
				if (!(ext && /^(rar|zip|doc|wps|pdf|ppt|docx|pptx|xls|xlsx|jpg|png|jpeg|gif)$/i.test(ext))) {
					alert(ext + '文件格式不支持 ，请重新上传！');
					return false;
				}
				
				this.disable();
				$("#uploadfile").html('<img src="images/ajax.gif"/>');
			},
			onComplete: function(file, response){
				var data = eval('(' + response + ')');
				if (data.flag == 1) {
					$("#posteditor_cmd_file_url").val(data.name);
				}
				else {
					alert("文件上传失败");
				}
				$("#uploadfile").html('上传附件');
				this.enable();
			}
		});
	}
}

function checkPhoneNumber(num){
	 var reg0=/^1\d{6,10}$/;   //130--139。至少7位
	 //var reg1=/^153\d{8}$/;  //联通153。至少7位
	 //var reg2=/^159\d{8}$/;  //移动159。至少7位
	 //var reg3=/^158\d{8}$/;
	 //var reg4=/^150\d{8}$/;
	 var my=false;
	 if (reg0.test(num))my=true;
	 //if (reg1.test(num))my=true;
	 //if (reg2.test(num))my=true;
	 //if (reg3.test(num))my=true;
	 //if (reg4.test(num))my=true;
	 return my;
}

function isabc(str)
{
	 var reg = /^[a-zA-Z]+$/;
	 return reg.test(str);
}

function rewidth(id)
{
	var y = id.offset().top;
    var x = id.offset().left;
	var ww = document.body.clientWidth;
	if(ww-420<x){
		x = ww-420;
	}
	if(x<20) x=20;
    $("#pop-window").css({top:y+20,left:x});
}
