    var ajax = new sack();
    
    function whenLoading(){
        var e = document.getElementById('ajaxContainer'); 
        e.innerHTML = '<table border="0" width="100%"><tr><td align="center"><img src="/portalWeb/resources/images/ajax/indicator_medium.gif"><BR><BR>Caricamento in corso...</td></tr></table>';
        
    }
    
    function whenGetOfferteCompleted(){
        var e = document.getElementById('ajaxContainer'); 
        //alert(ajax.response);
        //alert("ok")
        if (ajax.responseStatus){
            var string = "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
            //alert("comp:" + ajax.responseXML.getElementsByTagName("offerta").length);
            var appo="pluto";
            var xmlDoc = ajax.responseXML.documentElement;
            var offerte = xmlDoc.getElementsByTagName('offerta');
            //alert(offerte.length);
            string = '<table border="0" width="100%">';
            
            if (offerte.length == 0)
                string = "Nessuna offerta trovata."
            for (i = 0; i < offerte.length; i++)
            {
             string += "<tr>"; 
             string += '<td ><a href="javascript:mostraPopUp1(\'' + offerte[i].getElementsByTagName("titolo")[0].firstChild.nodeValue + ' - ' + offerte[i].getElementsByTagName("cooperativa")[0].firstChild.nodeValue + '\',\''+offerte[i].getElementsByTagName("id")[0].firstChild.nodeValue+'\',\''+offerte[i].getElementsByTagName("coop")[0].firstChild.nodeValue+'\',\''+offerte[i].getElementsByTagName("titolo")[0].firstChild.nodeValue+'\');" class="titoloOfferta" alt="Canditati per questa offerta">' + offerte[i].getElementsByTagName("titolo")[0].firstChild.nodeValue + "</a></td>"
             //string += "<td>" + offerte[i].getElementsByTagName("professione")[0].firstChild.nodeValue + "</td>"
             //string += "<td>" + offerte[i].getElementsByTagName("provincia")[0].firstChild.nodeValue + "</td>"
             string += "<td>" + offerte[i].getElementsByTagName("cooperativa")[0].firstChild.nodeValue + "</td>"
             if(offerte[i].getElementsByTagName("tipologia")[0].firstChild.nodeValue == "PdV")
                string += "<td>Punto Vendita</td>"
             else
                string += "<td>" + offerte[i].getElementsByTagName("tipologia")[0].firstChild.nodeValue + "</td>"
             string += "</tr>";
             var maxChars = 150;
             var testo = offerte[i].getElementsByTagName("descrizione")[0].firstChild.nodeValue;
             var testoCorto;
             //alert(testo);
             if (testo.length > maxChars)
                testoCorto = testo.substring(0, (testo.indexOf(" ", maxChars) != -1 ? testo.indexOf(" ", maxChars) : testo.length())) + "...";
             else
             	testoCorto = testo;
             string += '<tr>'; 
             string += '<td colspan="3" class="descrizioneOfferta"><div id="testoCorto'+i+'" style="display:block;"><a href="javascript:mostraTesto(\'testo'+i+'\',\'testoCorto'+i+'\');">' + testoCorto + '</a></div>'
             string += '<div id="testo'+i+'" style="display:none;"><a href="javascript:mostraTesto(\'testoCorto'+i+'\',\'testo'+i+'\');">' + testo + '</a></div></td>'
             string += "</tr>"; 
             string += "<tr>"; 
             string += '<td colspan="3" class="spazioOfferte"></td>'
             string += "<tr>";
            }
            string += "<table>"
            //alert(string);
        } else {
            alert(ajax.responseStatus[0]);
            //var string = "<p>URLString Sent: " + ajax.URLString + "</p>";
            var string ="";
        }
        e.innerHTML = string;	
    }
    
    function whenLoaded(){
        var e = document.getElementById('ajaxContainer'); 
        e.innerHTML = "<p>Data Sent...</p>";
    }
    function error(){
        var e = document.getElementById('ajaxContainer'); 
        e.innerHTML = '<font color="red">Attenzione si è verificato un errore durante il caricamento.</font>';
    }
    function whenInteractive(){
        var e = document.getElementById('ajaxContainer'); 
        e.innerHTML = "<p>getting data...</p>";
    }

    function getOfferte(jsessionId){
        //alert('dd');
        var form = document.getElementById('form');
        ajax.setVar("cooperativa", form.cooperativa.value); 
        //ajax.setVar("professione", form.professione.value); 
        ajax.setVar("posizione", form.posizione.value); 
        ajax.setVar("provincia", form.provincia.value); 
        ajax.requestFile = "getOfferte.jsp" + ";jsessionid=" + jsessionId ;
        ajax.method = "GET";
        //ajax.element = 'replaceme'; // debug
        ajax.onLoading = whenLoading;
        //ajax.onLoaded = whenLoaded; 
        //ajax.onInteractive = whenInteractive;
        ajax.onCompletion = whenGetOfferteCompleted;
        ajax.onError = error;
        ajax.runAJAX();
    }
    
    function getUserInfo(jsessionId){
        //alert('dd');
        var form = document.getElementById('userForm');
        ajax.setVar("userIdLog", form.userIdLog.value); 
        ajax.setVar("password", form.password.value); 
        ajax.requestFile = "getUserInfo.jsp" + ";jsessionid=" + jsessionId ;
        ajax.method = "GET";
        //ajax.element = 'replaceme'; // debug
        ajax.onLoading = whenLoading;
        //ajax.onLoaded = whenLoaded; 
        //ajax.onInteractive = whenInteractive;
        ajax.onCompletion = whenGeUserInfoCompleted;
        ajax.onError = error;
        ajax.runAJAX();
    }
    
    function whenGeUserInfoCompleted(){
        var e = document.getElementById('ajaxContainer'); 
        //alert(ajax.response);
        if (ajax.responseStatus){
            //alert(ajax.response)
            //var string = "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
            var string = ajax.response;
        } else {
            alert(ajax.responseStatus[0]);
            //var string = "<p>URLString Sent: " + ajax.URLString + "</p>";
            var string ="";
        }
        e.innerHTML = string;	
    }
    function getForgotPassword(){
        //alert('dd');
        var form = document.getElementById('userForm');
        ajax.setVar("codiceFiscale", form.codiceFiscale.value); 
        ajax.requestFile = "getForgotPassword.jsp";
        ajax.method = "GET";
        //ajax.element = 'replaceme'; // debug
        ajax.onLoading = whenLoading;
        //ajax.onLoaded = whenLoaded; 
        //ajax.onInteractive = whenInteractive;
        ajax.onCompletion = whenForgotPasswordCompleted;
        ajax.onError = error;
        ajax.runAJAX();
    }
    
    function whenForgotPasswordCompleted(){
        var e = document.getElementById('ajaxContainer'); 
        //alert(ajax.response);
        if (ajax.responseStatus){
            //alert(ajax.response)
            //var string = "<p>Status Code: " + ajax.responseStatus[0] + "</p><p>Status Message: " + ajax.responseStatus[1] + "</p><p>URLString Sent: " + ajax.URLString + "</p>";
            var string = ajax.response;
        } else {
            alert(ajax.responseStatus[0]);
            //var string = "<p>URLString Sent: " + ajax.URLString + "</p>";
            var string ="";
        }
        e.innerHTML = string;	
    }
    function cancella(){
        window.location = '/portalWeb/portlets/LavoraConNoi/tree.jsp'
    }
    function goToOfferte()
    {
        document.location.href = "/portalWeb/portlets/LavoraConNoi/offerte.jsp";
    }
    
    function formCVSubmit(myForm)
    {   
        document.forms[myForm].submit();
        return false;
    }
    
    function goToSetOfferta(id,coopId,titolo)
    {
        document.location.href = "/portalWeb/portlets/LavoraConNoi/setOfferta.jsp?ID=" + id + "&coopId=" + coopId + "&titolo=" + titolo;
    }
    
    function goToLogin()
    {
        document.location.href = "/portalWeb/portlets/LavoraConNoi/cvProfile.jsp"
    }
    
/* 20080111 inserimento funzione per la gestione delle stringhe xml della mappa_italia.swf */
var isInternetExplorer = navigator.appName.indexOf("Microsoft") != -1;
// Handle all the FSCommand messages in a Flash movie.

function mappa_italia_DoFSCommand(command, args) {
	var mappa_italiaObj = isInternetExplorer ? document.all.mappa_italia : document.mappa_italia;
	if (command == "passXML") {
		passa_cv(args)
	}
}

// Hook for Internet Explorer.
if (navigator.appName && navigator.appName.indexOf("Microsoft") != -1 && navigator.userAgent.indexOf("Windows") != -1 && navigator.userAgent.indexOf("Windows 3.1") == -1) {
    document.write('<script language=\"VBScript\"\>\n');
	document.write('On Error Resume Next\n');
	document.write('Sub mappa_italia_FSCommand(ByVal command, ByVal args)\n');
	document.write('	Call mappa_italia_DoFSCommand(command, args)\n');
	document.write('End Sub\n');
	document.write('</script\>\n');
}
