// JavaScript Document
/* "adapted" from ala's domtricks2 */
/*  L'element plegador-desplegador ha de tenir la ID "Amaga#". 
    L'element a plegar-desplegar ha de tenir la ID "Taula#" */
/* Modificat per: Jordi Guilleumes, 29/10/2004 */
var IE;
function getUA() {
   if (navigator.appName.indexOf("Explorer") >= 0) { IE = true }
}

function showHide( TaulaNum ) {	
   if (getIdProperty( "Taula" + TaulaNum, "display") == "block" ) {
      setIdProperty("Taula" + TaulaNum, "display", "none");
      setIdProperty("Amaga" + TaulaNum, "background", "url(http://www.ub.edu/comint/img/deco/mes1.gif) 0 50% no-repeat");
      //setIdProperty("MesMenys" + TaulaNum, "src", "../etc/img/mes1.gif");
   } else {
      setIdProperty("Taula" + TaulaNum, "display", "block");
      setIdProperty("Amaga" + TaulaNum, "background", "url(http://www.ub.edu/comint/img/deco/menys1.gif) 0 50% no-repeat");
      //setIdProperty("MesMenys" + TaulaNum, "src", "../etc/img/menys1.gif");
   }
}

function getStyleBySelector( selector ) {
  if (IE) {
    return null;
  }
  var sheetList = document.styleSheets;
  var ruleList;
  var i, j;
  for (i=sheetList.length-1; i >= 0; i--) {
     ruleList = sheetList[i].cssRules;
     for (j=0; j<ruleList.length; j++) {
        if (ruleList[j].type == CSSRule.STYLE_RULE && ruleList[j].selectorText == selector) {
           return ruleList[j].style;
        }   
     }
  }
  return null;
}

function getIdProperty( id, property ) {
  if (!IE) {
     var styleObject = document.getElementById( id );
     if (styleObject != null) {
        styleObject = styleObject.style;
        if (styleObject[property]) {
           return styleObject[ property ];
        }
     }
     styleObject = getStyleBySelector( "#" + id );
     return (styleObject != null) ?  styleObject[property] : null;
  } else {
     return document.all[id].style[property];
  }
}

function setIdProperty( id, property, value ) {
  if (!IE) {
    var styleObject = document.getElementById( id );
    if (styleObject != null) {
       styleObject = styleObject.style;
       styleObject[ property ] = value;
    }   
  } else {
     document.all[id].style[property] = value;
  }
}