var XMLHttpRequestObject = false;

if (window.XMLHttpRequest) {
	XMLHttpRequestObject = new XMLHttpRequest();
	}
	else if (window.ActiveXObject) {
		XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHTTP");
	}
	
function showerror(tid, testo) {
	var tid;
	tid = document.getElementById(tid);
	tid.style.display = "block";
	tid.innerHTML = testo;
}

function showresponse(tid, testo) {
	var tid;
	tid = document.getElementById(tid);
	tid.style.display = "block";
	tid.innerHTML = testo;
	document.getElementById("marginForm").style.display = "none";
	document.getElementById("formhidden").style.display = "none";
	//clearform("marginForm")
}

function showresponsecartolina(tid, testo) {
	var tid;
	tid = document.getElementById(tid);
	tid.style.display = "block";
	tid.innerHTML = testo;
	document.getElementById("formhidden").style.display = "none";
	document.getElementById("comando").style.display = "none";
	//clearform("marginForm")
}

function showresponsesito(tid, testo) {
	var tid;
	tid = document.getElementById(tid);
	tid.style.display = "block";
	tid.innerHTML = testo;
	document.getElementById("marginForm").style.display = "none";
	//clearform("marginForm")
}

function splitidcartolina(id1, id2, idresponse, idcmd, txt1, txt2){
	id1 = document.getElementById(id1);
	id2 = document.getElementById(id2);
	idresponse = document.getElementById(idresponse);
	if (id1.style.display == "block") {
		id1.style.display = "none";
		id2.style.display = "block";
		idcmd.innerHTML = txt1;
		idresponse.style.display = "none";
		}
	else{
		id1.style.display = "block";
		id2.style.display = "none";
		idcmd.innerHTML = txt2;
		}
}

function splitidsito(id1, id2, idresponse, idcmd, txt1, txt2){
	id1 = document.getElementById(id1);
	id2 = document.getElementById(id2);
	idresponse = document.getElementById(idresponse);
	if (id1.style.display == "block") {
		id1.style.display = "none";
		id2.style.display = "block";
		document.getElementById("marginForm").style.display = "block";
		idcmd.innerHTML = txt1;
		idresponse.style.display = "none";
		}
	else{
		id1.style.display = "block";
		id2.style.display = "none";
		idcmd.innerHTML = txt2;
		}
}


function splitid(id1, id2, txt1, txt2, idcmd){
	id1 = document.getElementById(id1);
	id2 = document.getElementById(id2);
	if (id1.style.display == "block") {
		id1.style.display = "none";
		id2.style.display = "block";
		idcmd.innerHTML = txt2;
		}
	else{
		id1.style.display = "block";
		id2.style.display = "none";
		idcmd.innerHTML = txt1;
		}
}

function splitidsemplice(iddanascondere, iddavisualizzare){
	iddanascondere = document.getElementById(iddanascondere);
	iddavisualizzare = document.getElementById(iddavisualizzare);
	if (iddanascondere.style.display == "block") {
		iddanascondere.style.display = "none";
		iddavisualizzare.style.display = "block";
			}
	else{
		iddanascondere.style.display = "block";
		iddavisualizzare.style.display = "none";
		}
}

function clearform(frm){
	document.forms[frm].reset();
}

// Controllo testi composti di soli spazi
function isBlank(s){
	for(i=0;i<s.length;i++) {
    	c=s.charAt(i);
        if((c!=' ')&&(c!='\n')&&(c!='\t')){return false;}
	}
    return true;
}

// Controllo attivazione Javascript
function jstest(){
	var divjstet;
	divjstet = document.getElementById("jstest");
	divjstet.innerHTML = "";
}

function popupSegnalaPagina(f, windowname){
	var txtIndirizzoOpener;
	txtIndirizzoOpener = document.location;
	f.indirizzo.value = txtIndirizzoOpener; 
	window.open('', windowname, 'height=400,width=630,scrollbars=no');
	f.target = windowname;
	return true;
}

function checkTextAreaLengthSegnalaSito(str, varlength) {
	var strTesto = str.value;
	if (strTesto.length > varlength) {
		alert("Il testo della descrizione non deve superare i " + varlength + " caratteri");
		str.value = strTesto.slice(0, varlength);
		return false;
	}
}



// ancora da testare

function hideresponse(targetname) {
	var divtarget;
	divtarget = document.getElementsByName(targetname);
	for (var j=0; j<divtarget.length; j++){
		divtarget[j].style.display = "none";
	}
}


	

