﻿var nHelp=2;
function ApriDettaglio(itm){
    document.form1.Comando.value="";
    window.open("Admin/DettaglioArticolo.aspx?itm="+itm,"","width=500,height=300,toolbar=no,status=no,scrollbars=no,resizable=no,location=no");    
}
function SelImage(nFile){
    document.form1.imgItem.value=nFile;
    document.form1.imgArticolo.setAttribute("src","../ImgProdotti/"+nFile);
}
function SalvaImg(itm){
    document.form1.Comando.value="13 itm="+itm+";img="+document.form1.imgItem.value+";"
    document.form1.submit();
}
function Verifica(ID) {
    document.form1.Comando.value = "CHVS" + ID;
    document.form1.submit();
}
function OpenFile(){
    var stile="width=650,height=400,menubar=no,toolbar=no,scrollbar=no,resizable=no";
    window.open("SelFileImage.aspx",'',stile);
}

/* News */
function StatoOnLine(ID){
    document.form1.IDNews.value=ID;
    document.form1.Comando.value="N3";
    document.form1.submit();
}
function SelNews(ID){
    document.form1.IDNews.value=ID;
    document.form1.submit();
}
function EliminaNews(ID){
    if(!confirm("Eliminare la news selezionata ?")){
        return;
    }
    document.form1.IDNews.value=ID;
    document.form1.Comando.value="N2";
    document.form1.submit();
}
function NuovaNews(){
    document.form1.Titolo.value="";
    document.form1.TestoNews.value="";
    document.form1.IDNews.value="";
    document.form1.ImageNews.setAttribute("src","../Images/noimage.gif");    
    document.form1.ImgNews.value="";
}
function SalvaNews(){
    if (document.form1.Titolo.value==""){
        alert("Inserire il titolo della news.");
        return;
    }
    if (document.form1.TestoNews.value==""){
        alert("Inserire il testo della news.");
        return;
    }
    document.form1.Comando.value="N1";
    document.form1.submit();
}
function SalvaOptNews(){
    var pgn=new String;
    pgn=document.form1.PagNews.value
    
    if(pgn=="0"){
        pgn="5"
        document.form1.PagNews.value=pgn;
    }
    document.form1.Comando.value="N4";
    document.form1.submit();
}
function OpenNews(ID){
    window.location="News.aspx?ID="+ID;
}
function SelezionaImg(Img){
    if(Img=="(Nessuna...)"){
        document.form1.ImageNews.setAttribute("src","../Images/noimage.gif");    
        document.form1.ImgNews.value="";
    }
    else{
        document.form1.ImageNews.setAttribute("src","../ImgNews/"+Img);
        document.form1.ImgNews.value=Img;
    }
}
/*---------------------------------------------------------*/

/* Gestione utenti */
function StatoUtente(ID){
    document.form1.IDUtente.value=ID;
    document.form1.Comando.value="U1";
    document.form1.submit();
}
function SelUtente(ID){
    document.form1.IDUtente.value=ID;
    document.form1.Comando.value="S1";
    document.form1.submit();
}
function SalvaUtente(){
    if(document.form1.IDUtente.value==""){
        return;
    }
    if(document.form1.txtPassword.value!=document.form1.txtConferma.value){
        alert("La password inserita e la password di conferma non coincidono.");
        return;
    }
    document.form1.Comando.value="SAVE";
    document.form1.submit();
}
function EliminaUtente(ID){
    if(!confirm("Eliminare l'utente selezionato ?")){
        return;
    }
    document.form1.IDUtente.value=ID;
    document.form1.Comando.value="DEL";
    document.form1.submit();
}
function SalvaAdmin(){
    if(document.form1.txtPassword.value!=document.form1.txtConferma.value){
        alert("La password inserita e la password di conferma non coincidono.");
        return;
    }
    document.form1.Comando.value="SAVE";
    document.form1.submit();
}
function NuovoAdmin(){
    document.form1.txtNome.value="";
    document.form1.txtUtente.value="";
    document.form1.txtPassword.value="";
    document.form1.txtConferma.value="";
    document.form1.IDUtente.value="";
    document.form1.Comando.value="";
}
/*---------------------------------------------------------*/

/* Impostazioni Generali */
function SaveConfig(){
    document.form1.Comando.value="CFG1";
    document.form1.submit();
}
function SaveAdmin(){
    if(document.form1.txtPass.value=="" || document.form1.txtPassConf.value==""){
        alert("Inserire la password e la password di conferma per l'utente amministratore.");
        return;
    }
    if(document.form1.txtPass.value != document.form1.txtPassConf.value){
        alert("La password inserita e la password di conferma non coincidono.");
        return;
    }
    document.form1.Comando.value="CFG2";
    document.form1.submit();
}

/* Corrieri */
function EliminaCorriere(ID){
    if(!confirm("Eliminare il corriere selezionato dall'archivio ?")){
        return;
    }
    document.form1.IDCorriere.value=ID;
    document.form1.Comando.value="CFG3";
    document.form1.submit();
}
function SelCorriere(ID){
    document.form1.IDCorriere.value=ID;
    document.form1.Comando.value="GET1";
    document.form1.submit();
}
function NuovoCorriere(){
    document.form1.IDCorriere.value="";
    document.form1.txtCorriere.value="";
    document.form1.txtCosto.value="";
    document.form1.submit();
}
function SalvaCorriere(){
    if(document.form1.txtCorriere.value==""){
        alert("Inserire il corriere.");
        return;
    } 
    if(document.form1.txtCosto.value==""){
        alert("Inserire il costo del trasporto.");
        return;
    }
    document.form1.Comando.value="CFG4";
    document.form1.submit();
}
function SalvaCorDefault(){
    document.form1.Comando.value="CFG5";
    document.form1.submit();
}
/*---------------------------------------------------------*/

/*Gestione files*/
function Anteprima(img){
    document.getElementById("AnteprimaImg").setAttribute("src","../ImgProdotti/"+img);   
}
function EliminaImg(fl){
    if(confirm("Eliminare il file selezionato ?\nAttenzione, prima di procedere con l'eliminazione del file verificare che non sia utilizzato nelle pagine.")){
        document.form1.Comando.value="DELIMG";
        document.form1.NomeFile.value=fl;
        document.form1.submit();
    }
}
function EliminaDoc(fl){
    if(confirm("Eliminare il file selezionato ?\nAttenzione, prima di procedere con l'eliminazione del file verificare che non sia utilizzato nelle pagine.")){
        document.form1.Comando.value="DELDOC";
        document.form1.NomeFile.value=fl;
        document.form1.submit();
    }
}
/* LOG */
function ChangePag(pag){
    document.form1.CurrPage.value=pag;
    document.form1.submit();
}

