﻿
TABS = new Array();
TABS[0]="Descripcio";
TABS[1]="Dades";
TABS[2]="Genesis";
TABS[3]="Bio";
TABS[4]="Mediateca";
function canviTab(sNomTab){
    for (var i=0;i<TABS.length;i++){
        var oTab = document.getElementById("li" + TABS[i]);
        var oDiv = document.getElementById("div" + TABS[i]);
        
        if (oTab != undefined && oDiv != undefined){
            if (TABS[i] == sNomTab){
                oTab.className = "seleccionat";
                oDiv.style.display = "block";
            }
            else{
                oTab.className = "";
                oDiv.style.display = "none";
            }
        }
    }
    if (sNomTab == "Descripcio") {
        $("#mesinfo").hide();
    }
    else {
        $("#mesinfo").show();
    }
}

function displayTab(sNomTab, sDisplay){
    var oTab = document.getElementById("li" + sNomTab);
    if (oTab != undefined){
        oTab.style.display = sDisplay;
    }
}

function getObra(sId) {
    //Obtenim el Identificador del hidden a on hem de guardar l'identificador de l'obra
    var oIdH = document.getElementById("HidHIdObra");
    if (oIdH != null){
        //En oIdH tenim el id del hidden a on de guardar l'obra
        var oIdObra = document.getElementById(oIdH.value);
        if (oIdObra != null){
        //Posem el valor de l'identificador de l'obra en el hidden
            oIdObra.value = sId;
            //Fem click en el botó per demanar aquesta obra via AJAX
            var oIdButton = document.getElementById("HidButGetObra");
            if (oIdButton != null){
                var oButton = document.getElementById(oIdButton.value);
                ////oButton.click();
                var sLoc = '' + document.location
                var aLoc = sLoc.split("/");
                var sAspx = aLoc[aLoc.length - 1];
                var aAspx = sAspx.split(".aspx");
                var sNameFile = aAspx[0]

                var ieVersion = getIEVersionNumber();
                if (sNameFile == "cronologia") {
                    if (!(document.all && ieVersion < 7)) {
                        document.location = '#contingut';
                    }
                }
                else {
                    if (!document.all || (document.all && ieVersion == 7)) {
                        document.location = '#flash';
                    }
                }
                __doPostBack(oButton.name, '');
                
                oUp = document.getElementById(oIdH.value.replace('_hIdObra', '_upObra'));
                if (oUp != null) {
                    oChilds = oUp.childNodes;
                    if (oChilds != null && oChilds.length > 2) {
                        var oL = oChilds.length;
                        var bMenu = false;
                        var bContingut = false;
                        for (var i = 0; i < oL; i++) {
                            var oChild = oUp.childNodes[i];
                            if (oChild.className == "fondo-menu") {
                                oChild.style.visibility = "hidden";
                                bMenu = true;
                            }
                            if (oChild.className == "continguts") {
                                oChild.style.visibility = "hidden";
                                bContingut = true;

                            }
                            if (bMenu == true && bContingut == true) {
                                break;
                            }
                        } //for
                    }
                }
            }
            
        }
    }
    
}
