﻿function assegnaClasse(idLink) {
    try {
        eliminaClasse();
        //
        var num;
        if (idLink < 10)
            num = "0" + idLink;
        else
            num = idLink;
        var elemento = document.getElementById("link" + num);
        if (elemento != null) {
            //elemento.setAttribute("class", "selezionato");
            elemento.className = "menu_sel";
        }
        var elemento2 = document.getElementById("linkBasso" + num);
        if (elemento2 != null) {
            //elemento.setAttribute("class", "selezionato");
            elemento2.className = "menu_sel";
        }
        //
        var elemento3 = document.getElementById("imglink" + num);
        if (elemento3 != null) {
            if (idLink < 10)
                elemento3.className = "img_menuSelezionato";
            else
                elemento3.className = "img_menuBassoSelezionato";
        }
    }
    catch (error) {
        //fai nulla
    }
}

function eliminaClasse() {
    try {
        for (i = 1; i <= 15; i++) {
            var num;
            if (i < 10)
                num = "0" + i;
            else
                num = i;
            var elemento = document.getElementById("link" + num);
            if (elemento != null)
                elemento.className = null;
            //
            var elemento2 = document.getElementById("linkBasso" + num);
            if (elemento2 != null)
                elemento2.className = null;
            //
            var elemento3 = document.getElementById("imglink" + num);
            if (elemento3 != null)
                elemento3.className = "img_menu";
        }
    }
    catch (error) {
        //fai nulla
    }
}


function seleziona(id, nomeDiv, nomeClasse) {
    var elemento = document.getElementById(nomeDiv + id);
    if (elemento != null) {
        elemento.className = nomeClasse;
    }
    var navigatore = navigator.appName;

    var boxGrigio = document.getElementById("box" + id);
    if (boxGrigio != null) {
        elemento.style.top = boxGrigio.offsetTop + 'px';
        if (nomeDiv != "ombra")
            elemento.style.left = boxGrigio.offsetLeft - 13 + 'px';
        else
            elemento.style.left = boxGrigio.offsetLeft - 10 + 'px';
        elemento.style.width = 65 + 'px'; //boxGrigio.offsetWidth + 'px';
        elemento.style.height = 65 + 'px'; //boxGrigio.offsetHeight + 'px';
    }
}

function deseleziona(nomeClasse) {
    try {
        var elemento = document.getElementsByTagName("div");
        for (i = 1; i < elemento.length; i++)
            if (elemento[i].className == nomeClasse)
                elemento[i].className = "trasparente";

        /*
        for (i = 1; i <= 20; i++) {
        var elemento = document.getElementById(nomeDiv + i);
        elemento.className = "trasparente";
        }
        */
    }
    catch (error) {
        //fai nulla
    }
}

function vaiapagina(pagina) {
    document.location.href = pagina;
}

function anteprima(modello, prezzo, prezzoIVA, nomeProdotto, descrizione, bordo, sfondoScuro, immagine) {
    try {
        var elContenitoreOriginale = document.getElementById("contenitoreDettaglioProdotto");
        var elNomeProdSelezionato = document.getElementById("nomeProdottoSelezionato");

        var elContenitore = document.getElementById("contenitoreAnteprimaProdotto");
        var elDivImgProdotto = document.getElementById("divImgAnteprimaProdotto");
        var elImgProdotto = document.getElementById("imgAnteprimaProdotto");
        var elNomeProdotto = document.getElementById("nomeAnteprimaProdotto");
        var elDescrProdotto = document.getElementById("descrizioneAnteprimaProdotto");
        var elPrezzoProdotto = document.getElementById("prezzoAnteprimaProdotto");
        var elModelloProdotto = document.getElementById("modelloAnteprimaProdotto");
        //
        var nomeProdottoSelezionato = elNomeProdSelezionato.innerText;
        if (nomeProdottoSelezionato == undefined)
            nomeProdottoSelezionato = elNomeProdotto.textContent;

        if (nomeProdottoSelezionato.valueOf().trim() != modello.valueOf()) {
            elContenitoreOriginale.style.visibility = "hidden";
            elContenitore.style.visibility = "visible";
            elImgProdotto.setAttribute("src", immagine);
            elImgProdotto.setAttribute("alt", nomeProdotto);
            var presenzaBordo = (bordo == "true");
            if (presenzaBordo) {
                elDivImgProdotto.setAttribute("style", "width:398px;height:398px;background-color:White;padding:1px 1px 1px 1px;");
                elImgProdotto.setAttribute("style", "width:398px;height:398px;");
            }
            else {
                elDivImgProdotto.setAttribute("style", "width:400px;height:400px;padding:0px 0px 0px 0px;");
                elImgProdotto.setAttribute("style", "width:400px;height:400px;");
            }
            if(elNomeProdotto.innerText != undefined)
                elNomeProdotto.innerText = nomeProdotto.toString().toUpperCase();
            else
                elNomeProdotto.textContent = nomeProdotto.toString().toUpperCase();
            //
            if(elDescrProdotto.innerHTML!=undefined)
                elDescrProdotto.innerHTML = descrizione;
            else
                elDescrProdotto.textContent = descrizione;
            //
            if (elPrezzoProdotto.innerHTML != undefined)
                elPrezzoProdotto.innerHTML = prezzo + "<br />" + prezzoIVA;
            else
                elPrezzoProdotto.textContent = prezzo + "<br />" + prezzoIVA;
            //
            if(elModelloProdotto.innerText != undefined)
                elModelloProdotto.innerText = modello;
            else
                elModelloProdotto.textContent = modello;
            //
            if (sfondoScuro.valueOf() == "true")
                elModelloProdotto.style.color = "white";
            else
                elModelloProdotto.style.color = "#333333";
        }
        else {
            elContenitoreOriginale.style.visibility = "visible";
            elContenitore.style.visibility = "hidden";
        }
    }
    catch (Error) {
        //alert("Errore: " + Error);
    }
}

function annullaAnteprima() {
    var elContenitoreOriginale = document.getElementById("contenitoreDettaglioProdotto");
    var elContenitore = document.getElementById("contenitoreAnteprimaProdotto");
    elContenitoreOriginale.style.visibility = "visible";
    elContenitore.style.visibility = "hidden";
}


function ridimensionaItemDetails() {

    var elContenitoreDettaglio = document.getElementById("intestazionePagina");
    var elContenitoreImmagini = document.getElementById("divPannelloImmagini");
    try {
        elContenitoreDettaglio.style.height = elContenitoreImmagini.offsetHeight + 770 + 'px';
    }
    catch (Error) { }
    

}

//funzioni della pagina squadra

function visualizzaScheda(idScheda) {
    var el01 = document.getElementById("panel01");
    //
    var elemento = document.getElementById("panel0" + idScheda);
    if (elemento != null) {
        elemento.className = "visibile";
        //elemento.style.top = el01.style.top;
        elemento.style.height = "auto";
    }
    //contenitoreAjax
    //divDettaglioAtleta
    //contenitorePannelli
    var elemento2 = document.getElementById("contenitorePannelli");
    var elemento3 = document.getElementById("divDettaglioAtleta");
    var elemento4 = document.getElementById("contenitoreAjax");
    var elemento5 = document.getElementById("divDescrizDettaglio");
    
    try {

        try {
            if (idScheda == 1) {
                elemento5.style.height = "100%";
                var elemento6 = document.getElementById("divImmagineAtleta");
                elemento6.style.height = "100%";
            }
            else
                elemento5.style.height = "0";
        }
        catch (Error) { }
        /*
        if (idScheda == 4) {
        elemento.style.height = "650px";
        elemento2.style.height = "650px";
        elemento3.style.height = "950px";
        elemento4.style.height = "100%";
        }
        if (idScheda == 3) {
        elemento.style.height = "750px";
        elemento2.style.height = "750px";
        elemento3.style.height = "1050px";
        elemento4.style.height = "100%";
        }
        */
        if (idScheda < 5) {
            if (elemento2 != null) {
                elemento2.style.height = elemento.offsetHeight + 'px';
                elemento3.style.height = elemento2.offsetHeight + elemento2.offsetTop + 'px';
                elemento4.style.height = "110%";
            }
        }
    }
    catch (Error) {
    }
}


function tastoPremuto(idTasto) {
    deselezionaTasti("visibile");
    //
    var elemento2 = document.getElementById("btnDettaglio0" + idTasto);
    elemento2.className = "tastoSelezionato";
    //
    if (idTasto == 3)
        visualizzaFotografie();
    if (idTasto == 4)
        visualizzaFilmato();
    //
    visualizzaScheda(idTasto);
}

function deselezionaTasti(nomeClasse) {
    try {
        var elemento = document.getElementsByTagName("div");
        for (i = 1; i < elemento.length; i++)
            if (elemento[i].className == nomeClasse)
                elemento[i].className = "nascosto";
        //        
        for (i = 1; i <= 4; i++) {
        var elemento2 = document.getElementById("btnDettaglio0" + i);
        elemento2.className = "tastoDeselezionato";
        //elemento2.style.backgroundColor = "#e7e7dd";
        //elemento2.style.color = "#000000";
        }
    }
    catch (error) {
        //fai nulla
    }
}


//funzione per visualizzare il filmato video del corridore selezionato
function visualizzaFilmato() {
    try
    {
        var nomeFilmFLV = document.getElementById("nomeFilmato");
        var nomeFileFLV = "";
        if (nomeFilmFLV != null) 
        {
            var spanFile = nomeFilmFLV.childNodes[0];
            if (spanFile != null)
            {
                nomeFileFLV = spanFile.innerHTML;
                //alert("Nome file FLV= " + spanFile.innerHTML);
            }
            else 
            {
                nomeFileFLV = "";
                //alert("spanFile nullo!");
            }
        }
        //alert(nomeFileFLV);
        var fo = new SWFObject("./flash/video/VideoFLV.swf", "VideoFLV", "750px", "540px", "9", "#ffffff");
        fo.addParam("wmode", "transparent");
        fo.addParam("FlashVars", "nomeFilmato=" + nomeFileFLV);
        fo.write("flash_gallery");
    }
    catch (error)
    {
        //fai nulla
    }
}

function visualizzaFotografie() {
    try {
        //nomeGalleria
        var nomeGalleria = document.getElementById("nomeGalleria");
        var nomeFileGalleria = "";
        if (nomeGalleria != null) {
            var spanFile = nomeGalleria.childNodes[0];
            if (spanFile != null)
                nomeFileGalleria = spanFile.innerHTML;
            else
                nomeFileGalleria = "";
        }
        //percorsoGalleria
        var percorsoGalleria = document.getElementById("percorsoGalleria");
        var percorsoFileGalleria = "";
        if (percorsoGalleria != null) {
            var spanFile2 = percorsoGalleria.childNodes[0];
            if (spanFile2 != null)
                percorsoFileGalleria = spanFile2.innerHTML;
            else
                percorsoFileGalleria = "";
        }
        //
        var fo = new SWFObject("/flash/Fotografie.swf", "Fotografie", "750px", "720px", "9", "#ffffff");
        fo.addParam("wmode", "transparent");
        fo.addParam("FlashVars", "nomeGalleria=" + nomeFileGalleria + "&percorsoGalleria=" + percorsoFileGalleria);
        fo.write("divFotografie");
    }
    catch (error) {
        //fai nulla
    }
}

function visualizzaGalleriaFotografica() {

    //try {
        var fo = new SWFObject("./flash/galleria/viewer.swf", "viewer", "780px", "860px", "8", "#ffffff");

        //percorsoGalleria
        var percorsoGalleria = document.getElementById("percorsoGalleria");
        var percorsoFileGalleria = "";
        if (percorsoGalleria != null) {
            var spanFile2 = percorsoGalleria.childNodes[0];
            if (spanFile2 != null)
                percorsoFileGalleria = spanFile2.innerHTML;
            else
                percorsoFileGalleria = "";
        }

        // SIMPLEVIEWER CONFIGURATION OPTIONS
        // To use an option, uncomment it by removing the "//" at the start of the line
        // For a description of config options, go to: 
        // http://www.airtightinteractive.com/simpleviewer/options.html

        //fo.addVariable("xmlDataPath", "gallery.xml");
        //fo.addVariable("firstImageIndex", "5");	
        //fo.addVariable("langOpenImage", "Open Image in New Window");
        //fo.addVariable("langAbout", "About");	
        //fo.addVariable("preloaderColor", "0x000000");
        fo.addVariable("preloaderColor", "0x000000");
        fo.addVariable("xmlDataPath", percorsoFileGalleria);
        fo.addParam("wmode", "transparent");
        fo.write("flash_gallery");
    //}
    //catch (error) {
        //fai nulla
    //}
}