﻿$(document).ready(function() {
    $(".adminNavDrop").click(function() {
        var num = $(this).attr("name");
        var disp = $("#adminSubNav" + num).css("display");
        if (disp == 'block') {
            $("#adminSubNav" + num).hide();
        }
        else {
            $(".adminSubNav").hide();
            $("#adminSubNav" + num).show();
        }
    });
    $(".pendLink").click(function() {

        $(".pendLink").addClass("on");
        $(".actLink").removeClass("on");
        $("#Active").val("false");
    });
    $(".actLink").click(function() {
        $(".pendLink").removeClass("on");
        $(".actLink").addClass("on");

        $("#Active").val("true");
    });
    $(".tToggle").click(function() {
        var hidden = $("#HideTitle").val();
        if (hidden == "true") {
            $("#HideTitle").val("false");
            $(this).addClass("seeTitle");
            $(this).removeClass("hideTitle");
            $(this).html("Title Is Visible");
        } else {
            $("#HideTitle").val("true");
            $(this).removeClass("seeTitle");
            $(this).addClass("hideTitle");
            $(this).html("Title Is Hidden");
        }
    });
    $(".addMobile").click(function() {
        if (CheckMobile()) {
            var content = $("#Content_designEditor").contents().find("body").html();
            var pendingContent = $("#PendingContent").html();
            $("#MobileContent").html(content);
            $(this).hide();
            $(".editMobile").css("display", "block");
            $(".editMobile").click();
            FTB_API["MobileContent"].InsertBeginingHtml(content);
            $("#PendingMobileContent").html(pendingContent);
        } else {
            return false;
        }
    });
    $(".editMobile").click(function() {
        $(".mainContent").hide();
        $(".MobileContent").show();
        $(this).addClass("on");
        $(".editPage").removeClass("on");
    });
    $(".editPage").click(function() {
        $(".mainContent").show();
        $(".MobileContent").hide();
        $(this).addClass("on");
        $(".editMobile").removeClass("on");
    });
    $(".commentTab").click(function() {
        $(".adminBox_right2").show();
        $(".adminBox_rightTop1").addClass("adminBox_rightTop2");
        $(".adminBox_right1_bot").hide();
    });
    $(".pageTab").click(function() {
        $(".adminBox_right1_bot").show();
        $(".adminBox_rightTop1").removeClass("adminBox_rightTop2");
        $(".adminBox_right2").hide();
    });
    $(".deletePage").click(function() {
        $(".remove").submit();
    });
    $(".adminBox_right2 .postComment").click(function() {
        var comment = $(".adminBox_right2 #CommentText").val();
        $(".commentForm #Text").val(comment);
        $(".commentForm").submit();
        return false;
    });
    $(".mobileForm a").click(function() {
        $(".mobileForm").submit();
    });
    $("#Section").change(function() {
        var sec = $(this).val();
        var key = $(".sectionpagelist select").attr("id");
        if (key != "") {
            var urlm = "/Admin/SectionPageList?section=" + sec + "&key=" + key;
            $.get(urlm, null, function(datam) {
                if (datam != "") {
                    $(".sectionpagelist").html(datam);
                }
            });
        }
    });
});

function DropdownClose()
{
    $(".adminSubNav").hide();
}

function CheckMobile() {
    return confirm("This will create separate content on mobile devices than desktops. If you do not want different mobile content, select a mobile template instead.\n\n Would you like to add mobile content to this page?");
}
