$(document).ready(function(){
	$('#node_id_9057').hide();
	$('#node_id_9064').hide();
	$('.zwin').hide();
	
    
    $('img[title="logo_nad"]').before('<div id="logo_nad"></div>');
    $('img[title="logo_nad"]').hide();
    
	$('.zwin').click(function(){
		var poz = $(this).parent().parent();
		poz.find('div.desc').hide();
		$(this).hide();
		poz.find('.rozwin').show();
		return false;
	});
	
	$('.rozwin').click(function(){
		var poz = $(this).parent().parent();
		poz.find('div.desc').show();
		$(this).hide();
		poz.find('.zwin').show();
		return false;
	});	

	$('.rozwin_title').click(function(){
		var poz = $(this).attr('name');
		$("#"+poz).show();
		$("#"+poz+"_zwin").show();
		$("#"+poz+"_rozwin").hide();
		return false;
	});	
var hashes = window.location.href.slice(window.location.href.indexOf('#') + 1).split('&amp;');
if(hashes != ''){
    $("."+hashes).show();
    $("."+hashes+"hide").hide();
}
    
	// -> wersja dla artykułu
	
	$('.rozwin_art').show();
	$('.zwin_art').hide();
	
	$('.zwin_art').click(function(){
		var poz = $(this).parent().parent();
		poz.find('div.desc_art').hide();
		$(this).hide();
		poz.find('.rozwin_art').show();
		return false;
	});
	
	$('.rozwin_art').click(function(){
		var poz = $(this).parent().parent();
		poz.find('div.desc_art').show();
		$(this).hide();
		poz.find('.zwin_art').show();
		return false;
	});
    
    $(".show_tree").click(function() {
          $(this).parent().addClass('selected');
          $(this).parent().find('div.subcat').css('display', 'block');
          $(this).css('display', 'none');
    });  
    $(".hide_tree").click(function() {
          $(this).parent().parent().removeClass('selected');
          $(this).parent().parent().find('a.show_tree').css('display', 'block');
          $(this).parent().css('display', 'none');
    });
     
    $("#generate_form").click(function() {
        var page_get = '';
        $("input:checkbox:checked").each(function(){
            page_get += $(this).val() + 'i';
        });

        if(page_get == ''){ 
            alert("Rozdział nie został wybrany");
        }else{  
            $.ajax({
               type: "GET",
               url: "/ajx/pdf.php",
               data: "page="+page_get,
               success: function(msg){
                 window.location.href = msg;
               }
             });
         }
              
    });     		
	
	$('#generate_field').click(function(){
		var req ='';
		$('.pages-range').each(function(i, el){
			if ($('.pages-from',el).val() != '' && $('.pages-to',el).val() != '')
				req += $('.pages-from',el).val() + 'do' + $('.pages-to',el).val() + 'i';
		}); 
		
		if(req == ''){ 
            alert("Rozdział nie został wybrany");
        }else{  
            $.ajax({
               type: "GET",
               url: "/ajx/pdf.php",
               data: "page="+req,
               success: function(msg){
                 window.location.href = msg;
               }
             });
         }
	});
	
	$("#add-input-pages").click(function() {
		var el = $('.pages-range').last();
		el.clone().insertAfter(el);
	});
	
$("ul.thumb li").each(function(){
    $(this).css('width', Number($(this).find('img').attr('width'))+Number(10))
    $(this).css('height', Number($(this).find('img').attr('height'))+Number(10));
});

$("ul.thumb li").hover(function() {
	var img_url = $(this).find('img').attr('src');
	var img_url_big = $(this).find('a').attr('href');
	$(this).find('img').attr('src', img_url_big );
	$(this).find('img').css('z-index', '1000' );
	$(this).find('a').attr('href', img_url );
	$(this).css({'z-index' : '11'}); /*Add a higher z-index value so this image stays on top*/ 
	$(this).find('img').addClass("hover").stop() /* Add class of "hover", then stop animation queue buildup*/
		.animate({
			marginTop: '-110px', /* The next 4 lines will vertically align this image */ 
			marginLeft: '-480px',
			top: '50%',
			left: '50%',
			width: $(this).find('a').attr('id'), /* Set new width */
			height: $(this).find('a').attr('class'), /* Set new height */
			padding: '5px'
		}, 200); /* this value of "200" is the speed of how fast/slow this hover animates */

	} , function() {
	var img_url_big = $(this).find('img').attr('src');
	var img_url = $(this).find('a').attr('href');
	$(this).find('img').attr('src', img_url );
	$(this).find('a').attr('href', img_url_big );
	$(this).css({'z-index' : '11'}); /* Set z-index back to 0 */
	$(this).find('img').removeClass("hover").stop()  /* Remove the "hover" class , then stop animation queue buildup*/
		.animate({
			marginTop: '0', /* Set alignment back to default */
			marginLeft: '0',
			top: '0',
			left: '0',
			width: $(this).find('img').attr('width'), /* Set width back to default */
			height: $(this).find('img').attr('height'), /* Set height back to default */
			padding: '5px'
		}, 400);
});



});



