﻿/// <reference name="MicrosoftAjax.js"/>

/// <reference name="MicrosoftAjax.js"/>
Type.registerNamespace("TraderMagazine");

TraderMagazine.Dialog = function() {
    TraderMagazine.Dialog.initializeBase(this);
    //  global images




}

TraderMagazine.Dialog.prototype = {
    initialize: function() {
        TraderMagazine.Dialog.callBaseMethod(this, 'initialize');




    },

    /// <summary>
    //  create container for dialogboxes
    /// </summary>
    createDialogContainer: function(Header, SettingsFlag, Width, Height) {

        var scrolls = COMP.getScrollXY();

        var screenHeight = Sys.UI.DomElement.getBounds($get("Content")).height +2000;

        $get("DialogLayer").style.display = "block";
        $get("DialogLayer").style.height = screenHeight + scrolls[1] + "px";
 
        $get("DialogBox").style.height = screenHeight + "px";
        $get("DialogBox").style.display = "block";
        var DialogBox = $get("DialogBox");

        var DialogContainer = document.createElement("DIV");
        DialogContainer.style.position = "absolute";
        DialogContainer.style.left = "100px";



        DialogContainer.style.top = (scrolls[1] + 100) + "px";
        DialogContainer.style.width = Width + "px";
        DialogContainer.style.height = Height + "px";

        DialogContainer.id = "DialogContainer";





        DialogBox.appendChild(DialogContainer);


        //  inner table / grid for content
        var OuterBorder = COMP.createTable("OuterBorder", 1, 1, "100%", "middle");
        OuterBorder.style.border = "solid 1px #555";
        DialogContainer.appendChild(OuterBorder);
        //  inner table / grid for content
        var TContainer = COMP.createTable("TContainer", 3, 1, "100%", "middle");

        TContainer.style.backgroundColor = "#666";
        $get("OuterBorder_0_0").appendChild(TContainer);
        TContainer.style.border = "solid 1px #7d7d7d";
        TContainer.style.height = "100%";
        $get("TContainer_0_0").style.height = "35px";

        $get("TContainer_2_0").style.height = "40px";
        //====================================================
        // create dialog header
        var T = COMP.createTable("DialogHead", 1, 3, "100%", "middle");
        T.style.height = "35px";
        T.style.backgroundColor = "#5b5b5b";
        T.style.borderBottom = "solid 1px #505050";
        $get("TContainer_0_0").appendChild(T);

        var HeaderHead = document.createElement("DIV");
        HeaderHead.className = "dialog_title";
        HeaderHead.id = "DialogTitle";
        HeaderHead.innerHTML = Header;
        $get("DialogHead_0_0").appendChild(HeaderHead);
        if (SettingsFlag) {
            var SettingsBtn = document.createElement("A");
            SettingsBtn.id = "SettingsBtn";
            SettingsBtn.className = "SettingsBtn";
            SettingsBtn.innerHTML = Loc.Dat.settings;
            $get("DialogHead_0_1").style.width = "5px";
            $get("DialogHead_0_1").appendChild(SettingsBtn);
        }
        var CloseBtn = document.createElement("Img");
        CloseBtn.onclick = function() { DIALOG.closeDialog(); }
        CloseBtn.style.cursor = "pointer";
        CloseBtn.id = "DialogCloseBtn";
        CloseBtn.src = "Images/x.gif";


        $get("DialogHead_0_2").appendChild(CloseBtn);
        $get("DialogHead_0_2").style.paddingRight = "8px";
        $get("DialogHead_0_2").style.width = "2px";
        COMP.addAttribute("align", "right", "DialogHead_0_2");

        //====================================================
        // create dialog content holder
        var DialogContent = document.createElement("DIV");
        DialogContent.id = "DialogContent";
        DialogContent.style.margin = "10px";
        DialogContent.style.color = "#fff";
        $get("TContainer_2_0").appendChild(DialogContent);

        // create dialog footer holder
        var DialogFooter = document.createElement("DIV");
        DialogFooter.id = "DialogFooter";
        DialogFooter.style.margin = "10px";
        DialogFooter.style.color = "#fff";
        $get("TContainer_2_0").appendChild(DialogFooter);

        //  addFloatingBehavior($get('DialogContainer'), $get('DialogTitle'));

    },
    /// <summary>
    //  close dialog box
    /// </summary>
    closeDialog: function() {
        //if (floatingObj != undefined) floatingObj.dispose();
        $get("DialogBox").innerHTML = "";
        $get("DialogBox").style.display = "none";
        $get("DialogLayer").style.display = "none";

    },
    dispose: function() {
        //Add custom dispose actions here
        TraderMagazine.Dialog.callBaseMethod(this, 'dispose');
    }
}
TraderMagazine.Dialog.registerClass('TraderMagazine.Dialog', Sys.Component);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
