// JavaScript External Document
// Scripting by: andrea.bettoni@ideaup.com

function addBookmark(){
	var url="http://www.crea-test.com/area_clienti/default.asp";
	var title = "CREA TEST - Area B2B";
  if ((navigator.appName == "Microsoft Internet Explorer") && (parseInt(navigator.appVersion) >= 4)) {
  window.external.AddFavorite(url,title);
  } else if (navigator.appName == "Netscape") {
    window.sidebar.addPanel(title,url,"");
  } else {
    alert("Premete i tasti CTRL + D (per Netscape) o CTRL + T (per Opera)\n\rper aggiungere questo sito ai preferiti...");
  }
}


function controllaBrowser() 
{
var	avviso = 0;
var name = navigator.appName;
var vers = navigator.appVersion;
vers = vers.substring(0,1);
if (name == "Microsoft Internet Explorer")  
		{  
 avviso = 1 
		}
var strAvviso="ATTENZIONE!\n";
strAvviso+="Questo pannello di controllo č stato progettato per funzionare con Microsoft Internet Explorer(R)\n\r";
strAvviso+="Il Vs. attuale browser non risulta essere compatibile con alcune funzioni utilizzate dall\'applicazione.\n\r \n";
strAvviso+="Vi invitiamo perciņ ad effettuare il logout ed a riprovare utilizzando il software appropriato.\n\r \n\r";
if (avviso != 1) 
		{  
		alert(strAvviso); 
		}
}

function contatti(param) { 
var UrlToOpen = "/modulo.asp?flag=1&p=" + param;
larg=505; 
alt=565; 
toptop=20; //(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
searchWin = window. open(UrlToOpen,'formwindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function verificaQuestaEmail(questa) {
if ((questa == "") || (questa.indexOf('@') == -1) || (questa.indexOf('.') == -1)) {
alert("\n     -  E-mail in formato non valido!");
}
}
/********************************************************
FUNZIONI UPLOAD PUREUPLOAD
********************************************************/
//Open window with progress bar.
function ProgressBar(){
  var ProgressURL
  ProgressURL = 'progress.asp?UploadID=<%=UploadID%>'

  var v = window.open(ProgressURL,'_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=yes,width=350,height=200')
  
  return true;
}
//Expand form with a new File fields if needed.
var nfiles = 3;
function Expand(){
  nfiles++
  var adh = '<BR> File '+nfiles+' : <input type="file" name="File'+nfiles+'">';
  files.insertAdjacentHTML('BeforeEnd',adh);
  return false;
}
/*********************************************************/


function prendiElementoDaId(id_elemento) {
 var elemento;
 if(document.getElementById)
  elemento = document.getElementById(id_elemento);
 else
  elemento = document.all[id_elemento];
 return elemento;
}

function checkFileUpload() {
var blob=prendiElementoDaId('blob');
var loading=prendiElementoDaId('loading')
if (blob.value == '') {
alert('Selezionate un file!');
loading.innerHTML='';
return false;
	}  else {
loading.innerHTML='Attendere il completamento del caricamento file...';
uploadPDF();
return true;
	}
}
 
/*****************************************/

function upload(mac,ut,tab) { 
if ((mac=='')||(mac=='undefined')) { 
mac=0; 
alert('ERRORE DURANTE IL PASSAGGIO DEI PARAMETRI!');
return
}
if ((ut=='')||(ut=='undefined')) { 
ut=0; 
alert('ERRORE DURANTE IL PASSAGGIO DEI PARAMETRI!');
return
}
var urlToPop='/area_clienti/_add_files'+tab+'.asp'
urlToPop+='?mac='+mac+'&uid='+ut;
larg=500; 
alt=300; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open(urlToPop,'uploadWin','top='+toptop+',left='+leftleft+',scrollbars=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no');
} 

function vedifile(mac,ut,tab) { 
// fare il return!!!
var urlToPop='/area_clienti/_mod_files'+tab+'.asp'
urlToPop+='?mac='+mac+'&uid='+ut;
larg=750; 
alt=300; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open(urlToPop,'vedifileWin','top='+toptop+',left='+leftleft+',scrollbars=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no');
/*alert(mac+"\n"+ut+"\n"+tab+"\n");*/
} 

function editfile1(mac,ut) { 
// fare il return!!!
var urlToPop='/area_clienti/_mod_files1.asp'
urlToPop+='?mac='+mac+'&uid='+ut;
larg=750; 
alt=500; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open(urlToPop,'uploadWin','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no');
/*alert(mac+"\n"+ut+"\n"+tab+"\n");*/
} 

/*****************************************/
function uploadProgress() { 
larg=500; 
alt=300; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('/area_clienti/Upload-Progress.asp','uploadProgressWin','top='+toptop+',left='+leftleft+',scrollbars=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function uploadPDF() { 
larg=480; 
alt=120; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('/_PDF/outputFile.asp','uploadWin','top='+toptop+',left='+leftleft+',scrollbars=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function popVediFiles(uid,mac,tab){	
larg=700;
alt=530;
if(uid!=0) {
url = "_mod_files.asp?uid=" + idx+"&mac="+mac+"&tab="+tab;
toptop=(screen.height/2)-(alt/2);
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'FileEditWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} else {
alert('Dovete selezionare un cliente di cui visualizzare i files!');
return false
}
}
function popEditFilesFiscale(idx){	
larg=700;
alt=530;
if(idx!=0) {
url = "_mod_files_fiscale.asp?uid=" + idx;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'FileEditWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} else {
alert('Dovete selezionare un cliente di cui visualizzare i files!');
return false
}
}
function controllaEmail(flag) {
if(flag!=0) {
popNewUser()
return true
} else {
alert('Dovete selezionare un cliente a cui inviare il messaggio!');
return false
}
}
function controllaEmail2(flag) {
if(flag!=0) {
popMail()
return true
} else {
alert('Dovete selezionare un cliente a cui inviare il messaggio!');
return false
}
}

function checkAddMacchina(flag) {
if(flag!=0) {
return true
} else {
alert('Dovete selezionare un cliente a cui attribuire la macchina!');
return false
}
}

function controllacodice(what,how) {
if(what.length != parseInt(how)){
 alert('Codice inserito di lunghezza non valida');
} 
}
// return (inputString.length <= inputLength) ? true : false;

function popFileAce(flag) { 
file = "/fileace/fileace.asp"
larg=900;
alt=700;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(file,'FileAceWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
}

function uploadFileAce() { 
larg=500; 
alt=120; 
toptop=(screen.height/2)-(alt/2); 
leftleft=(screen.width/2)-(larg/2); 
window.open('/area_clienti/_upload_fileace.asp','uploadFileAceWin','top='+toptop+',left='+leftleft+',scrollbars=no,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
}

function popFileManager(flag) { 
if(flag==1) {
versione = "/filemanager/default2.asp"
} else if(flag==2) {
versione = "/filemanager/default1.asp"
} else if(flag==3) {
versione = "/filemanager/default3.asp"
} else {
versione = "/filemanager/default.asp"
} 
larg=770;
alt=550;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(versione,'FMWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function pfilemanager() { 
file = "/filemanager/default.asp"
larg=770;
alt=550;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(file,'FMWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
}

function popNewUser() {   
larg=640;
alt=480;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open('','mailWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function popMail() { 
larg=640;
alt=480;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open('','mailWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no');  
} 

function popLog(idx,nome){
larg=640;
alt=480;
url = "_log_utente.asp?id=" +idx+"&nome_azienda="+nome;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'LogWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function popSendMail(idx){
larg=640;
alt=480;
url = "_email_user.asp?uid=" + idx;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'UserEditWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
}

function popSendMailAdmin() { 
larg=700; 
alt=550; 
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window. open('','SendMailWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 


function popEditUser(idx) {
larg=640;
alt=480;
url = "_mod_utente.asp?id="+idx;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'UserEditWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function popEditCommessa(idx,uid){
larg=640;
alt=480;
url = "_mod_commessa.asp?id="+idx+"&uid="+uid;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'CommEditWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function scriviMessaggio(){
larg=640;
alt=480;
url = "_messaggio_user.asp";
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(url,'CommEditWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function popHelp(quale) { 
if(quale==1) {
UrlDaAprire = "/area_clienti/_help.asp#uno"
} else if(quale==2) {
UrlDaAprire = "/area_clienti/_help.asp#due"
} else {
UrlDaAprire = "/area_clienti/_help.asp"
} 
larg=650;
alt=500;
toptop=(screen.height/2)-(alt/2)
leftleft=(screen.width/2)-(larg/2); 
window.open(UrlDaAprire,'HelpWindow','top='+toptop+',left='+leftleft+',scrollbars=yes,resizable=yes,width='+larg+',height='+alt+',status=no,location=no,toolbar=no'); 
} 

function checkAdmin() {
missinginfo = "";
if (document.adminform.adminpwd.value == "") {
alert('\n\n\nNon avete inserito alcuna password!!\n\n\n');
return false;
} else return true;
}



function checkLogin() {
missinginfo = "";
if (document.modulocomm.username.value == "") {
missinginfo += "\n     -  Nome Utente";
}
if (document.modulocomm.password.value == "") {
missinginfo += "\n     -  Password";
}
if (missinginfo != "") {
missinginfo2 = "\n\nNon avete inserito i seguenti dati:\n" ;
missinginfo2 += missinginfo+"\n\n";
alert(missinginfo2);
return false
}
else return true 
//document.modulocomm.submit();
}

function calcolaLivello(quale) { 
if(quale==0) {
strOut = "CLIENTE"
} else if(quale==1) {
strOut = "OPERATORE"
} else if(quale==2) {
strOut = "AMMINISTRATORE"
} else {
strOut = "Non definito"
} 
//document.newUserEmail.livello.value=strOut;
stringa="&nbsp;"+strOut+"&nbsp;";
stringa+="<input name='livello' type='hidden' id='livello' value='"+strOut+"'>";
document.write(stringa);
} 

function eliminaUtente(quale) {
if (confirm("Eliminare il cliente selezionato?")) 	{
strUrl = "_del_utente.asp?id=" + quale;
document.location.replace(strUrl);
}  else {
return false
}  
}

function conferma() {
if (confirm("Procedere con la cancellazione definitiva?"))
 {
return true;
	}  else {
return false;
	}
}
function confermaElimina(){
if (confirm("Eliminare il record selezionato?"))
 {
return true;
	}  else {
return false;
	}
}
/*******************************************************/

function selezionaLog(id) {
  if (!document.getElementById) return;
  selDiv = document.getElementById(id);
	selDiv.style.fontWeight = "Bold";
}
function deselezionaLog(id) {
  if (!document.getElementById) return;
  selDiv = document.getElementById(id);
		selDiv.style.fontWeight = "Normal";
}


function checkLogin() {
if ((document.loginform.username.value != "")&&(document.loginform.password.value != "")) {
return true
} else {
alert('Inserite un nome e una password validi!!');
document.loginform.username.value='';
document.loginform.password.value='';
document.loginform.username.focus();
return false
}
}
function checkAdminLogin() {
if (document.adminlogin.password.value != "") {
return true
} else {
alert('Inserite una password valida!!');
document.adminlogin.password.value='';
document.adminlogin.password.focus();
return false
}
}
/****************************************************/



/* FUNZIONI SHOW/HIDE PER TABELLE DEI FILES */
var subs_array = new Array("sub1","sub2","sub3");
// Put the id's of your hidden divs in this array

function aprichiudi(the_sub){
	 if (document.getElementById(the_sub).style.display=="block"){
	   document.getElementById(the_sub).style.display = "none";

  } else {
	   document.getElementById(the_sub).style.display = "block";

  }
  return
  }

/**********************************/


