var myShow=null;
var paused=false;
var cookie_name="logo";
var static_image=false;


jQuery.noConflict();

window.addEvent('domready', function(){
    //je nastavena cookie pro zastaveni animace?
    if (jQuery.cookie(cookie_name)=="stop") {
        showStaticPicture();
    } else {
        animate();
    }
});

function showStaticPicture() {
    var data;
    switch (lang) {
        case "cs":
            data = {
                '02s.jpg': {
                    caption: 'Společnost Franze Kafky je nevládní nezisková organizace, která byla založena v roce 1990. <div id="slideshow_author">Autor: Jan Lukas</div>'
                },
                '01s.jpg': {
                    caption: 'Jejím hlavním cílem je přispět k oživení tradic, z nichž vzešel unikátní fenomén tzv. pražské německé literatury.'
                }
            };  
            break;
        case "en" :
            data = {
                '02s.jpg': {
                    caption: 'Established in 1990, the Franz Kafka Society is a non-governmental non-profit organization. <div id="slideshow_author">Author: Jan Lukas</div>'
                },
                '01s.jpg': {
                    caption: 'Its main goal is to contribute to reviving the traditions that gave rise to the phenomenon called Prague German literature.'
                }
            };
            break;
        case "de" :
            data = {
                '02s.jpg': {
                    caption: 'Franz-Kafka-Gesellschaft ist eine nichtstaatliche Organisation, die im Jahre 1990 gegründet wurde. <div id="slideshow_author">Autor: Jan Lukas</div>'
                },
                '01s.jpg': {
                    caption: 'Ihr Hauptziel ist es zur Wiederbelebung von Traditionen beizutragen, aus denen das einzigartige Phänomen der sog.'
                }
            };
            break;
    }
    
    myShow = new Slideshow('show', data, {
        controller: false, 
        captions: true, 
        href:dir, 
        delay: 20000, 
        height: 200, 
        hu: dir+'/logo_pics/', 
        width: 950
    });	
    jQuery("#slideshow_toggle").html(start_animation_text);
    static_image=true;
}

function animate() {
    var data;
    switch (lang) {
        case "cs":
            data = {
                '02.jpg': {
                    caption: 'Společnost Franze Kafky je nevládní nezisková organizace, která byla založena v roce 1990. <div id="slideshow_author">Autor: Jan Lukas</div>'
                },
                '01.jpg': {
                    caption: 'Jejím hlavním cílem je přispět k oživení tradic, z nichž vzešel unikátní fenomén tzv. pražské německé literatury...'
                },
                '03.jpg': {
                    caption: '...a obnovit obecné povědomí o významu kulturní plurality středoevropského regionu, kde spolu po staletí žili Češi, Němci a Židé <div id="slideshow_author">Autor: Jan Lukas</div>'
                },
                '04.jpg': {
                    caption: 'Společnost Franze Kafky má nyní kolem 1000 členů z celkem 23 států světa.'
                },
                '05.jpg': {
                    caption: '&nbsp;'
                }
                
            };
            break;
        case "en" :
            data = {
                '02.jpg': {
                    caption: 'Established in 1990, the Franz Kafka Society is a non-governmental non-profit organization. <div id="slideshow_author">Author: Jan Lukas</div>'
                },
                '01.jpg': {
                    caption: 'Its main goal is to contribute to reviving the traditions that gave rise to the phenomenon called Prague German literature...'
                },
                '03.jpg': {
                    caption: '...while restoring general awareness of the great significance of cultural plurality in Central Europe. <div id="slideshow_author">Author: Jan Lukas</div>'
                },
                '04.jpg': {
                    caption: 'The Franz Kafka Society now has some 1000 members in a total of 23 countries throughout the world.'
                },
                '05.jpg': {
                    caption: '&nbsp;'
                }
            };
            break;
        case "de" :
            data = {
                '02.jpg': {
                    caption: 'Franz-Kafka-Gesellschaft ist eine nichtstaatliche Organisation, die im Jahre 1990 gegründet wurde. <div id="slideshow_author">Autor: Jan Lukas</div>'
                },
                '01.jpg': {
                    caption: 'Ihr Hauptziel ist es zur Wiederbelebung von Traditionen beizutragen, aus denen das einzigartige Phänomen der sog.'
                },
                '03.jpg': {
                    caption: 'Prager deutschen Literatur hervorgekommen war und das allgemeine Bewusstsein der kulturellen Pluralität... <div id="slideshow_author">Autor: Jan Lukas</div>'
                },
                '04.jpg': {
                    caption: '... der mitteleuropäischen Region zu erneuern, wo Tschechen, Deutsche und Juden einmal zusammen lebten.'
                },
                '05.jpg': {
                    caption: '&nbsp;'
                }
            };
            break;
    }
   
    myShow = new Slideshow.KenBurns('show', data, {
        controller: false, 
        captions: true, 
        href:dir, 
        duration:1000, 
        delay: 10000, 
        height: 200, 
        hu: dir+'/logo_pics/', 
        width: 950
    });
}
                
function pause() { 
    var cookie_val=jQuery.cookie(cookie_name);
    if (cookie_val==null || cookie_val=="go") {
        jQuery.cookie(cookie_name, "stop", {
            expires: 7
        });
    } else {
        if (static_image) location.reload(true);
        jQuery.cookie(cookie_name, "go", {
            expires: 7
        });
    }
    myShow.pause();  
    if (paused==true) {
        jQuery("#slideshow_toggle").html(stop_animation_text);
        paused=false;
    } else {
        myShow.destroy();
        showStaticPicture();
        jQuery("#slideshow_toggle").html(start_animation_text);
        paused=true;
    }
}

// lightbox

jQuery(function() {
    jQuery('#pictures a').lightBox();
    jQuery('.main_picture a').lightBox();
});

//init paginator
jQuery(function() {
    val=jQuery("#pages").text();
    if(val!="") {
        var pages = parseInt(val);
        if (pages > 1) {
            if (jQuery.browser.msie) {
                pages++;
            }
            jQuery("#paginator").paginate({
                count:pages,
                start:1,
                display:5,
                border:true,
                border_color:'#fff',
                text_color:'#fff',
                background_color:'#ac997b',	
                border_hover_color:'#ccc',
                text_hover_color:'#ac997b',
                background_hover_color:'#fff', 
                images:false,
                mouse:'press',
                onChange:function(page){
                    jQuery('.current','#entries').removeClass('.current').fadeOut();
                    jQuery('#p'+page).addClass('current').delay(500).fadeIn();
                    jQuery("#paginator").fadeOut();
                    jQuery("#paginator").delay(500).fadeIn();
                }
            });          
            if (jQuery.browser.msie) {
                jQuery("#paginator li").last().css('visibility', 'hidden');
            }
        }
    }
});


jQuery(function() {
    str = (jQuery("#datepicker").val());
    jQuery("#datepicker").datepicker({
        minDate: 0
    });
    jQuery("#datepicker").datepicker( "option", "dateFormat", "dd.mm.yy" );
    jQuery("#datepicker").val(str);

});
