;$(document).ready(function()
{
    $('a[href=#top]').click(function(){
        $('html, body').animate({scrollTop:0}, 'slow');
        return false;
    });
    
    $('#head-images').cycle({
        fx:            'fade',
        speed:         1000, 
        timeout:       5000, 
        cleartypeNoBg: true 
    });
    
    $('.rolling-park .cycle') 
        .cycle({ 
            fx:         'fade',
            speed:      500, 
            timeout:    5000,
            delay:      0,
            pause:      1,
            random:     1,
            prev:       '.rolling-park .prev',
            next:       '.rolling-park .next'
    });
    
    $('.rolling-park-item .img').each(function(){
        $(this).cycle({
            activePagerClass:      'active', 
            fx:                    'fade',
            speed:                 'slow', 
            timeout:               5000, 
            pager:                 '#' + $(this).attr('rel'),
            pagerAnchorBuilder:    function(idx, slide){
                return '<li><a href="javascript:void(0);">' + (idx+1) + '</a></li>';
            },
            updateActivePagerLink: function(pager, idx, activeClass){
                $(pager).find('a').removeClass(activeClass).filter('a:eq('+idx+')').addClass(activeClass);
            },
            pause:  1,
            cleartypeNoBg: true 
        });
    });
    
	$("a[rel=colorbox]").colorbox({
            maxWidth    :   800,
            maxHeight   :   600,
            current     :   "foto {current} z {total}",
            next        :   "následující",
            previous    :   "předchozí",
            close       :   "zavřít",
            photo       :   true
    });

    $('.mail').each(function(){
        text = $(this).text().replace(/ \(a\) /g, '@').replace(/ \(?(tecka|\.)\)? /g, '.');
        $(this).html('<a href="mailto:'+text+'" title="napsat email">'+text+'</a>');
    });
    
    e=$.ajax({
        type        :   'GET',
        url         :   Vanilla.baseURL + '/stats.php',
        data        :   null,
        success     :   function(data) {
            if (data)
            {
                $('.stats .visit_total_value').text(data.stats.celkem_navstev);
                $('.stats .visit_today_value').text(data.stats.den_navstev);
                $('.stats .visit_week_value').text(data.stats.tyden_navstev);
                $('.stats .visit_online_value').text(data.stats.online);
            }
        },
        dataType    :   'json'
    });
});

var Vanilla=new function(){this.scriptMatch=/media\/js\/\w+\.js$/i;var scriptTags=document.getElementsByTagName("script");for(var i=0;i<scriptTags.length;i++){if(scriptTags[i].src&&scriptTags[i].src.match(this.scriptMatch)){this.baseURL=scriptTags[i].src.replace(this.scriptMatch,'');break;}}this.webRoot=this.baseURL.replace(/^http(s)?:\/\/[^\/]+/,'');this.httpMethod=document.URL.replace(/^(http|https)(:\/\/).*$/,"$1$2");if(this.webRoot==this.baseURL){this.baseURL=this.httpMethod+document.domain+this.webRoot;}return this;};
