﻿/* ###############################################################################################

Namespaces:

BlackDiamond
    .About

Dependancies:

    NJKCS.js
    NJKCS.AJAX.js

/* ############################################################################################### */
/* ############################################################################################### */
/* ------------------------------------------------------------------------------------------------- 
Namespace : BlackDiamond

Create the Main BlackDiamond library object and generate the properties and methods. All properties and 
methods are then available to be called via the full namespace hierarchy
------------------------------------------------------------------------------------------------- */

addNamespace("BlackDiamond");          // Create the core namespace

/* -------------------------------------------------------------------------------------------------
Create the default properties
------------------------------------------------------------------------------------------------- */

/// <name>BlackDiamond.majorVersion</name>
/// <summary>Property to return the major version of the script</summary>
/// <returns>Major version number of the script</returns>

BlackDiamond.majorVersion = "0";    

/// <name>BlackDiamond.minorVersion</name>
/// <summary>Property to return the minor version of the script</summary>
/// <returns>Minor version number of the script</returns>

BlackDiamond.minorVersion = "5";
BlackDiamond.debug        = false;

/* -------------------------------------------------------------------------------------------------
Returns about information for the BlackDiamond library

Return: String - Contains about information

Usage:  BlackDiamond.About()
------------------------------------------------------------------------------------------------- */
BlackDiamond.About = function ()
{
    var sAbout = "BlackDiamond Core Library v" + this.majorVersion + "." + this.minorVersion + 
                 " (" + NJKCS.GetScriptBaseUrl("BlackDiamond.js") + ")";

    return sAbout;
}

/* -------------------------------------------------------------------------------------------------
Processes AJAX callbacks for operations. It is taken that the ID of the AJAX return is the name of
the invoking operation

Internal Use Only

Return: None

Usage:  BlackDiamond._AJAXCallBack()
------------------------------------------------------------------------------------------------- */
BlackDiamond._AJAXCallBack = function (ajaxReturn)
{
    if (ajaxReturn.hasError)
    {
        BlackDiamond.DisplayErrorPopup(ajaxReturn.error);
    }
    else
    {
        BlackDiamond.HideProcessingPopup();
    }
}

//------------------------------------------------------------------------------------------------
// Description:
//      Displays the specified message and indicates that processing is occurring. The method uses
//      the NJKCS.Popup control to block the screen.
//
//      DisplayProcessingPopup message
//
// Arguments:
//
//      actionArgs  - Object specifying name values as attributes
//
BlackDiamond.DisplayProcessingPopup = function(message)
{
    NJKCS.Controls.Popup.ShowNotice.BackgroundColor = "#003466";
    NJKCS.Controls.Popup.ShowNotice.Color = "white";

    var sHTML = BlackDiamond.Controls.GetLoadingHtml(message);

    NJKCS.Controls.Popup.ShowNotice(sHTML);
}

//------------------------------------------------------------------------------------------------
BlackDiamond.HideProcessingPopup = function()
{
    NJKCS.Controls.Popup.HideNotice();
}

//------------------------------------------------------------------------------------------------
BlackDiamond.DisplayErrorPopup = function(message)
{
    NJKCS.Controls.Popup.ShowNotice.BackgroundColor = "#003466";
    NJKCS.Controls.Popup.ShowNotice.Color = "red";

    alert("ERROR:" + message);
    
    return;

    var sHTML = "<div>" +
                    "<table>" +
                        "<tr>" +
                            "<td valign='middle'><img alt='' src='/Images/Icons/error.png' /></td>" +
                            "<td valign='middle'>Error</td>" +
                        "</tr>" +
                        "<tr>" +
                            "<td colspan='2'>" + message + "</td>" +
                        "</tr>" +
                        "<table>" +
                "</div>";

    NJKCS.Controls.Popup.ShowNotice(sHTML, true);
}

//------------------------------------------------------------------------------------------------
BlackDiamond.DisplayWarningPopup = function(message)
{
    NJKCS.Controls.Popup.ShowNotice.BackgroundColor = "#003466";
    NJKCS.Controls.Popup.ShowNotice.Color = "red";

    var sHTML = "<div>" +
                    "<table>" +
                        "<tr>" +
                            "<td valign='middle' width='50px'><img alt='' src='/Images/Icons/warning.png' /></td>" +
                            "<td valign='middle' align='left'>Warning</td>" +
                        "</tr>" +
                        "<tr>" +
                            "<td colspan='2'>" + message + "</td>" +
                        "</tr>" +
                        "<table>" +
                "</div>";

    NJKCS.Controls.Popup.ShowNotice(sHTML, true);
}

//------------------------------------------------------------------------------------------------
// Description:
//
//      PerformAction action [actionArgs]
//
// Arguments:
//
//      actionArgs  - Object specifying name values as attributes
//
BlackDiamond.PerformAction = function (action)
{
    var oReturn = NJKCS.UNDEFINED;
    
    if (!NJKCS.Utils.HasValue(action))
    {
        alert("PerformAction called without an action being specified");
    }
    else
    {
        //---------------------------------------------------------------------------------            
        switch (action)
        {
            //---------------------------------------------------------------------------------            
            case BlackDiamond.Actions.Help:        NJKCS.NavigateUrl("/Help"); break;

                
            //---------------------------------------------------------------------------------            
            default:
                alert("BlackDiamond.PerformAction: ERROR:: Unknown action - " + action);
                break;
        }
    }
        
    return oReturn;
}


/* ------------------------------------------------------------------------------------------------- 
Include other scripts
------------------------------------------------------------------------------------------------- */

NJKCS.LoadScript("/Scripts/BlackDiamond.Actions.js");
NJKCS.LoadScript("/Scripts/BlackDiamond.Controls.js");

                

