function showTab(divId, ulClass, contentClass) {
    //divId - id del div contenedor
    //ulClass - class del ul que contiene los li de los tabs
    //contentClass - class de los div contenedores del contenido de cada tab
    var tabSelected = $("#" + divId).metadata().tabSelected;
    $("." + contentClass).hide();
    $("ul." + ulClass + " li:eq(" + tabSelected + ")").addClass("active").show();
    $("." + contentClass + ":eq(" + tabSelected + ")").show();

    $("ul." + ulClass + " li").click(function() {
        $("ul." + ulClass + " li").removeClass("active");
        $(this).addClass("active");
        $("." + contentClass).hide();

        var activeTab = $(this).find("a").attr("href");
        //$(activeTab).toggle();
        $(activeTab).fadeIn();
        return false;
    });
};



function tamFuente(cuerpoNoticia, elem) {
    var elemento = document.getElementById(elem)
    elemento.className = "cuerpoNoticia" + cuerpoNoticia;

}



function muestra_oculta(id) {
    if (document.getElementById) {
        //se obtiene el id
        var el = document.getElementById(id); //se define la variable "el" igual a nuestro div
        if (el) {
            el.style.display = (el.style.display == 'none') ? 'block' : 'none'; //damos un atributo display:none que oculta el div
        }
        /*else {
            alert('error en muestra_oculta - id no existente: ' + id);
        }*/
    }
}


$(document).ready(function() {
    var rotationSpeed = $('#tabs').metadata().rotationSpeed;
    var tabSelected = $('#tabs').metadata().tabSelected;
    var fadeSpeed = $('#tabs').metadata().fadeSpeed;
    $("#tabs").tabs({ selected: tabSelected, fx: { opacity: 'toggle', duration: fadeSpeed} }).tabs('rotate', rotationSpeed);
    $("#overlay").hide();
});


$(document).ready(function() {
    showTab("contenedorTabsMultimedios", "tabsVideos", "tab_contentMultimedios");
    showTab("contenedorTabsHoroscopos", "tabs", "tab_contentHoroscopos");
    showTab("contenedorTabsSondeos", "tabsSondeos", "tab_contentSondeos");
    ///showTab("contenedorTabsRegistros", "tabsRegistros", "tab_contentRegistros");
});
function overlayLogin() {
    var api = $("#overlay").overlay({ expose: '#000000', api: true, closeOnClick: false, onBeforeClose: $.cookie('END:Reg', null) });
    $('#tabLogin, .tabsRegistros').show();
    $('#loginTab').addClass("active");
    $('#tabUnete, #P2, #P3, #P4, #P5, #P6, #P7, #P8, #P9').hide();
    $('#uneteTab').removeClass("active");
    $('.close').removeClass("white");
    $('.contRegistros').removeClass("removeBackground");
    api.load();
    $('#P1').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
    $('#P1').load('../template/ctrlLoginTab.aspx');
}
function overlayUnete() {
    var api = $("#overlay").overlay({ expose: '#000000', api: true, closeOnClick: false, onBeforeClose: $.cookie('END:Reg', null) });
    $('#tabUnete, #P2, .tabsRegistros').show();
    $('#P3, #P4, #P5, #P6, #P7, #P8, #P9').hide();
    $('#uneteTab').addClass("active");
    $('#tabLogin, #P8, #P9').hide();
    $('#loginTab').removeClass("active");
    $('.close').removeClass("white");
    $('.contRegistros').removeClass("removeBackground");
    api.load();
    $('#P2').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
    $('#P2').load('../template/block.aspx?strControl=ctrlLoginTabRedes');
}
$("#menuHeader a.loginButton, #loginTab a.tabLogin").each(function() {
    var href = $(this).attr("href");
    $(this).attr({ href: "#" });
    $(this).click(function() {
        $("#P1").load(href);
    });
});


$("#menuHeader a.uneteButton, #uneteTab a.tabUnete").each(function() {
    var href = $(this).attr("href");
    $(this).attr({ href: "#" });
    $(this).click(function() {
        $("#P2").load(href);
    });
});
function registroNuevoDia() {
    $('#tabUnete, ').hide();
    $('#P3').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
    $('#P3').show();
    $('#P3').load('../template/ctrlLoginMediador.aspx?qc=ctrlLoginTabProcesos&qa=fr&rand=' + Math.random());
}
function registroNuevoDiaSuscripcion() {
    $('#tabUnete').hide();
    $('#P3').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
    $('#P3').show();
    $('#P3').load('../template/ctrlLoginMediador.aspx?qc=ctrlLoginTabProcesos&qa=fr&qb=ok&rand=' + Math.random());
}
function registroFacebook() {
    FB.Facebook.init('888b2201ee47f93cccdb10251573e970', '/xd_receiver.htm');
    FB.ensureInit(function() {
        FB.Connect.get_status().waitUntilReady(function(status) {
            switch (status) {
                case FB.ConnectState.connected:
                    $('#P2').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
                    $('#P2').show();
                    $('#P2').load('../template/ctrlLoginMediador.aspx?qc=ctrlLoginTabProcesosRedes&qa=fred&qb=fb&rand=' + Math.random());
                    break;
                case FB.ConnectState.appNotAuthorized:
                    //                    getpermisos();
                case FB.ConnectState.userNotLoggedIn:
                    overlayLogin();
                    popupFacebookConnect();
                    break;
            }
        });

    });
}
function registroTwitter() {
    $('#tabUnete').hide();
    $('#P5').show();
    $('#P5').load();
}
function registroGoogle() {
    $('#tabUnete').hide();
    $('#P6').show();
    $('#P6').load();
}
function registroYahoo() {
    $('#tabUnete').hide();
    $('#P7').show();
    $('#P7').load();
}
function volver() {
    $('#P3, #P4, #P5, #P6, #P7').hide();
    $('#tabUnete').show();
}
function uneteHoy() {
    $('#tabLogin').hide();
    $('#tabUnete, #P2').show();
    $('#loginTab').removeClass("active");
    $('#uneteTab').addClass("active");
}
function popupFacebook() {
    $('#popupFacebook').fadeIn("fast");
}
function popupFacebookConnect() {
    $('#popupFacebookConnect').fadeIn("fast");
}
function popupTwitter() {
    $('#popupTwitter').fadeIn("fast");
}
function popupGoogle() {
    $('#popupGoogle').fadeIn("fast");
}
function popupYahoo() {
    $('#popupYahoo').fadeIn("fast");
}
function closePopups() {
    $('#popupFacebook,#popupFacebookConnect, #popupTwitter, #popupGoogle, #popupYahoo').fadeOut("fast");
}
function bienvenido() {
    $('#P3, #P4, #P5, #P6, #P7, .tabsRegistros').hide();
    $('.contRegistros').addClass("removeBackground");
    $('.close').addClass("white");
    $('#P8').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
    $('#P8').show();
    $('#P8').load('registrosLogin_P8.htm');
}
function gracias() {
    $('#P3, #P4, #P5, #P6, #P7, .tabsRegistros, #P8').hide();
    $('.contRegistros').addClass("removeBackground");
    $('.close').addClass("white");
    $('#P9').html('<div align="center"><img src="../images/icons/ajax-loader3.gif"/></div>');
    $('#P9').show();
    $('#P9').load('registrosLogin_P9.htm');
}

function cerrarNavegadores() {
    $('#navegador').fadeOut("slow");
}

function cerrarResultadosMultimedia() {
    $('#navegador').fadeOut("slow");
}

