﻿//______  ZOBACZ CO SLYCHAC _______________________________
    //---------------------------------------------------------
    
    //*** rozwijanie opisow do zajawek ***
    //funkcja rozwijajaca opis
    
    //funkcja obslugujaca zdarzenie przy najechaniu mysza na element
    function ZcSSlider_onOver() {
        var elemPosition = jQuery(this).offset(); //pozycja biezacego elementu
        var nextElem = jQuery(this).next(".tab-content"); //pozycja nastepnego elementu
        //sprawdzanie czy element biezacy element jest ostatnim
        if(nextElem.length)
        {
           var nextElemPos = nextElem.offset();
           //sprawdzanie czy biezacy element jest ostatnim w linii
           if(elemPosition.top != nextElemPos.top)
            {
//                jQuery(this).prev().css("margin-right", "10px");
                jQuery(this).prev().css("margin-right", "200px");
            }
            else
            {
                //dla IE6 trzeba inaczej postepowac z wyswietlanymi elementami 
                if(jQuery.browser.msie && (jQuery.browser.version.substring(0,1)==6))
                {
                    prevElem = jQuery(this).prev().offset();
                    if(elemPosition.top == prevElem.top)
                    {
                        //dla srodkowego elementu w rzedzie
//                        nextElem.css("margin-left", "232px");
                        nextElem.css("margin-left", "224px");
                    }
                    else
                    {
                        //dla pierwszego elementu w rzedzie
//                        nextElem.css("margin-left", "121px");
                        nextElem.css("margin-left", "115px");
                    }
                }
                else
                {
                    nextElem.css("margin-left", "238px");
                }
//                nextElem.css("margin-left", "121px");
//                nextElem.css("margin-left", "232px");
            }
        }
        //zmiana css'a dla biezacego elementu
        jQuery(this).css("position", "absolute");
        jQuery(this).css("top", elemPosition.top - 10);
        //dla mozilli trzeba ustawic inny margines niz dla
        //pozostalych przegladarek
        if(jQuery.browser.mozilla)
        {
            jQuery(this).css("left", elemPosition.left - 12);
        }
        else
        {
            jQuery(this).css("left", elemPosition.left - 13);
            if(jQuery.browser.msie && (jQuery.browser.version.substring(0,1)==6))
            {
//                jQuery(this).css("left", elemPosition.left - 10);
                jQuery(this).css("left", elemPosition.left - 6);
            }
        }
        //ustawianie ccs'a dla rozwijanego elementu
        jQuery(this).css({'height' : 'auto', 'background' : '#5189be'});
        jQuery(this).find("h3").css("color", "#fff");
        jQuery(this).find("p").css("color", "#3A509B");
        jQuery(this).find(".Opis").css("color", "#fff");
//        jQuery(this).find(".Opis").show("fast");
        jQuery(this).find(".Opis").slideDown("normal");
//        jQuery(this).find(".Opis").fadeIn(900);
        jQuery(this).css("z-index", "2");
        
        if(jQuery(this).css('borderColor')=='rgb(81, 137, 190) rgb(81, 137, 190) rgb(81, 137, 190) rgb(81, 137, 190)') //dlaczego to sie wyswietla 4 razy
        {
            jQuery(this).css({'height' : '70px', 'background' : '#FFF'});
            jQuery(this).find('h3').css({'color' : '#5189be'});
            jQuery(this).find('.Opis').css({'display' : 'none'});
        }
    }
    //funkcja obslugujaca zdarzenie przy zjechaniu myszy z danego elementu
    function ZcSSlider_onOut() {
        //zmiana css'a dla zwijanego elementu na pierwotne wartosci
        jQuery(this).css("background", "#fff");
        jQuery(this).find("h3").css("color", "#5189be");
        jQuery(this).find("p").css("color", "#7A7F83");
        jQuery(this).next(".tab-content").css("margin-left", "13px");
        if(jQuery.browser.msie && (jQuery.browser.version.substring(0,1)==6))
        {
//            jQuery(this).next(".tab-content").css("margin-left", "10px");
            jQuery(this).next(".tab-content").css("margin-left", "6px");
        }
        jQuery(this).prev().css("margin-right", "0");
//        jQuery(this).find(".Opis").css("display", "none");
        jQuery(this).find(".Opis").slideUp("normal");
        jQuery(this).css("height", "70px");
        jQuery(this).css("position", "static");
    }
    //glowna funckja wywolywana przy zaladowaniu strony
    function ZcSSlider() {
        var element = jQuery("#c_l_szp .p_szp .tab-content"); 
        if(jQuery.browser.msie && (jQuery.browser.version.substring(0,1)==6))
        {
//            element.css("margin-left", "10px");
            element.css("margin-left", "6px");
        }
        element.css("height", "70px");
        element.css({'cursor' : 'pointer'});
        element.hover(ZcSSlider_onOver, ZcSSlider_onOut);
    }
    //*** wyswietlanie 12 zajawek wideo i audio
    //przesylane argumenty:
    // elem - numer nacisnietej strony
    // count - liczba wszystkich stron w panelu
    // panel - oznaczenie panelu wideo/audio
    function DisplayNews(elem, pageCount, count, panel) 
    {
        for(var i=0; i< count; i++)
        {
            jQuery("#c_l_szp .p_szp").eq(panel).find(".tab-content").eq(i).css("display", "none");
        }
        elem = parseInt(elem);
        var startElem = (parseInt(elem) - 1) * 12;
        var endElem = parseInt(elem) * 12;
        jQuery("#c_l_szp .p_szp").eq(panel).find(".PageCounter").html("");
        for(a=0; a< pageCount; a++)
        {
            jQuery("<span class=\"PageNmb\"><img src=\"./Images/Layout/punkt_niebieski.PNG\" alt=\"" + (a + 1) + "\" /></span>").appendTo(jQuery("#c_l_szp .p_szp").eq(panel).find(".PageCounter"));
        }
        jQuery("#c_l_szp .p_szp").eq(panel).find(".PageCounter .PageNmb").eq(elem - 1).html("<img src=\"./Images/Layout/punkt_czerwony.PNG\" alt=\"" + elem + "\" />");
        for(var i = startElem; i < endElem; i++)
        {
            jQuery("#c_l_szp .p_szp").eq(panel).find(".tab-content").eq(i).show(1000);
        }
        jQuery("#c_l_szp .p_szp").eq(0).find(".PageNmb").click(function() {DisplayNews(jQuery(this).find("img").attr("alt"), pageCount, count, 0)});
        jQuery("#c_l_szp .p_szp").eq(1).find(".PageNmb").click(function() {DisplayNews(jQuery(this).find("img").attr("alt"), pageCount, count, 1)});
        if(elem==pageCount)
        { 
            if(jQuery.browser.msie && (jQuery.browser.version.substring(0,1)!=8))
            {
                 jQuery("<span style=\"font-size: 10px; color: #aaa; display: block; position: relative; top:-19px; left: 150px; width: 200px\">Starszych materiałów szukaj w kalendarzu</span>").appendTo(jQuery("#c_l_szp .p_szp").eq(panel).find(".PageCounter"));
            }
            else
            {
                 jQuery("<span style=\"font-size: 10px; color: #aaa; display: block; position: relative; top:-19px; left: 360px; width: 200px\">Starszych materiałów szukaj w kalendarzu</span>").appendTo(jQuery("#c_l_szp .p_szp").eq(panel).find(".PageCounter"));
            }
        }
    }
    //stronnicowanie w zobacz co slychac
    function Pager() {
        //ukrywanie calej listy video i audio przy ladowaniu strony
        jQuery("#c_l_szp .p_szp .tab-content").each(function(i){jQuery(this).css("display", "none")});
        //calkowita liczba wideo
        var videoCount =  jQuery("#c_l_szp .p_szp").eq(0).find(".tab-content").length;
        //calkowita liczba audio
        var audioCount = jQuery("#c_l_szp .p_szp").eq(1).find(".tab-content").length;
        if(videoCount > 12)
        {
//            var pageVideoCount = parseInt(videoCount / 12);
            if(videoCount >= 60)
            {
                var pageVideoCount = parseInt(videoCount / 12);
            }
            else
            {
                var pageVideoCount = parseInt(videoCount / 12) + 1;
            }
            jQuery("<p class=\"clearboth\"></p><div class=\"PageCounter\"></div><p class=\"clearboth\"></p>").appendTo(jQuery("#c_l_szp .p_szp .c_art_tresc").eq(0));
            for(a=0; a< pageVideoCount; a++)
            {
                jQuery("<span class=\"PageNmb\"><img src=\"./Images/Layout/punkt_niebieski.PNG\" alt=\"" + (a + 1) + "\" /></span>").appendTo(jQuery("#c_l_szp .p_szp").eq(0).find(".PageCounter"));
            }
            jQuery("#c_l_szp .p_szp").eq(0).find(".PageCounter .PageNmb").eq(0).html("<img src=\"./Images/Layout/punkt_czerwony.PNG\" alt=\"1\" />");
            jQuery("#c_l_szp .p_szp").eq(0).find(".PageCounter").css("display", "block");
            jQuery("#c_l_szp .p_szp").eq(0).find(".PageCounter p span").html();
        }
        if(audioCount > 12)
        {
            if(audioCount >= 60)
            {
                var pageAudioCount = parseInt(audioCount / 12);
            }
            else
            {
                var pageAudioCount = parseInt(audioCount / 12) + 1;
            }
            jQuery("<p class=\"clearboth\"></p><div class=\"PageCounter\"></div><p class=\"clearboth\"></p>").appendTo(jQuery("#c_l_szp .p_szp .c_art_tresc").eq(1));
            for(a=0; a< pageAudioCount; a++)
            {
                jQuery("<span class=\"PageNmb\"><img src=\"./Images/Layout/punkt_niebieski.PNG\" alt=\"" + (a + 1) + "\" /></span>").appendTo(jQuery("#c_l_szp .p_szp").eq(1).find(".PageCounter"));
            }
            jQuery("#c_l_szp .p_szp").eq(1).find(".PageCounter .PageNmb").eq(0).html("<img src=\"./Images/Layout/punkt_czerwony.PNG\" alt=\"1\" />");
            jQuery("#c_l_szp .p_szp").eq(1).find(".PageCounter").css("display", "block");
            jQuery("#c_l_szp .p_szp").eq(1).find(".PageCounter p span").text("1");
        }
        var pageName = '' + document.location;
        if((tagPos = pageName.indexOf('?video')) != -1)
        {
            for(var a=0; a<12; a++)
            {
                jQuery("#c_l_szp .p_szp").eq(0).find(".tab-content").eq(a).css("display", "block");
                jQuery("#c_l_szp .p_szp").eq(1).find(".tab-content").eq(a).css("display", "block");
            }
        }
        else if((tagPos = pageName.indexOf('?audio')) != -1)
        {
            for(var a=0; a<12; a++)
            {
                jQuery("#c_l_szp .p_szp").eq(0).find(".tab-content").eq(a).css("display", "block");
                jQuery("#c_l_szp .p_szp").eq(1).find(".tab-content").eq(a).css("display", "block");
            }
        }
        else
        {
            for(var a=0; a<12; a++)
            {
                jQuery("#c_l_szp .p_szp").eq(0).find(".tab-content").eq(a).css("display", "block");
                jQuery("#c_l_szp .p_szp").eq(1).find(".tab-content").eq(a).css("display", "block");
            }
        }
        jQuery("#c_l_szp .p_szp").eq(0).find(".PageNmb").click(function() {DisplayNews(jQuery(this).find("img").attr("alt"), pageVideoCount, videoCount, 0)});
        jQuery("#c_l_szp .p_szp").eq(1).find(".PageNmb").click(function() {DisplayNews(jQuery(this).find("img").attr("alt"), pageAudioCount, audioCount, 1)});        
    }