
var baseUrl = "/hci/";
var questid = 115;  // ;
var userid = 0;
var tStart  = null;
var tempi = null;
var userlog = null;


function load () {
        //alert ("load");
	ajaxLoadRegistrationForm();
}

/**
 * la prima funzione chiamata. chiama registration.do, 
 * e passa la palla a registrationCallback
 */

function ajaxLoadRegistrationForm () {
        //alert ("ajaxLoadRegistrationForm");
	var url = baseUrl + "registration.do?mini=true&questid=" + questid;
	document.body.style.cursor = "wait";
        //sending.style.visibility = "visible";
        //alert ("ajaxLoadRegistrationForm: " + url);
	var request = YAHOO.util.Connect.asyncRequest("get", url, registrationCallback, null);
	return false;
}

/**
 *  registration.do, nella versione mini, ritorna "pseudoform"
 *  
 *  <pseudoform>
<input type="hidden" name="testid" value="<%=test.getId()%>" />
<input type="hidden" name="questid" value="<%=questionnaire.getId()%>" />
<input type="hidden" name="condition" value="<%=condition%>" />
<input type="hidden" name="referer" value="<%=referer%>" />
<input type="hidden" name="mini" value="true" />
</pseudoform>
 *
 *  praticamente: legge le info e le scrive nel form.
 *  uno script nella pagina html associa il bottone ad ajaxRegister
 */

var registrationCallback = {
	timeout: 5000,
        success: function (oResponse) {
                //alert ("registrationCallback");
                var pag1 = document.getElementById ("pag1");
                pag1.style.display = "block";
                pag1.style.visibility = "visible";
                //handle a successful response
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                
                var xmlDoc = oResponse.responseXML;
                //  var pseudoform = xmlDoc.documentElement.getElementsByTagName("pseudoform");
                var inputs = xmlDoc.documentElement.getElementsByTagName("input");
                var newForm = document.getElementById("regForm");
                
                //newForm.setAttribute ("action","registerUser.do");
                //newForm.setAttribute ("method","POST");

                for (var i = 0; i < inputs.length; i++) {
                        var theInput = inputs[i];
                        var name = theInput.getAttribute ('name');
                        var value = theInput.getAttribute ('value');
                        var newInput = document.createElement ("input");
                        newInput.setAttribute ("type","hidden");
                        newInput.setAttribute ("name",name);
                        newInput.setAttribute ("value",value);
                        newForm.appendChild(newInput);

                }
                var registerButton = document.getElementById("registerButton");
                YAHOO.util.Event.on(registerButton, 'click', ajaxRegister,null,false);
        },
        failure: function (oResponse) {
                printFailure ("");
                return false;
        }
}


/**
 *  chiamata dal bottone di pagina1
 *  invoca registerUser.do, e associa la risposta al registerCallback appropriato
 *
 *
 */


function ajaxRegister () {
        //alert ("ajaxRegister");
	var url = baseUrl + "registerUser.do";
	//alert (url);
	document.body.style.cursor = "wait";
        //sending.style.visibility = "visible";
	var oForm = document.getElementById("regForm");
	YAHOO.util.Connect.setForm(oForm);
	var request =YAHOO.util.Connect.asyncRequest("get", url, registerCallbackCons);
	//var request =YAHOO.util.Connect.asyncRequest("get", url, registerCallbackCS);
	return false;
}


// =====================================


var registerCallbackFreeListing = {
	timeout: 20000,
        success: function (oResponse) {
                //handle a successful response
                //alert ("registerCallback");
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                var testo = oResponse.responseText;
                var theTest = document.getElementById ("theTest");
                var theFLForm = document.createElement ("form");
                theFLForm.setAttribute ("method","post");
                theFLForm.setAttribute ("id","flForm");
                theFLForm.innerHTML = testo;
                theTest.appendChild (theFLForm);
                var theButton2 = document.createElement("input");
                theButton2.setAttribute ("id","testButton");
                theButton2.setAttribute ("type","submit");
                theButton2.setAttribute ("value","invia le tue risposte");
                YAHOO.util.Event.on(theButton2, 'click', ajaxFLSubmit,null,false);
                theTest.appendChild (theButton2);
                var pag1 = document.getElementById ("pag1");
                pag1.parentNode.removeChild (pag1);
                var pag2 = document.getElementById ("pag2");
                pag2.style.display = "block";
                pag2.style.visibility = "visible";
        },
        failure: function (oResponse) {printFailure ("");return false;}
}


var registerCallbackCons = {
	timeout: 20000,
        success: function (oResponse) {
                //handle a successful response
                //alert ("registerCallback");
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                //var testo = oResponse.responseText;
                //alert (testo);
                var xmlDoc = oResponse.responseXML;
                //alert (xmlDoc);

                
                var inputs = xmlDoc.documentElement.getElementsByTagName("input");
                var useridInput = inputs[0];
                userid = useridInput.getAttribute ('value');
                //  alert ("userid: " + userid);
                
                var theTestForm = document.getElementById("consForm");
                //theFLForm.innerHTML = testo;
                useridInput = document.createElement("input");
                useridInput.setAttribute ("id","userid");
                useridInput.setAttribute ("type","hidden");
                useridInput.setAttribute ("value",userid);
                theTestForm.appendChild (useridInput);
                
                var questidInput = document.createElement("input");
                questidInput.setAttribute ("id","questid");
                questidInput.setAttribute ("type","hidden");
                questidInput.setAttribute ("value",questid);
                theTestForm.appendChild (questidInput);
                
                var theButton2 = document.createElement("input");
                theButton2.setAttribute ("id","testButton");
                theButton2.setAttribute ("type","submit");
                theButton2.setAttribute ("value","invia le tue risposte");
                YAHOO.util.Event.on(theButton2, 'click', ajaxConsSubmit,null,false);
                theTestForm.parentNode.appendChild (theButton2);
                var pag1 = document.getElementById ("pag1");
                pag1.parentNode.removeChild (pag1);
                var pag2 = document.getElementById ("pag2a");
                pag2.style.display = "block";
                pag2.style.visibility = "visible";
                document.body.style.cursor = "default";
        },
        failure: function (oResponse) {printFailure ("");return false;}
}


function ajaxConsSubmit () {
        // alert ("ajaxConsSubmit");
	var url = baseUrl + "production.do";
	//alert (url);
	document.body.style.cursor = "wait";
        //  sending.style.visibility = "visible";
	//  var theTest = document.getElementById ("theTest");
	var theConsForm = document.getElementById("consForm");
	YAHOO.util.Connect.setForm(theConsForm);
	var request = YAHOO.util.Connect.asyncRequest("post", url, consSubmitCallback);
	return false;
}

var consSubmitCallback = {
	timeout: 5000,
        success: function (oResponse) {
                //handle a successful response
                //  alert ("consSubmitCallback success 0 " + userid);
                
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                
                document.body.style.cursor = "default";

                var theTestForm = document.getElementById("prosForm");
                //alert ("consSubmitCallback success 1 ");
                //theFLForm.innerHTML = testo;
                useridInput = document.createElement("input");
                useridInput.setAttribute ("id","userid");
                useridInput.setAttribute ("type","hidden");
                useridInput.setAttribute ("value",userid);
                theTestForm.appendChild (useridInput);
                //alert ("consSubmitCallback success 2 ");
                
                var questidInput = document.createElement("input");
                questidInput.setAttribute ("id","questid");
                questidInput.setAttribute ("type","hidden");
                questidInput.setAttribute ("value",questid);
                theTestForm.appendChild (questidInput);
                //alert ("consSubmitCallback success 3 ");
                
                var theButton2 = document.createElement("input");
                theButton2.setAttribute ("id","testButton");
                theButton2.setAttribute ("type","submit");
                theButton2.setAttribute ("value","invia le tue risposte");
                YAHOO.util.Event.on(theButton2, 'click', ajaxProsSubmit,null,false);
                theTestForm.parentNode.appendChild (theButton2);
                //alert ("consSubmitCallback success 4 ");
                var pag2a = document.getElementById ("pag2a");
                pag2a.parentNode.removeChild (pag2a);
                //alert ("consSubmitCallback success 5 ");
                var pag2b = document.getElementById ("pag2b");
                pag2b.style.display = "block";
                pag2b.style.visibility = "visible";
                //alert ("consSubmitCallback success 6 ");



        },
        failure: function (oResponse) {
                //  alert ("consSubmitCallback failure");
                return false;
        }
}

function ajaxProsSubmit () {
        //  alert ("ajaxProsSubmit");
	var url = baseUrl + "production.do";
	//alert (url);
	document.body.style.cursor = "wait";
        //  sending.style.visibility = "visible";
	//  var theTest = document.getElementById ("theTest");
	var prosForm = document.getElementById("prosForm");
	YAHOO.util.Connect.setForm(prosForm);
	var request = YAHOO.util.Connect.asyncRequest("get", url, prosSubmitCallback);
	return false;
}

var prosSubmitCallback = {
	timeout: 20000,
        success: function (oResponse) {
                //alert ("success");
                //handle a successful response
                //sending.style.visibility = "hidden";
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                var pag2b = document.getElementById ("pag2b");
                pag2b.parentNode.removeChild (pag2b);

                var testo = oResponse.responseText;
                var theFeedback = document.getElementById ("theFeedback");
                var theFBForm = document.createElement ("form");
                theFBForm.setAttribute ("method","post");
                theFBForm.setAttribute ("id","fbForm");
                theFBForm.innerHTML = testo;
                theFeedback.appendChild (theFBForm);
                var theButton3 = document.createElement("input");
                theButton3.setAttribute ("id","fbButton");
                theButton3.setAttribute ("type","submit");
                theButton3.setAttribute ("value","invia i tuoi suggerimenti");
                YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
                theFeedback.appendChild (theButton3);
                var pSuggest = document.getElementById ("pSuggest");
                pSuggest.style.display = "block";
                pSuggest.style.visibility = "visible";
	
        },
        failure: function (oResponse) {
                printFailure ("");
                return false;
        }
}


var registerCallbackImportance = {timeout: 20000,
        success: function (oResponse) {
                //handle a successful response
                //alert ("registerCallback");
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                var testo = oResponse.responseText;
                var theTest = document.getElementById ("theTest");
                var theFLForm = document.createElement ("form");
                theFLForm.setAttribute ("method","post");
                theFLForm.setAttribute ("id","flForm");
                theFLForm.innerHTML = testo;
                theTest.appendChild (theFLForm);
                var theButton2 = document.createElement("input");
                theButton2.setAttribute ("id","testButton");
                theButton2.setAttribute ("type","submit");
                theButton2.setAttribute ("value","invia le tue risposte");
                var instructionMin = document.getElementById ("istruction_min");
	instructionMin.appendChild (document.createTextNode ("Nessuna"));
	var instructionMax = document.getElementById ("istruction_max");
	instructionMax.appendChild (document.createTextNode ("Moltissima"));

                YAHOO.util.Event.on(theButton2, 'click', ajaxImportanceSubmit,null,false);
                theTest.appendChild (theButton2);
                var pag1 = document.getElementById ("pag1");
                pag1.parentNode.removeChild (pag1);
                var pag2 = document.getElementById ("pag2");
                pag2.style.display = "block";
                pag2.style.visibility = "visible";
	
        },
        failure: function (oResponse) {
                printFailure ("");
                return false;
        }
}


var registerCallbackCS = {
	timeout: 5000,
        success: function (oResponse) {
                //handle a successful response
                //alert ("registerCallback");
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                var testo = oResponse.responseText;
                var theTest = document.getElementById ("theTest");
                var theFLForm = document.createElement ("form");
                theFLForm.setAttribute ("method","post");
                theFLForm.setAttribute ("id","csForm");
                theFLForm.innerHTML = testo;
                theTest.appendChild (theFLForm);
                tStart   = new Date();
                tempi = theFLForm.tempi;
                //  userlog = theFLForm.userlog;
                //  userlog.value = "- ";
                var theButton2 = document.createElement("input");
                theButton2.setAttribute ("id","testButton");
                theButton2.setAttribute ("type","submit");
                theButton2.setAttribute ("value","invia le tue risposte");
                YAHOO.util.Event.on(theButton2, 'click', ajaxCsSubmit,null,false);
                var inviaButtonPlace = document.getElementById ("inviaButtonPlace");
                inviaButtonPlace.appendChild (theButton2);
                var pag1 = document.getElementById ("pag1");
                pag1.parentNode.removeChild (pag1);
                var pag2 = document.getElementById ("pag2");
                pag2.style.display = "block";
                pag2.style.visibility = "visible";
	
        },
        failure: function (oResponse) {
                printFailure ("");
                return false;
        }
}




function ajaxImportanceSubmit () {
	//var url = baseUrl + "production.do";
	var url = baseUrl + "importance.do";
	//alert (url);
	var theTest = document.getElementById ("theTest");
	var theFLForm = document.getElementById("flForm");
	YAHOO.util.Connect.setForm(theFLForm);
	var request =	YAHOO.util.Connect.asyncRequest("get", url, importanceSubmitCallback);
	var testButton = document.getElementById("testButton");
	testButton.disabled=true;
	document.body.style.cursor = "wait";
	return false;
}

var importanceSubmitCallback = {
    success: function (oResponse) {
        //handle a successful response
	var pag2 = document.getElementById ("pag2");
	pag2.parentNode.removeChild (pag2);

	var testo = oResponse.responseText;
	var theFeedback = document.getElementById ("theFeedback");
	var theFBForm = document.createElement ("form");
	theFBForm.setAttribute ("method","post");
	theFBForm.setAttribute ("id","fbForm");
	//alert (testo);
	theFBForm.innerHTML = testo;
	theFeedback.appendChild (theFBForm);
	var theButton3 = document.createElement("input");
	theButton3.setAttribute ("id","fbButton");
	theButton3.setAttribute ("type","submit");
	theButton3.setAttribute ("value","invia i tuoi suggerimenti");
	YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
	theFeedback.appendChild (theButton3);

	//alert (testo);
	var pSuggest = document.getElementById ("pSuggest");
        pSuggest.style.display = "block";
	pSuggest.style.visibility = "visible";
	document.body.style.cursor = "default";
	
    },
    failure: function (oResponse) {
        printFailure ("");
        /*
                
	alert ("attenzione: problemi di connessione.\nInvia nuovamente i tuoi dati");
	var testButton = document.getElementById("testButton");
	testButton.disabled=false;
	document.body.style.cursor = "default";
	return false;
        */
        //handle an unsuccessful request
    }
}



/*
	funzioni x il card sorting classico
*/


function source2group (dest) {
	//sorg = document.forms["cardlists"].source;
	sorg = document.getElementById("csForm").source;
	sorglen = sorg.length ;
	for ( i=0; i<sorglen ; i++){
		if (sorg.options[i].selected == true ) {
			destlen = dest.length;
			dest.options[destlen]= new Option(sorg.options[i].text,sorg.options[i].value);
//			dest.options[destlen].value = sorg.options[i].value;
			userlog.value = userlog.value + "\t+" + sorg.options[i].value + "_" + dest.name;
		}
	}

	for ( i = (sorglen -1); i>=0; i--){
		if (sorg.options[i].selected == true ) {
		sorg.options[i] = null;
		}
	}
}

function group2source (dest) {
	sorg = document.getElementById("csForm").source;
	destlen = dest.length ;
	for ( i=0; i<destlen ; i++){
		if (dest.options[i].selected == true ) {
			sorglen = sorg.length;
			sorg.options[sorglen]= new Option(dest.options[i].text,dest.options[i].value);
			userlog.value = userlog.value + "\t-" + dest.options[i].value + "_" + dest.name;
//			dest.options[sorglen].value = dest.options[i].value;
		}
	}
	for ( i=(destlen-1); i>=0; i--) {
		if (dest.options[i].selected == true ) {
			dest.options[i] = null;
		}
	}
}

/*
function selectall () {
	var tDate = new Date();
	var tempoTrascorso = tDate.getTime() - tStart.getTime(); 
	tempi.value = tempoTrascorso;
	formcardlists = document.forms["cardlists"]
	listsnum = formcardlists.numgroups.value;
	elemennum = formcardlists.elements.length;

	for (i=0; i<elemennum ; i++){
		lista = formcardlists.elements [i];
		listlen = lista.length;
		for (j= 0; j < listlen; j++) {
			lista.options[j].selected = true;
		}
	}
}
*/

function ajaxCsSubmit () {

	var tDate = new Date();
	var tempoTrascorso = tDate.getTime() - tStart.getTime(); 
	tempi.value = tempoTrascorso;

	var url = baseUrl + "cardsorting1.do"; // volutamente errato. correggere, poi
	var theTest = document.getElementById ("theTest");
	var csForm = document.getElementById("csForm");

	//formcardlists = document.forms["cardlists"]
	listsnum = csForm.numgroups.value;
	elemennum = csForm.elements.length;

	for (i=0; i<elemennum ; i++){
		lista = csForm.elements [i];
		listlen = lista.length;
		for (j= 0; j < listlen; j++) {
			lista.options[j].selected = true;
		}
	}

	//alert (url);
	YAHOO.util.Connect.setForm(csForm);
	var request =	YAHOO.util.Connect.asyncRequest("get", url, csSubmitCallback);
	var testButton = document.getElementById("testButton");
	testButton.disabled=true;
	document.body.style.cursor = "wait";
	return false;
}

var csSubmitCallback = {
	timeout: 5000,
    success: function (oResponse) {
        //handle a successful response
        //alert ("success1");
	//alert ("csSubmitCallback success:");
        openFB ();
        /*
	var pag2 = document.getElementById ("pag2");
	pag2.parentNode.removeChild (pag2);

	// var testo = oResponse.responseText;
	//alert (testo);
	//  var theFBForm = document.createElement ("form");
	//  theFBForm.setAttribute ("method","post");
	//  theFBForm.setAttribute ("id","fbForm");
	//  theFBForm.innerHTML = testo;
	//  theFeedback.appendChild (theFBForm);
	//  var theButton3 = document.createElement("input");
	//  theButton3.setAttribute ("id","fbButton");
	//  theButton3.setAttribute ("type","submit");
	//  theButton3.setAttribute ("value","invia i tuoi suggerimenti");
	var theButton3 = document.getElementById ("fbButton");
        YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
	//  var theFeedback = document.getElementById ("theFeedback");
	//  theFeedback.appendChild (theButton3);

	//alert (testo);
        
	var pSuggest = document.getElementById ("pSuggest");
        pSuggest.style.display = "block";
	pSuggest.style.visibility = "visible";
	document.body.style.cursor = "default";
        */
        
    },
    failure: function (oResponse) {
        //handle an unsuccessful request
        //alert ("failure1");
        ajaxCsSubmit2();
    },
    
    abort: function (oResponse) {
        //handle an unsuccessful request
        //alert ("abort1");
        ajaxCsSubmit2();
    }
    
}

function ajaxCsSubmit2 () {

	var tDate = new Date();
	var tempoTrascorso = tDate.getTime() - tStart.getTime(); 
	tempi.value = tempoTrascorso;

	var url = baseUrl + "ns2/Cs2.jsp";
	var theTest = document.getElementById ("theTest");
	var csForm = document.getElementById("csForm");

	//formcardlists = document.forms["cardlists"]
	listsnum = csForm.numgroups.value;
	elemennum = csForm.elements.length;

	for (i=0; i<elemennum ; i++){
		lista = csForm.elements [i];
		listlen = lista.length;
		for (j= 0; j < listlen; j++) {
			lista.options[j].selected = true;
		}
	}

	//alert (url);
	YAHOO.util.Connect.setForm(csForm);
	var request =	YAHOO.util.Connect.asyncRequest("get", url, csSubmitCallback2);
	var testButton = document.getElementById("testButton");
	testButton.disabled=true;
	document.body.style.cursor = "wait";
	return false;
}



var csSubmitCallback2 = {
    timeout: 5000,
    success: function (oResponse) {
        //handle a successful response
        //alert ("success2");
        openFB ();
        /*
	var pag2 = document.getElementById ("pag2");
	pag2.parentNode.removeChild (pag2);
	var theButton3 = document.getElementById ("fbButton");
        YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
	var pSuggest = document.getElementById ("pSuggest");
        pSuggest.style.display = "block";
	pSuggest.style.visibility = "visible";
	document.body.style.cursor = "default";
        */
        
    },
    failure: function (oResponse) {
        //handle an unsuccessful request
        //alert ("failure2");
        openFB();
        /*/
	var pag2 = document.getElementById ("pag2");
	pag2.parentNode.removeChild (pag2);
	var theButton3 = document.getElementById ("fbButton");
        YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
	var pSuggest = document.getElementById ("pSuggest");
        pSuggest.style.display = "block";
	pSuggest.style.visibility = "visible";
	document.body.style.cursor = "default";
        */
    },
    
    abort: function (oResponse) {
        //handle an unsuccessful request
        //alert ("abort2");
        /*/
	var pag2 = document.getElementById ("pag2");
	pag2.parentNode.removeChild (pag2);
	var theButton3 = document.getElementById ("fbButton");
        YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
	var pSuggest = document.getElementById ("pSuggest");
        pSuggest.style.display = "block";
	pSuggest.style.visibility = "visible";
	document.body.style.cursor = "default";
        */
    }
    
}


function openFB () {
    //alert ("openFB");
	var pag2 = document.getElementById ("pag2");
	pag2.parentNode.removeChild (pag2);

	// var testo = oResponse.responseText;
	//alert (testo);
	var theFBForm = document.getElementById ("fbForm");
	theFBForm.setAttribute ("method","post");
	//  theFBForm.setAttribute ("id","fbForm");
	//  theFBForm.innerHTML = testo;
	//  theFeedback.appendChild (theFBForm);
	var theButton3 = document.createElement("input");
	theButton3.setAttribute ("id","fbButton");
	theButton3.setAttribute ("type","submit");
	theButton3.setAttribute ("value","invia i tuoi suggerimenti");
	theFBForm.appendChild (theButton3);
	//var theButton3 = document.getElementById ("fbButton");
        YAHOO.util.Event.on(theButton3, 'click', ajaxFBSubmit,null,false);
	//  var theFeedback = document.getElementById ("theFeedback");

	//alert (testo);
        
	var pSuggest = document.getElementById ("pSuggest");
        pSuggest.style.display = "block";
	pSuggest.style.visibility = "visible";
	document.body.style.cursor = "default";
    
}

/* feedback */
function ajaxFBSubmit () {
        //  alert ("ajaxFBSubmit");
	var url = baseUrl + "suggestions.do";
        //  alert ("1");
	//alert (url);
	document.body.style.cursor = "wait";
        //  alert ("2");
        //sending.style.visibility = "visible";
	// var theTest = document.getElementById ("theTest");
	var theFLForm = document.getElementById("fbForm");
        //  alert ("3");
	YAHOO.util.Connect.setForm(theFLForm);
        //  alert ("4");
	var request =	YAHOO.util.Connect.asyncRequest("get", url, fbSubmitCallback);
        //  alert ("5");
	return false;
}




var fbSubmitCallback = {
        timeout: 20000,
        success: function (oResponse) {
                //alert ("fbSubmitCallback success");
                //handle a successful response
                //sending.style.visibility = "hidden";
        	var divSending = document.getElementById("sendMsg");
                divSending.style.display = "none";
                divSending.style.visibility = "hidden";
                document.body.style.cursor = "default";
                var pSuggest = document.getElementById ("pSuggest");
                pSuggest.parentNode.removeChild (pSuggest);
                var pThanks = document.getElementById ("pThanks");
                pThanks.style.display = "block";
                pThanks.style.visibility = "visible";
	
        },
        failure: function (oResponse) {
                //alert ("fbSubmitCallback failure");
                printFailure ("");
                return false;
        }
}


function printSending (dove) {
	var divSending = document.getElementById("sendMsg");
        var h2Sending = document.createElement("h2");
        h2Sending.appendChild(document.createTextNode("Salvataggio delle tue risposte in corso"));
        var pSending = document.createElement("p");
        pSending.appendChild(document.createTextNode("Le tue risposte stanno per essere inviate al server. Poiché il processo può durare qualche minuto, ti preghiamo di attendere."));
        divSending.appendChild(h2Sending);
        divSending.appendChild(pSending);
        divSending.style.display = "block";
        divSending.style.visibility = "visible";
}

/*
 * 	<h2>Salvataggio delle tue risposte in corso</h2>
	<p>Le tue risposte stanno per essere inviate al server.<br />
	Poiché il processo può durare qualche minuto, ti preghiamo di attendere.<br />
	<span style="color:#a00">Attenzione: non chiudere la pagina e non ricaricarla.</span></p>

 * 
 */

function printFailure (oResponse) {
        
        var infos = "";
        infos += "?tId=" + oResponse.tId + "&status=" + oResponse.status;
        
        /*
	var divFailure = document.getElementById("failureMsg");
        var h2Failure = document.createElement("h2");
        h2Failure.appendChild(document.createTextNode("Attenzione: problemi di connessione"));
        var pFailure = document.createElement("p");
        pFailure.appendChild(document.createTextNode("Non è stato purtroppo possibile inviare i tuoi dati, per un problema di connessione al server."));
        divFailure.appendChild(h2Failure);
        divFailure.appendChild(pFailure);
        divFailure.style.display = "block";
        divFailure.style.visibility = "visible";
        */
}



/*
 * 
 *
	<form id="fbForm" method="post">
	<fieldset id="suggestions" class="fieldset">
	<legend>Il tuo suggerimento</legend>
	<textarea id="suggestions" name="suggestions" rows="10" cols="80"/>
	<br/>
	<label class="legend">la tua e-mail (non è obbligatoria)</label>
	<input type="text" name="mail" size="50" maxlength="150" value=""/>
	</fieldset>
	<input id="defaultcomment" type="hidden" value="Il tuo suggerimento"/>
	<input type="hidden" value="105" name="testid"/>
	<input type="hidden" value="112" name="questid"/>
	<input id="fbButton" type="submit" value="invia i tuoi suggerimenti"/>
	</form>
 
*/
 
