function dialogDisclaimer() {
    if (!$.cookie('disclaimer')) {
			embeds = document.getElementsByTagName('embed');
			for(i = 0; i < embeds.length; i++) {
				embeds[i].style.visibility = 'hidden';
			}
				
			objects = document.getElementsByTagName('object');
			for(i = 0; i < objects.length; i++) {
				objects[i].style.visibility = 'hidden';
			}

			iframes = document.getElementsByTagName('iframe');
			for(i = 0; i < iframes.length; i++) {
				iframes[i].style.visibility = 'hidden';
			}
            
			$("#dialogDisclaimer").dialog({
				bgiframe: true,
				resizable: false,
				draggable: false,
                autoOpen: true,
				height:600,
				width:600,
				closeText: 'hide',
				modal: true,
                closeOnEscape: false,
				overlay: {
					backgroundColor: '#000',
					opacity: 0.5
				},
				buttons: {
					 'NIE AKCEPTUJĘ': function() {
						window.location.href = '/';
					},
					'AKCEPTUJĘ': function() {
						$.cookie('disclaimer', '1');
						embeds = document.getElementsByTagName('embed');
						for(i = 0; i < embeds.length; i++) {
							embeds[i].style.visibility = 'visible';
						}
						
						objects = document.getElementsByTagName('object');
						for(i = 0; i < objects.length; i++) {
							objects[i].style.visibility = 'visible';
						}

						iframes = document.getElementsByTagName('iframe');
						for(i = 0; i < iframes.length; i++) {
							iframes[i].style.visibility = 'visible';
						}
						$(this).dialog('close');
					}
				}
			});
            
            $('.ui-dialog-titlebar-close').hide();
		}
}


function winopen(plik, w, h) {
	if(window.screen) {
	aw=screen.availwidth;
	ah=screen.availheight;
	}else{
	aw=760;
	ah=480;
	}
	ustawienia=
	"left="+(aw-w)/2+","
	+"top="+(ah-h)/2+","
	+"screenX="+(aw-w)/2+","
	+"screenY="+(ah-h)/2+","
	+"width="+w+","
	+"height="+h+","
	+"toolbar=no,"
	+"location=no,"
	+"directories=no,"
	+"status=no,"
	+"menubar=no,"
	+"scrollbars=yes,"
	+"resizable=no"
	noweokno=window.open(plik,'Karta',ustawienia);
	noweokno.focus();
}

function targetBlank(el){
    var ref=el.attr("href");
 	window.open(ref);
}

$(document).ready(function() {
    /* font aaa*/
    // Reset Font Size
    var originalFontSize = $('#srodek').css('font-size');
    $(".resetFont").click(function(){
        $('#srodek').css('font-size', originalFontSize);
    });
    
    // Increase Font Size
    $(".increaseFont").click(function(){
        var currentFontSize = $('#srodek').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum*1.2;
        $('#srodek').css('font-size', newFontSize);
	    $('#srodek').css('line-height','normal');
	
        return false;
    });
    // Decrease Font Size
    $(".decreaseFont").click(function(){
        var currentFontSize = $('#srodek').css('font-size');
        var currentFontSizeNum = parseFloat(currentFontSize, 10);
        var newFontSize = currentFontSizeNum*0.8;
        $('#srodek').css('font-size', newFontSize);
	    $('#srodek').css('line-height','normal');
        return false;
    });
	
	$('.targetBlank').click(function(e){
        e.stopPropagation();
		targetBlank(this);
	});

    $('a.colorbox').colorbox({maxWidth:800,maxHeight:600});
    
    $('a.icolorbox').colorbox({iframe:true,width:960,height:660});
    
    $('a[rel="scolorbox"]').colorbox({maxWidth:800,maxHeight:600,slideshow:true,slideshowAuto:false,slideshowStart:'uruchom pokaz slajdów',slideshowStop:'zatrzymaj',current:'zdjęcie {current} z {total}',previous:'wstecz',next:'dalej'});
    
    $('a[rel="cscolorbox"]').colorbox({maxWidth:800,maxHeight:600,slideshow:true,slideshowAuto:false,slideshowStart:'uruchom pokaz slajdów',slideshowStop:'zatrzymaj',current:'zdjęcie {current} z {total}',previous:'wstecz',next:'dalej'});
    
    $('a.cscolorbox').colorbox({maxWidth:800,maxHeight:600,slideshow:true,slideshowAuto:false,slideshowStart:'uruchom pokaz slajdów',slideshowStop:'zatrzymaj',current:'zdjęcie {current} z {total}',previous:'wstecz',next:'dalej'});
	
	if ($('#slideshow').children().length > 0) {
		$('#slideshow').diapo({fx: 'simpleFade', time: '2000', loader: 'none', navigation: false, mobileNavigation: false, navigationHover: false, mobileNavHover: false, pagination: false, mobilePagination: false, thumbs: false, commands: false});
	}
    
    
    $('.files_tooltip').each(function() {
        var get_file_image = $(this).attr('id').split('_');
        
        $(this).qtip({
            content: {
                text: '<img class="throbber" src="/public/scripts/images/loading.gif" alt="Loading..." />',
                url: base_uri('ajax/file_info/'+get_file_image[1]),
                title: {
                    text: 'Informacje o pliku'
                }
            },
            position: {
                corner: {
                    target: 'bottomMiddle',
                    tooltip: 'topMiddle'
                },
                adjust: {
                    screen: true
                }
            },
            show: {
                when: 'mouseover',
                solo: true
            },
            hide: 'mouseout',
            style: {
                tip: true,
                border: {
                    width: 0,
                    radius: 4
                },
                name: 'light',
                width: 270
            }
        })
   });
   
   $('.gallery_tooltip').each(function() {
        var get_gallery_image = $(this).attr('id').split('_');
        
        $(this).qtip({
            content: {
                text: '<img class="throbber" src="/public/scripts/images/loading.gif" alt="Loading..." />',
                url: base_uri('ajax/image_info/'+get_gallery_image[1]),
                title: {
                    text: 'Informacje o obrazku'
                }
            },
            position: {
                corner: {
                    target: 'bottomMiddle',
                    tooltip: 'topMiddle'
                },
                adjust: {
                    screen: true
                }
            },
            show: {
                when: 'mouseover',
                solo: true
            },
            hide: 'mouseout',
            style: {
                tip: true,
                border: {
                    width: 0,
                    radius: 4
                },
                name: 'light',
                width: 270
            }
        })
   });
});
