    
$(document).ready(function(){
                    $('.fb').hover(function(){
			$('.fb').stop(true, false).animate({right:'194'},100);
		},function(){
			$('.fb').stop(true, false).animate({right:'-50'},100);
		});

    var akcesoriaRozwiniete = false;
    if ( $("#left_menu").is(".isRollout") )
        akcesoriaRozwiniete = true;

    if ($("#left_menu").length > 0) {

        

        $("#left_menu > li:has(ul) > a").click(function(e){
            
            if ( $(this).is(".akcesoriaSubElement") ) {
				return false;
                

                // Zwi wszystkie elementy.
                $("#left_menu > li:has(ul)").each(function(){

                        $(this).children("ul").slideUp("normal");
                        $(this).removeClass("active");
                
                });

                if ( false && akcesoriaRozwiniete ) {
                    
                    akcesoriaRozwiniete = false;
                   // $("li.akcesoriaElement").slideUp("normal");

                    // Zwi wszystkie elementy.
                    $("#left_menu > li:has(ul)").each(function(){

                        if ( $(this) != par ) {
                            $(this).children("ul").slideUp("normal");
                            $(this).removeClass("active");
                        }
                    });
                } else {
                    
                    akcesoriaRozwiniete = true;
                   // $("li.akcesoriaElement").slideDown("normal");
                }

                return;
            }
            
            if ( ! $(this).parents('li').is('.akcesoriaElement') ) {
               // akcesoriaRozwiniete = false;
               // $("li.akcesoriaElement").slideUp("normal");
            }

            par = $(this).parents("li");
            if ( par.is(".active")) {
                par.children("ul").slideUp("normal");
                par.removeClass("active");
                return false;
            }

            // Zwi wszystkie elementy.
            $("#left_menu > li:has(ul)").each(function(){

                if ( $(this) != par ) {
                    $(this).children("ul").slideUp("normal");
                    $(this).removeClass("active");
                }
            });


            // Zwi wszystkie elementy.
            $("#specjalne > li:has(ul)").each(function(){

                $(this).children("ul").slideUp("normal");
                $(this).removeClass("active");
                
            });

            if (par.is("li")) {
                par.children('ul').slideDown("normal");
                par.addClass("active");
            }

            return false;
        });
    }

    
    if ($("#specjalne").length > 0) {
        $("#specjalne > li:has(ul) > a").click(function(e){
            
            par = $(this).parents("li");
            if ( par.is(".active")) {
                par.children("ul").slideUp("normal");
                par.removeClass("active");
                return false;
            }

            $("#left_menu > li:has(ul)").each(function() {
                
                $(this).children("ul").slideUp("normal");
                $(this).removeClass("active");

            });
                

            // Zwi wszystkie elementy.
            $("#specjalne > li:has(ul)").each(function(){

                if ( $(this) != par ) {
                    $(this).children("ul").slideUp("normal");
                    $(this).removeClass("active");
                }
            });

            if (par.is("li")) {
                par.children('ul').slideDown("normal");
                par.addClass("active");
            }

            return false;
        });
    }
    /*
    $("div.linie ul li a").mouseover ( function ( ) {
        src = $(this).children("img").attr("src");
        src = src.replace('_on.gif', '.gif' );
        $(this).children("img").attr("src", src.replace('.gif', '_on.gif' ));
    });
    $("div.linie ul li a").mouseout ( function ( ) {
        src = $(this).children("img").attr("src");
        $(this).children("img").attr("src", src.replace('_on.gif', '.gif' ));
    });
    */

    $("#lista-ikonek li img").mouseover ( function ( ) {
        
        $(this).parents('li').addClass('active');
        file = $(this).parents('li').attr('id');
        file = file.replace('icon',''); 

        // Pobierz XML.
         $.ajax({
            url: ABS_PATH + "ikonka.php5",
            data: "ikonka=" + file,
            dataType: "xml",
            success: function(data){
                Element = $("#lista-ikonek li.active div");
                // Przechwy XML
                var Tytul = $(data).find('tytul').text();
                var Grafika = $(data).find('grafika').text();
                var Tekst = $(data).find('opis').text();

                // Wpisz dane do HTML-a.
                Element.children('h1').html(Tytul);
                Element.children('p').html(Tekst);
                Element.children('img').attr("src", Grafika);
                
                // Poka element.
                Element.show();

                // poka rekinka.
                $("<img src='" + ABS_PATH + "www/img/rekin.gif' class='rekin' />").appendTo(Element.parents('li'));
            }
        });
    });

    $("#lista-ikonek li img").mouseout ( function ( ) {
        $(this).parents('li').children('div').hide();
        $(this).parents('li').children('img.rekin').removeClass('rekin').addClass('rm');
        $(this).parents('li').children('img.rm').hide();
        $(this).parents('li').removeClass('active');
    });


    

	$("div#home > ul > li").hover ( function ( ) {

		if ( $(this).is(":not(.active)")) {
			$("div#home ul > li:has(ul)").each ( function ( ) {

					$(this).children("ul").hide();
					$(this).removeClass("active");

			});
		}

		if ( $(this).is(":not(.active)") ) {
			//if (!$(this).is('.rozwijany')) {
				elem = $(this);
				$(this).children("ul:not(visible)").show();
				 
			//	$(this).addClass('rozwijany');
				$(this).addClass("active");
			//}
		}

	},
	function(){
		$("div#home ul > li:has(ul)").children('ul').fadeOut();
		$("div#home ul > li.active").removeClass("active");
	});
    

    try {
        loadswf();
    } catch (e){};


    $("div.kat-container ul li div.klatka").not('div.noHover').mouseover ( function ( ) {
        $(this).addClass('klatka-akt');
        $("#panel-linie").hide();
        $("#panel-linie").show();
    });
    $("div.kat-container ul li div.klatka").not('div.noHover').mouseout ( function ( ) {
        $(this).removeClass('klatka-akt');
        $("#panel-linie").hide();
        $("#panel-linie").show();
    });
    /*$("div.kat-container ul li div.klatka").click ( function ( ) {
        window.top.location.href = $(this).children('a').attr('href');
    });*/

    $("ul#lista_grup li:not(.current)").mouseover ( function ( ) {
        $(this).addClass('klatka-hover');
        $("#panel-linie").hide();
        $("#panel-linie").show();
    });
    $("ul#lista_grup li:not(.current)").mouseout ( function ( ) {
        $(this).removeClass('klatka-hover');
        $("#panel-linie").hide();
        $("#panel-linie").show();
    });
    
    $('div.kat-noborder div.klatka-ramka a').click(function() {
    	$(this).parents('li').children('div.images').children('a:first').click();
    	return false;
	});
	
			$('.box').hover(function(){
			$('.box').stop(true, false).animate({right:'0'},100);
		},function(){
			$('.box').stop(true, false).animate({right:'-5'},100);
		});
		
		$('.box2').hover(function(){
			$('.box2').stop(true, false).animate({right:'0'},100);
		},function(){
			$('.box2').stop(true, false).animate({right:'-5'},100);
		});
		
});


function Box_Szukaj ( link ) {
    
        $("div#site-box div.top a.szukaj").addClass('aktywny');
        $("div#site-box div.top a.newsletter").removeClass('aktywny');
    
        $("div#site-box div.newsletter").hide();
        $("div#site-box div.szukaj").show();

        
        $("div#site-box div.top a.szukaj").blur();

}

function Box_Newsletter ( link ) {
    
        $("div#site-box div.top a.szukaj").removeClass('aktywny');
        $("div#site-box div.top a.newsletter").addClass('aktywny');
    
        $("div#site-box div.newsletter").show();
        $("div#site-box div.szukaj").hide();
        
        $("div#site-box div.top a.newsletter").blur();

}


function Oferta_PokazLinie ( ) {
    $("div#oferta li.be_linie a").addClass("aktywny");
    $("div#oferta li.be_produkty a").removeClass("aktywny");

    $("div.zaw_linie").show();
    $("div.zaw_oferta").hide();

    
    $("div#oferta li.be_linie a").blur();
}

function Oferta_PokazProdukty ( ) {
    $("div#oferta li.be_linie a").removeClass("aktywny");
    $("div#oferta li.be_produkty a").addClass("aktywny");

    $("div.zaw_linie").hide();
    $("div.zaw_oferta").show();

    $("div#oferta li.be_produkty a").blur();
}

function ProduktPop ( image ) {
    
    if ( image == null ) 
        image = 'transparent.gif';
    filePath = $("img#product-hover").attr("src").match(/.*\// );
    $("img#product-hover").attr("src", filePath + image)

    if (image != 'transparent.gif')
        $("img#product-hover").show();
    else
        $("img#product-hover").hide();
    
}

function Linia_Splash ( image ) {
    
    // Pokazanie splasha
    if ( image != null ) {
        $("#paczka-slide img." + image + "1" ).show();
        $("#paczka-slide").show();
    } else {
        $("#paczka-slide img" ).hide();
        $("#paczka-slide").hide();    
    }

}

function switchKat ( katID ) {

    // Usu� zaznaczenia z wszystkich element�w.
    $(".kat-container").hide();
    $("#lista_grup li").removeClass("current");

    // Poka� ten konkretny "model".
    $("#kat-" + katID ).show();
    $("#przelacznik-" + katID ).addClass("current");
}



function Rozwin_Tekst ( tekstID ) {
    
    $("ul#drzewko-tekstow li").each(function(e){
        $(this).children('span.body').hide();
        $(this).removeClass('aktywna');
        $(this).children('a.head').removeClass('aktywny');
    });

    var Oferta = $("#drzewko-tekstow #tekst-" + tekstID );
    if ( ! Oferta.is(".aktywna") ) {
        $(Oferta).children('span.body').show();
        $(Oferta).addClass('aktywna');
        $(Oferta).children('a.head').addClass('aktywny');
    } else {
        $(Oferta).children('span.body').hide();
        $(Oferta).removeClass('aktywna');
        $(Oferta).children('a.head').removeClass('aktywny');
    }

}

function Rozwin_Oferte ( ofertaID ) {


    var Oferta = $("#lista-ofert #oferta-" + ofertaID );
    if ( ! Oferta.is(".aktywna") ) {
        $(Oferta).children('span.body').show();
        $(Oferta).addClass('aktywna');
        $(Oferta).children('a.head').addClass('aktywny');
    } else {
        $(Oferta).children('span.body').hide();
        $(Oferta).removeClass('aktywna');
        $(Oferta).children('a.head').removeClass('aktywny');
    }

}

function Wyslij_Oferte(){
    
    var oferta_ImieNazwisko = $("#imie_nazwisko").val();
    var oferta_AdresEmail = $("#adres_email").val();
    var oferta_Telefon = $("#telefon").val();
    var oferta_CV = $("#cv").val();
    var oferta_ListMotywacyjny = $("#list_motywacyjny").val();
    var oferta_WyrazamZgode = $("#wyrazam_zgode").is(':checked');

    if ( oferta_ImieNazwisko == '' || oferta_AdresEmail == '' || oferta_Telefon == '' || oferta_CV == '' || oferta_ListMotywacyjny == '' ){
        window.alert('Prosz� wype�ni� wszystkie dane');
    } else if ( oferta_WyrazamZgode == false ) {
        window.alert('Prosz� wyrazi� zgod� na przetwarzanie danych osobowych');
    } else {
        $("#wyslij-oferte-form").submit();
        $("#wyslij-oferte-form ul").hide();
        $("#wyslij-oferte-form p").show();
    }


    
    
}


function Add_Newsletter ( source )  {

	var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
	if ( !filter.test( $(source).val() ) ) {
		window.alert ( "Podany adres e-mail jest niepoprawny!" );
		return false;
	}

	$("#nl-window").show();
	$("#nl-window-backg").show();

	$("#kartka").css('position', 'static');
	
	$('#comm').attr('src', '/pl/newsletter-dodaj/dodaj?email=' + $(source).val());

	return true;
}


function Hide_Newsletter ( source )  {
	$("#nl-window").fadeOut();
	$("#nl-window-backg").slideUp();

	$("#kartka").css('position', 'absolute');

	return true;
}

function enterSubmit(func, e) {

	var characterCode;

	if(e && e.which){ 
		e = e;
		characterCode = e.which;
	} else{
		e = event;
		characterCode = e.keyCode;
	}

	if(characterCode == 13){ 
		window.top.location.href = '#';
		eval(func);
		return false;
	} else {
		return true;
	}

}


function koniec_rozwijania() {

	elem.removeClass('rozwijany');
}
