﻿$(document).ready(function () {

    // Initialize Apple Doc
    var labelTransform = function (labelText, optionIndex) {
        var splitComma = labelText.split(',')
                , cls = optionIndex < 4 ? '' : ' class="Bold"'
                , rtn = '<div>&nbsp;</div>';
        rtn += '<div class="Title">' + splitComma[1] + '</div>';
        return rtn;
    }
    , dockOptions =
        { align: 'bottom' // horizontal menu, with expansion DOWN from a fixed TOP edge
        , labels: true  // add labels
        , setLabel: labelTransform // called during initialisation to transform labels
        };

    //Initial Apple Doc
    $('#AppleDoc').jqDock(dockOptions);

    $("#AppleDoc").mouseover(function () {
        $("#PagePopupProperty").css("bottom", "150px");
    });

    $("#AppleDoc").mouseout(function () {
        $("#PagePopupProperty").css("bottom", "70px");
    });

    // Set Media Panel Positioning
    $("#PagePanel").css("width", $(window).width() + 20 + "px").css("left", "-" + ($(window).width() + 20));

    //Set Language List
    $("FlagLanguages").css("height", "0px").css("display", "inline");

    // Page Icon Click to show Pages Setting slide from left to right
    $("#PageIcon").click(function () {
        // Load Pag List in Tree view
        LoadPageList();

        if ($("#PagePanel").position().left < 300) {
            $("#PagePanel").animate({
                left: "0px"
            }, 500);
        }
        else {
            $("#PagePanel").animate({
                left: "4000px"
            }, 500);
        }
    });

    // Btn Back Icon on Media page Click Back
    $("#BtnBack").click(function () {
        $("#PagePanel").animate({
            left: $(window).width() / 100 + "px"
        }, 500);
        $("#PagePanel").animate({
            left: "-" + ($(window).width() + 20) + "px"
        }, 500);
    });

    // Slide Down Property Tab
    $("#Property .Title").click(function () {
        if ($("#Property").height() > 100) {
            $("#Property").animate({
                height: "20px"
            }, 500);
        }
        else {
            $("#Property").animate({
                height: "500px"
            }, 500);
        }
    });

    //Btn Close Popup
    $("#BtnCloseLanguagePopup").click(function () {
        $("#BtnAddNewPage").css("display", "inline");
        $("#BtnAddNewLanguage").css("display", "inline");
        $('#FlagLanguages').css('display', 'none');
    });
});

