﻿var oTable;
var WRONG_MSG = 'TELL US WHAT\'S WRONG.';
   
//Ajax Generic Call
function SendAjax(urlMethod, jsonData, returnFunction) {
    $.ajax({
        type: "POST",
        contentType: "application/json; charset=utf-8",
        url: urlMethod,
        data: jsonData,
        dataType: "json",
        success: function(msg) {
            if (msg != null) returnFunction(msg);
        },
        error: function(xhr, status, error) {
            // Boil the ASP.NET AJAX error down to JSON.
            var err = eval("(" + xhr.responseText + ")");
            // Display the specific error raised by the server
            alert('Unexpected Error: ' + err.Message);
        }
    });
}

//This fires when the DOM is ready
//So this starts the ball rolling...
$(document).ready(function () {

    $('#wrong-button').click(function () {
        PostWrong();
    });

    $('#wrong-close').click(function () {
        $('#wrong-expandable').animate({ height: '115px' }, 500);
        ResetWrongForm();
    });

    $('#contact-submit').click(function () {
        SendContactForm();
    });

    $('#pledge-submit').click(function () {
        SendPledgeForm();
    });

    $('.slideshow').cycle({
        fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
    });

    $('#content-save').click(function () {
        UpdateContent();
    });

    $('#wrongbox').focus(function () {
        if ($('#wrongbox').val() == WRONG_MSG) {
            $('#wrongbox').val('');
            //Expand the orange box
            // $('#wrong-expandable').animate({ height: '430px' }, 500);
        }
    });

    $('#linkvideo').click(function () {
        AskVideoURL();
    });

    $('#filephoto').uploadify({
        'uploader': 'App_Themes/Default/images/uploadify.swf',
        'script': 'upload.ashx',
        'scriptData': {},
        'cancelImg': 'App_Themes/Default/images/cancel.png',
        'auto': true,
        'multi': false,
        'fileDesc': 'Image File (jpg, jpeg, png, bmp or gif)',
        'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.gif',
        'sizeLimit': 2097152,
        'buttonImg': 'App_Themes/Default/images/browse.gif',
        'width': '83',
        'height': '25',
        'wmode': 'transparent',
        'onComplete': function (event, queueID, fileObj, response, data) { PhotoUploaded(response); }
    });

    $('#video-remove').click(function () {
        $('#hdnvideo').val('');
        $('#video-linked').fadeOut();
    });

    $('#photo-remove').click(function () {
        $('#hdnphoto').val('');
        $('#photo-linked').fadeOut();
    });

    $('#another-wrong').click(function () { ResetWrongForm(); });
    $('#close-wrong').click(function () {
        $('#wrongbox').val(WRONG_MSG);
        $('#wrong-expandable').animate({ height: '115px' }, 500, function () { ResetWrongForm(); });
    });

    if ($('#slideshowWrongest').length > 0) {
        $('#slideshowWrongest').serialScroll({
            items: 'li',
            prev: '#controls a.up',
            next: '#controls a.down',
            axis: 'y',
            duration: 600,
            force: true,
            stop: true,
            lock: false,
            cycle: false,
            easing: 'linear',
            jump: true
        });
    }

    $('div#ctl00_ContentPlaceHolder1_singleWrong div.preview a.thumbnail').ceebox({ imageGallery: false });
    $('div#ctl00_ContentPlaceHolder1_singleWrong div.preview a.video').ceebox({ videoGallery: false, videoWidth: 500 });
    $('div#ctl00_ContentPlaceHolder1_singleWrong div.preview a.video img.video').each(function () {
        $(this).attr("src", $.jYoutube($(this).parent().attr("href"), 'big'));
    });


    $('#download-zip').click(function (event) {
        event.preventDefault();

        //Creates params
        var params = '?files=';
        var qty = $('a.download').size();

        $('a.download').each(function (index) {
            params += $(this).attr('rel');
            if(index < (qty-1))
                params += ',';
        });

        window.location.href = 'downloadzip.aspx' + params;
    });

    if ($('#admin-grid').length)
        oTable = $('#admin-grid').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "bProcessing": true,
            "bServerSide": true,
            "bStateSave": true,
            "iDisplayLength": 50,
            "sAjaxSource": "../administrator/wrongslist.ashx",
            "aaSorting": [[1, "desc"]],
            "aoColumns": [
						    { "sClass": "center", "bSortable": false, "sWidth": "30px" },
						    { "sClass": "center", "sWidth": "30px" },
						    null,
						    { "sWidth": "130px" },
						    { "sClass": "center", "sWidth": "60px" },
						    { "sClass": "center", "sWidth": "60px" },
						    { "sClass": "center", "sWidth": "65px" },
						    { "sClass": "center", "sWidth": "70px" },
                            { "sClass": "center", "sWidth": "70px" },
						    { "sClass": "center", "bSortable": false, "sWidth": "80px" }
					    ],
            "fnDrawCallback": fnAssignEvents
        });

    if ($('#admin-pledge').length)
        oTable = $('#admin-pledge').dataTable({
            "bJQueryUI": true,
            "sPaginationType": "full_numbers",
            "bProcessing": true,
            "bServerSide": true,
            "bStateSave": true,
            "iDisplayLength": 50,
            "sAjaxSource": "../administrator/pledgelist.ashx",
            "aaSorting": [[0, "desc"]],
            "aoColumns": [
						    { "sClass": "center", "sWidth": "30px" },
						    null,
						    null,
						    null,
						    null,
						    null
					    ]
        });

    AddLighBoxesPhotoAndVideo();
    $('#list-wrongs').jScrollPane();
    $('#bad-words').jScrollPane();

    $('#bad-words div.word').hover(function () {
        $(this).addClass('selected');
    }, function () {
        $(this).removeClass('selected');
    });

    $('#bad-words div.word img').click(function () {
        DropBadWord($(this).parent().children('[type=hidden]').val());
        $(this).parent().remove();
    });

    if ($('a#new-word').length > 0) $('a#new-word').click(AskBadWord);


    if ($('div.affiliate-checkin-container').length > 0) {
        $('#affiliate-register-submit').click(function () {
            SendRegisterAffiliateForm();
        });
        $('#affiliatesubmit').click(function () {
            SendLoginAffiliateForm();
        });

        $('#register-guidelines').click(function () {
            ShowRegisterGuidelines();
        });
        $('#cb_new_visitor').click(function () {
            ToggleRegisterForm();
        });
    }


    $("a.wrong-topic-action-button").click(function (event) {
        event.preventDefault();
        WrongTopicAction($(this).attr("href"), null);
    });

    $("div#bannertext div.middle div.message a#registerBanner, div.box-slideshow div.box-footer a#registerSlider").click(function (event) {
        event.preventDefault();
        if (!$("#cb_new_visitor").attr("checked")) {
            $("#cb_new_visitor").attr("checked", true);
            ToggleRegisterForm();
        }
    });

    /*Batch uploaders*/

    if ($("table.wrong-batch-loader-grid").length > 0) {

        $("table.wrong-batch-loader-grid a.command-delete").click(function (event) {
            event.preventDefault();
            $(this).parents("tr:first").remove();

            if ($("table.wrong-batch-loader-grid tr").length == 1) {
                $("table.wrong-batch-loader-grid").remove();
                return;
            }

            var count = 1;

            $("table.wrong-batch-loader-grid td.rownum").each(function () {
                $(this).text(count);
                count++;
            });

            $("ul.error-list").empty().hide();

        });

        $("div.button-placeholder a.action-button").click(function (event) {
            event.preventDefault();
            SaveWrongList("t&v");
        });
    }
    if ($("#multiple-filephoto").length > 0) {


        var 
            files = null,
            $dynamicContainer = $("#div-step2").find("div.new-wrong-list"),
            $template = $("#item_template")
        value = "";

        $("#lnk_save_items").click(function (event) {
            event.preventDefault();
            SaveWrongList("p");
        });


        function RemoveItem(event) {
            event.preventDefault();
            var $item = $(this).parent().remove();

            $.get("../deletefile.ashx", { filepath: $item.find("input.photo").val() });
            $item.remove();

            if ($dynamicContainer.find("div.item").length == 0) {
                $("#div-step1").show();
                $("#div-step2").hide();
                return;
            }

            var count = 1;

            $dynamicContainer.find("div.wrong-id").each(function () {
                $(this).text("Wrong " + count);
                count++;
            });

            $("ul.error-list").empty().hide();
        }


        $("#lnk_apply_to_all").click(function (event) {
            event.preventDefault();

            var 
                $usernames = $dynamicContainer.find("div.username input"),
                $states = $dynamicContainer.find("div.state select"),
                $emails = $dynamicContainer.find("div.email input"),
                usernameValue = $.trim($("#tb_all_username").val()),
                stateValue = $("select[id$='_ddl_all_states']").val(),
                emailValue = $.trim($("#tb_all_email").val());

            for (var i = 0; i < $usernames.length; i++) {
                // if(usernameValue != "" && $.trim($usernames.eq(i).val()) == "")
                $usernames.eq(i).val(usernameValue);
                // if(stateValue != "-1" && $states.eq(i).val() == "-1")
                $states.eq(i).val(stateValue);
                /// if(emailValue != "" && $.trim($emails.eq(i).val()) == "")
                $emails.eq(i).val(emailValue);
            }
        });

        var onAllComplete = function () {
            if (files.length > 0) {
                $("#div-step1").hide();
                $("#div-step2").show();
                var $items = $([]), $item = null, $temp = null, wrong = "";

                if (errors.length > 0) {
                    var items = '';
                    for (var j = 0; j < errors.length; j++) {
                        items += '<li>' + errors[j].fileName + ' - ' + errors[j].type + ' Error</li>';
                    }
                    $("ul#ulPhoto").html(items).show();
                }
                else {
                    $("ul#ulPhoto").empty().hide();
                }

                for (var i = 0; i < files.length; i++) {

                    wrong = files[i].replace(/\.[^.]*$/, "");

                    $item = $template.clone(false);
                    $item.removeAttr("id").removeClass("hide");

                    $temp = $item.find("div.thumbnail");
                    $temp.find("a").attr("href", "../App_Resources/photos/" + files[i]).ceebox({ imageGallery: false });
                    $temp.find("img").attr({ src: "../ShowImage.aspx?w=250&h=150&img=~/App_Resources/photos/" + files[i], alt: wrong });

                    $temp = $item.find("div.username");
                    $temp.find("label").attr("for", "tb_username" + (i + 1));
                    $temp.find("input").attr("id", "tb_username" + (i + 1));

                    $temp = $item.find("div.state");
                    $temp.find("label").attr("for", "ddl_state" + (i + 1));
                    $temp.find("select").attr("id", "ddl_state" + (i + 1)).removeAttr("name");

                    $temp = $item.find("div.email");
                    $temp.find("label").attr("for", "tb_email" + (i + 1));
                    $temp.find("input").attr("id", "tb_email" + (i + 1));

                    $temp = $item.find("div.wrong");
                    $temp.find("label").attr("for", "tb_wrong" + (i + 1));
                    $temp.find("input").attr("id", "tb_wrong" + (i + 1)).val(wrong);

                    $item.find("a.command-delete").click(RemoveItem);

                    $item.find("input.photo").val(files[i]);

                    $item.find("div.wrong-id").text("Wrong " + (i + 1));

                    $items = $items.add($item);
                }
                $dynamicContainer.html($items);
                $template.remove();
            }
        };


    }

    $("#multiple-filephoto").uploadify({
        'uploader': '../App_Themes/Default/images/uploadify.swf',
        'script': '../upload.ashx',
        'scriptData': {},
        'cancelImg': '../App_Themes/Default/images/cancel.png',
        'auto': true,
        'multi': true,
        'fileDesc': 'Image File (jpg, jpeg, png, bmp or gif)',
        'fileExt': '*.jpg;*.png;*.gif;*.bmp;*.jpeg;*.gif',
        'sizeLimit': 20971520,
        'buttonImg': '../App_Themes/Default/images/browse.gif',
        'width': '83',
        'height': '25',
        'wmode': 'transparent',
        'onSelectOnce': function () { files = []; errors = []; },
        'onAllComplete': onAllComplete,
        'onComplete': function (event, queueID, fileObj, response, data) { files.push(response); },
        'onError': function (event, ID, fileObj, errorObj) {
            var error = {
                fileName: fileObj.name,
                type: errorObj.type
            };
            errors.push(error);
        }
    });

    // Setting up height for banner billboard
    if ($('div#bannertext div.billboard').length > 0) {
        setTimeout(function () {
            $('div#bannertext div.billboard').css("height", ($('div#bannertext div.billboard').height()) + "px");
        }, 2000);
    }

});

/* Event handler function */
function fnAssignEvents(oSettings) {
    $('td a.approve', oTable.fnGetNodes()).each(function() {
        $(this).click(function() {

            var nTr = this.parentNode.parentNode;
            var aData = oTable.fnGetData(nTr);

            //Ajax
            var urlMethod = "aws.asmx/ChangeStatus";
            var jsonData = "{wrongId:'" + aData[1] + "',status:'1'}";
            $("#admin-grid_processing").css('visibility', 'visible');
            SendAjax(urlMethod, jsonData, StatusWasChanged);
        });
    });

    $('td a.reject', oTable.fnGetNodes()).each(function() {
        $(this).click(function() {

            var nTr = this.parentNode.parentNode;
            var aData = oTable.fnGetData(nTr);

            //Ajax
            var urlMethod = "aws.asmx/ChangeStatus";
            var jsonData = "{wrongId:'" + aData[1] + "',status:'2'}";
            $("#admin-grid_processing").css('visibility', 'visible');
            SendAjax(urlMethod, jsonData, StatusWasChanged);
        });
    });

    $('td a.pending', oTable.fnGetNodes()).each(function() {
        $(this).click(function() {

            var nTr = this.parentNode.parentNode;
            var aData = oTable.fnGetData(nTr);

            //Ajax
            var urlMethod = "aws.asmx/ChangeStatus";
            var jsonData = "{wrongId:'" + aData[1] + "',status:'3'}";
            $("#admin-grid_processing").css('visibility', 'visible');
            SendAjax(urlMethod, jsonData, StatusWasChanged);
        });
    });

    $('table#admin-grid td a.icon-photo').ceebox({ imageGallery: false });
    $('table#admin-grid td a.icon-video').ceebox({ videoGallery: false, videoWidth: 500 });
    $('table#admin-grid td a.details').ceebox({ videoGallery: false });
}

function StatusWasChanged() {

    $("#admin-grid_processing").css('visibility', 'hidden');
    oTable.fnDraw();
}

function AskVideoURL(){
    var url = "http://";
    if ($('#hdnvideo').val() != "") url = $('#hdnvideo').val();
    var txt = 'You need to have loaded your video in YouTube. Please enter your YouTube URL:<br /><input type="text" id="txtUrlVideo" name="txtUrlVideo" style="width:365px" value="' +  url + '" />';

    $.prompt(txt, {
        callback: VideoEntered,
        buttons: { Done: 'Done', Cancel: 'Cancel' }
    });
}

function VideoEntered(v, m, f) {
    if (v == undefined || v == "Cancel") return;

    var enteredValue = f.txtUrlVideo.trim();
    if (enteredValue.indexOf("http://") != 0) enteredValue = "http://" + enteredValue;
    
    if(!isValidURL(enteredValue)){
        $.prompt('Please enter a valid YouTube URL',{ callback: AskVideoURL });
        return;
    }

    $('#hdnphoto').val('');
    $('#hdnvideo').val(enteredValue);
    $('#photo-linked').hide();
    $('input#txtusername').focus();
    $('#video-linked').fadeIn('fast');
    $('#video-url').attr("href", enteredValue);
}

function PhotoUploaded(response) {
    if (response == "0") {
        alert('Fail :-(');
        return;
    }
    $('#hdnvideo').val('');
    $('#hdnphoto').val(response);
    $('#photo-linked').fadeIn('fast');
    $('#video-linked').hide();
    $('input#txtusername').focus();
    $('#photo-url').attr("href", "App_Resources/photos/" + response);
    $('#photo-url').ceebox({ imageGallery: false });
}

/* Login functions */

function SendRegisterAffiliateForm(event) {
    //event.preventDefault();

    if ($("#cb_agreed_with_guidelines").attr("checked")) {

        $("div.agreed-with-guidelines").hide();
        $("#divWaitAffiliationSubmit").show();
        var fullname = trim($("#tb_fullname").val());
        var affiliatename = trim($("#tb_affiliatename").val());
        var email = trim($("#tb_email").val());
        var city = trim($("#tb_city").val());
        var state = $("#" + $("#hd_ddl_state_dotnet_id").val()).val();

        PostResgisterAffiliateForm(fullname, affiliatename, email, city, state);
    }

    else {
        $.prompt("<p>You must agree with our guidelines to continue!</p>");
    }

}

function SendLoginAffiliateForm(event) {
    //event.preventDefault();

    $("#divWaitFieldValidationSubmit").show();
    var username = trim($("#tb_username").val());
    var password = trim($("#tb_password").val());

    DisableLoginForm(true);

    var urlMethod = "ws.asmx/LoginAffiliate";
    var jsonData = "{ username: '" + escape(username) + "', password: '" + escape(password) + "'}"
    SendAjax(urlMethod, jsonData, LoginAffiliateFormSent);

}

function DisableLoginForm(disabled) {
    $("#tb_username").attr("disabled", disabled);
    $("#tb_password").attr("disabled", disabled);
    $("#tb_fullname").attr("disabled", disabled);
    $("#tb_affiliatename").attr("disabled", disabled);
    $("#tb_email").attr("disabled", disabled);
    $("#tb_city").attr("disabled", disabled);
    $("#cb_new_visitor").attr("disabled", disabled);
    $("#cb_agreed_with_guidelines").attr("disabled", disabled);
    $("#" + $("#hd_ddl_state_dotnet_id").val()).attr("disabled", disabled);

    if (disabled) {
        $("#affiliate-register-submit").hide();
        $("#affiliatesubmit").hide();
    }
    else {
        $("#affiliate-register-submit").show();
        $("#affiliatesubmit").show();
    }
}

function PostResgisterAffiliateForm(fullname, affiliatename, email, city, state) {
    DisableLoginForm(true);

    var urlMethod = "ws.asmx/SaveAffiliate";
    var jsonData = "{ fullname: '" + escape(fullname) + "', affiliatename: '" + escape(affiliatename) + "',  email: '" + escape(email) +
                   "', city: '" + escape(city) + "', state : " + escape(state) + "}"
    SendAjax(urlMethod, jsonData, ResgisterAffiliateFormSent);
}

function ResgisterAffiliateFormSent(msg) {
    DisableLoginForm(false);
    $("#divWaitAffiliationSubmit").hide();
    $("div.agreed-with-guidelines").show();
    var message = "";

    if (msg.d.length == 0) {
        $("#cb_new_visitor").attr("checked", false);
        ToggleRegisterForm();
        message = '<p>Thank you for your registration. An email will be sent to the address you provided with your username and password (will come from <a href="mailto:no-reply@litteringiswrongtoo.org">no-reply@litteringiswrongtoo.org</a>). If you do not receive this email, please check your <span class="caps">SPAM</span> folder. Please do not re-register. <a href="mailto:communications@kab.org">Contact us</a> if you need assistance. </p>';
    } else {
        message = "<p>It looks like you have to check data entered&hellip;</p><ul class='error-list'>";
        $.each(msg.d, function (key, val) {
            if (val.Message != "") message += "<li>" + val.Message + "</li>";
        });
        message += "</ul>";
    }
    $.prompt(message);
}


function LoginAffiliateFormSent(msg) {
    var showError = true;
    DisableLoginForm(false);
    $("#divWaitFieldValidationSubmit").hide();

    var errorMessage = "<p>It looks like you have to check data entered&hellip;</p><ul class='error-list'>";
    $.each(msg.d, function (key, val) {
        if (val.Message === "administrator") { document.location = "administrator/"; showError = false; return showError; }
        if (val.Message === "user") { document.location = "user/campaigntoolkit.aspx"; showError = false; return showError; }
        if (val.Message != "") errorMessage += "<li>" + val.Message + "</li>";
    });
    errorMessage += "</ul>";

    if(showError==true)
        $.prompt(errorMessage);
}

function ClearAffiliateForm() {
    $("#tb_username").val("");
    $("#tb_password").val("");
    $("#tb_fullname").val("");
    $("#tb_affiliatename").val("");
    $("#tb_email").val("");
    $("#tb_city").val("");
    $("#cb_agreed_with_guidelines").attr("checked", false);
    $("#" + $("#hd_ddl_state_dotnet_id").val()).val("-1");
}

function ToggleRegisterForm() {
    var checked = $("#cb_new_visitor").attr("checked");
    if (checked) {
        $('div.affiliate-checkin-container div.field-container').animate({ height: '424px' }, 500);
        ClearAffiliateForm();
    }
    else {
        $('div.affiliate-checkin-container div.field-container').animate({ height: '176px' }, 500);
    }

}

function ShowRegisterGuidelines(event) {
   // event.preventDefault();
    var guidelines = "<div class='guidelines-placeholder'><h2 class='title'>Guidelines</h2><div class='guidelines-scrollpane' style='height:400px;'><p>To get the most out of this campaign, please be sure to maintain brand consistency. Some guidelines include:</p><ul><li> - Please leave all typefaces unchanged;</li><li> - Please do not alter colors or images;</li><li> - Never remove the URL (web address) from any executions;</li><li> - Do read the specific guidelines that accompany each campaign element; and</li><li> - Do send us local lines and other ideas so we can help you integrate them into your local campaign.</li></ul></div></div>";
    $.prompt(guidelines, { loaded: function () { $("div.guidelines-scrollpane").jScrollPane(); } });
}

function PostWrong() {
    $('#saving').show();

    $('#wrongbox').attr("disabled", true);
    $('#txtusername').attr("disabled", true);
    $('#txtemail').attr("disabled", true);
    $('#txttwitter').attr("disabled", true);
    $('#ctl00_ContentPlaceHolder1_ddl_state').attr("disabled", true);
    $('#wrong-button').hide();
    $('#wrong-close').hide();
    
    //Ajax
    var urlMethod = "ws.asmx/SaveWrong";
    var jsonData = "{wrong:'" + escape($('#wrongbox').val().trim()) +
                   "',photo:'" + escape($('#hdnphoto').val().trim()) +
                   "',video:'" + escape($('#hdnvideo').val().trim()) +
                   "',username:'" + escape($('#txtusername').val().trim()) +
                   "',email:'" + escape($('#txtemail').val().trim()) +
                   "',twitter:'" + escape('') +
                   "',state:'" + escape($('#ctl00_ContentPlaceHolder1_ddl_state').val().trim()) +
                    "'}";
    SendAjax(urlMethod, jsonData, WrongWasPosted);
}

function WrongWasPosted(msg) {
    //alert('Success: ' + msg.d);
    $('#saving').hide();
    $('#wrongbox').removeAttr("disabled");
    $('#txtusername').removeAttr("disabled");
    $('#txtemail').removeAttr("disabled");
    $('#txttwitter').removeAttr("disabled");
    $('#ctl00_ContentPlaceHolder1_ddl_state').removeAttr("disabled");
    $('#wrong-button').show();
    $('#wrong-close').show();
    
    if (msg.d.length == 0) {
        //Confirm aknowledge
        $('#posting-wrong').hide();
        $('#wrong-posted').fadeIn(1000);
        return;
    }

    var errorMessage = "<p>It looks like you have to check data entered&hellip;</p><ul class='error-list'>";
    $.each(msg.d,function(key, val) {
        if (val.Message != "") errorMessage += "<li>" + val.Message + "</li>";
    });
    errorMessage += "</ul>";

    $.prompt(errorMessage);
}

function ResetWrongForm() {

    $('#wrongbox').val(WRONG_MSG);
    $('#hdnphoto').val('');
    $('#hdnvideo').val('');
    $('#txtusername').val('');
    $('#txtemail').val('');
    $('#txttwitter').val('');

    $('#video-linked').hide();
    $('#photo-linked').hide();
    
    $('#wrong-posted').hide();
    $('#posting-wrong').fadeIn(500);
}

function WrongTopicAction(action, response) {

    switch (action) {
        case 'save':
            $("#div_wait_save_new_wrong_topic").show();
            $("a.save-wrong-topic").hide();
            $("#div_new_wrong_topic_place_holder").hide();
            SendAjax("ws.asmx/SaveWrongTopic", "{ description: '" + escape($("#tb_new_wrong_topic").val()) + "' }", function (msg) {
                WrongTopicAction("ajaxResponse", msg);
            });
            break;
        case 'edit':
            $("a.edit-wrong-topic").hide();
            $("a.save-wrong-topic").show();
            $("#div_new_wrong_topic_place_holder").show().find("#tb_new_wrong_topic").focus().val("");
            $("#current_wrong_topic").hide();
            break;
        case 'ajaxResponse':
            console.log(response);
            $("#current_wrong_topic").show();
            $("a.edit-wrong-topic").show();
            $("#div_wait_save_new_wrong_topic").hide();
            $("#current_wrong_topic").text(response.d.Description + "?");
            break;
    }
}

