var hideMessages = function hideMessage() {
    $(".message").hide("slow");
    
    return false;
};
// wyświetlaniemessages
var showMessageFunction = function() {
	if($(".message")) {
		$(".message").hide();
		$(".message").show("slow");
	}
};
$(document).ready(showMessageFunction);

var bannerRedirectUrl = '';
$(document).ready(function() {
    $("a.chowajMsg").click(hideMessages);

    $('.banner_click').click(function() {
        var u = $(this).attr('id');
        u = u.replace(/_/g, '/');
        bannerRedirectUrl = $(this).attr('href');
        $.ajax({
            url: '/banners/click/'+u,
            success:function(data){
                if(data) {
                    document.location.href = data;
                }
                else {
                    document.location.href = bannerRedirectUrl;
                }
            }
        });
        
        return false;
    });
    
    // Lightbox rules
    /*
    $('a.lightbox').lightBox({
        overlayBgColor: '#000',
        overlayOpacity: 0.6,
        imageLoading:   '/images/lightbox/loading.gif',
        imageBtnClose:  '/images/lightbox/close.gif',
        imageBtnPrev:   '/images/lightbox/lewo.png',
        imageBtnNext:   '/images/lightbox/prawo.png',
        containerResizeSpeed: 350,
        txtImage: '',
        txtOf: '/'
    });
    */
});


function registerCourse() {
    document.location.href = '/index/signup';
}

function fixAfterPlayer() {
    $('#galleryHolder').css('height', '700px');
    $('#player').empty();
}

function playGalleryVideo(file) {
    //alert('test');
    
    if ($('.player')) {
        //$('.pika_main .pika_subdiv').empty();
        
        $('#galleryHolder').css('height', '200px');
        $('#player').append(
        flowplayer("player", "http://releases.flowplayer.org/swf/flowplayer-3.2.2.swf", {
            "clip":{
                "url":file,
                autoPlay: false
            },
            "screen":{
                "height":"100pct",
                "top":0
            },
            "plugins":{
                "controls":{
                    "borderRadius":"0px",
                    "timeColor":"#ffffff",
                    "slowForward":true,
                    "bufferGradient":"none",
                    "backgroundColor":"rgba(0, 0, 0, 0)",
                    "volumeSliderGradient":"none",
                    "slowBackward":false,
                    "timeBorderRadius":20,
                    "progressGradient":"none",
                    "time":true,
                    "height":26,
                    "volumeColor":"#4599ff",
                    "tooltips": {
                        "marginBottom":5,
                        "volume":true,
                        "scrubber":true,
                        "buttons":false
                    },
                    "opacity":1,
                    "fastBackward":false,
                    "timeFontSize":12,
                    "border":"0px",
                    "volumeSliderColor":"#ffffff",
                    "bufferColor":"#a3a3a3",
                    "buttonColor":"#ffffff",
                    "mute":true,
                    "autoHide": {
                        "enabled":true,
                        "hideDelay":500,
                        "mouseOutDelay":500,
                        "hideStyle":"fade",
                        "hideDuration":400,
                        "fullscreenOnly":true
                    },
                    "backgroundGradient":"none",
                    "width":"100pct",
                    "sliderBorder":"1px solid rgba(128, 128, 128, 0.7)",
                    "display":"block",
                    "buttonOverColor":"#ffffff",
                    "fullscreen":true,
                    "timeBgColor":"rgb(0, 0, 0, 0)",
                    "scrubberBarHeightRatio":0.2,
                    "bottom":0,
                    "stop":false,
                    "sliderColor":"#000000",
                    "zIndex":1,
                    "scrubberHeightRatio":0.6,
                    "tooltipTextColor":"#ffffff",
                    "sliderGradient":"none",
                    "timeBgHeightRatio":0.8,
                    "volumeSliderHeightRatio":0.6,
                    "timeSeparator":" ",
                    "name":"controls",
                    "volumeBarHeightRatio":0.2,
                    "left":"50pct",
                    "tooltipColor":"rgba(0, 0, 0, 0)",
                    "playlist":false,
                    "durationColor":"#b8d9ff",
                    "play":true,
                    "fastForward":true,
                    "progressColor":"#4599ff",
                    "timeBorder":"0px solid rgba(0, 0, 0, 0.3)",
                    "volume":true,
                    "scrubber":true,
                    "volumeBorder":"1px solid rgba(128, 128, 128, 0.7)",
                    "builtIn":false
                }
            }
        }));
    }

}

$(document).ready(function() {
    /*
    $('#playervideo').bind('click', function(){
       alert('teest'); 
    });
    */
    $('input.left, input.right').click(function() {
        if (this.value == this.defaultValue) {
            this.value = '';
        }
    });
    
    $('input.left, input.right').blur(function() {
        if (this.value == '') {
            this.value = this.defaultValue;
        }
    });
});


$(document).ready(function() {
    $(".button").click(function(){
        $("#newsletter_form").submit();
	});
});

