/**
 * Copyright 2003, IMTEAM www.imteam.it
 * QUESTO PROGRAMMA E' COPERTO DA COPYRIGHT E NON PUO' ESSERE COPIATO O
 * MODIFICATO (NEMMENO PARZIALMENTE) SENZA ESPLICITO CONSENSO DEL PROPRIETARIO.
 * NON PUO' ESSERE UTILIZZATO AL DI FUORI DEL PRODOTTO CON CUI E' STATO FORNITO.
 */

//  DATA ULTIMA MODIFICA: 2003-10-17;
//  VERSIONE: 0.1-2003;
//  MODIFICATO: C.Lanza clanza@imteam.it;

/* Versione: $Revision: 1.3 $ */


var toolDescrizione = 'descrFunz';

// clip layer display to clipleft, cliptip, clipright, clipbottom
// Not working with Mozilla Milestone 12 (Nav5)
function layerClip2(name, clipleft, cliptop, clipright, clipbottom) {
  this.layer = layerGetStyle(name);
  if ( typeof(is)=="undefined" || is == null || this.layer == null) {
    return true;
  }
  if (is.ns4) {
    this.layer.clip.left   = clipleft;
    this.layer.clip.top    = cliptop;
    this.layer.clip.right  = clipright;
    this.layer.clip.bottom = clipbottom;
  } else {
    this.layer.clip = 'rect(' + cliptop + 'px, ' +  clipright + 'px, ' + clipbottom + 'px, ' + clipleft +'px)';
  }
  return true;
}

// ATTENZIONE ! Non è da cancellare perchè viene utilizzata da mapDrawZoomBox
function layerClip(name, clipleft, cliptop, clipright, clipbottom) {
  this.layer = layerGetStyle(name);
  if ( typeof(is)=="undefined" || is == null || this.layer == null) {
    return true;
  }
  if (is.ns4) {
      this.layer.clip.left   = clipleft;
      this.layer.clip.top    = cliptop;
      this.layer.clip.right  = clipright;
      this.layer.clip.bottom = clipbottom;
  } else {
    var newWidth = clipright - clipleft;
    var newHeight = clipbottom - cliptop;
    this.layer.height = newHeight + "px";
    this.layer.width    = newWidth + "px";
    this.layer.top  = cliptop + "px";
    this.layer.left = clipleft + "px";
  }
  return true;
}

function layerGetStyle(name) {
  if ( typeof(is)=="undefined" || is == null) {
    return null;
  }
  if (is.ns4) {
    return(window.document.layers[name]);
  }
  if (is.ie4) {
    this.style = window.document.all[obj].style;
    return this.style;
  }
  if (is.ns6 || is.ie5) {
    this.style = document.getElementById(name).style;
    return this.style;
  }
  if (is.not) {
    return null;
  }
}

function layerGet(name) {
  if ( typeof(is)=="undefined" || is == null) {
    return null;
  }
  if (is.ns4) {
    return(window.document.layers[name]);
  }
  if (is.ie4) {
    return window.document.all[obj];
  }
  if (is.ns6 || is.ie5) {
    return document.getElementById(name);
  }
  if (is.not) {
    return null;
  }
}

function layerHide(name) {
  this.layer = layerGetStyle(name);
  if ( typeof(is)=="undefined" || is == null || this.layer == null) {
    return true;
  }
  if (is.ns4) {
    this.layer.visibility = "hide";
  } else {
    this.layer.visibility = "hidden";
    this.layer.display="none";
    this.layer.speak="none";
  }
  return true;
}

function layerShow(name) {
  this.layer = layerGetStyle(name);
  if ( typeof(is)=="undefined" || is == null || this.layer == null) {
    return true;
  }
  if (is.ns4) {
    this.layer.visibility = "show";
  } else {
    this.layer.display="";
    this.layer.speak="";
    this.layer.visibility = "visible";
  }
  return true;
}

// move layer to coords
function layerMove(name, x, y) {
  this.layer = layerGetStyle(name);
  if (is.ns4) {
    this.layer.moveTo(x, y);
  } else {
    this.layer.left = x + "px";
    this.layer.top  = y + "px";
  }
}

function layerSwitchVisibility(name) {
  return (layerIsVisibile(name)) ? layerHide(name) : layerShow(name);
}

function layerIsVisibile(name) {
  return ((layerGetStyle(name).visibility == "show") || (layerGetStyle(name).visibility == "visible"));
}

function layerChangeMouseLayout(obj) {
  this.style = layerGetStyle(obj);
  if ( typeof(is)=="undefined" || is == null) {
    return true;
  }
  if (is.ie5) {
    this.style.cursor = "hand";
  } else {
    this.style.cursor = "pointer";
  }
  return true;
}
