$(document).ready(function(){
	$('.menuItem').hover(function(){
        $(this).children("a").addClass("hover");
        $(this).children("a").children("span").removeClass("nohover");
        $(this).children("a").children("span").addClass("hover");

	},function(){
        $(this).children("a").removeClass("hover");
        $(this).children("a").children("span").removeClass("hover");
        $(this).children("a").children("span").addClass("nohover");
	});
	

	$('#cycleImg').children("img").show();
	if ($('#cycleImg') && ($('#cycleImg').children().length == 1)) {
	    $('#cycleImg :first').show();
	}
	else {
		$('#cycleImg').cycle({ 
			fx: 'scrollLeft',
			pause:  1
		});
	}
	
	if ($('#rightCycle') && ($('#rightCycle').children().length == 1)) {
		$('#rightCycle :first').show();
	}
	else {
		$('#rightCycle').cycle({
			fx: 'fade',
			speed: 'fast',
			timeout: 0,
			next: '#nextNav',
			prev: '#prevNav'
		});
	}

    $(".removeAction").click(function(){
        return confirm('Czy na pewno chcesz usunąć wybrany element');
    });



    $('img[hspace]').each(function(el){
        var pixels = parseInt($(this).attr('hspace'));
        if(isNaN(pixels) || pixels < 1)
            pixels = 0;
        $(this).css('marginLeft', pixels + 'px')
             .css('marginRight', pixels + 'px')
             .removeAttr('hspace');
    });

    $('img[vspace]').each(function(el){
        var pixels = parseInt($(this).attr('vspace'));
        if(isNaN(pixels) || pixels < 1)
            pixels = 0;
        $(this).css('marginTop', pixels + 'px')
             .css('marginBottom', pixels + 'px')
             .removeAttr('vspace');
    });

    $('img[border]').each(function(el){
        var pixels = parseInt($(this).attr('border'));
        if(isNaN(pixels) || pixels < 1)
            pixels = 0;
        $(this).css('border', pixels + 'px').removeAttr('border');
    });

    $('#galleryContentDiv .onePhotoGallery').each(function(){
        $('#'+$(this).attr('id')+' a').lightBox({fixedNavigation:true});
    });

    // Obsługa wyświetlania podstrony
    $('.galleryBottomField a').lightBox({fixedNavigation:true});

    $('#ckSubpageContent img').click(function(el){
        var fullPath = $(this).attr('src');
        var filename = fullPath.split('\\').pop().split('/').pop();
        $('#'+filename.substring(0, 32)).click();
    });

    $('.closeIco').click(function(){
             $(this).parent("div").css('display','none');
    })

    $('.datepicker').datepicker();

    $('.newsMainCont img').each(function(){
        if ( ! $(this).parent('a').hasClass('nolightbox')) {
            $(this).parent('a').lightBox({fixedNavigation:true})
        }        
    });

});

function resizeTextTo(size)
{
    $('div.newsDescription span').css('font-size', size);
    $('div.newsMainCont span').css('font-size', size);
    $('.mapInfo').css('font-size', size);
}
