// Author: Juergen Steiner
// Date: 03/2004
//
// SWL-specific listener functions for top window

// ----------------------------------------------------------------------
// Loading of overview map
// ---------------------------------------------------------------------

// this constant defines the name of the view that should be
// displayed in the overview window
var GtSwlOverviewViewName = "Default";

// initialize the overview view name with a value from the config file
if (top.config["map"] && top.config["map"]["overview"] && top.config["map"]["overview"]["viewName"])
	GtSwlOverviewViewName = top.config["map"]["overview"]["viewName"];



function GtSwlLoadOverviewMap() {

    // Listener that loads the overview map into the hcf_overview frame

    // get and set the overview map width & height. This is based
    // on the window width & height minus twice the offset (the
    // offsets are defined in ../styles/gt_swl_overview_map.css) 
    
    // -- GT-JUS(SWL): changed this for the time being to full extents for the overview map
    // --              display and turned off scrolling for hcf_overview
    // --              in index.html. Users are supposed to use the fit-to-window
    // --              feature to get the overview map fitted correctly into the 
    // --              overview frame in case they resize the overall browser window.
    /*
     * var overviewMapWidth = getCurrentWinWidth(top.hcf_overview) - 4;
     * var overviewMapHeight = getCurrentWinHeight(top.hcf_overview) - 4;
    */
    var overviewMapWidth = getCurrentWinWidth(top.hcf_overview);
    var overviewMapHeight = getCurrentWinHeight(top.hcf_overview);
    
    // GT-JUS(SWL): Register request parameters
    
    registerParam('width', overviewMapWidth);
    registerParam('height', overviewMapHeight);
    registerParam('swldy_view', GtSwlOverviewViewName);


    if ( top.config["map"] && top.config["map"]["overview"])
    {
    	// Register display scale if available
    	if (top.config["map"]["overview"]["displayScale"])
			registerParam('swldy_dscale', top.config["map"]["overview"]["displayScale"]);
			    	
    	// Register image format if available
    	if (top.config["map"]["overview"]["imageFormat"])
    		registerParam('swldy_image_format', top.config["map"]["overview"]["imageFormat"]);

    }

	// use SRS from main map
    var clientReg = top.hcf_content.response.client_registry;
    registerParam('srs', clientReg.srs.value);    

    // -- GT-JUS(SWL): ensure that all themes are turned on in the overview map
    // --              thus explicitly pass an empty string as an argument
    registerParam('swldy_themes', "");
    
    // set up request and stylesheet
    var aRequest = '<request>' + 
	'<name>map</name>' + 
	'<format>xml</format>' + 
	'</request>';
    var aStyleSheet = 'gt_swl_overview_map.xsl';
    
    
    // -- GT-JUS(SWL): display some progress information in the "hcf_overview" frame while waiting for the server response
    top.header.GtSwlActivateProgressIndicator(top.hcf_overview, top.GT_SWL_PROGRESS_INDICATOR_MSG_LOADING_OVERVIEW );
   
    
    // now execute the request - this will go to the overview frame
    executeRequest(top.hcf_overview, aRequest, aStyleSheet);
}


// -- GT-JUS(SWL): added this function to get themes loaded into the frame 'themes' on start-up. 
// --              Themes are supposed to be permanently available throughout a SWL_WEB-GIS session.

function GtSwlLoadThemes() {

    // set up a request for aces and a stylesheet
    var aRequest =  '<request>' +
                        '<name>ace</name>' +
                        '<command>aces</command>' +
                        '<format>xml</format>' +
                    '</request>';
                    
    var aStyleSheet = 'gt_swl_panel_themes_bottom.xsl';


    // -- GT-JUS(SWL): display some progress information in the "themes" frame while waiting for the server response
    top.header.GtSwlActivateProgressIndicator(top.themes, top.GT_SWL_PROGRESS_INDICATOR_MSG_LOADING_THEMES );


    // now execute the request - this will go into the themes frame (below the hcf_content frame).
    executeRequest(top.themes, aRequest, aStyleSheet);
}
