/**
 * wBox
 */
(function($){
    //class为.wBoxClose为关闭
    $.fn.wBox = function(options){
        var defaults = {
			wBoxURL:"http://a.pojaaimg.cn/club/linju/js/wbox/",
			handle:"click",
			timeout:0,
			IE6:'',
			middle:false,
            opacity: 0.5,//背景透明度
            drag: false,//是否可拖拽
            title: 'wBox弹出框',//wBox窗口名字
            noTitle: false,//是否不显示wBox标题边框
            html: '',//wBox内容
            callBack: null,//wBox返回函数
            isImage: false,// image灯箱
            images: [],//image灯箱图片地址数组
            left: 300,//wBox位置，当setPos为true时有用
            top: 400,
            iframeWH: {//跨域的iframe 设置高宽
                width: 400,
                height: 300
            },
            setPos: false,//是否自定义wBox位置
            overlay: true,//是否显示wBox背景
            isFrame: false,//是否为 iframe，为跨域可以自适应窗口大小            
            imageTypes: ['png', 'jpg', 'jpeg', 'gif']//支持image查看的图片类型，用于正则
        };
        var YQ = $.extend(defaults, options);
        init();
        var wBoxHtml = '\
				    <div id="wBox" style="display:none;"> \
				      <div class="popup"> \
				        <table> \
				          <tbody> \
				            <tr class="imgRemove"> \
				              <td class="tl"/><td class="b"/><td class="tr"/> \
				            </tr> \
				            <tr> \
				              <td class="b imgRemove">'+(YQ.IE6?"&nbsp;&nbsp;":"")+'</td> \
				              <td class="body">' + (YQ.noTitle ? '' : '<table class="title imgRemove"><tr><td class="dragTitle"><div class="itemTitle">' + YQ.title + '</div></td>\
                                  <td width="30px" title="关闭"><div class="close"></div></td></tr></table> ') +
				                '<div class="content"> \
				                </div> \
				              </td> \
				              <td class="b imgRemove">'+(YQ.IE6?"&nbsp;&nbsp;":"")+'</td>\
				            </tr> \
				            <tr class="imgRemove"> \
				              <td class="bl"/><td class="b"/><td class="br"/> \
				            </tr> \
				          </tbody> \
				        </table> \
				      </div> \
				    </div>';
        
        var Loading = $("<div class='wBox_loading'><img src='"+YQ.wBoxURL+"loading.gif'/></div>");
        var imgObj = [];
        var imgNum = 0;
        var B = null;//背景jquery div
        var C = null;//内容jquery div             
        var E = null;//正则匹配img
        
		function showWbox(href){
			B ? B.remove() : null;
            C ? C.remove() : null;
            
            YQ.overlay ? B = $("<div id='wBox_overlay' class='wBox_hide'></div>").hide().addClass('wBox_overlayBG').css('opacity', YQ.isImage ? 0.8 : YQ.opacity).dblclick(function(){
                close();
            }).appendTo('body').fadeIn(300) : null;
            C = $(wBoxHtml).appendTo('body');
            handleClick(href);
		}
        /*
         * 处理点击
         * @param {string} what
         */
        function handleClick(what){
            var con = C.find(".content");
            if (YQ.isImage) { //img灯箱
                C.find('.imgRemove').remove();
                C.find('.content').css({
                    'padding': '10px',
                    'background-color': '#FFFFFF'
                });
                Loading.appendTo(con);
                var lt = calPosition(370);
                C.css({
                    left: lt[0],
                    top: lt[1]
                });
                imgHandle()
            }
            else 
                if (YQ.isFrame) {//iframe
                    ifr = $("<iframe name='wBoxIframe' style='width:" + YQ.iframeWH.width + "px;height:" + YQ.iframeWH.height + "px;' scrolling='auto' frameborder='0' src='" + what + "'></iframe>");
                    ifr.appendTo(con);
                    ifr.load(function(){
                        try {
                            $t = $(this).contents();
                            $t.find('.wBoxClose').click(close);
                            fH = $t.height();//iframe height
                            fW = $t.width();
                            w = $(window);
                            newW = Math.min(w.width() - 40, fW);
                            newH = w.height() - 25 - (YQ.noTitle ? 0 : 30);
                            newH = Math.min(newH, fH);
                            if (!newH) 
                                return;
                            var lt = calPosition(newW);
                            C.animate({
                                left: lt[0],
                                top: lt[1]
                            }, 1000);
                            $(this).animate({
                                height: newH,
                                width: newW
                            }, 1000);
                        //                          setPosition();
                        } 
                        catch (e) {
                        }
                    });
                }
                else 
                    if (what !== window.location.href && what) {
                        if (what.match(/#/)) {//href=#info
                            var url = window.location.href.split('#')[0]
                            var target = what.replace(url, '');
                            con.append($(target).clone(true).show());
                        }
                        else 
                            if (what.match(Exp)) {//href=*.jpg gif png
                                var image = new Image();
                                Loading.appendTo(con);
                                image.onload = function(){
                                    w = image.width < 100 ? 100 : image.width;
                                    h = image.height < 100 ? 100 : image.height + 24;
                                    var lt = calPosition(w);
                                    imgC = $('<div class="image"><img src="' + image.src + '" /></div>');
                                    C.css({
                                        left: lt[0],
                                        top: lt[1]
                                    })
                                    Loading.remove();
                                    con.html(imgC.hide().fadeIn());
                                    
                                }
                                image.src = what;
                            }
                            else {//href=1.html
                                Loading.appendTo(con);
                                con.load(what, function(){
                                    Loading.remove();
                                    //加载完成后重新定位，修改者：wuyong，2010-7-6
                                    setPosition();
                                });
                            }
                    }
                    else {//使用YQ.html
                        con.html(YQ.html)
                    }
            afterHandleClick();
        }
        /*
         * img 处理函数
         * 用于图片预加载后运行处理
         * 为防止IE出现错误，使用onload在src之前
         */
        function imgHandle(){
            for (var i = YQ.images.length; i--;) {
                imgObj[i] = new Image();
                i ? null : imgObj[0].onload = function(){
                    Loading.fadeOut(300, imgAjax);
                    
                }
                imgObj[i].src = YQ.images[i];
            }
            
        }
        /*
         * img load handle fn
         */
        function imgAjax(){
            var tImg = imgObj[imgNum], con = C.find(".content").html(Loading.show());
            w = tImg.width < 100 ? 100 : tImg.width;
            h = tImg.height < 100 ? 100 : tImg.height + 24;
            var lt = calPosition(w);
            var speed = w * 2 < 900 ? 900 : w * 2;
            var imgC = $("<div id='IMG'><img src='" + tImg.src + "' id='imgURL'/><div class='imgBTN'><a href='' id='imgPrev' title='点击查看上一张图片'></a><a id='imgNext' href='' title='点击查看下一张图片'></a></div></div>");
            imgC.find("#imgPrev").click(function(){
                imgPrev();
                return false;
            }).next().click(function(){
                imgNext();
                return false;
            });
			if(YQ.IE6){
				imgC.find("a").css({
					height:32,
					position:"absolute",
					width:tImg.width/2,
					top:(tImg.height-32)/2
				});
			}
            C.animate({
                left: lt[0],
                top: lt[1]
            }, speed).find(".body").animate({
                height: h,
                width: w
            }, speed, function(){
                con.html(imgC.hide().fadeIn());
                Loading.stop().hide();
            })
        }
        /*
         *img next handle fn
         */
        function imgNext(){
            ++imgNum === YQ.images.length ? imgNum = 0 : null;
            imgAjax()
        }
        /*
         * img prev handle fn
         */
        function imgPrev(){
            --imgNum < 0 ? imgNum = YQ.images.length - 1 : null;
            imgAjax()
        }
        /*
         * first kiss
         */
        function init(){
            var imageTypes = YQ.imageTypes.join('|');
			if(!$("#wBoxCSS")[0]){
				//$("head").append('<link rel="stylesheet" href="'+YQ.wBoxURL+'wbox.css" id="wBoxCSS" type="text/css"/>');
			}			
            Exp = new RegExp('\.' + imageTypes + '$', 'i');
            var iA = ['titleBG.png', 'wbox.png', 'close.png', 'loading.gif', 'btn-prev.gif', 'btn-next.gif'];
            var v = [];
            for (var i = iA.length; i--;) {
                v[i] = new Image();
                v[i].src = YQ.wBoxURL+iA[i];
            }
			if($.browser.msie&&$.browser.version==="6.0"){
				YQ.IE6=true;
			}
        }
        /*
         * 处理点击之后的处理
         */
        function afterHandleClick(){
            setPosition();
            C.find('.close').click(function(){
                close()
            }).hover(function(){
                $(this).addClass("on");
            }, function(){
                $(this).removeClass("on");
            });
            $(document).unbind('keydown.wBox').bind('keydown.wBox', function(e){
                if (e.keyCode === 27) 
                    close();
                return true
            });
            YQ.drag ? drag() : null;
            typeof YQ.callBack === 'function' ? YQ.callBack() : null;
			C.find('.wBoxClose').click(close);
			if(YQ.timeout){
				setTimeout(close,YQ.timeout);
			}
        }
        /*
         * 设置wBox的位置
         */
        function setPosition(){
            var lt = calPosition($("#wBox").width());
            $("#wBox").css({
                left: lt[0],
                top: lt[1]
            }).show();
            if(B){
				var $w = $(window); 
				var $h=$("body").height(),$wh=$w.height();
				$h=Math.max($h,$wh);
				B.height($h).width($w.width())
			}          
        }
        /*
         * 计算wBox的位置
         * @param {number} w 宽度
         */
        function calPosition(w){
            var $win = $(window);
            if (YQ.setPos) {
                l = YQ.left;
                t = YQ.top;
            }
			else {
				l = ($win.width() - w) / 2;
				//高度算法调整为居中，修改者：wuyong,2010-7-6
				t = $win.scrollTop() + ($win.height() - $('#wBox').height()) / 2;
			}
            return [l, t];
        }
        /*
         * 拖拽函数drag
         */
        function drag(){
            var dx, dy, moveout;
            var T = C.find('.dragTitle').css('cursor', 'move');
            T.bind("selectstart", function(){
                return false;
            });
            
            T.mousedown(function(e){
                dx = e.clientX - parseInt(C.css("left"));
                dy = e.clientY - parseInt(C.css("top"));
                C.mousemove(move).mouseout(out).css('opacity', 0.8);
                T.mouseup(up);
            });
            /*
             * 移动改变生活
             * @param {Object} e 事件
             */
            function move(e){
                moveout = false;
                win = $(window);
                if (e.clientX - dx < 0) {
                    l = 0;
                }
                else 
                    if (e.clientX - dx > win.width() - C.width()) {
                        l = win.width() - C.width();
                    }
                    else {
                        l = e.clientX - dx
                    }
                C.css({
                    left: l,
                    top: e.clientY - dy
                });
                
            }
            /*
             * 你已经out啦！
             * @param {Object} e 事件
             */
            function out(e){
                moveout = true;
                setTimeout(function(){
                    moveout && up(e);
                }, 10);
            }
            /*
             * 放弃
             * @param {Object} e事件
             */
            function up(e){
                C.unbind("mousemove", move).unbind("mouseout", out).css('opacity', 1);
                T.unbind("mouseup", up);
            }
        }
        /*
         * 关闭弹出框就是移除还原
         */
        function close(){
            if (C) {
                B ? B.remove() : null;
                C.find('.body').stop();
                C.stop().fadeOut(300, function(){
                    C.remove();
                })
            }
        }
		/*
         * 触发click事件
         */
		switch (YQ.handle) {
			case "show":
			showWbox();
			break;
			default:
                $(this).click(function(){
                    showWbox(this.href);
                    return false;
                });
            break;
		}
        
        $('.wBoxClose').click(close);
        $(window).resize(function(){
            setPosition();
        });
    };
	wBox = $.fn.wBox;
})(jQuery);

/*
 * 邻居弹出框                                                  
 */

//调用方式：lj.方法名(参数);
(function($){
window.lj={
    
    /**
     * show方法，示例:lj.show('.forward');
     *
     * @param  string target  目标 $(target).wBox();
     * @param  object 扩展选项
     * @return void
     */
    show:function(target, options){
        var defaults = {
            opacity:'0',
            drag:true,
            title:'提示'
        };
        $(target).wBox($.extend(defaults, options));
    },

    /**
     * alert方法
     *
     * @param  string message
     * @param  object 扩展选项
     * @return void
     */
    alert:function(message, options){
        var defaults = {
            handle:'show',
            opacity:'0',
            drag:true,
            title:'提示',
            html:'<div class="wBoxMessage">'+message+'<br /><input type="button" id="wBoxConfirm" value="确定"  class="btn12px-1" /></div>'
        };
        wBox($.extend(defaults, options));
        $('#wBoxConfirm').click(function(){ lj.close(); });
    },

    /**
     * info方法
     *
     * @param  string message
     * @param  object 扩展选项
     * @return void
     */
    info:function(message, options){
        var defaults = {
            handle:'show',
            opacity:'0',
            noTitle:true,
            html:'<div class="wBoxMessage">'+message+'</div>',
            timeout:2000
        };
        wBox($.extend(defaults, options));
    },

    /**
     * confirm方法
     *
     * @param  string   message
     * @param  function 点击确定执行的函数
     * @param  object   扩展选项
     * @return void
     */
    confirm:function(message, callback, options){
        var defaults = {
            handle:'show',
            opacity:'0',
            title:'提示',
            drag:true,
            cancel:null,
            html:'<div class="wBoxMessage">'+message+'<br /><input type="button" id="wBoxConfirm" class="btn12px-1" value="确定" /><input type="button" id="wBoxCancel" class="btn12px-1" value="取消" /></div>'
        };
        var params = $.extend(defaults, options);
        wBox(params);
        $("#wBoxConfirm").click(function(){
            if(callback && $.isFunction(callback)){ callback(); }
            lj.close();
        });
        $("#wBoxCancel").click(function(){
            if(params.cancel && $.isFunction(params.cancel)){ params.cancel(); }
            lj.close();
        });
    },

    /**
     * prompt方法
     *
     * @param  string message
     * @param  function 点击确定执行的回调函数
     * @param  object 扩展选项
     * @return void
     */
    prompt:function(message, callback, options){
        var defaults = {
            handle:'show',
            opacity:'0',
            title:'输入框',
            cancel:null,
            drag:true,
            value:'',
            html:'<div class="wBoxPrompt">'+message+'<br /><input type="text" id="wBoxInput" /><div class="wBoxButton"><input type="button" id="wBoxConfirm" value="确定" /><input type="button" id="wBoxCancel" value="取消" /></div></div>'
        };
        var params = $.extend(defaults, options);
        wBox(params);
        $("#wBoxInput").val(params.value);
        $("#wBoxConfirm").click(function(){
            if(callback && $.isFunction(callback)){ callback($("#wBoxInput").val()); }
            lj.close();
        });
        $("#wBoxCancel").click(function(){
            if(params.cancel && $.isFunction(params.cancel)){ params.cancel(); }
            lj.close();
        });
    },

    /**
     * 关闭弹出框
     *
     * @param  none
     * @return void
     */
    close:function(){
        $("#wBox").remove();
        $("#wBox_overlay").remove();
    }

};
})(jQuery);


//----------邻居的js------------
/*
 * 加载某个页面至对应的目标
 * @todo
 */
function loadTo(url, param, target)
{
    $.get(url, param, function(data){
        $(target).html(data);
    });
}

/*
 * 加载页面至中间区域
 */
function loadToMain(url, param, hold)
{
    $.get(url, param, function(data){
        if(hold) $('#state-list').append(data);
        else     $('#state-list').html(data);
    });
}

/*
 * 加载页面至左侧边栏
 */
function loadToSide(url, param, hold)
{
    //url未提供时，将清空侧边栏
    if(!url) {$('#side-container').html('');return;}
    $.get(url, param, function(data){
        if(hold) $('#side-container').append(data);
        else     $('#side-container').html(data);
    });
}

/*
 * 设置当前标签
 *
 * @param tab = my/msg/info/album
 */
function setCurTab(tab)
{
    $('#tab-list li.on').removeClass('on');
    $('#tab-'+tab).addClass('on');
}

/**
 * 表情js
 *
 * @author wuyong
 * @param  string appendID 表情栏要放置的id，含#
 * @param  string inputID 输入框id等，含#
 * @param  string url
 * @return void
 */
function showFace(appendID, inputID, url)
{
    //检查是否存在，只取一次，存在则显示隐藏切换，不存在则取数据
    var $tag = $(appendID).find('.eFaceHidden');
    if($tag.length > 0)
    {
        var $face = $(appendID).find(".eFaceWrap");
        if ($face.length > 0) {
            if($face.css('display') == 'none')
            {
                $face.show();
                //重新绑定任意处点击关闭事件，加mousemove事件是防止自动触发body的click事件
                $("body").mousemove(function(){
                    $("body").bind('click', function(){
                        hideFace(appendID);
                        $("body").unbind('click').unbind('mousemove');
                    })
                });
            }
            else
            {
                $face.hide();
            }
        }
    }
    else
    {
        $('<input type="hidden" class="eFaceHidden" />').appendTo(appendID);
        $.get(url, {'inputID':inputID, 'appendID':appendID}, function(data){
            $(appendID).append(data);
        });
    }
}

/**
 * 隐藏表情栏
 * @param  string appendID 表情栏要放置的id，含#
 */
function hideFace(appendID)
{
    var $face = $(appendID).find(".eFaceWrap");
    if($face.length > 0)
    {
        $face.hide();
    }
}

//美化效果
$(function(){
    $('a').bind('focus',function(){
        if(this.blur){ //如果支持 this.blur
            this.blur();
        };
    });
});

//图片浏览
function toggleImg(jqid)
{
    var $id = $(jqid);
    var oldClass = $id.attr('class');
    var newClass = oldClass=='breviary'? 'big-pic' : 'breviary';
    var oldSrc   = $id.find("img").attr('src');
    var newSrc   = $id.siblings('input[type="hidden"]').val();
    $id.siblings('input[type="hidden"]').val(oldSrc);
    //加载大图时首先显示载入中效果
    if(oldClass=='breviary')
    {
        $id.addClass('loading').html('载入中...');
    }
    var temp = $('<img src="'+newSrc+'"  />');
    temp.load(function(){
    $id.removeClass(oldClass).addClass(newClass).html(temp).removeClass('loading'); 
    });
}

/**
 * 计算输入框长度
 *
 * @author wuyong
 * @param string id     jq的id,如#input
 * @param int    len 最大长度
 * @param string retID  显示消息的id，如#ret
 * @return void
 */
function countLength(id, len, retID)
{
    var content = $(id).val();
    if(content.length <= len)
    {
        $(retID).stop(true, true).html('您还可以输入<span style="font-weight:bold;"><font color="#F38F6C">'+(len-content.length)+'</font></span>个字').show();
    }
    else
    {
        $(retID).html('<font color="red">输入内容太长，应小于'+len+'字</font>').show();
    }
}

/***********************************情报***********************************************/
//列表页删除情报
function delMessage(id, postUrl)
{
    lj.confirm('确认删除吗？此操作不可恢复', function(){
        $.post(postUrl, {'type':'del', 'id':id}, function(data){
            data = eval("("+data+")");
            if(data.status == 1)
            {
                $("#qingbao"+id).remove();
            }
        });
    });
}
//单个情报页面删除情报
function delOneMessage(id, postUrl, jumpUrl)
{
    lj.confirm('确认删除吗？此操作不可恢复', function(){
        $.post(postUrl, {'type':'del', 'id':id}, function(data){
            data = eval("("+data+")");
            if(data.status == 1)
            {
                location.href = jumpUrl;
            }
            else
            {
                alert('删除失败');
            }
        });
    });
}
/**
 * 获取更多情报
 *
 * @param  object
 */
function getMoreMsg(obj)
{
    var $box  = $('#contentQingbao').addClass('gettingMore');
    var $more = $('#news-more').html('载入中...');
    var pos = $more.offset().top-20;
    $.get(obj.rel, function(data){
        $more.parent('li').remove();
        $box.append(data).removeClass('gettingMore');
        $('html,body').delay(200).animate({scrollTop:pos},1500);
    });  
}
/**
 * 回复情报的评论
 */
function replyMsgCmt(memberID, memberName, messageID)
{
    $("#replyMsg"+messageID).focus().val('回复@'+memberName+'：');
    $('#to'+messageID).val(memberID);
}
//添加情报的评论
function addMsgCmt(messageID, memberID, postUrl, delUrl)
{
    var addNewMsg  = ($("#addReplyMsg"+messageID).attr('checked') == true) ? 1 : 0;
    var msgComment = $.trim($("#replyMsg"+messageID).val());
    var to         = $('#to'+messageID).val();
    var isReply    = to? 1 : 0;
    if(msgComment == '' || msgComment == '添加评论')
    {
        $("#replyMsg"+messageID+'Status').hide().html('<font color="red">请输入评论内容</font>').fadeIn(1000).fadeOut(2000);
        $("#replyMsg"+messageID).focus();
    }
    else
    {
        //按钮变化，防止网速慢多次提交
        $('#replyMsgSub'+messageID).val('').addClass('processing').attr('disabled', 'disabled');
        $.post(postUrl, {'messageID':messageID, 'msgComment':msgComment, 'addNewMsg':addNewMsg, 'to':to, 'isReply':isReply}, function(data){
            if(data.status == 1)
            {
                msgComment   = $("#replyMsg"+messageID).parents(".recall").before(data.data.piece);
                $("#replyMsg"+messageID).val('');
                $('#to'+messageID).val('');
            }
            else
            {
                $("#replyMsg"+messageID+'Status').hide().html(data.info).fadeIn(1000).fadeOut(2000);
            }
            $('#replyMsgSub'+messageID).removeClass('processing').removeAttr('disabled').val('提交');
        }, 'json');
    }
}
//删除情报的评论
function delMsgCmt(commentID, messageID, postUrl)
{
    lj.confirm('确认删除吗？此操作不可恢复！', function(){
        $.post(postUrl, {'messageID':messageID, 'commentID':commentID}, function(data){
            if(data.status){
                $("#dl"+commentID).remove();
            }
        }, 'json');
    });
}


/***********************************留言***********************************************/
function noteInit()
{
    dq.ajaxSubmit('#noteForm','',function(data){
        $('#noteSubmit').removeClass('processing').attr('disabled', '').val('留言');
        if(data.status)
        {
            $('#noteList').prepend(data.data.piece);
            $('#noteContent').val('我要留言（不超过200字，超出部分不显示）');
            $('#noteContent').attr('style', 'color:#B1B1B1');
            $('#replyTo').val('');
            $('#replyPre').val('');
            $('#noteLen').hide();
            $('#noteMsg').stop(true,true).html('发表留言成功').css('color', 'green').show().fadeOut(4000);
        }
        else
        {
            //lj.alert(data.info);
            $('#noteMsg').stop(true,true).html(data.info).css('color', 'red').fadeIn(1000).fadeOut(4000);
        }
    },{dataType:'json',beforeFn:function(){
        var value = $.trim($('#noteContent').val());
        $('#noteContent').val(value);
        var pre = $('#replyPre').val();
        if((pre && pre==value) || 
            value == '' || value == '我要留言（不超过200字，超出部分不显示）')
        {
            //lj.alert('留言不能为空');
            $('#noteMsg').stop(true,true).html('留言不能为空').css('color', 'red').fadeIn(1000).fadeOut(4000);
            return false;
        }
        if(value.length > 200)
        {
            if(!confirm('您的留言内容超过最大字数限制，继续提交超出部分将不会显示。您确定继续吗？')) return false;
        }
        $('#noteSubmit').val('').addClass('processing').attr('disabled', 'disabled');
        return true;
    }});
}
function getMore(url, id)
{
    var $list = $('#noteList').addClass('gettingMore');
    var $more = $('#news-more').html('加载中...'); 
    $.get(url, function(data){
        $more.remove();
        $(id).append(data);
        $list.removeClass('gettingMore'); 
    });
    //留言页面首次显示时，查看更多链接并不存在
    if($more.length)
    { 
        var pos = $more.offset().top;
        $('html,body').delay(200).animate({scrollTop:pos},1500);
    }
}
function delNote(url, id, type)
{
    lj.confirm('您确定删除此条留言吗?', function(){
        $.get(url, {'type':type}, function(data){
            if(data.status) {$(id).remove();}
            else { lj.alert(data.info); }
        }, 'json');
    }); 
}
function replyNote(replyTo, rName)
{
    var prefix = '回复@'+rName+':';
    $('#replyTo').val(replyTo);
    $('#replyPre').val(prefix);
    //首页
    if($('#msg-board').length > 0){
        var moff = $("#msg-board").offset().top;
    //单页
    }else {
        var moff = $('#state-list').offset().top;
    }
    var $noteContent = $('#noteContent');
    var content = $noteContent.val();
    if(content && content != '我要留言（不超过200字，超出部分不显示）')
    {
        content = content.replace(/回复@.*?:/, '');
        prefix += content;
    }
    $noteContent.val(prefix);
    $("html,body").animate({scrollTop: moff+'px'}, 500, function(){
        $noteContent.attr('style', 'color:#000000').focus();
    });
}


//判断是否加载完成
function imageloaded(url){ 
	//判断浏览器
	var Browser=new Object();
	Browser.userAgent=window.navigator.userAgent.toLowerCase();
	Browser.ie=/msie/.test(Browser.userAgent);
	Browser.Moz=/gecko/.test(Browser.userAgent);

    var val=url;
    var img=new Image();
    if(Browser.ie){
        img.onreadystatechange =function(){ 
            if(img.readyState=="complete"||img.readyState=="loaded"){
                //callback(img,imgid);
            	return true;
            }
        }       
    }else if(Browser.Moz){
        img.onload=function(){
            if(img.complete==true){
                //callback(img,imgid);
            	return true;
            }
        }       
    }
}
