<%@page info="Root Onepane" language="java"%>
<%@page contentType="text/html;charset=UTF-8"%>
<%--
 ******************************************************************************* 
 * $RCSfile: Welcome.jsp,v $
 *
 * Description: This file contains the plain version of the root view
 *                in the APOC Manager
 *
 * Copyright 2003 Sun Microsystems, Inc. All rights reserved.
 * Use of this product is subject to license terms.
 *
 *******************************************************************************
 * Source Code Control System - Header
 *
 * $Header: /sgnome/cvsroots/jds/apoc/web/manager/jsp/Welcome.jsp,v 1.22 2006/03/03 15:24:51 slewis Exp $
 *******************************************************************************
--%> 
<%@taglib uri="/WEB-INF/tld/com_iplanet_jato/jato.tld" prefix="jato"%> 
<%@taglib uri="/WEB-INF/tld/com_sun_web_ui/cc.tld" prefix="cc"%>

<jato:useViewBean className="com.sun.apoc.manager.WelcomeViewBean">

<%-- Header --%>
<cc:header pageTitle="APOC.masthead.altText" copyrightYear="2003"
 baseName="com.sun.apoc.manager.resource.apoc_manager"
 bundleID="apocBundle">

<script type="text/javascript" src="/apoc/js/MainWindow.js"></script> 

<script type="text/javascript">
<!--
    params=window.location.search;
    params=params.substr(1);
    if (params.indexOf("ClosePopups") != -1) {
        setTimeout("closePopups() ;",1000);
    }
    
    function handleSelection(selectedLink) {
        var willSubmit  = false;
        var f           = document.WelcomeForm;
        if (f != null) {
            if (selectedLink.name.indexOf("RemoveButton")!=-1) {
                // remove
                willSubmit = confirm('<cc:text name="RemoveMessage" bundleID="apocBundle" defaultValue="APOC.pool.removeContextMessage"/>');

                allowSubmit(willSubmit);
                return willSubmit;
                
            } else if (selectedLink.name.indexOf("RenameButton")!=-1) {
                // rename
                var contextName = getSelectedLink(document).text;
                    contextName = prompt('<cc:text name="RenameMessage" bundleID="apocBundle" defaultValue="APOC.pool.renameContextMessage"/>', unescape(contextName));

                if (contextName!=null) {
                    willSubmit=true;
                    f['Welcome.SelectedContext'].value=contextName;
                }

                allowSubmit(willSubmit);
                return willSubmit;

            } else if (selectedLink.name.indexOf("SyncButton")!=-1) {
                // sync
                var selectedContexts = getSelectedIds(document, "ManagerTableView");
                var leftContext = ""; 
                var rightContext = "";
                if (selectedContexts.indexOf(" ")>-1) {
                    leftContext = selectedContexts.substring(0, selectedContexts.indexOf(" "));
                    rightContext = selectedContexts.substring(selectedContexts.indexOf(" ")+1, selectedContexts.length);
                } else {
                    leftContext = selectedContexts;
                    rightContext = selectedContexts;
                }
                openWindow(window, null, '/apoc/manager/SyncLogin?SyncLogin.LeftContext='+leftContext+'&SyncLogin.RightContext='+rightContext, 'SyncWindow', 0.8, 0.5);

                allowSubmit(willSubmit)
                return willSubmit;

            }
        }
    }
    
    function toggleMenu() {
        var nElementRunner=0;
        var nElements=0;
        var nCheckedElements=0;
        var deleteButton    = "Welcome.ManagerTableView.RemoveButton";
        var renameButton    = "Welcome.ManagerTableView.RenameButton";
        var syncButton      = "Welcome.ManagerTableView.SyncButton";
        
        while (document.WelcomeForm.elements[nElementRunner]!=null) {
            if ( (document.WelcomeForm.elements[nElementRunner].name.indexOf("SelectionCheckbox")!=-1)) {
                nElements++;
                if (document.WelcomeForm.elements[nElementRunner].checked==true) {
                    nCheckedElements++;
                }
            }
            nElementRunner++;
        }

        // enable "delete" button if at least one profile is selected
        ccSetButtonDisabled(deleteButton, "WelcomeForm", (nCheckedElements==0));

        // enable "rename" button if exactly one profile is selected
        ccSetButtonDisabled(renameButton, "WelcomeForm", (nCheckedElements!=1));

        // enable "sync" button item if one or two profiles are selected
        ccSetButtonDisabled(syncButton, "WelcomeForm", ((nCheckedElements!=1) && (nCheckedElements!=2)));
    }
// -->
</script>  

<a name="top" id="top"/>

<cc:form name="WelcomeForm" method="post" onSubmit="javascript:return isSubmitAllowed();">

    <cc:primarymasthead name="Masthead" bundleID="apocBundle"/>

    <jato:content name="DisplayAlert">
        <div class="content-layout">
            <BR>
            <cc:alertinline name="Alert" bundleID="apocBundle"/>
            <BR>
            <!-- 
                <cc:text name="StackTrace"/>
            -->
        </div>
    </jato:content>
    
    <cc:pagetitle name="ManagerTitle" 
        bundleID="apocBundle"
        pageTitleText="APOC.contexts.title"
        pageTitleHelpMessage="APOC.contexts.help"
        showPageTitleSeparator="true"
        showPageButtonsTop="false"
        showPageButtonsBottom="true"> 

        <BR>

        <jato:containerView name="ManagerTableView">

            <cc:actiontable name="ContextTable"
                bundleID="apocBundle"
                title="APOC.contexts.table.title"
                summary="APOC.contexts.table.summary"
                empty="APOC.contexts.table.empty"
                selectionType="multiple"
                selectionJavascript="setTimeout('toggleMenu()', 0)" 
                showAdvancedSortIcon="false"
                showLowerActions="false"
                showPaginationControls="false"
                showPaginationIcon="false"
                showSelectionIcons="true"
                showSelectionSortIcon="false"
                maxRows="10"
                page="1" />
                
            <cc:hidden name="WizardLaunched"/>        
        </jato:containerView>
    </cc:pagetitle> 

    <cc:hidden name="Anchor"/>
    <cc:hidden name="HelpLocale"/>
    <cc:hidden name="SelectedContext"/>

</cc:form>

<script type="text/javascript">
<!--
    setTimeout('toggleMenu()', 0);
// -->
</script> 

</cc:header>

</jato:useViewBean> 
