﻿function clientButtonClicking(sender, args) {
    var toolBar = sender;
    var button = args.get_item();

    if (button.get_value() == "Settings") {
        showDialog(button.get_commandArgument());
    }
}

//show the window
function showDialog(value) {
    showDialogWithDimensions(value, "300px", "250px");
}

function showDialogWithDimensions(value, w, h) {
    //Force reload in order to guarantee that the onload event handler 
    //of the dialog which configures it executes on every show.
    var oWnd = window.radopen(value, "DialogWindow");
    oWnd.setSize(w, h);

}

//Called when a window is being shown. Good for setting an argument to the window 
function onClientshow(radWindow) {
    //                    //Get current content of textarea
    //                    var oText = document.getElementById("InfoArea").value;
    //                    
    //                    //Create a new Object to be used as an argument to the radWindow
    //                    var arg = new Object();                    
    //                    //Using an Object as a argument is convenient as it allows setting many properties.
    //                    arg.TextValue = oText;
    //                    arg.Color = "red";
    //                    arg.BackColor = "yellow";
    //                                        
    //                    //Set the argument object to the radWindow        
    //                    radWindow.Argument = arg;
}

function callBackFunction(radWindow, returnValue) {
    //var oArea = document.getElementById("InfoArea");
    //if (returnValue) oArea.value = returnValue;
    //else alert ("No text was returned");
}

// Called when a window is being closed.
function onClientclose(radWindow) {
    if (radWindow.argument == "logged") 
    {
        location.reload(true);
    }
}

function onNavigate(url) {
    top.location.href = url;
}

function containerToolClicked(sender, args) {
    //Container tool bar button clicked
    //opens window for editing or module settings
    var attrs = args.get_item().get_attributes();
    var wW = attrs.getAttribute("wWidth");
    var wH = attrs.getAttribute("wHeight");
    var jU = attrs.getAttribute("scriptUrl");

    if (jU == undefined) {
        return;
    }

    var oWnd = window.radopen(jU, "DialogWindow");
    oWnd.setSize(wW, wH);
}