//
// Ventana "Pop-up like" con un texto. Se usa para ayudas cortas.
//
// Parámetros:
// 
// caller: el ID del div con el enlace al pop-up. Se usa para mostrar el pop-up justo encima del enlace.
// content: el ID del div con el texto de la ayuda.
//
// Uses windows.js y pos-functions.js
// $Id: help_window.js,v 1.1 2006/04/18 20:48:05 eli Exp $

var helpWin = null;
function openHelpWindow(title, param) {
   if (!param) {
     param = {};
   }
   if (helpWin != null) {
         helpWin.show();
   }
   else {
        var caller_div_id = param.caller || 'help_win_caller';
        var content_div_id = param.content || 'help_content';
        $(content_div_id).style.display='block';


        var win_height = 23+19+parseFloat(Element.getStyle($(content_div_id), 'height'));
                        // dialog_nw + dialog_sw + help_content
        var win_param = {};
        win_param.title = title; 

        win_param.top = param.top || findPosY($(caller_div_id))-win_height-10;
       
        if (param.show_left != null) {
          win_param.left = parseFloat(findPosX($(caller_div_id)));
        } else {
          var content_width = parseFloat(Element.getStyle($(content_div_id), 'width')) || 100;
          var caller_width = parseFloat(Element.getStyle($(caller_div_id), 'width')) || 100;
          win_param.left = param.left || parseFloat(findPosX($(caller_div_id)))-content_width+caller_width;
        }
        if (param.width) win_param.width = param.width;
        win_param.resizable = param.resizable || false;


        helpWin = new Window('help_win', win_param);
        helpWin.setContent(content_div_id, true);
        helpWin.toFront();
        helpWin.setDestroyOnClose();
        helpWin.show();
   }
}           

// Set up a windows observer
// By default the div with the help message is help_content and it is a child of help_container.
// To override this values change the global variables g_help_container_id and g_help_content_id
g_help_container_id = 'help_container';
g_help_content_id = 'help_content';
var myObserver = {
    onStartMove: function(eventName, win) {
    },
    onEndMove: function(eventName, win) {
    },
    onStartResize: function(eventName, win) {
    },
    onEndResize: function(eventName, win) {
    },
    onClose: function(eventName, win) {
    },
    onDestroy: function(eventName, win) {
       if (win == helpWin) {
          $(g_help_content_id).style.display='none';
          $(g_help_container_id).appendChild($(g_help_content_id));
          helpWin = null;
       }
   }
}
Windows.addObserver(myObserver);   
