function sendVerifyCodeAgain(){ 
    $("verifyMobileSuccField").hide();
    $("mobileNumberField").show();
    $("verifyMobileField").hide();
}

function showMessage(div, msg, type) {
    div.update( msg );
    if(type){
        div.className = "ok_message"; 
    }else{
        div.className = "wrong_message";
    }
//    setTimeout(function(){
//        div.update("");
//        div.className = "clear";
//        div.className = "clear";
//    },3000);
}

function removeConfirm(){
    if(confirm("确定删除?")){
        return true;
    }
    return false;
}

function compareTwoDate(bStr,eStr){
    var bb = bStr.toString().split("/");
    var ee = eStr.toString().split("/");
    if(bb[0]>ee[0] || bb[0]==ee[0]&&bb[1]>ee[1]|| bb[0]==ee[0]&& bb[1]==ee[1] && bb[2]>ee[2] ){
        return false;
    }else{
        return true;
    }
}

function getRedirectURL() {
    var url  = '/mblogs/pub/mblogmine';
    if(location.pathname == '/mblogs/mblogmine' || location.pathname == '/mblogs/mblogmine#') {
        url = '/mblogs/mblogmine';
    } else if(location.pathname.indexOf("/groups") != -1) {
        var groupURL = $F("groupUrl");
        url = '/groups/' + groupURL;
    } else if(location.pathname.indexOf("/events") != -1) {
        var eventURL = $F("eventUrl");
        url = '/events/' + eventURL;
    } else if(location.pathname.indexOf("/qa") != -1) {
        url = '/qa';
    }
    return url;
}
var MobileVerify = {
    _generateVerifyCodeUrl : "Microblog.do?action=GENERATE_VERIFY_CODE",
    _verifyMobileUrl : "Microblog.do?action=VERIFY_MOBILE_NUMBER",
    _mobileNumber : "",
    _verifyCode : "",
    _timer : null,

    _checkGenerate : function(){
        this._mobileNumber = $F("mobileNumber");
        if(this._mobileNumber.empty()){
            showMessage($("mobileNumberMsg"), "请输入您的手机号码", false);
            return false;  
        }
        if(!isAllNumberStr(this._mobileNumber)){
            showMessage($("mobileNumberMsg"), "手机号码只能是数字组合", false);
            return false;
        }
        return true;
    },

    generateVerifyCode : function(){
        if(this._checkGenerate()){
            new Ajax.Request(this._generateVerifyCodeUrl,{
                parameters : {
                    "mobileNumber" : this._mobileNumber
                },
                requestHeaders : {
                    Accept: 'application/json'
                },
                onCreate : function(){
                    //$("mobileNumberLoading").update('确认码发送中,请稍候...');
                    $("mobileNumberLoading").update('请稍候...');
                    $("mobileNumberLoading").className = "ok_message";
                    $("mobileNumberLoading").removeClassName("clear");
                    $("generateVerifyCodeBtn").disabled = true;
                },
                onSuccess : function(transport){
                    var json = transport.responseText.evalJSON(true);
                    if(json.RETURN){
                        this._timer = setTimeout(function(){
                            $("mobileNumberLoading").className = "";
                            $("mobileNumberLoading").update('');
                            showMessage($("verifyMobileMsg"), "保存成功", true);
                            $("verifyMobileSuccField").show();
                            $("mobileNumberField").hide();
                            $("verifyMobileField").hide();                            
                            $('mobile_number_modify').update(json.mobileVerify.mobileNumber);
                        //showMessage($("verifyMobileMsg"), "确认码已发送至 " + json.mobileVerify.mobileNumber, true);
                            
                        },1000);
                    }else{
                        showMessage($("mobileNumberMsg"), json.MESSAGE, false);
                        $("mobileNumberLoading").update();
                        $("mobileNumberLoading").className = "clear";
                        this._timer = setTimeout(function(){
                            $("mobileNumberMsg").update("");
                            $("mobileNumberMsg").className = "clear";
                            $("mobileNumberLoading").className = "clear";
                        },3000);
                    }
                }.bind(this),
                onComplete : function(){
                    this._timer = setTimeout(function(){
                        $("mobileNumberLoading").update();
                        $("mobileNumberLoading").className = "clear";
                        $("generateVerifyCodeBtn").disabled = false;
                    },5000);
                }
            })
        }
    },

    _checkVerify : function(){
        this._verifyCode = $F("verifyCode");
        if(this._verifyCode.empty()){
            showMessage($("verifyMobileMsg"), "请输入您的手机确认码", false);
            return false;
        }
        if(!isAllNumberStr(this._verifyCode)){
            showMessage($("verifyMobileMsg"), "手机确认码只能是数字组合", false);
            return false;
        }
        return true;
    },

    verifyMobileNumber : function(fromPage, objStr){
        if(this._checkVerify()){
            new Ajax.Request(this._verifyMobileUrl,{
                parameters : {
                    "verifyCode" : this._verifyCode,
                    "fromPage" : fromPage,
                    "objStr" : objStr
                },
                requestHeaders : {
                    Accept: 'application/json'
                },
                onCreate : function(){
                    $("verifyMobileLoading").update('<img src="/images/032.gif" />');
                    $("verifyMobileLoading").removeClassName("clear");
                    $("verifyMobileBtn").disabled = true;
                },
                onSuccess : function(transport){
                    var json = transport.responseText.evalJSON(true);
                    if(json.RETURN){
                        $("verifyMobileSuccMsg").show();
                        //$("verifyMobileSuccMsg").className = "ok_message";
                        $("verifyMobileNumber").update(json.mobileNumber);
                        $("verifyMobileSuccField").show();
                        $("mobileNumberField").hide();
                        $("verifyMobileField").hide();
                    }else{
                        showMessage($("verifyMobileMsg"), json.MESSAGE, false);

                        this._timer = setTimeout(function(){
                            $("verifyMobileMsg").update("");
                            $("verifyMobileMsg").className = "clear";
                            $("verifyMobileLoading").className = "clear";
                        },3000);
                    }
                }.bind(this),
                onComplete : function(){
                    $("verifyMobileLoading").update();
                    $("verifyMobileBtn").disabled = false;
                }
            })
        }
    }
}
var microblogForwardDialog = null;
var Microblog = {
    _createFollower : "/Microblog.do?action=CREATE_MICROBLOG_FOLLOWER",
    _removeFollower : "/Microblog.do?action=REMOVE_MICROBLOG_FOLLOWER",
    _createMicroblog : "/Microblog.do?action=PUBLISH_MICROBLOG",
    _timer : null,

    _editMblogContentTextarea : "editMblogContentTextarea",
    _set_microblog_str : "SET_MICROBLOG",
    _remove_microblog_str : "REMOVE_MICROBLOG",
    showProfileMblogList : function(showDivId , hideDivId) {
        $(hideDivId).hide();
        $(showDivId).show();
    },
    showPictureWindow : function(mblogId){
        var width  = null;
        var height = null;
        var left   = null;
        var top    = null;
        var common_multiple = null;
        var w_constant = 16;
        var h_constant = 9;
        var top_constant = screen.height > 960 ?0.090:0.059;
        width = Math.round(screen.width*0.98);
        common_multiple = Math.round(width/w_constant);
        height = common_multiple*h_constant;
        left = width < 1000?5:7;
        top = screen.height * top_constant;
        window.open('/mblogs/'+mblogId+'/show','','toolbar=no,menubar=no, scrollbars=yes, resizable=yes, location=no, status=no,width='+width+',height='+height+',left='+left+',top='+top);
    },
    mblogFocus : function(defaultStr){
        var microblogContent = $("microblogContent").value.strip();
        if(microblogContent == defaultStr){
            $("microblogContent").value = "";
            $("microblogContent").className = "textareaBolg";
        }
    },

    mblogBlur : function(defaultStr){
        var microblogContent = $("microblogContent").value.strip();
        if(microblogContent == ""){
            $("microblogContent").value = defaultStr;
            $("microblogContent").className = "textareaBolg";
        }
    },
    showSynBlogToSinaWindow:function(url, wname, eId){
        var cb = $(eId);
        if(cb.checked) {
            window.open(url, wname, 'width=560,height=400,toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=yes, copyhistory=yes');
        // window.showModalDialog(url, null,"dialogWidth=600px;dialogHeight=400px");
        } else {
//            if(eId == "forward_to_sina_cbox") {
//                this.hideForwardMicroblogDialog();
//            }
            if(eId == "forward_question_to_sina_cbox") {
                QuestionForward.hideDialog();
            }
        }
    },
    showForwardMicroblogDialog:function(mblogId,originId){
        $("mblog_id").value = mblogId;
        $("origin_id").value = originId;
        var isLogOut=false;
        new Ajax.Request("/Microblog.do?action=MICROBLOG_CONTENT",
        {
            parameters : {
                "microblogId" : mblogId
            },
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    if(json.microblog.forwardOriginMicroblog!=null&&json.microblog.content!=null&&json.microblog.content.length>0){
                        $('forward_mblog_comment').value='//@'+json.microblog.user.refName+":"+json.microblog.content;
                    }else{
                        $('forward_mblog_comment').value='';
                    }   
                   
                }else{
                    isLogOut=true;
                    alert("请先登录");
                    return;
                }
            },
            onComplete : function(){
                if(isLogOut){
                    return;
                }
                new Ajax.Request("/templates/mblog_item_forward_content.jsp",
                {
                    parameters : {
                        "microblogId" : mblogId,
                        "originId" : originId,
                        "forwardDialog":true
                    },
                    requestHeaders : {
                        Accept: 'html/text'
                    },
                    onCreate : function(){
                        $("forwarding_"+mblogId).update('<img src="/images/loading.gif">');
                    },
                    onSuccess : function(transport){
                        $("forwarding_"+mblogId).update('');
                        $("origin_mblog_content_div").update(transport.responseText);
                    },
                    onComplete : function(){
                        if(microblogForwardDialog == null) {
                            microblogForwardDialog = new YAHOO.widget.Dialog("microblog_forward_dialog");
                        }
                        $("forward_before_section").show();
                        $("forward_after_section").hide();
                        $("microblog_forward_dialog").show();
                        microblogForwardDialog.center();
                        microblogForwardDialog.render();
                        microblogForwardDialog.show();
                        if ($('forward_mblog_comment').setSelectionRange) {//光标移到textarea最前方
                            setTimeout(function() {
                                $('forward_mblog_comment').setSelectionRange(0, 0); //将光标定位在textarea的开头，需要定位到其他位置的请自行修改
                                $('forward_mblog_comment').focus();
                            }, 0);
                        }else if ($('forward_mblog_comment').createTextRange) {
                            setTimeout(function() {
                                var txt=$('forward_mblog_comment').createTextRange();
                                txt.moveEnd("character",0-txt.text.length);
                                txt.select();
                            },10);
                        } 
                    }
                });
            }
        });
       
    },
    hideForwardMicroblogDialog:function(){
        microblogForwardDialog.hide();
    },
    createMicroblog : function(currentUrl){
        var microblogContent = $("microblogContent").value.strip();

        if(microblogContent.length < 1 || microblogContent == "我在忙些什么..." || microblogContent.length > 1000){
            if(microblogContent.length < 1 || microblogContent == "我在忙些什么..."){
                showMessage($("mblogMsg"), "微博内容不能为空", false);
            }else{
                showMessage($("mblogMsg"), "微博内容长度不能大于1K", false);
            }
            this._timer =Controltime();
            return false;
        }
        $("mblog_submit").disabled = true;
        $("mblog_cancel").disabled = true;
        new Ajax.Request(this._createMicroblog,
        {
            parameters : {
                "microblogContent" : microblogContent
            },
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
                $("mblogLoading").update('<img src="/images/loading.gif">');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    document.location.href = currentUrl;
                }else{
                    showMessage($("mblogMsg"), json.MESSAGE, false);
                    this._timer =Controltime();
                }
            },
            onComplete : function(){
                $("mblogLoading").update("");
                $("mblog_submit").disabled = false;
                $("mblog_cancel").disabled = false;
            }
        });
        return false;
    },
    recommandGroupMicroblog:function(microblogId){
        new Ajax.Request("/Microblog.do?action=SENDEMAILTOGROUPMEMBER", {
            method: "post",
            parameters : {
                "microblogId" : microblogId
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("send_email_ok").update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    $("send_email_ok").update('');
                    emailToGroupMemberDialog.hide();
                    showEmailToGroupMemberOkDialog();

                }
            },
            onComplete : function(){

            }
        })
    },
    reportBad:function(microblogId){
        showReportDialog();
        $('confirmReportBad').onclick=function(){
            var reason=$('reportReason').value.strip();
            if(reason=='请说明不良信息内容...'){
                reason="";
            }
            new Ajax.Request("/Microblog.do?action=REPORTBAD", {
                method: "post",
                parameters : {
                    "microblogId" : microblogId,
                    "reason":reason
                },
                requestHeaders: {
                    Accept : "application/json"
                },
                onCreate : function(){
                    $("confirm_report_bad").update('<img src="/images/loading.gif" />');
                },
                onSuccess : function(transport){
                    var json = transport.responseText.evalJSON(true);
                    if(json.RETURN){
                        $("confirm_report_bad").update('');
                        reportDialog.hide();
                        showReportOkDialog();
                    //emailToGroupMemberDialog.hide();
                    //showEmailToGroupMemberOkDialog();

                    }else{
                        alert(json.MESSAGE);
                    }
                },                
                onComplete : function(){
                    $('reportReason').style.color='#999999';
                    $('reportReason').value='请说明不良信息内容...';
                }
            })
        }
    },

    toGroupTop : function(microblogId,groupUrl){//群组内微博置顶
        new Ajax.Request("/Microblog.do?action=GROUPTOP", {
            method: "post",
            parameters : {
                "microblogId" : microblogId
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("groupTop"+microblogId).update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    $("groupTop"+microblogId).update('');
                    location.href="/groups/"+groupUrl+"/discussion";
                }
            },
            onComplete : function(){

            }
        })
    },
    noGroupTop : function(microblogId,groupUrl){//取消置顶
        new Ajax.Request("/Microblog.do?action=NOGROUPTOP", {
            method: "post",
            parameters : {
                "microblogId" : microblogId
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("noGroupTop"+microblogId).update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    $("noGroupTop"+microblogId).update('');
                    location.href="/groups/"+groupUrl+"/discussion";
                }
            },
            onComplete : function(){

            }
        })
    },
    createMusicBlog : function(){
        var musicblog_file = $("musicblog_file").value.strip();
        if(musicblog_file.length < 1 ){
            showMessage($("mblogMsg"), "音频文件不能为空", false);
            this._timer =Controltime();
            return false;
        }
        musicblog_file = musicblog_file.toLowerCase();
        if(!musicblog_file.endsWith(".mp3")){
            showMessage($("mblogMsg"), "请上传MP3文件", false);
            this._timer =Controltime();
            return false;
        }
        var microblogContent = $("musicblog_content").value.strip();

        if(microblogContent.length < 1 || microblogContent.length > 1000){
            if(microblogContent.length < 1){
                showMessage($("mblogMsg"), "微博内容不能为空", false);
            }else{
                showMessage($("mblogMsg"), "微博内容长度不能大于1K", false);
            }
            this._timer =Controltime();
            return false;
        }

        $('musicblog_upload_form').submit();
        return true;
    },

    createOtherfileBlog : function(){
        var otherfileblog_file = $("otherfileblog_file").value.strip();
        if(otherfileblog_file.length < 1 ){
            showMessage($("mblogMsg"), "上传文件不能为空", false);
            this._timer =Controltime();
            return false;
        }
        otherfileblog_file = otherfileblog_file.toLowerCase();
        if(otherfileblog_file.endsWith(".exe") || otherfileblog_file.endsWith(".bat") || otherfileblog_file.endsWith(".com")){
            showMessage($("mblogMsg"), "文件格式受限", false);
            this._timer =Controltime();
            return false;
        }
        var microblogContent = $("otherfileblog_content").value.strip();

        if(microblogContent.length < 1 || microblogContent.length > 1000){
            if(microblogContent.length < 1){
                showMessage($("mblogMsg"), "微博内容不能为空", false);
            }else{
                showMessage($("mblogMsg"), "微博内容长度不能大于1K", false);
            }
            this._timer =Controltime();
            return false;
        }

        $('otherfileblog_upload_form').submit();
        return true;
    },

    createUrlBlog : function(currentUrl){
        var microblogLink = $("urlblog_link").value.strip();
        if(microblogLink.length < 1 || microblogLink.length > 1000){
            if(microblogLink.length < 1){
                showMessage($("mblogMsg"), "链接地址不能为空", false);
            }else{
                showMessage($("mblogMsg"), "链接地址长度不能大于1K", false);
            }
            this._timer =Controltime();
            return false;
        }

        var linkArrar = microblogLink.split("://", 2);
        if(linkArrar.size()==2){
            var address = linkArrar[1].strip();
            if(address.length<1){
                showMessage($("mblogMsg"), "链接地址不能为空", false);
                this._timer =Controltime();
                return false;
            }

            var protocal = linkArrar[0].toLowerCase();
            if(protocal=="http"||protocal=="https"){
                microblogLink = protocal+"://"+address;
            }else{
                showMessage($("mblogMsg"), "链接地址应用http://或者https://开始", false);
                this._timer =Controltime();
                return false;
            }
        }else{
            microblogLink = "http://"+microblogLink;
        }

        var microblogContent = $("urlblog_content").value.strip();

        if(microblogContent.length < 1 || microblogContent.length > 1000){
            if(microblogContent.length < 1){
                showMessage($("mblogMsg"), "微博内容不能为空", false);
            }else{
                showMessage($("mblogMsg"), "微博内容长度不能大于1K", false);
            }
            this._timer =Controltime();
            return false;
        }

        // join two string together
        microblogContent = microblogContent +"\n" + microblogLink;

        $("urlblog_submit").disabled = true;
        $("urlblog_cancel").disabled = true;
        new Ajax.Request(this._createMicroblog,
        {
            parameters : {
                "microblogContent" : microblogContent
            },
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
                $("mblogLoading").update('<img src="/images/loading.gif">');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    document.location.href = currentUrl;
                }else{
                    showMessage($("mblogMsg"), json.MESSAGE, false);
                    this._timer =Controltime();
                }
            },
            onComplete : function(){
                $("mblogLoading").update("");
                $("urlblog_submit").disabled = false;
                $("urlblog_cancel").disabled = false;
            }
        });
        return false;
    },
    showPictureBlogDiv : function(){
        $("fakemblog_div").hide();
        $("mblog_div").hide();
        $("urlblog_div").hide();
        $("musicblog_div").hide();
        $("otherfileblog_div").hide();
        $("pictureblog_div").show();
    },
    showOtherfileBlogDiv : function(){
        $("fakemblog_div").hide();
        $("mblog_div").hide();
        $("urlblog_div").hide();
        $("musicblog_div").hide();
        $("pictureblog_div").hide();
        $("otherfileblog_div").show();
    },
    showMusicBlogDiv : function(){
        $("fakemblog_div").hide();
        $("mblog_div").hide();
        $("urlblog_div").hide();
        $("pictureblog_div").hide();
        $("otherfileblog_div").hide();
        $("musicblog_div").show();
    },
    showUrlBlogDiv : function(){
        $("fakemblog_div").hide();
        $("pictureblog_div").hide();
        $("musicblog_div").hide();
        $("otherfileblog_div").hide();
        $("mblog_div").hide();
        $("urlblog_div").show();
    },
    showMicroBlogDiv : function(){
        $("fakemblog_div").hide();
        $("pictureblog_div").hide();
        $("musicblog_div").hide();
        $("otherfileblog_div").hide();
        $("urlblog_div").hide();
        $("mblog_div").show();
    },
    showFakeMicroBlogDiv : function(){
        $("mblog_div").hide();
        $("pictureblog_div").hide();
        $("musicblog_div").hide();
        $("otherfileblog_div").hide();
        $("urlblog_div").hide();
        $("fakemblog_div").show();
    },
    showEditContent : function(mblogId){
        $("showMblogContent" + mblogId).hide();
        $("editMblogContent" + mblogId).show();
    },

    cancelEditContent : function(mblogId){
        $("showMblogContent" + mblogId).show();
        $("editMblogContent" + mblogId).hide();
    },

    setMicroblog : function(mblogId,blogType){
        var content = $F(this._editMblogContentTextarea + mblogId).strip();
        if(content == ""){
            alert("请输入微博内容");
            return;
        }
        if(blogType=="all"){

            new Ajax.Request("/Microblog.do?action=SET_MICROBLOG", {
                parameters : {
                    "mblogActionType":this._set_microblog_str,
                    "microblogId" :mblogId ,
                    "mblogContent": content
                },
                requestHeaders : {
                    Accept: 'application/json'
                },
                onCreate : function(){
                    $("show_loadimage_"+mblogId).update('<img src="/images/loading.gif" />');
                },
                onSuccess : function(transport){
                
                    var json = transport.responseText.evalJSON(true);
                    if(json.RETURN){
                        $("show_loadimage_"+mblogId).update('');
                        $('mblog_content_'+mblogId).innerHTML=json.content;
                        this.cancelEditContent(mblogId);
                    }else{

                }
                }.bind(this),

                onComplete : function(){

                }
            });
            return;
        }
        $("mblogActionType").setValue(this._set_microblog_str);
        $("microblogId").setValue(mblogId);
        $("mblogContent").value = content;
        var locationHref = location.href;
        $("mblogForm").setAttribute("action", locationHref.split("#")[0] + "#mblog" + mblogId);
        $("mblogForm").submit();
    },

    removeMicroblog : function(mblogId){
        if(removeConfirm()){
            $("mblogActionType").setValue(this._remove_microblog_str);
            $("microblogId").setValue(mblogId);
            $("mblogForm").submit();
        }
    },

    createMicroblogFollower : function(userScreenName){
        new Ajax.Request(this._createFollower,{
            parameters : {
                "userid" : userScreenName
            },
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
                $("mbfLoading").update('<img src="/images/032.gif" />');
                $("mbfLoading").removeClassName("clear");
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    $("mbfMsg").update("您已成功订阅");
                    $("mbfMsg").className = "ok_message";
                    $("mbfStatus").remove();
                }else{
                    showMessage($("mbfMsg"), json.MESSAGE, false);
                }
            }.bind(this),
            onComplete : function(){
                $("mbfLoading").update();
                $("mbfLoading").addClassName("clear");
            }
        })
    },

    removeMicroblogFollower : function(userScreenName){
        new Ajax.Request(this._removeFollower,{
            parameters : {
                "userid" : userScreenName
            },
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
                $("mbfLoading").className = "";
                $("mbfLoading").update('<img src="/images/032.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    $("mbfMsg").update("订阅已取消");
                    $("mbfMsg").className = "ok_message";
                    $("mbfStatus").remove();
                }else{
                    showMessage($("mbfMsg"), json.MESSAGE, false);
                }
            },
            onComplete : function(){
                $("mbfLoading").update();
                $("mbfLoading").className = "clear";
            }
        })
    },

    removeMyFollowing : function(userScreenName){

        new Ajax.Request(this._removeFollower,{
            parameters : {
                "userid" : userScreenName
            },
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    alert("succ");
                }else{
                    alert(json.MESSAGE);
                }
            }.bind(this),
            onComplete : function(){
            }
        })
    }
}

var MicroblogComment = {
    _showMoreCommentDiv : "commentMore",
    _showOrHideMoreCommentDiv : "showOrHideMoreComment",
    _createCommentDiv : "createComment",
    _commentTextarea : "mblogCommentTextarea",
    _showCommentDiv : "showComment",
    _editCommentDiv : "editComment",
    _editCommentTextarea : "editCommentTextarea",
    _showReplyDiv : "showReply",
    _editReplyDiv : "editReply",
    _replyTextarea : "replyTextarea",

    _create_comment_str : "CREATE_MBLOG_COMMENT",
    _set_comment_str : "SET_MBLOG_COMMENT",
    _remove_comment_str : "REMOVE_MBLOG_COMMENT",
    _set_comment_reply_str : "SET_MBLOG_COMMENT_REPLY",
    _remove_comment_reply_str : "REMOVE_MBLOG_COMMENT_REPLY",

    showOrHideMoreComment : function(mblogId,blogType){
        var moreHideDiv = this._showOrHideMoreCommentDiv + mblogId;
        if($(this._showMoreCommentDiv + mblogId).style.display == "none"){
            $(this._showMoreCommentDiv + mblogId).show();

            $(moreHideDiv).update("收回 <<");
           
            
        //$(moreHideDiv).show();
        }else{
            $(this._showMoreCommentDiv + mblogId).hide();
            //$(moreHideDiv).hide();
            //alert($(moreHideDiv).innerHTML);
            if(blogType=="all"){
                $(moreHideDiv).update("");
            }else{
                $(moreHideDiv).update("更多评论 >>");
            }
                
            
            

        }
        return false;
    },
    showOrHideMoreComment1 : function(mblogId){
        var moreHideDiv = this._showOrHideMoreCommentDiv + mblogId;
        if($(this._showMoreCommentDiv + mblogId).style.display == "none"){
            $(this._showMoreCommentDiv + mblogId).show();
            $(moreHideDiv).update("收回<<");
        //$(moreHideDiv).show();
        }else{
            $(this._showMoreCommentDiv + mblogId).hide();
            //$(moreHideDiv).hide();
            $(moreHideDiv).update("");
        }
        return false;
    },

    showCreateComment : function(mblogId){
        $(this._createCommentDiv + mblogId).show();
        AtSignAutoComplete.init(this._commentTextarea + mblogId, "mblogCommentContainer" + mblogId);
        
    },

    cancelCreateComment : function(mblogId){
        $(this._createCommentDiv + mblogId).hide();
    },

    createMblogComment : function(mblogId,blogType,parentPage){
        var comment = $F(this._commentTextarea + mblogId).strip();
        if(comment == ""){
            alert("请输入回复内容");
            return;
        }
        if(blogType=="all"){

            new Ajax.Request("/Microblog.do?action=CREATE_MBLOG_COMMENT", {
                parameters : {
                    "commentActionType":this._create_comment_str,
                    "mblogId" :mblogId ,
                    "mblogIdForm": mblogId,
                    "isShowCommentMore":true,
                    "comment":comment
                    
                },
                requestHeaders : {
                    Accept: 'application/json'
                },
                onCreate : function(){
                    $('create_comment_image_'+mblogId).update('<img src="/images/loading.gif" />');
                },
                onSuccess : function(transport){
                    var json = transport.responseText.evalJSON(true);
                    if(json.RETURN){
                        $('create_comment_image_'+mblogId).update("");
                        reLoadCommentsPage(mblogId,parentPage);//重新加载评论
                        var ahref="<a href='javascript:void(0);' onclick=\"return MicroblogComment.showOrHideMoreComment("+mblogId+",'all'"+")\"> 共 "+json.count+" 条 >></a>";
                        //alert();
                        $('show_comments_count_'+mblogId).update(ahref);////////////////////////
                    }else{

                }
                }.bind(this),

                onComplete : function(){

                }
            });
            return;
        }
        $("commentActionType").setValue(this._create_comment_str);
        //alert($("commentActionType").value);

        $("mblogId").setValue(mblogId);
        //alert($("mblogId").value);

        $("mblogIdForm").setValue(mblogId);
        //alert($("mblogIdForm").value);

        $("mblogComment").value = comment;
        //  alert($("comment").value);

        $("isShowCommentMore").value = "true";
        // alert($("isShowCommentMore").value);
        
        var locationHref = location.href;
        $("commentForm").setAttribute("action", locationHref.split("#")[0] + "#mblogComment" + mblogId);
        $("commentForm").submit();
    },

    showEditComment : function(mblogCommentId){
        $(this._showCommentDiv + mblogCommentId).hide();
        $(this._editCommentDiv + mblogCommentId).show();
        AtSignAutoComplete.init(this._editCommentTextarea + mblogCommentId, "mblogCommentEditContainer" + mblogCommentId);
    },

    cancelEditComment : function(mblogCommentId){
        $(this._showCommentDiv + mblogCommentId).show();
        $(this._editCommentDiv + mblogCommentId).hide();
    },

    setMblogComment : function(mblogId, mblogCommentId, isShowCommentMore,blogType,parentPage){
        var comment = $F(this._editCommentTextarea + mblogCommentId).strip();
        if(comment == ""){
            alert("请输入回复内容");
            return;
        }
        if(blogType=="all"){
            new Ajax.Request("/Microblog.do?action=SET_MBLOG_COMMENT", {
                parameters : {
                    "commentActionType":this._create_comment_str,
                    "mblogId" :mblogId ,
                    "mblogIdForm": mblogId,
                    "isShowCommentMore":true,
                    "comment":comment,
                    "mblogCommentId":mblogCommentId
                },
                requestHeaders : {
                    Accept: 'application/json'
                },
                onCreate : function(){
                    $('set_comment_image_'+mblogId+'_'+mblogCommentId).update('<img src="/images/loading.gif" />');
                },
                onSuccess : function(transport){
                    var json = transport.responseText.evalJSON(true);
                    if(json.RETURN){
                        $('set_comment_image_'+mblogId+'_'+mblogCommentId).update("");
                        reLoadCommentsPage(mblogId,parentPage);//从新加载评论
                    }else{

                }
                }.bind(this),

                onComplete : function(){

                }
            });
            return;
        }
        $("commentActionType").setValue(this._set_comment_str);
        $("mblogIdForm").setValue(mblogId);
        $("mblogCommentId").setValue(mblogCommentId);
        $("mblogComment").value = comment;
        $("isShowCommentMore").value = isShowCommentMore;
        var locationHref = location.href;
        $("commentForm").setAttribute("action", locationHref.split("#")[0] + "#mblogComment" + mblogId);
        $("commentForm").submit();
    },

    removeComment : function(mblogId, mblogCommentId, isShowCommentMore,blogType,parentPage){
        //alert(44);
        if(removeConfirm()){
            if(blogType=="all"){
                new Ajax.Request("/Microblog.do?action=REMOVE_MBLOG_COMMENT", {
                    parameters : {
                        "commentActionType":this._create_comment_str,
                        "mblogIdForm": mblogId,
                        "isShowCommentMore":true,
                        "mblogCommentId":mblogCommentId
                    },
                    requestHeaders : {
                        Accept: 'application/json'
                    },
                    onCreate : function(){
                        $('remove_comment_image_'+mblogId+'_'+mblogCommentId).update('<img src="/images/loading.gif" />');
                    },
                    onSuccess : function(transport){
                        
                        var json = transport.responseText.evalJSON(true);
                        //alert(transport.responseText);
                        if(json.RETURN){
                            $('remove_comment_image_'+mblogId+'_'+mblogCommentId).update('');
                            reLoadCommentsPage(mblogId,parentPage);//重新加载评论
                            if(json.count>0){
                                var ahref="<a href='javascript:void(0);' onclick=\"return MicroblogComment.showOrHideMoreComment("+mblogId+",'all'"+")\"> 共 "+json.count+" 条 >></a>";
                            }else{
                                var ahref="";
                            }
                            
                            $('show_comments_count_'+mblogId).update(ahref);////////////////////////
                        }else{

                    }
                    }.bind(this),

                    onComplete : function(){

                    }
                });
                return;
            }
            $("commentActionType").setValue(this._remove_comment_str);
            $("mblogIdForm").setValue(mblogId);
            $("mblogCommentId").setValue(mblogCommentId);
            $("isShowCommentMore").value = isShowCommentMore;
            var locationHref = location.href;
            $("commentForm").setAttribute("action", locationHref.split("#")[0] + "#mblogComment" + mblogId);
            $("commentForm").submit();
        }
    },

    showEditReply : function(mblogCommentId){
        $(this._showReplyDiv + mblogCommentId).hide();
        $(this._editReplyDiv + mblogCommentId).show();
        AtSignAutoComplete.init(this._replyTextarea + mblogCommentId, "mblogReplyContainer" + mblogCommentId);
    },

    cancelEditReply : function(mblogCommentId){
        $(this._showReplyDiv + mblogCommentId).show();
        $(this._editReplyDiv + mblogCommentId).hide();
    },

    setReply : function(mblogId, mblogCommentId, isShowCommentMore,blogType){
        //alert(11);
        var reply = $F(this._replyTextarea + mblogCommentId).strip();
        if(reply == ""){
            alert("请输入回复内容");
            return;
        }
        if(blogType=="all"){
            new Ajax.Request("/Microblog.do?action=SET_MBLOG_COMMENT_REPLY", {
                parameters : {
                    "commentActionType":this._create_comment_str,
                    "mblogIdForm": mblogId,
                    "isShowCommentMore":true,
                    "mblogCommentId":mblogCommentId,
                    "reply":reply
                },
                requestHeaders : {
                    Accept: 'application/json'
                },
                onCreate : function(){
                    $('set_reply_image_'+mblogId+'_'+mblogCommentId).update('<img src="/images/loading.gif" />');
                },
                onSuccess : function(transport){

                    var json = transport.responseText.evalJSON(true);
                    //alert(transport.responseText);
                    if(json.RETURN){
                        $('set_reply_image_'+mblogId+'_'+mblogCommentId).update('');
                        reLoadCommentsPage(mblogId);//重新加载评论
                    }else{

                }
                }.bind(this),

                onComplete : function(){

                }
            });
            return;
        }
        $("commentActionType").setValue(this._set_comment_reply_str);
        $("mblogIdForm").setValue(mblogId);
        $("mblogCommentId").setValue(mblogCommentId);
        $("reply").value = reply;
        $("isShowCommentMore").value = isShowCommentMore;
        //        if(blogType=="all"){
        //            new Ajax.Request("/templates/mblog_comment.jsp", {
        //                parameters : {
        //                "commentActionType" : this._set_comment_reply_str,
        //                "mblogIdForm" : mblogCommentId,
        //                "reply"   : reply,
        //                "isShowCommentMore":isShowCommentMore
        //                },
        //                requestHeaders : {
        //                Accept: 'html/text'
        //                },
        //                onCreate : function(){
        //                },
        //                onSuccess : function(transport){
        //                $('show_comments'+mblogId).update(transport);
        //            }.bind(this),
        //            onComplete : function(){
        //
        //            }
        //        });
        //    }
        //$(moreHideDiv).update("收回<<");
        var locationHref = location.href;
        $("commentForm").setAttribute("action", locationHref.split("#")[0] + "#mblogComment" + mblogId);
        $("commentForm").submit();
    },
    removeReply : function(mblogId, mblogCommentId, isShowCommentMore,blogType){
        if(removeConfirm()){
            //alert(blogType);
            if(blogType=="all"){
                new Ajax.Request("/Microblog.do?action=REMOVE_MBLOG_COMMENT_REPLY", {
                    parameters : {
                        "commentActionType":this._create_comment_str,
                        "mblogIdForm": mblogId,
                        "isShowCommentMore":true,
                        "mblogCommentId":mblogCommentId
                    },
                    
                    requestHeaders : {
                        Accept: 'application/json'
                    },
                    onCreate : function(){
                        $('remove_reply_image_'+mblogId+'_'+mblogCommentId).update('<img src="/images/loading.gif" />');
                    },
                    onSuccess : function(transport){

                        var json = transport.responseText.evalJSON(true);
                        //alert(transport.responseText);
                        if(json.RETURN){
                            $('set_reply_image_'+mblogId+'_'+mblogCommentId).update('');
                            reLoadCommentsPage(mblogId);//重新加载评论
                        //                            if(json.count>0){
                        //                                var ahref="<a href='javascript:void(0);' onclick=\"return MicroblogComment.showOrHideMoreComment("+mblogId+",'all'"+")\"> 共 "+json.count+" 条 >></a>";
                        //                            }else{
                        //                                var ahref=" 共 0 条";
                        //                            }
                        //
                        //                            $('show_comments_count_'+mblogId).update(ahref);////////////////////////
                        }else{

                    }
                    }.bind(this),

                    onComplete : function(){

                    }
                });
                return;
            }
            $("commentActionType").setValue(this._remove_comment_reply_str);
            $("mblogIdForm").setValue(mblogId);
            $("mblogCommentId").setValue(mblogCommentId);
            $("isShowCommentMore").value = isShowCommentMore;
            var locationHref = location.href;
            $("commentForm").setAttribute("action", locationHref.split("#")[0] + "#mblogComment" + mblogId);
            $("commentForm").submit();
        }
    }
}
function reLoadCommentsPage(mblogId,parentPage){//重新加载评论页面
    parentPage=parentPage==null?'home':parentPage;
    new Ajax.Request("/templates/mblog_comment.jsp", {
        parameters : {
            "mblogId":mblogId,
            "blogType": "all",
            "isShowCommentMore":true,
            "mblogIdForm":mblogId,
            "parentPage":parentPage
        },
        requestHeaders : {
            Accept: 'html/text'
        },
        onCreate : function(){
        },
        onSuccess : function(transport){
            //alert(transport.responseText );
            $('show_comments'+mblogId).update(transport.responseText);
        }.bind(this),

        onComplete : function(){

        }
    });
}
var MicroblogBookmark = {
    add : function(microblogId,count){
        new Ajax.Request("/Microblog.do?action=BOOKMARK", {
            method: "post",
            parameters : {
                "microblogId" : microblogId
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("bookmark_loading_img_"+microblogId).update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    //$("alert_msg_td").innerHTML = "您已成功收藏此条微博";
                    // showAlertDialog();
                    ++count;
                    $("bookmark_count_span_"+microblogId).show();
                    $("bookmark_count_"+microblogId).innerHTML = count;
                    $("bookmark_loading_img_"+microblogId ).update('');
                    $("bookmark_link_button_"+microblogId).innerHTML = "不再收藏";
                    $("bookmark_link_button_"+microblogId).setAttribute("href", "javascript:MicroblogBookmark.remove('"+microblogId+"','"+count+"')");
                }
            },
            onComplete : function(){
            }
        })
    },
    remove : function(microblogId,count){
        new Ajax.Request("/Microblog.do?action=REMOVE_BOOKMARK", {
            method: "post",
            parameters : {
                "microblogId" : microblogId
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("bookmark_loading_img_"+microblogId).update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    //$("alert_msg_td").innerHTML = "取消成功";
                    //showAlertDialog();
                    --count;
                    if(count==0) {
                        $("bookmark_count_span_"+microblogId).hide();
                    }
                    $("bookmark_count_"+microblogId).innerHTML = count;
                    $("bookmark_loading_img_"+microblogId).update('');
                    $("bookmark_link_button_"+microblogId).innerHTML = "收藏";
                    $("bookmark_link_button_"+microblogId).setAttribute("href", "javascript:MicroblogBookmark.add('"+microblogId+"','"+count+"')");
                }
            },
            onComplete : function(){

            }
        })
    }
}

var MicroblogFollower = {
    add : function(targetScreenName){
        new Ajax.Request("/Microblog.do?action=SET_MICROBLOG_FOLLOWER", {
            method: "post",
            parameters : {
                "targetScreenName" : targetScreenName,
                "followStatus" : 1
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("mblog_following_loading_img").update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    showCommonMsgDialog('关注成功');
                    $("mblog_following_loading_img").update('');
                    $("mblog_following_link_text").innerHTML = "取消关注";
                    $("mblog_following_link_button").setAttribute("href", "javascript:MicroblogFollower.remove('"+targetScreenName+"')");
                }
            },
            onComplete : function(){
            }
        })
    },
    addAndChecked:function(targetScreenName,isProfileComplete){
        if(!isProfileComplete){
            showAttentionDialog();
        }else{
            this.add(targetScreenName);
        }
    },
    remove : function(targetScreenName){
        new Ajax.Request("/Microblog.do?action=SET_MICROBLOG_FOLLOWER", {
            method: "post",
            parameters : {
                "targetScreenName" : targetScreenName,
                "followStatus" : -1
            },
            requestHeaders: {
                Accept : "application/json"
            },
            onCreate : function(){
                $("mblog_following_loading_img").update('<img src="/images/loading.gif" />');
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if(json.RETURN){
                    showCommonMsgDialog("取消成功");
                    $("mblog_following_loading_img").update('');
                    $("mblog_following_link_text").innerHTML = "关注";
                    $("mblog_following_link_button").setAttribute("href", "javascript:MicroblogFollower.add('"+targetScreenName+"')");
                }
            },
            onComplete : function(){

            }
        })
    }
}

var MicroblogFollowType = {
    setFollowType : function(){
        var param = new Hash();
        param.set("targetScreenName", $F("target_screenname"));
        var followStatus = $$('input:checked[type="radio"][name="follow_status"]').pluck('value');
        param.set("followStatus", followStatus);

        new Ajax.Request("/Microblog.do?action=SET_MICROBLOG_FOLLOWER", {
            method : 'post',
            parameters : param.toQueryString(),
            requestHeaders : {
                Accept: 'application/json'
            },
            onCreate : function(){
                $("mblog_follow_type_loading").update('<img src="/images/loading.gif" />');
                $("mblog_follow_type_loading").show();
            },
            onSuccess : function(transport){
                var json = transport.responseText.evalJSON(true);
                if (json.RETURN) {
                    show_success_msg("mblog_follow_type_loading", "设置成功");
                } else {
                    if(json.MESSAGE_TYPE == "MOBILE_NUMBER_IS_NOT_VERIFIED"){
                        show_error_msg("mblog_follow_type_loading", "若要接受微博短信，您的手机号码必须经过验证，请<a href='/mobile_verify.jsp'>验证您的手机号码</a>");
                    }else{
                        show_error_msg("mblog_follow_type_loading", json.MESSAGE);
                    }
                }

                setTimeout(function(){
                    $("mblog_follow_type_loading").update("");
                    $("mblog_follow_type_loading").className = "";
                },3000);
            },
            onComplete : function(){
            //$("loading").hide();
            }
        })
    }
}

var HomeMblogSection = {
    showFakeMblogDiv : function(){
        this.hideAllSections();
        $("section_fakemblog_div").show();
        if(parentPage=="home") {
            this._setMenu('提问');
        }else {
            this._setMenu('微博');
        }
        
    },
    showSectionMicroBlogDiv : function(keyword){
       
        this.hideAllSections();
        $("section_mblog_div").show();
        this._setMenu(keyword);
        AtSignAutoComplete.init("microblogContent", "microblogContainer");
    },

    showSectionEventDiv : function(keyword){
        
        this.hideAllSections();
        $("section_event_div").show();
        this._setMenu(keyword);
        AtSignAutoComplete.init("hzDescription", "eventContainer");
    },
    showSectionProjectDiv : function(keyword){
        
        this.hideAllSections();
        $("section_project_div").show();
        this._setMenu(keyword);
        AtSignAutoComplete.init("project_description", "projectContainer");
    },
    showSectionJobDiv : function(keyword){
        this.hideAllSections();
        $("section_job_div").show();
        this._setMenu(keyword);
        AtSignAutoComplete.init("responsibilities", "jobContainer");
    },
    showSectionSlideDiv : function(keyword){
        
        this.hideAllSections();
        $("section_slide_div").show();
        this._setMenu(keyword);
        AtSignAutoComplete.init("slide_descr", "slideContainer");
    },
    showSectionQuestionDiv : function(keyword){
        
        this.hideAllSections();
        $("section_question_div").show();
        this._setMenu(keyword);
        $("question_target_individual_checkbox").checked = "true";
        QuestionTargetSection.toggleTargetIndividualSection();
        QuestionTargetSection.showImportEmailSection();
        AtSignAutoComplete.init("question_content", "qaContainer");
    },
    hideAllSections: function(){
        $("section_fakemblog_div").hide();
        $("section_mblog_div").hide();
        $("section_event_div").hide();
        $("section_job_div").hide();
        $("section_project_div").hide();
        $("section_slide_div").hide();
        $("section_question_div").hide();
    },
    _setMenu : function(keyword){
        setMenuSelection('home_mblog_section_menu_div', keyword);
    }
}

function setMenuSelection(parentDivId, keyword){
    var aSelected = $(parentDivId).select("li");
    for(var i=0;i<aSelected.size();i++){
        var tmp = aSelected[i];

        if(tmp.innerHTML.include(keyword)){
            // SET ID=CURRENT, WILL HIGH LIGHT MENU
            tmp.setAttribute('id', 'selected');
        }else{
            // REMOVE ALL OTHER ID, IF PRE-SET
            tmp.removeAttribute('id');
        }
    }
}

var HomeMblogAttach = {
    _redirectURL : '',
    _setMenu : function(keyword){
        setMenuSelection('mblog_attach_menu_div', keyword);
    },

    _clearAttach : function(){
        //CLEAR USER INPUT DATA
        $$("#section_mblog_div input[type='file']").each(function(file) {
            file.value = "";
        });
        $("microblogType").setValue("100");
        // HIDE ALL DIV
        $('mblog_attach_url_div').hide();
        $('mblog_attach_files_div').hide();
        $('mblog_attach_pic_div').hide();
        $('mblog_attach_music_div').hide();
        // CLEAR MENU
        this._setMenu(null);
    },
    showURL: function(keyword){
        this._clearAttach();
        $("microblogType").setValue("110");
        $('mblog_attach_url_div').show();
        this._setMenu(keyword);
    },
    showDocument: function(keyword){
        this._clearAttach();
        $("microblogType").setValue("500");
        $('mblog_attach_files_div').show();
        this._setMenu(keyword);
    },
    showPicture : function(keyword){
        this._clearAttach();
        $("microblogType").setValue("400");
        $('mblog_attach_pic_div').show();
        this._setMenu(keyword);
    },
    showMusic: function(keyword){
        this._clearAttach();
        $("microblogType").setValue("300");
        $('mblog_attach_music_div').show();
        this._setMenu(keyword);
    },
    onCancel : function(){
        $("common_mblog_form").reset();
        this._clearAttach();
        HomeMblogSection.showFakeMblogDiv();
    },
    deleteFileField : function(divId){
        $(divId).remove();
    },
    addFileField : function(filesDivId,fileDivId,type){
        var num = fileDivId.substr(fileDivId.lastIndexOf('_div')+4);
        var prefix = fileDivId.substr(0, (fileDivId.lastIndexOf('_div')+4));
        num++;
        var newFileDivId = prefix + num;
        var newinputNameId = type + num;
        var typeDisplay = "文档";
        if(type=="picblog_file") {
            typeDisplay = "图片";
        }
        var element =  "<div class='MarginTop'  id='"+newFileDivId+"'><span>"+typeDisplay+":</span>\n\
                                                            <span><input name='"+newinputNameId+"' type='file' id='"+newinputNameId+"' size='30' /></span>\n\
                                                            <span class='MarginLeft'><a href='#' onclick=HomeMblogAttach.addFileField('"+
        filesDivId+"','"+newFileDivId+"','"+type+"')>添加更多"+typeDisplay+"</a></span></div>";
        $(fileDivId).select('a')[0].innerHTML = "删除";
        $(fileDivId).select('a')[0].onclick = function(){
            HomeMblogAttach.deleteFileField(fileDivId);
        };
        $(filesDivId).insert(element);
    },
    addPicFileField : function(templateId,insertId){
        var num = insertId.substr(insertId.lastIndexOf('_tr')+3);
        var templ = new Template($(templateId).innerHTML);
        var data = {
            id: ++num
        };
        var newField  = templ.evaluate(data);
        $(insertId).select('a')[0].innerHTML = "删除";
        $(insertId).select('a')[0].onclick = function(){
            HomeMblogAttach.deleteFileField(insertId);
        };
        new Insertion.After(insertId, newField);
    },
    _checkContent:function(){
        var microblogContent = $("microblogContent").value.strip();

        if(microblogContent.length < 1 || microblogContent == "我在忙些什么..." || microblogContent.length > 1000){
            if(microblogContent.length < 1 || microblogContent == "我在忙些什么..."){
                showMessage($("section_mblogMsg"), "微博内容不能为空", false);
            }else{
                showMessage($("section_mblogMsg"), "微博内容长度不能大于1K", false);
            }
            this._timer =setTimeout(function(){
                $("section_mblogMsg").update("");
                $("section_mblogMsg").className = "clear";
                $("section_mblogLoading").className = "clear";
            //window.location.href="/home_mblog_my.jsp";
            },3000);
            return false;
        }
        return true;
    },

    _checkUrl:function(){
        var microblogLink = $("urlblog_link").value.strip();
        if(microblogLink.length < 1 || microblogLink.length > 1000){
            if(microblogLink.length < 1){
                showMessage($("section_mblogMsg"), "链接地址不能为空", false);
            }else{
                showMessage($("section_mblogMsg"), "链接地址长度不能大于1K", false);
            }
            this._timer =setTimeout(function(){
                $("section_mblogMsg").update("");
                $("section_mblogMsg").className = "clear";
                $("section_mblogLoading").className = "clear";
            //window.location.href="/home_mblog_my.jsp";
            },3000);
            return false;
        }

        var linkArrar = microblogLink.split("://", 2);
        if(linkArrar.size()==2){
            var address = linkArrar[1].strip();
            if(address.length<1){
                showMessage($("section_mblogMsg"), "链接地址不能为空", false);
                this._timer =setTimeout(function(){
                    $("section_mblogMsg").update("");
                    $("section_mblogMsg").className = "clear";
                    $("section_mblogLoading").className = "clear";
                // window.location.href="/home_mblog_my.jsp";
                },3000);
                return false;
            }

            var protocal = linkArrar[0].toLowerCase();
            if(protocal=="http"||protocal=="https"){
                microblogLink = protocal+"://"+address;
            }else{
                showMessage($("section_mblogMsg"), "链接地址应用http://或者https://开始", false);
                this._timer =setTimeout(function(){
                    $("section_mblogMsg").update("");
                    $("section_mblogMsg").className = "clear";
                    $("section_mblogLoading").className = "clear";
                //window.location.href="/home_mblog_my.jsp";
                },3000);
                return false;
            }
        }else{
            microblogLink = "http://"+microblogLink;
        }
        // join two string together, THIS IS DONE ON SERVER SIDE.
        //microblogContent = microblogContent +"\n" + microblogLink;
        $("urlblog_link").setValue(microblogLink);
        return true;
    },

    _checkMusic:function(){
        var musicblog_file = $("musicblog_file").value.strip();
        if(musicblog_file.length < 1 ){
            showMessage($("section_mblogMsg"), "音频文件不能为空", false);
            this._timer =setTimeout(function(){
                $("section_mblogMsg").update("");
                $("section_mblogMsg").className = "clear";
                $("section_mblogLoading").className = "clear";
            },3000);
            return false;
        }
        musicblog_file = musicblog_file.toLowerCase();
        if(!musicblog_file.endsWith(".mp3")){
            showMessage($("section_mblogMsg"), "请上传MP3文件", false);
            this._timer =setTimeout(function(){
                $("section_mblogMsg").update("");
                $("section_mblogMsg").className = "clear";
                $("section_mblogLoading").className = "clear";
            },3000);
            return false;
        }
        return true;
    },
    _checkPicture:function(){
        //        var title = $F("pic_title").strip();
        //        if(title == "") {
        //            showMessage($("section_mblogMsg"), "请填写标题", false);
        //            return false;
        //        }
        var picblog_files = $$("#mblog_attach_pic_table  input[type=file]");
        var legalType = [".jpg",".jpeg",".gif",".png",".bmp"];
        var count = 0;
        var result = true;
        picblog_files.each(function(e) {
            var picblog_file = e.value.strip();
            if(picblog_file.length > 0) {
                count++;
                picblog_file = picblog_file.toLowerCase();
                var ext_name = picblog_file.substr(picblog_file.lastIndexOf('.'));
                if(legalType.indexOf(ext_name)==-1) {
                    showMessage($("section_mblogMsg"), "请上传JPG、JPEG、GIF或PNG格式的图片", false);
                    this._timer =setTimeout(function(){
                        $("section_mblogMsg").update("");
                        $("section_mblogMsg").className = "clear";
                        $("section_mblogLoading").className = "clear";
                    },3000);
                    result = false;
                    throw $break;
                }
            }
        });
        if(count < 1) {
            showMessage($("section_mblogMsg"), "上传图片不能为空", false);
            this._timer =setTimeout(function(){
                $("section_mblogMsg").update("");
                $("section_mblogMsg").className = "clear";
                $("section_mblogLoading").className = "clear";
            },3000);
            result = false;
        }
        //        if($("pic_perm_passcode_radio").checked){
        //            if($("pic_perm_code").value.trim() ==''){
        //                showMessage($("section_mblogMsg"),"请输入密码",false);
        //                this._timer =setTimeout(function(){
        //                    $("section_mblogMsg").update("");
        //                    $("section_mblogMsg").className = "clear";
        //                    $("section_mblogLoading").className = "clear";
        //                },3000);
        //                result = false;
        //            }
        //        }
        //        if($("pic_download").checked && $("pic_download_free_false").checked) {
        //            var fee = $F("pic_download_fee");
        //            if(fee.trim()=="") {
        //                showMessage($("section_mblogMsg"),"收费点应为正整数",false);
        //                result = false;
        //            }
        //        }
        return result;
    },
    _checkDocument:function(){
        var docblog_files = $$("#mblog_attach_files_div  input");
        var illegalType = [".exe",".bat",".com",".dll",".msi"];
        var count = 0;
        var result = true;
        docblog_files.each(function(e) {
            var docblog_file = e.value.strip();
            if(docblog_file.length > 0) {
                count++;
                docblog_file = docblog_file.toLowerCase();
                var ext_name = docblog_file.substr(docblog_file.lastIndexOf('.'));
                if(illegalType.indexOf(ext_name)!=-1) {
                    showMessage($("section_mblogMsg"), "非法文件类型", false);
                    this._timer =setTimeout(function(){
                        $("section_mblogMsg").update("");
                        $("section_mblogMsg").className = "clear";
                        $("section_mblogLoading").className = "clear";
                    },3000);
                    result = false;
                    throw $break;
                }
            }
        });
        if(count < 1) {
            showMessage($("section_mblogMsg"), "上传文档不能为空", false);
            this._timer =setTimeout(function(){
                $("section_mblogMsg").update("");
                $("section_mblogMsg").className = "clear";
                $("section_mblogLoading").className = "clear";
            //window.location.href="/home_mblog_my.jsp";
            },3000);
            result = false;
        }
        return result;
    },
    onSubmit : function(){
        this._redirectURL = getRedirectURL();
        // check mblog text empty
        if(!this._checkContent()){
            return false;
        }
        // check other inputs
        var microblogType = $F('microblogType');
        microblogType=parseInt(microblogType);
        switch(microblogType){
            case 100:
                break;
            case 110:
                if(!this._checkUrl()){
                    return false;
                }
                break;
            case 300:
                if(!this._checkMusic()){
                    return false;
                }
                break;
            case 400:
                if(!this._checkPicture()){
                    return false;
                }
                break;
            case 500:
                if(!this._checkDocument()){
                    return false;
                }
                break;
            case 600:
                if(!this._checkPPT()){
                    return false;
                }
                break;
            default:
                alert('default case');
        }
        if(100!=microblogType && 110!=microblogType){
            $("section_mblogLoading").update('<img src="/images/loading.gif"> <strong>（上传文件可能需要几分钟时间，请您耐心等待。）</strong>');
        }else{
            $("section_mblogLoading").update('<img src="/images/loading.gif">');
        }

        $("mblog_submit").disabled = true;
        $("mblog_cancel").disabled = true;
        return true;
    },

    onAjaxUploadComplete : function(jsonStr){
        var json = jsonStr.evalJSON(true);
        if(json.RETURN){
            showMessage($("section_mblogMsg"), "微博发布成功", true);
        }else{
            showMessage($("section_mblogMsg"), json.MESSAGE, false);
        }
        this._timer =Controltime(1000,this._redirectURL);
        // loading picture stop
        $("section_mblogLoading").update("");
        $("mblog_submit").disabled = false;
        $("mblog_cancel").disabled = false;
        this._clearAttach();
    } ,
    picPermPassCodeChecked :function(){
        $("pic_perm_passcode_radio").checked=true;
        $("pic_perm_grant_div").hide();
        $("pic_perm_passcode_div").show();
    },
    picPermGrantChecked :function(){
        $("pic_perm_grant_radio").checked=true;
        $("pic_perm_passcode_div").hide();
        $("pic_perm_grant_div").show();
    },
    picPermPublicChecked: function(){
        $("pic_perm_public_radio").checked=true;
        $("pic_perm_passcode_div").hide();
        $("pic_perm_grant_div").hide();
    },
    togglePicDownloadField : function() {
        var download_free_true = $("pic_download_free_true");
        var download_free_false = $("pic_download_free_false");
        var download_free_true_tr = $("pic_download_free_true_tr");
        var download_free_false_tr = $("pic_download_free_false_tr");
        var download_fee = $("pic_download_fee");
        if($("pic_download").checked) {
            download_free_true.enable();
            download_free_false.enable();
            download_free_true_tr.show();
            download_free_false_tr.show();
            if(download_free_false.checked) {
                download_fee.enable();
            }
        } else {
            download_free_true.disable();
            download_free_false.disable();
            download_fee.disable();
            download_free_true_tr.hide();
            download_free_false_tr.hide();
        }
    },
    togglePicDownloadFeeField: function() {
        var download_fee = $("pic_download_fee");
        if($('pic_download_free_false').checked) {
            download_fee.enable();
        } else {
            download_fee.disable();
        }
    }
}

function Controltime(time,reload){
    var t = 3000;
    if(time != null) {
        t = time;
    }
    setTimeout(function(){
        $("mblogMsg").update("");
        $("mblogMsg").className = "clear";
        $("mblogLoading").className = "clear";
        if(reload!=null) {
            window.location.href = reload;
        }
    },t);
}
var ProjectMblogAttach={
    _redirectURL:'',
    checkFormMblog:function(){
        this._redirectURL=getRedirectURL();
        $("Projectmblog_submit").disabled=false;
        var title=$("project_title").value.strip();
        if(title.length<1){  
            showMessage($("mblogMsgProject"),"项目名称不能为空",false);
            this._timer=setTimeout(function(){
                $("mblogMsgProject").update("");
                $("mblogMsgProject").className = "clear";
                $("mblogLoadingProject").className = "clear";
            },3000);
            return false;
        }
        var fundScale=$("fundScale").value.strip();
        if(fundScale==0){
            showMessage($("mblogMsgProject"),"请选择资本规模",false);
            this._timer=setTimeout(function(){
                $("mblogMsgProject").update("");
                $("mblogMsgProject").className = "clear";
                $("mblogLoadingProject").className = "clear";
            },3000);
            return false;
        }
        var category=$("category").value.strip();
        if(category==0){
            showMessage($("mblogMsgProject"),"请选择类别",false);
            this._timer=setTimeout(function(){
                $("mblogMsgProject").update("");
                $("mblogMsgProject").className = "clear"; 
                $("mblogLoadingProject").className = "clear";
            },3000);
            return false;
        }
        var categoryCustom=$("categoryCustom").value.strip();
        if(categoryCustom==""&&category==1016){
            showMessage($("mblogMsgProject"),"请填写类别",false);
            this._timer=setTimeout(function(){
                $("mblogMsgProject").update("");
                $("mblogMsgProject").className = "clear";
                $("mblogLoadingProject").className = "clear";
            },3000);
            return false;
        }
        var description=$("project_description").value.strip();
        if(description.length<1||description.length > 10000){
            if(description.length<1){
                showMessage($("mblogMsgProject"),"简介不能为空", false);
                this._timer =setTimeout(function(){
                    $("mblogMsgProject").update("");
                    $("mblogMsgProject").className = "clear";
                    $("mblogLoadingProject").className = "clear";
                //window.location.href="/home_mblog_my.jsp";
                },3000);
                return false;
            }
            if(description.length > 10000){
                showMessage($F("mblogMsgProject"),"简介过长", false);
                this._timer =setTimeout(function(){
                    $("mblogMsgProject").update("");
                    $("mblogMsgProject").className = "clear";
                    $("mblogLoadingProject").className = "clear";

                },3000);
                return false;
            }
        }
        var filePh=$("project_filePh").value.strip();
        var illegalType=[".doc",".docx",".pdf",".ppt",".txt"];
        var ext_file=filePh.substr(filePh.lastIndexOf("."));
        //        if(filePh.length>0){
        //           if((illegalType.indexOf(ext_file)<0)){
        //                showMessage($("mblogMsgProject"),"非法的文件类型", false);
        //                this._timer =setTimeout(function(){
        //                    $("mblogMsgProject").update("");
        //                    $("mblogMsgProject").className = "clear";
        //                    $("mblogLoadingProject").className = "clear";
        //                //window.location.href="/home_mblog_my.jsp";
        //                },3000);
        //                return false;
        //        }
        //        }

        $("mblogLoadingProject").update('<img src="/images/loading.gif">');
        //$("event_upload_form").submit();
        $("Projectmblog_submit").disabled=true;
        $("Project_cancel").disabled = true;
        return true;
    },
    onAjaxUploadComplete : function(jsonStr){
        var json = jsonStr.evalJSON(true);
        if(json.RETURN){
            showMessage($("mblogMsgProject"), "项目发布成功", true);
            this._timer =Controltime(1000,this._redirectURL);
        }else{
            showMessage($("mblogMsgProject"), json.MESSAGE, false);
        }
        
        // loading picture stop
        $("mblogLoadingProject").update("");
        $("Projectmblog_submit").disabled = false;
        $("Project_cancel").disabled = false;
        this.clearMblogProject();

    },
    clearMblogProject:function(){
        $("title").value="";
        $("address").value="";
        $("description").value="";
        $("startDate").value="";
        $("endDate").value="";
    }
}
var EventMblogAttach = {
    _redirectURL : '',
    checkFormMblog: function(){
        this._redirectURL = getRedirectURL();
        $("Eventmblog_submit").disabled=false;
        var title=$("eventTitle").value.strip();
        if(title.length < 1){
            showMessage($("mblogMsgEvent"),"活动名称不能为空",false);
            this._timer =setTimeout(function(){
                $("mblogMsgEvent").update("");
                $("mblogMsgEvent").className = "clear";
                $("mblogLoadingEvent").className = "clear";
            //window.location.href="/home_mblog_my.jsp";
            },3000);
            return false;
        }

        var address=$("address").value.strip();
        if(address.length < 1){
            showMessage($("mblogMsgEvent"),"活动地点不能为空", false);
            this._timer =setTimeout(function(){
                $("mblogMsgEvent").update("");
                $("mblogMsgEvent").className = "clear";
                $("mblogLoadingEvent").className = "clear";
            //window.location.href="/home_mblog_my.jsp";
            },3000);
            return false ;
        }
        var description=$("hzDescription").value.strip();
        if(description.length<1||description.length > 10000){
            if(description.length<1){
                showMessage($("mblogMsgEvent"),"简介不能为空", false);
                this._timer =setTimeout(function(){
                    $("mblogMsgEvent").update("");
                    $("mblogMsgEvent").className = "clear";
                    $("mblogLoadingEvent").className = "clear";
                //window.location.href="/home_mblog_my.jsp";
                },3000);
                return false;
            }
            if(description.length > 10000){
                showMessage($F("mblogMsgEvent"),"简介过长", false);
                this._timer =setTimeout(function(){
                    $("mblogMsgEvent").update("");
                    $("mblogMsgEvent").className = "clear";
                    $("mblogLoadingEvent").className = "clear";

                },3000);
                return false;
            }
        }
        var startData=$("startDate").value.strip();
        if(startData == "" ||  startData=="yyyy/mm/dd" ){
            showMessage($("mblogMsgEvent"),"请输入开始时间", false);
            this._timer =setTimeout(function(){
                $("mblogMsgEvent").update("");
                $("mblogMsgEvent").className = "clear";
                $("mblogLoadingEvent").className = "clear";

            },3000);
            return false;
        }
        var endData=$("endDate").value.strip();
        if(endData == ""||endData=="yyyy/mm/dd"){
            showMessage($("mblogMsgEvent"),"请输入结束时间", false);
            this._timer =setTimeout(function(){
                $("mblogMsgEvent").update("");
                $("mblogMsgEvent").className = "clear";
                $("mblogLoadingEvent").className = "clear";
            },3000);
            return false;
        }

        if(!compareFourDate($F("startDate"),$F("endDate"),$F("startTime"),$F("endTime"))){
            showMessage("开始时间必须小于结束时间",false);
            return false;
        }
        $("mblogLoadingEvent").update('<img src="/images/loading.gif">');
        //$("event_upload_form").submit();
        $("Eventmblog_submit").disabled=true;
        $("Event_cancel").disabled = true;
        return true;
    },
    onAjaxUploadComplete : function(jsonStr){
        var json = jsonStr.evalJSON(true);
        if(json.RETURN){
            //alert("ok");
            showMessage($("mblogMsgEvent"), "活动发布成功", true);
            this._timer =Controltime(1000,this._redirectURL);
            this.clearMblogEvent();
        }else{
            showMessage($("mblogMsgEvent"), json.MESSAGE, false);
        }

        // loading picture stop
        $("mblogLoadingEvent").update("");
        $("Eventmblog_submit").disabled = false;
        $("Event_cancel").disabled = false;
    },
    clearMblogEvent:function(){
        $("title").value="";
        $("address").value="";
        $("description").value="";
        $("startDate").value="";
        $("endDate").value="";
    }
}

var JobMblogAttach = {
    _redirectURL : '',
    Submit : function(){
        this._redirectURL = getRedirectURL();
        var title=$("jobtitle").value.strip();
        if(title.length < 1){
            showMessage($("mblogMsgJob"),"招聘名称不能为空",false);
            this._timer =setTimeout(function(){
                $("mblogMsgJob").update("");
                $("mblogMsgJob").className = "clear";
                $("mblogLoadingJob").className = "clear";
            },3000);
            return false;
        }

        var location=$("location").value.strip();
        if(location.length < 1){
            showMessage($("mblogMsgJob"),"招聘地点不能为空",false);
            this._timer =setTimeout(function(){
                $("mblogMsgJob").update("");
                $("mblogMsgJob").className = "clear";
                $("mblogLoadingJob").className = "clear";
            },3000);
            return false;
        }
        if($("salary").getValue() == -1){
            showMessage($("mblogMsgJob"),"招聘薪金不能为空",false);
            this._timer =setTimeout(function(){
                $("mblogMsgJob").update("");
                $("mblogMsgJob").className = "clear";
                $("mblogLoadingJob").className = "clear";
            },3000);
            return false;
        }
        var responsibilities=$("responsibilities").value.strip();
        if(responsibilities.length < 1){
            showMessage($("mblogMsgJob"),"职位描述不能为空",false);
            this._timer =setTimeout(function(){
                $("mblogMsgJob").update("");
                $("mblogMsgJob").className = "clear";
                $("mblogLoadingJob").className = "clear";
            },3000);
            return false;
        }
        var requirements=$("requirements").value.strip();
        if(requirements.length < 1){
            showMessage($("mblogMsgJob"),"招聘要求不能为空",false);
            this._timer =setTimeout(function(){
                $("mblogMsgJob").update("");
                $("mblogMsgJob").className = "clear";
                $("mblogLoadingJob").className = "clear";
            },3000);
            return false;
        }
        $("Jobmblog_submit").disabled = true;
        $("job_cancel").disabled = true;
        return true;
    },

    clearMblogJob:function(){
        $("jobtitle").value="";
        $("location").value="";
        $("salary").value="";
        $("responsibilities").value="";
        $("requirements").value="";
    },


    onAjaxUploadComplete : function(jsonStr){
        var json = jsonStr.evalJSON(true);
        if(json.RETURN){
            showMessage($("mblogMsgJob"), "职位发布成功", true);
            this._timer =Controltime(1000,this._redirectURL);
            this.clearMblogJob();
        }else{
            showMessage($("mblogMsgJob"), json.MESSAGE, false);
        }

        // loading picture stop
        $("mblogLoadingJob").update("");
        $("Jobmblog_submit").disabled = false;
        $("job_cancel").disabled = false;
    }
}

var SlideMblogAttach = {
    _redirectURL : '',
    checkFormMblog: function(){
        var msgDiv = $("slide_mblog_msg");
        $("slide_mblog_msg").update("");
        $("slide_mblog_msg").className = "clear";
        this._redirectURL = getRedirectURL();
        $("slide_mblog_submit").disabled=false;
        if($('slide_title').value.strip() ==''){
            showMessage(msgDiv,"请输入标题",false);
            return false;
        }
        if($('slide_descr').value.strip() ==''){
            showMessage(msgDiv,"请输入简介",false);
            return false;
        }
        if($('fileField').value == ''){
            showMessage(msgDiv,"请选择要上传的PPT文件",false);
            return false;
        }
        var illegalType = [".rar",".zip",".ppt",".pps",".pdf"];
        var slideFile = $('fileField').value.strip().toLowerCase();
        var extName = slideFile.substr(slideFile.lastIndexOf('.'));
        if(illegalType.indexOf(extName)==-1) {
            showMessage(msgDiv, "只能上传PDF、PPT、PPS、RAR、ZIP类型的文件",false);
            return false;
        }
     
        if($("perm_passcode_radio").checked){
            if($("perm_code").value.trim() ==''){
                showMessage(msgDiv,"请输入密码",false);
                return false;
            }
        }
        if($("download").checked && $("download_free_false").checked) {
            var fee = $F("download_fee"); 
            if(fee.trim()=="") {
                showMessage(msgDiv,"收费点应为正整数",false);
                return false;
            }
        }
        $("slide_mblog_loading").update('<img src="/images/loading.gif">');
        //防止连续恶意上传
        $("slide_mblog_submit").disabled=true;
        $("slide_mblog_reset").disabled = true;
        return true;
    },
    onAjaxUploadComplete : function(jsonStr){
        var json = jsonStr.evalJSON(true);
        if(json.RETURN){
            showMessage($("slide_mblog_msg"), "幻灯片上传成功", true);

            if(json.slideType=='slideSecrect'){
                this._timer =Controltime(1000,'/slides/mine');
            }else{
                this._timer =Controltime(1000,this._redirectURL);
            }
            
        }else{
            showMessage($("slide_mblog_msg"), json.MESSAGE, false);
        }
        // loading picture stop
        $("slide_mblog_loading").update("");
        $("slide_mblog_submit").disabled = false;
        $("slide_mblog_reset").disabled = false;
    }
}

var QuestionMblogAttach = {
    _redirectURL : '', 
    checkFormMblog: function(){
        this._redirectURL = getRedirectURL();
        $("question_create_common_msg").update("");
        $("question_create_common_msg").className = "clear";
        this._redirectURL = getRedirectURL();
        $("question_create_submit").disabled=false;
        return Question.create.checkForm();
    },
    cancleForm : function() {
        var flag1 = $("qt_network_one_fill_flag").value;
        var flag2 = $("qt_network_category_fill_flag").value;
        HomeMblogAttach.onCancel();
        $("question_upload_form").reset();
        $("question_target_individual_div").hide();
        QuestionSection.hideAllAttachSection();
        QuestionTargetSection.showInputEmailSection();
        $("qt_import_email_before_table").show();
        $("qt_import_email_after_div").hide();
        $("question_create_common_msg").className = "clear";
        $("qt_import_email_fill_tbody").update('');
        $("question_create_common_msg").update('');
        $("question_attachment_type").value = "0";
        $("input_emails").setStyle({
            color: "#999"
        });
        $("qt_network_one_fill_flag").value = flag1;
        $("qt_network_category_fill_flag").value = flag2;
    }, 
    onAjaxUploadComplete : function(jsonStr){ 
        var json = jsonStr.evalJSON(true);
        $("question_create_common_loading").update('');
        $("question_create_submit").disabled = false;
        if(json.RETURN){
            
            showMessage($("question_create_common_msg"), "问题发布成功", true);
            if(json.categorySetting != null && json.categorySetting) {
                CategoryForQuestionTarget.showDialog(json.qid);
            }else {
                //HzTimer.redirectPage("/qa", 1000);
                this._timer =Controltime(1000,this._redirectURL);
            }
        }else{
            showMessage($("question_create_common_msg"), json.MESSAGE, false);
        }
    }
}



