if (document.getElementById)
	w3c = true;
else 
	w3c = false;
if (document.all) 
	ie4 = true;
else
	ie4 = false;

function semaphore(campo) {
	campo.value = "si";
}

function seleziona(nome) {
	var elemento;
	if (w3c) {elemento = document.getElementById(nome);}
	else {if (ie4) {elemento = document.all(nome); }
	else {alert('Questo browser non supporta l\'operazione richiesta'); elemento=false;}}
	return elemento;
}
function vuota(elemento) {
         var indice; var ultimo; var lunghezza;
         while (lunghezza = elemento.childNodes.length) {
		indice = lunghezza - 1;
		ultimo = elemento.childNodes[indice];
		elemento.removeChild(ultimo);
	 }
}
function chiudiMsg() {
         var div = seleziona('msgDiv');
         div.style.visibility='hidden';
}
function opacity(id, opacStart, opacEnd, millisec) {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;

    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
        for(i = opacStart; i >= opacEnd; i--) {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    } else if(opacStart < opacEnd) {
        for(i = opacStart; i <= opacEnd; i++)
            {
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
            timer++;
        }
    }
}

//change the opacity for different browsers
function changeOpac(opacity, id) {
	var element = seleziona(id);
    var object = element.style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function showElement(name) {
   var el = seleziona(name);
   el.style.display = 'block';
}
function hideElement(name) {
   var el = seleziona(name);
   el.style.display = 'none';
}
function checkBodyHeight() {
   var h = 0; var w = 0;
   if (document.body.scrollWidth) {
	 w = document.body.scrollWidth;
	 h = document.body.scrollHeight;
   } else {
	 w = document.width;
	 h = document.height;
   }
alert('document.body.clientHeight = ' + document.body.clientHeight);
alert('document.body.scrollHeight = ' + document.body.scrollHeight);
alert('document.body.offsetHeight = ' + document.body.offsetHeight);
alert('window.innerHeight = ' + window.innerHeight);
alert('container height = ' + document.getElementById('container').offsetHeight);
}
