function show(obj) {
	document.getElementById(obj).style.display = 'block';
}

function hide(obj) {
	document.getElementById(obj).style.display = 'none';
}

function showHide(obj) {
    document.getElementById(obj).style.display = (document.getElementById(obj).style.display == 'block') ? 'none' : 'block';
}

/*####################################################################*/

function hideThem(obj, b, d) {
var a;
for (a=1; a<=d; a++) {
    var c = b+a;
    if (obj == c) {
        document.getElementById(c).style.display = (document.getElementById(c).style.display=='block') ? 'none' : 'block';
        }
    else {
    document.getElementById(c).style.display = 'none';
        }
    }
}

function showIn(image, ALL, CNT, TGT, w, h) {

  var wImg = w;
  var hImg = h;

	var x,y;
	if (window.innerHeight)  {
		x = window.innerWidth;
		y = window.innerHeight;
	}
	else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 e 7 Strict Mode
		var IE = true;
		x = document.documentElement.clientWidth;
		y = document.documentElement.clientHeight;
	}
	else if (document.body) {
		x = document.body.clientWidth;
		y = document.body.clientHeight;
	}
    
            var scrOfX = 0, scrOfY = 0;
          if( typeof( window.pageYOffset ) == 'number' ) {
            //Netscape compliant
            scrOfY = window.pageYOffset;
            scrOfX = window.pageXOffset;
          } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
            //DOM compliant
            scrOfY = document.body.scrollTop;
            scrOfX = document.body.scrollLeft;
          } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
            //IE6 standards compliant mode            
            scrOfY = document.documentElement.scrollTop;
            scrOfX = document.documentElement.scrollLeft;
          }
    if(document.getElementById(TGT).innerHTML) document.getElementById(TGT).innerHTML=''; //<-- se c'è già un'immagine, cancellala!
  
    var HeightPage = '';
    var Props = 'document.body.scrollHeight';
    
    var end = Props.substring(Props.lastIndexOf('.')+1); 
    var newprop = 'document.documentElement.' + end;
    if (eval(newprop)) HeightPage += eval(newprop);
    
    
    document.getElementById(ALL).style.display = 'block';
    document.getElementById(ALL).style.height = HeightPage+'px';
    
    document.getElementById(CNT).style.width = (parseFloat(w)+62)+'px';
    document.getElementById(CNT).style.height = (parseFloat(h)+62)+'px';
    
    document.getElementById('sx').style.height = (parseFloat(h)+2)+'px';
    document.getElementById('dx').style.height = (parseFloat(h)+2)+'px';
    document.getElementById('Top').style.width = (parseFloat(w)+2)+'px';
    document.getElementById('Bot').style.width = (parseFloat(w)+2)+'px';

    w = (parseFloat(w) + 124);
    h = (parseFloat(h) + 124);

    var top = Math.round((y - h) / 2) + scrOfY;
    if (top<=0) top=20;
    var left = ((x - w) / 2);

    document.getElementById(CNT).style.marginTop = top + 'px';
    document.getElementById(CNT).style.marginLeft = left + 'px';
    
    var outPut = '<a href="javascript:void(0);" title=" |>CLICK<|2|Close| " onclick="hide(\''+ ALL +'\');"><img src=' + image + ' width=' + wImg + ' height=' + hImg + ' alt="" /></a>';
    if (IE) {
        setTimeout(function write() {
        document.getElementById(TGT).innerHTML = outPut;
        //clearTimeout(pause);
        },40);
    }
    else document.getElementById(TGT).innerHTML = outPut;
    //alert('HeightPage= '+HeightPage+'\nProps= '+Props+'\nend= '+end+'\nnewprop= '+newprop+'\nscrOfY= '+scrOfY+'\nscrOfX= '+scrOfX+'\nw= '+w+'\nh= '+h+'\nx= '+x+'\ny= '+y+'\n\ntop= '+top+'\nleft= '+left);
    }

/*####################################################################*/

function checkSend() {
    var nome = document.contatti.nome.value;
    var cognome = document.contatti.cognome.value;
    var mail = document.contatti.mail.value;
    var mail_reg_exp = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-]{2,})+\.)+([a-zA-Z0-9]{2,})+$/;
    var oldMess = document.contatti.message.value;
    var mess = document.contatti.message.value;
    
    if (!nome) {
    alert('Inserisci il tuo NOME, grazie.');
    document.contatti.nome.focus();
    return false;
    }
    else if (!cognome) {
    alert('Inserisci il tuo COGNOME, grazie.');
    document.contatti.cognome.focus();
    return false;
    }
    else if (!mail) {
    alert('Inserisci il tuo indirizzo E-MAIL, grazie.');
    document.contatti.mail.focus();
    return false;
    }
    else if (!mail_reg_exp.test(mail)) {
    alert('L\'indirizzo E-Mail inserito non è corretto!');
    document.contatti.mail.select();
    return false;
    }
    
    else if (!mess) {
    alert('Non hai scritto nulla\nnel "Contenuto del Messaggio"!');
    document.contatti.message.focus();
    return false;
    }
    
    else if (mess=="Ciao Ale!\r\nTi scrivo perché...") {
    alert('Non hai aggiunto niente\nal contenuto del messaggio!');
    document.contatti.message.focus();
    return false;
    }
    
    else {
    document.contatti.action = "check.php";
    document.contatti.submit();
    }
    return false;
}  

/*####################################################################*/

function cancella() {
var messaggio = confirm("Questa operazione cancellerà tutti i dati inseriti.\nProcedo ugualmente?");
document.contatti.focus();
return messaggio;
}
/*####################################################################*/
