/***************************************************************************************************************************************/
/***************************************************************************************************************************************/
/*Clase _Layer
/*Compatibilitat testejada: NS7, IE6, Mozilla1.3
/***************************************************************************************************************************************/
/***************************************************************************************************************************************/
function _Layer_SetTop(){
  if (arguments.length > 0) if (!isNaN(parseInt(arguments[0]))) this._lyStyle.top = parseInt(arguments[0]);
  return parseInt(this._lyLayout.offsetTop);
}
function _Layer_SetLeft(){
  if (arguments.length > 0) if (!isNaN(parseInt(arguments[0]))) this._lyStyle.left = parseInt(arguments[0]);
  return parseInt(this._lyLayout.offsetLeft);
}
function _Layer_SetWidth(){
  if (arguments.length > 0) if (!isNaN(parseInt(arguments[0]))){
    this._lyStyle.width = (parseInt(arguments[0]) + (document.all? (this.lyBorderWidth() * 2):0));
    this.lyAutoSizeWidth(false);
  }
  return parseInt(this._lyLayout.offsetWidth);
}
function _Layer_SetHeight(){
  if (arguments.length > 0) if (!isNaN(parseInt(arguments[0]))){
    this._lyStyle.height = (parseInt(arguments[0]) + (document.all? (this.lyBorderWidth() * 2):0));
    this.lyAutoSizeHeight(false);
  }
  return parseInt(this._lyLayout.offsetHeight);
}
function _Layer_SetAutoSizeHeight(){
  if(arguments.length > 0){
    this._autoSizeHeight = arguments[0];
    this.lyAutoSize(false);
  }
  return this._autoSizeHeight;
}
function _Layer_SetAutoSizeWidth(){
  if(arguments.length > 0){
    this._autoSizeWidth = arguments[0];
    this.lyAutoSize(false);
  }
  return this._autoSizeWidth;
}
function _Layer_SetAutoSize(){
  with (this._lyStyle){
    if (arguments[0]){
      width = height = "auto";
      clip = "rect(0 auto auto 0)";
      this._autoSizeHeight = true;
      this._autoSizeWidth = true;
    }
    else if(arguments.length > 0){
      if (this._autoSizeWidth) width = "auto";
      if (this._autoSizeHeight) height = "auto";
      clip = "rect(0, " + (this._autoSizeWidth? "auto":this.lyWidth() + (2*parseInt(this._lyStyle.borderWidth))) + ", " + (this._autoSizeHeight? "auto" : this.lyHeight() + (2*parseInt(this._lyStyle.borderWidth))) + ", 0)";
    }
  }
  return (this._autoSizeHeight && this._autoSizeWidth);
}
function _Layer_SetBgColor(sBgColor){
  with (this._lyStyle){
    if (arguments.length > 0){
      if (arguments[0].toLowerCase() != "none") backgroundColor = arguments[0];
      else backgroundColor = "";
    }
    return (backgroundColor==""? "none": backgroundColor);
  }
}
function _Layer_SetBorderStyle(){
  if (arguments.length > 0) this._lyStyle.borderStyle = arguments[0];
  return this._lyStyle.borderStyle;
}
function _Layer_SetBorderWidth(){
  with (this._lyStyle){
    if (arguments.length > 0) if (!isNaN(parseInt(arguments[0]))){
      if (document.all){
        width = this._lyLayout.clientWidth + parseInt(arguments[0])*2;
        height = this._lyLayout.clientHeight + parseInt(arguments[0])*2;
      }
      borderWidth = parseInt(arguments[0]) + "px";
    }
    this.lyAutoSize(false);
    return  (isNaN(parseInt(borderWidth))? 0:parseInt(borderWidth));
  }
}
function _Layer_SetBorderColor(){
  with (this._lyStyle){
    if (arguments.length > 0) borderColor = (arguments[0].toLowerCase() != "none"? arguments[0]:"");
    return (borderColor==""? "none": borderColor);
  }
}
function _Layer_HTML(){
  if (arguments.length > 0){
    this._lyLayout.innerHTML = arguments[0];
    this.lyAutoSize(false);
  }
  return this._lyLayout.innerHTML;
}
function _Layer_Visibility(){ 
  with (this._lyStyle){
    if (arguments.length > 0) visibility = (arguments[0]=="hide"? "hidden" : "inherit");
    return (visibility == "visible"?  "show" : (visibility == "hidden"? "hide" : "inherit"));
  }
}
function _Layer(sNom){
  /*Arguments:
      arguments[0]: sNom: nom de la layer (requerit)
      arguments[1]: nom de la layer pare de la nova layer (opcional)
      arguments[2]: posició Top de la layer (opcional)
      arguments[3]: posició Left de la layer (opcional)
      arguments[4]: Amplada de la layer (opcional)
      arguments[5]: Alçada de la layer (opcional)
      arguments[6]: Color de fons de la layer (opcional)
      arguments[7]: Visibilitat de la capa (opcional) per defecte heredat del pare
      arguments[8]: Amplada del marc de la layer (opcional)
      arguments[9]: Color del marc de la layer (opcional)
      arguments[10]: Estil del marc de la layer (opcional)*/
  this.Nom = sNom;
  this._lyLayout = document.createElement("DIV");
  this._lyStyle = this._lyLayout.style;
  if (arguments[1]) arguments[1].appendChild(this._lyLayout);
  else document.body.appendChild(this._lyLayout);
  //inicialitzacions
  this._lyLayout.id = sNom;
  this._lyStyle.position = "absolute";
  this._lyStyle.overflow = "hidden";
  this._autoSizeHeight = this._autoSizeWidth = true;
  if (arguments[4] || arguments[5]) this.lyAutoSize(false);
  else this.lyAutoSize(true);
  this.lyTop((arguments[2]? arguments[2]:0));
  this.lyLeft((arguments[3]? arguments[3]:0));
  this.lyHeight(arguments[4]);
  this.lyWidth(arguments[5]);
  this.lyBgColor((arguments[6]? arguments[6]:"none"));
  this.lyVisibility((arguments[7]? arguments[7]:"inherit"));
  this.lyBorderWidth(arguments[8]?arguments[8]:0);
  this.lyBorderColor((arguments[9]? arguments[9]:"none"));
  this.lyBorderStyle((arguments[10]? arguments[10]:"none"));
}
_Layer.prototype.lyHTML = _Layer_HTML;
_Layer.prototype.lyAutoSize = _Layer_SetAutoSize;
_Layer.prototype.lyAutoSizeHeight = _Layer_SetAutoSizeHeight;
_Layer.prototype.lyAutoSizeWidth = _Layer_SetAutoSizeWidth;
_Layer.prototype.lyTop = _Layer_SetTop;
_Layer.prototype.lyLeft = _Layer_SetLeft;
_Layer.prototype.lyWidth = _Layer_SetWidth;
_Layer.prototype.lyHeight = _Layer_SetHeight;
_Layer.prototype.lyBgColor = _Layer_SetBgColor;
_Layer.prototype.lyVisibility = _Layer_Visibility;
_Layer.prototype.lyBorderWidth = _Layer_SetBorderWidth;
_Layer.prototype.lyBorderColor = _Layer_SetBorderColor;
_Layer.prototype.lyBorderStyle = _Layer_SetBorderStyle;
/***************************************************************************************************************************************/
/***************************************************************************************************************************************/
/*Clase _Layer
/*Compatibilitat testejada: NS7, IE6, Mozilla1.3
/***************************************************************************************************************************************/
/***************************************************************************************************************************************/