function effettuaLogin()
{       
    BI.setLoginDWR(do_effettuaLogin, document.getElementById("user").value, document.getElementById("password").value);    
} 

function do_effettuaLogin(b) {    
    if(!b)
    {   
        DWRUtil.setValue("risultato", "<center>Login e/o password errati. Si prega di riprovare.</center>");         
    } else {
        DWRUtil.setValue("risultato", "<center>Login effettuato con successo.</center>");         
    }
    DWRUtil.setValue("user", "");
    DWRUtil.setValue("password", "");
    document.getElementById("user").focus();
}

function effettuaLoginMaterialiOL_libro()
{       
    BI.setLoginDocenteStudenteDWR(do_effettuaLoginMaterialiOL_libro, document.getElementById("user").value, document.getElementById("password").value);    
} 

function do_effettuaLoginMaterialiOL_libro(b) {    
    retrieveURL('./Controller.do?query=__BOOK_MATERIALIOL_LIBRO_REFRESH');
}

function effettuaLoginMaterialiOL() {
    BI.setLoginDocenteStudenteDWR(do_effettuaLoginMaterialiOL, document.getElementById("user").value, document.getElementById("password").value);
}

function do_effettuaLoginMaterialiOL(b) {
    retrieveURL('./Controller.do?query=__BOOK_MATERIALIOL_REFRESH');
}

var allegato;
var path_relativo;

function scaricaAllegato(file, path){   
alert("file="+file+"    path="+path);
    allegato = file;
    path_relativo = path;
    BI.setLoginDWR(do_scaricaAllegato, document.getElementById("user").value, document.getElementById("password").value);      
} 



function do_scaricaAllegato(b) {    
    if(!b)
    {   
        DWRUtil.setValue("risultato", "<center>Login e/o password errati. Si prega di riprovare.</center>");         
    } else {
        DWRUtil.setValue("risultato", "");        
        var url = './allegatiDownload?file='+allegato+'&path='+path_relativo;
        window.open(url, '_self');
    } 
    DWRUtil.setValue("user", "");
    DWRUtil.setValue("password", "");
    document.getElementById("user").focus();
}

function scaricaAllegato2(file, path,isConnected, user, pw ){   

    //alert("file="+file+"    path="+path+"    isConnected="+isConnected+"    user="+user+"    pw="+pw);
    allegato = file;
    path_relativo = path;    
    
    if(isConnected == "false"){    
        retrieveURL('./Controller.do?query=__USERS_LOGIN_TEMPLATE');         
    } else { 
        DWRUtil.setValue("risultato", "");        
        var url = './allegatiDownload?file='+allegato+'&path='+path_relativo;
        window.open(url, '_self');
    } 
} 


function scaricaAllegato3(file, path,isConnected, user, pw ){   

    //alert("file="+file+"    path="+path+"    isConnected="+isConnected+"    user="+user+"    pw="+pw);
    allegato = file;
    path_relativo = path;    
   
    if(isConnected == "false"){  

                    BI.allegatoConsultazione(allegato ,path_relativo);  
                retrieveURL('./Controller.do?query=__USERS_LOGIN_TEMPLATE&jscr=0&file='+allegato+'&path='+path_relativo);   
 
          
    } else { 
        DWRUtil.setValue("risultato", "");        
        var url = './allegatiDownload?act=consultazione&file='+allegato+'&path='+path_relativo;
        window.open(url, '_self');
    } 
} 




function do_scaricaAllegato2(b) {     
    if(!b){    
       retrieveURL('./Controller.do?query=__USERS_LOGIN_TEMPLATE');         
    } else { 
        DWRUtil.setValue("risultato", "");        
        var url = './allegatiDownload?file='+allegato+'&path='+path_relativo;
        window.open(url, '_self');
    } 
}

function scaricaMaterialeOL(file, path)
{   
    allegato = file;
    path_relativo = path;
    BI.setLoginDocenteStudenteDWR(do_scaricaMaterialeOL, document.getElementById("user").value, document.getElementById("password").value);      
} 

function do_scaricaMaterialeOL(b) {  
    if(b)
    {                      
       var url = './allegatiDownload?file='+allegato+'&path='+path_relativo;
       window.open(url, '_self');        
    }  
    retrieveURL('./Controller.do?query=__BOOK_MATERIALIOL_LIBRO_REFRESH'); 
}
