﻿/*
Author: Jeffrey Gordillo
Date: 12/20/2006
Description: Functions required to control the top frame of the CMS
*/


function setActionButton(strButton, strLink) {
    var objWindow = parent.frames["top_frame"]

    if (objWindow) {
        var objElement;

        if (strButton) {
            objElement = objWindow.document.getElementById('ddlEditLinks');
            if (objElement)
                objElement.options[0].selected = true;

            objElement = objWindow.document.getElementById("btnAction");
            if (objElement) {
                objElement.disabled = false;
                objElement.value = strButton;
                objElement.style.display = "inline";
            }

            objElement = objWindow.document.getElementById("btnLink");
            if (objElement)
                objElement.value = strLink;
        }
        else {
            setButton(objWindow.document.getElementById("btnAction"), false)
        }
    }
}

function goToURL(obj) {
    var strURL = obj.options[obj.selectedIndex].value;
    if ((strURL != "") && (strURL != "Select")) {
        setButton(document.getElementById('btnAction'), true);
        top.document.getElementById('content_frame').src = strURL;
    }
}

function goToButton(objButton, strURL) {
    setButton(document.getElementById('btnAction'), true);
    top.document.getElementById('content_frame').src = strURL;
}

function openFrame(strURL) {
    top.document.getElementById('content_frame').src = strURL;
}

function setButton(objButton, bDisplay) {
    if (objButton) {
        if (bDisplay) {
            objButton.style.display = 'inline';
            objButton.value = "...loading...";
            objButton.disabled = true;
        }
        else {
            objButton.style.display = 'none';
        }
    }
}

function resetDropdown() {
    var objWindow = parent.frames["top_frame"]

    if (objWindow) {
        var objElement;

        objElement = objWindow.document.getElementById('ddlEditLinks');
        if (objElement)
            objElement.options[0].selected = true;

        setButton(objWindow.document.getElementById("btnAction"), true)
    }
}

function displayCenterPopup(url, name, width, height, scrollbar, toolbar, statusbar) {
    var properties = 'scrollbars=' + scrollbar + ',toolbar=' + toolbar + ',status=' + statusbar;
    var iLeft = (window.screen.width - width) / 2;
    var iTop = (window.screen.height - height) / 2;

    window.open(url, name, properties + ',width=' + width + ',height=' + height + ',left=' + iLeft + ',top=' + iTop);
}