
$(function(){
	$("#header").animate({
                backgroundPosition: "-=500"
    }, 80000);
	
	$('.tooltip_content').hide();
});


var RecaptchaOptions = {
    custom_translations: {
        visual_challenge: "Zadanie graficzne",
        audio_challenge: "Zadanie dźwiękowe",
        refresh_btn: "Nowe zadanie",
        instructions_visual: "Wpisz słowa z obrazka:",
        instructions_audio: "Wpisz osiem liczb:",
        help_btn: "Pomoc",
        play_again: "Odtwórz dźwięk ponownie",
        cant_hear_this: "Pobierz dźwięk jako MP3",
        incorrect_try_again: "Źle. Spróbuj ponownie."
    },
    theme: 'blackglass',
    lang: 'pl'
};

// Define configuration defaults
$.fn.qtip.defaults = $.extend(true, {}, $.fn.qtip.defaults, {
    prerender: false,
    id: false,
    overwrite: true,
    content: {
        text: true,
        attr: 'title',
        title: {
            text: false,
            button: false
        }
    },
    position: {
        my: 'center left', // Position my top left...
        at: 'center right',
        adjust: {
            x: 0,
            y: 0
        },
        viewport: $(window)
    },
    show: {
        target: false,
        event: 'mouseenter',
        effect: function(offset){
            $(this).fadeIn(300);
        },
        delay: 400,
        solo: true,
        ready: false,
        modal: false
    },
    hide: {
        target: false,
        event: 'mouseleave',
        effect: function(offset){
            $(this).fadeOut(300);
        },
        delay: 0,
        fixed: false,
        inactive: false
    },
    style: {
        classes: 'ui-tooltip-md',
        widget: false,
        tip: {
            corner: true,
            border: 4,
            width: 10,
            height: 10,
            offset: 10
        }
    },
    events: {
        render: null,
        move: null,
        show: null,
        hide: null,
        toggle: null,
        focus: null,
        blur: null
    }
});



$(function(){

    // Internet Exploder version specific CSS
    if (jQuery.browser.msie) {
        $("#header,#menu,#main,#footer").addClass("ie");
        $("#header,#menu,#main,#footer").addClass("ie" + parseInt(jQuery.browser.version));
    }
    
    // JQUERY UI DEFAULTS
    $.fx.speeds._default = 800;
    
    // DIALOG BOXES WITH SMOOTH OVERLAY HIDE EFFECT
    $("#dialog").dialog({
        autoOpen: true,
        height: 140,
        modal: true,
        closeText: 'Zamknij',
        height: 'auto',
        resizable: false,
        draggable: false,
        buttons: {
            "Ok": function(){
                $(this).dialog("close");
            }
        }
    });
    
    $("#dialog").bind("dialogbeforeclose", function(event, ui){
        $(".ui-dialog").fadeOut(500, function(){
            $(".ui-widget-overlay").fadeOut(500, function(){
                $('#dialog').unbind("dialogbeforeclose");
                $('#dialog').dialog('close');
            });
        });
        return false;
    });
    
    
    
    $("#accordion").accordion({
        'fillSpace': true
    });
    
    $(".tabs").tabs();
    
    $('ul > li:first-child').each(function(){
        $(this).find('a:first').addClass('first');
    });
    $('ul > li:last-child').each(function(){
        $(this).find('a:first').addClass('last');
    });
    // ==========================================================DATEPICKER
    $(function(){
        $(".datepicker").datepicker();
    });
    
});

jQuery(function($){
    $.datepicker.regional['pl'] = {
        closeText: 'Zamknij',
        prevText: '&#x3c;Poprzedni',
        nextText: 'Następny&#x3e;',
        currentText: 'Dziś',
        monthNames: ['Styczeń', 'Luty', 'Marzec', 'Kwiecień', 'Maj', 'Czerwiec', 'Lipiec', 'Sierpień', 'Wrzesień', 'Październik', 'Listopad', 'Grudzień'],
        monthNamesShort: ['Sty', 'Lu', 'Mar', 'Kw', 'Maj', 'Cze', 'Lip', 'Sie', 'Wrz', 'Pa', 'Lis', 'Gru'],
        dayNames: ['Niedziela', 'Poniedzialek', 'Wtorek', 'Środa', 'Czwartek', 'Piątek', 'Sobota'],
        dayNamesShort: ['Nie', 'Pn', 'Wt', 'Śr', 'Czw', 'Pt', 'So'],
        dayNamesMin: ['N', 'Pn', 'Wt', 'Śr', 'Cz', 'Pt', 'So'],
        weekHeader: 'Tydz',
        dateFormat: 'yy-mm-dd',
        firstDay: 1,
        isRTL: false,
        showMonthAfterYear: false,
        yearSuffix: ''
    };
    $.datepicker.setDefaults($.datepicker.regional['pl']);
    $.datepicker.formatDate('yy-mm-dd', new Date(2007, 1 - 1, 26));
});

$(function(){

    // ==========================================================FLASH MESSAGES
    $(function(){
        var t = setTimeout("$('.flash_message').fadeOut(1000);", 15000);
        $(".flash_message").click(function(){
            $(this).fadeOut(1000);
        })
    });
    
    // ==========================================================BUTTONS
   
    $(function(){
        $("input:submit").button();
    });
    
    
    // ==========================================================PANORAMAS
    
    $(".kontakt.tooltip").qtip({
            position: {
                my: 'top center', // Position my top left...
                at: 'bottom center',
                adjust: {
                    x: -50,
                    y: -190
                }
            },
            show: {
                event: 'mouseover',
				delay: 0
            },
			hide: {
				delay: 0,
				fixed: true
			},
            style: {
                classes: 'ui-tooltip-md blue',
                widget: false,
                tip: {
                    corner: true,
                    border: 3,
                    width: 12,
                    height: 12,
                    offset: 0
                }
            }
    });
    
    $(".panoramas .tooltip").each(function(){
        $(this).qtip({
            content: {
                text: $(this).next('.tooltip_content').html()
            },
            position: {
                my: 'top center', // Position my top left...
                at: 'bottom center',
                adjust: {
                    x: 0,
                    y: 0
                }
            },
            style: {
                classes: 'ui-tooltip-md blue',
                widget: false,
                tip: {
                    corner: true,
                    border: 3,
                    width: 12,
                    height: 12,
                    offset: 0
                }
            }
        });
    });
    
    
    //============================================================= IE 7 default browser tooltip hide fix 
    
    
    if ($.browser.msie) {
        if (parseInt($.browser.version) == 7) {
            $(".tooltip").each(function(){
                temp = $(this).attr('title');
                $(this).attr('tooltip', temp);
                $(this).attr('alt', '');
                $(this).find('img').attr('alt', '');
                $(this).attr('title', '');
            });
        }
    }
    
    
    
    // ==========================================================outside table overlay
    // Taki pomysł aby reszta poza tabelką z tooltipami przyciemniała się
    
    /*
     $(".tabela1").hover(function(){
     overlay_show();
     },function(){
     overlay_hide();
     })
     */
    // ==========================================================================TOOLTIPY W OFERCIE W TABELCE KORZYŚCI
    
    $(".tabela1 dt").each(function(){
        $(this).qtip({
            content: {
                text: $(this).next().html(),
                title: $(this).html(),
                button: 'Close'
            }
        });
    });
    
    // =================================================================FANCYBOX
    $(".fancybox").fancybox({
        'width': 800,
        'height': 500,
        'centerOnScroll': true,
        'overlayOpacity': 0.80,
        'overlayColor': "#111111",
        'titleShow': false,
        'titlePosition': 'outside',
        'transitionIn': 'elastic',
        'transitionOut': 'elastic',
        'speedIn': 700,
        'speedOut': 700,
        'padding': 7,
        'onCleanup': function(){
            $('iframe').remove();
        }
    });
    
});

// ================================================================OPEN VIDEO
function open_movie(link){
    $('<a href="' + link + '" class="iframe"></a> ').fancybox({
        'overlayShow': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#EEE',
        'width': 850,
        'height': 485
    }).trigger('click');
}


//================================================================OPEN TOUR
function open_tour(service, id){
    $('<a href="' + APP_URL + 'tour_viewer/viewext/' +
    service +
    "/" +
    id +
    '" class="iframe"></a> ').fancybox({
        'width': 800,
        'height': 500,
        'centerOnScroll': true,
        'overlayShow': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#EEE',
        'titleShow': false,
        'margin': 20,
        'padding': 7
    }).trigger('click');
}

function open_tour2(service, id){
    $('<a href="' + APP_URL + 'tour_viewer/view_tour/' +
    service +
    "/" +
    id +
    '" class="iframe"></a> ').fancybox({
        'width': 800,
        'height': 500,
        'centerOnScroll': true,
        'overlayShow': true,
        'overlayOpacity': 0.8,
        'overlayColor': '#EEE',
        'titleShow': false,
        'margin': 20,
        'padding': 7
    }).trigger('click');
}

function overlay_show(){
    $('#overlay').width($(document).width());
    $('#overlay').height($(document).height());
    $('#overlay').fadeIn(500);
}

function overlay_hide(){
    $('#overlay').fadeOut(500);
}

