/**********************************************************************
# js/css dhtml menu
# 
#  Copyright 2005 Christophe Le Bars - 2FP
#
#   This program is free software; you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation; either version 2 of the License, or
#   (at your option) any later version.
#
#   This program 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 General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with this program; if not, write to the Free Software
#   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
**********************************************************************/

var isDOM = (document.getElementById ? true : false);
var isIE4 = ((document.all && !isDOM) ? true : false);
var isNS4 = (document.layers ? true : false);
var isDyn = (isDOM || isIE4 || isNS4);

function getTag(id) {
  if (isDOM) return document.getElementById(id);
  if (isIE4) return document.all[id];
  if (isNS4) return document.layers[id];
}

function getTagStyle(id) {
  return (isNS4 ? getTag(id) : getTag(id).style);
}


var current = new Array();
var lastlevel2 = null;

function hide(level) {

      // if (navigator.appName != "Microsoft Internet Explorer") { return;}
      for (var i = level; i < current.length; i++) { 
           if (current[i]) {
               st = getTagStyle(current[i]);
               st.visibility = 'hidden';
	       current[i] = null;
           }
          if (i==2) menuoff(lastlevel2);
      } 
      
}

function down(name,level,t) {

      // if (navigator.appName != "Microsoft Internet Explorer") { return;}
      
      s = getTagStyle(name);

      if (s.visibility != 'visible') {
	  hide(level);

          if (level==3) {
		menuoff(lastlevel2,2);
		menuon(t,2);
          }

          s.visibility = 'visible';
          current[level] = name;
      }
 
}

function upcurrent() {

    if (current) {
         getTagStyle(current).visibility = 'hidden';
         current = null;
    }

}

function menuon(t, level) {

     if (current[level+1]) return;
     if (level==2) lastlevel2 = t;

     t.style.color = '#fff';
     t.style.background = '#c10012';
}


function menuoff(t, level) {

      if (current[level+1]) return;

      if (t) {
            t.style.background = '#fff';
	    t.style.color = '#000';
	  }
}


/*      */

function subcheck(t, c, cat) {

        var f=t.form;
        var m=t.value;

        for (var i=0; i < f.elements.length; i++) {
            if (f.elements[i] != t && f.elements[i].type == "checkbox") {
	       if (c == 'exclusive' || f.elements[i].id == cat ) {
                        if (t.checked) {
                                f.elements[i].disabled = true;
                                f.elements[i].checked = false;
                                //f.elements[i].style.background = "#dddddd";
                        } else {
                                f.elements[i].disabled = false;
                                //f.elements[i].style.background = "#ffffff";
                        }
		} 
            }
        }
}


function confirmation (url, my_message) {

	if (confirm (my_message)) {

	   window.location = url;
	
	}
}

function openWin(URLtoOpen, windowName, windowFeatures) {

        if (windowFeatures.search(/scrollbars/) == -1) {
                windowFeatures = windowFeatures + ",scrollbars=0";
        }
        if (windowFeatures.search(/resizable/) == -1) {
                windowFeatures = windowFeatures + ",resizable=0";
        }
        if (windowFeatures.search(/toolbar/) == -1) {
                windowFeatures = windowFeatures + ",toolbar=0";
        }
        if (windowFeatures.search(/titlebar/) == -1) {
                windowFeatures = windowFeatures + ",titlebar=0";
        }
        if (windowFeatures.search(/status/) == -1) {
                windowFeatures = windowFeatures + ",status=0";
        }
        if (windowFeatures.search(/location/) == -1) {
                windowFeatures = windowFeatures + ",location=0";
        }
        if (windowFeatures.search(/width/) == -1) {
                windowFeatures = windowFeatures + ",width=700";
        }
        if (windowFeatures.search(/height/) == -1) {
                windowFeatures = windowFeatures + ",height=480";
        }
        var popupWin = window.open(URLtoOpen, windowName, windowFeatures); 
        popupWin.focus();
}
