/* Rende un array contenente la grandezza (in px) della finestra del browser */
function grandezzaFinestraBrowser() {
if (window.innerHeight) {
   doc_height = window.innerHeight;
   doc_width = window.innerWidth;
} else {
   doc_height = document.documentElement.clientHeight;
   doc_width = document.documentElement.clientWidth;
}
return([doc_width, doc_height]);
}
/* Rende un array contenente la grandezza (in px) dell'oggetto passato come ID */
function grandezzaOggetto(id) {
o = document.getElementById(id);
/* if (o.innerHeight) {
   obj_height = o.innerHeight;
   obj_width = o.innerWidth;
} else { */
   obj_height = o.offsetHeight;
   obj_width = o.offsetWidth;
/* } */
return([obj_width, obj_height]);
}
/* Rende la posizione (in px) dell'angolo in alto a sinistra dell'oggetto passato come ID */
function posizioneOggetto(id) {
o = document.getElementById(id);
obj_top = o.offsetTop;
obj_left = o.offsetLeft;
return([obj_left, obj_top]);
}
/* Imposta la proprieta' dell'oggetto passato come ID */
function scriviProprieta(id, propr, valore) {
/*  Parametri _______________________________________________
 *  oggetto   : id dell'oggetto su cui operare
 *  proprieta : la proprieta' da alterare
 *  valore    : il valore da impostare
 *  Rende ___________________________________________________
 *  - se "S"  : true
 *  - se "L"  : il valore letto
 */
o = document.getElementById(id);
if (o == null)    return;
if (o.style.setAttribute) {
   prop = propr;
   if (propr == "background-color")    prop = "backgroundColor";
   if (propr == "text-align")          prop = "textAlign";
   if (propr == "margin-left")         prop = "marginLeft";
   if (propr == "margin-top")        prop = "marginTop";
   o.style.setAttribute (prop, valore);
} else {
   o.style.setProperty (propr, valore, null);
}
}
/* Rende la z-index dell'oggetto passato come ID */
function zindexOggetto(id) {
o = document.getElementById(id)
if (o.currentStyle)
   v = o.currentStyle["zIndex"];
else
   v = document.defaultView.getComputedStyle(o, null).getPropertyValue("z-index");
/* if (oggetto.style.getPropertyCSSValue)
   v = oggetto.style.getPropertyCSSValue("zIndex");
else
   v = oggetto.style.zIndex; */
return(v);
}
/* Rende true se JavaScript deve essere usato per gestire la formattazione
   USA UN RIFERIMENTO CABLATO ALL'INTERNO DELLA FUNZIONE PER L'OGGETTO id='testat1' */
function jsUsato() {
z = zindexOggetto('testat1');
if (z == 98) /* Il browser supporta CSS3 stili condizionali */
  return(true);
else
  return(false);
}
/* Esegue il reload solo se serve. Ha bisogno dell' ID dell'oggetto da passare a */
function doReload() {
   if (jsUsato())
      window.location.href = window.location.href;
}
