function DHTML() {return ((document.getElementById || document.all || document.layers));}

function pageWidth() {return window.innerWidth != null? window.innerWidth: document.body != null? document.body.clientWidth:null;}

function pageHeight() {return window.innerHeight != null? window.innerHeight: document.body != null? document.body.clientHeight:null;}

function posLeft() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}

function posTop() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}

function posRight() {return posLeft()+pageWidth();}

function posBottom() {return posTop()+pageHeight();}

var ua = navigator.userAgent.toLowerCase();
var	browserIE = ((ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1)); 
var	browserGecko = (ua.indexOf("gecko") != -1);
var	browserSafari = (ua.indexOf("safari") != -1);
var	browserKonqueror = (ua.indexOf("konqueror") != -1);

//**************************************************************
function getObj(name)
{
  if (document.getElementById)
  {
    this.obj = document.getElementById(name);
	  this.style = document.getElementById(name).style;
  }
  else if (document.all)
  {
	  this.obj = document.all[name];
	  this.style = document.all[name].style;
  }
  else if (document.layers)
  {
    this.obj = document.layers[name];
    this.style = document.layers[name];
  }
}

//**************************************************************
function nascondi(nome, pnascondo)
{
	if (!DHTML()) return;
	var x = new getObj(nome)
	x.style.visibility = (pnascondo) ? 'hidden' : 'visible'
}

//**************************************************************
function controlla_frames()
{
	top.window.name="";
	if (!DHTML()) return;
	if(parent.frames.length==0){
     var x = new getObj('frameset');
	   x.style.visibility = 'visible';
  }
}

//**************************************************************
function chiudi_frames()
{
	if(parent.frames.length!=0){
     parent.location=top.frames['frame_oggetti'].location;
  }
}

//**************************************************************
function refresh(pframe)
{
if(parent.frames.length>0){top.pframe.location.reload();}
}

//**************************************************************
function swapThisStile(x){

if (!DHTML()) return;
var s=x.className;
if(s.indexOf('1')>0){s=s.replace('1','0');}else {s=s.replace('0','1');}
x.className=s;
}

//**************************************************************
function swapIDStile(pID)
{
  if (!DHTML()) return;
  
  if (document.getElementById)
  {
     swapThisStile(document.getElementById(pID));
  }
  else if (document.all)
  {
    swapThisStile(document.all[pID]);
  }
  else if (document.layers)
  {
     swapThisStile(document.layers[pID]);
  }

}

//**************************************************************
function swapIDFile(pID)
{
  if (!DHTML()) return;
  if (document.getElementById)
  {
    var s=document.getElementById(pID).src;
  }
  else if (document.all)
  {
    var s=document.all[pID].src;
  }
  else if (document.layers)
  {
    var s=document.layers[pID].src;
  }

  if(s.indexOf('_on')>0){s=s.replace('_on','_off');}else {s=s.replace('_off','_on');}

  if (document.getElementById)
  {
    document.getElementById(pID).src=s;
  }
  else if (document.all)
  {
    document.all[pID].src=s;
  }
  else if (document.layers)
  {
    document.layers[pID].src=s;
  }
}

//**************************************************************
function FormatNumber(numero,CifreDecimali)
{
  var pnum=''+numero;
	pnum=pnum.replace(',','.');
	pnum=parseFloat(pnum);
  if(isNaN(pnum)) return "";

	var segno = pnum < 0 ? -1 : 1;
	pnum=Math.abs(pnum);
  var intero=Math.floor(pnum);
	var decimali=(pnum-intero)+'0000000000';
	var virgola=decimali.indexOf('.');
	decimali=decimali.substring(virgola+1,virgola+1+CifreDecimali);
	if(!segno){intero='-'+intero;}
	return intero+','+decimali;
}

//**************************************************************


