//------------------------------------------------------------------------------
// FICHIER : $RCSfile: ref.js,v $
// AUTEUR  : $Author: lc $
// VERSION : $Revision: 1.3 $
// DATE    : $Date: 2003/04/22 15:04:43 $
//------------------------------------------------------------------------------
// GSite - Web site management in PHP - ref js file
//
// Copyright (C) 2002 COUDOUNEAU Laurent (lc@gsite.org)
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------

//------------------------------------------------------------------------------

function ref_getDiv (divName) {
  var namedList = document.getElementsByName (divName);
  return namedList.item (0);
}

//------------------------------------------------------------------------------

function ref_swapDivVisibility (named) {
  if (named.style.display == "none") {
    named.style.display = "block";
    
  } else {
    named.style.display = "none";
  }
}

//------------------------------------------------------------------------------

var ref_LastOpenMenu = null;

function ref_closeMenu (sMenuName) {
  var named = ref_getDiv (sMenuName);
  
  ref_swapDivVisibility (named);
  
  ref_LastOpenMenu = null;
}

function ref_openMenu (sMenuName) {
  if (ref_LastOpenMenu != null) ref_swapDivVisibility (ref_LastOpenMenu);
  
  var named = ref_getDiv (sMenuName);
  
  ref_swapDivVisibility (named);
  
  ref_LastOpenMenu = named;
}

//------------------------------------------------------------------------------

function ref_showDocument (sProject, sLocale, sAnnu, sRef, iDocID) {
  var sParam =
    '&project='+sProject+
    '&locale='+sLocale+
    '&annu='+sAnnu+
    '&ref='+sRef+
    '&fct=ref_showdoc'+
    '&docid='+iDocID;
  
  openPopup ('ref', sParam, 710, 560, 'showdoc');
}

//------------------------------------------------------------------------------

function ref_eraseBrowserFields (sInputID, sInputChrono, sInputTitle) {
  sInputID.value     = 0;
  sInputChrono.value = '';
  sInputTitle.value  = '';
}

//------------------------------------------------------------------------------

function ref_documentBrowser (sProject, sLocale, sAnnu, sRef, sForm, sInputID, sInputChrono, sInputTitle) {
  var sParam =
    '&project='+sProject+
    '&locale='+sLocale+
    '&annu='+sAnnu+
    '&ref='+sRef+
    '&fct=ref_browser'+
    '&docbrw_form='+sForm+
    '&docbrw_id='+sInputID+
    '&docbrw_chrono='+sInputChrono+
    '&docbrw_title='+sInputTitle;
  
  openPopup ('ref', sParam, 660, 500, 'browsedoc');
}

//------------------------------------------------------------------------------

function ref_selectColumn (sSelect, sURL) {
  var sCols = sSelect.options[sSelect.selectedIndex].value;
  
  window.location = sURL+'&cols='+sCols;
}

//------------------------------------------------------------------------------

function ref_checkDateDoc (sLocale, sDate, sMsg) {
  var isOK = false;
  
  if (sLocale == 'fr') isOK = checkDateNull_fr (sDate);
  if (sLocale == 'sp') isOK = checkDateNull_fr (sDate);
  if (sLocale == 'en') isOK = checkDateNull_en (sDate);
  
  if (sMsg != '') {
    if (! isOK) window.alert (sDate+': '+sMsg);
  }
  
  return isOK;
}

//------------------------------------------------------------------------------

function ref_formatID (iID) {
  var sID = new String (iID);
  
  return sID.slice (0, 4)+'-'+sID.slice (4);
}

//------------------------------------------------------------------------------
// $Log: ref.js,v $
// Revision 1.3  2003/04/22 15:04:43  lc
// Enlarge windows
// Check date with or without alert window
//
// Revision 1.2  2003/03/07 13:56:25  lc
// Div (open/close) management
//
// Revision 1.1  2002/09/25 09:43:20  lc
// Initial revision.
//
//-- End of source  ------------------------------------------------------------
