var aImg = 1; 
var start = 1;
var isHome = true;
    
$(document).ready(function(){   
    // external links...

	$(".anketaVote").attr("href","javascript:void(0);");

    $("a[rel=external]").attr("target","_blank");         
    $("#lmenu>li").hover(function() { $(this).addClass("over"); }, function() { $(this).removeClass("over"); });     
    $("tr:even td").addClass("even");
    fancyBoxInit();
	
	if (fotoCount>1 && $("body#home").length==1) {
		isHome = $("body#home").attr("id")=="home";
	    $("#flash").css("background","url("+$("#flash img").attr("src")+")");
	    setTimeout("passImg();",1000);
	}
                                                               
	if (fontSizeD==0 || fontSizeD==undefined || fontSizeD==null) { setFontSize(3) } else { setFontSize(-1) }

});

var fontSizeD = readCookie("fontSize");
         
function setFontSize(s) {
                                                   
    if (fontSizeD<1) { fontSizeD = 1; }
    if (fontSizeD>5) { fontSizeD = 5; }

    $("body").removeClass("fontSize1");
    $("body").removeClass("fontSize2");
    $("body").removeClass("fontSize3");
    $("body").removeClass("fontSize4");
    $("body").removeClass("fontSize5");   
    
    if (s>0) { fontSizeD = s; }
    if (s=="minus") { fontSizeD--; }
    if (s=="reset") { fontSizeD = 3; }
    if (s=="plus") { fontSizeD++; }

    if (fontSizeD<1) { fontSizeD = 1; }
    if (fontSizeD>5) { fontSizeD = 5; }

    $("body").addClass("fontSize"+(fontSizeD)); 
    
    createCookie("fontSize",fontSizeD,365);   
    
} 


function fancyBoxInit() {

    $("a.thickbox").fancybox({   
        'titlePosition' : 'inside',     
        'transitionIn'    : 'elastic',
        'transitionOut'    : 'elastic'
    });
    

    $("a.thickbox[rel=gallery]").fancybox({
        'transitionIn'        : 'elastic',
        'transitionOut'        : 'elastic',
        'titlePosition'     : 'inside',        
        'titleFormat'        : function(title, currentArray, currentIndex, currentOpts) {
            return '<span id="fancybox-title-inside">Obrázek ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span>';
        }

    });
}


var fotoCount = 22; 

function rollImg() {
        $("#flash").css("background","url(/img/_promo/"+(isHome ? "foto" : "foto")+"-"+aImg+".jpg?v=1)");
        aImg++;
        var t = 1000;
        if (aImg==(fotoCount+1)) { aImg = 1; }
        setTimeout("passImg();",t);
}

function passImg() {

        $("#flash>img").hide();
        $("#flash>img").attr("src","/img/_promo/"+(isHome ? "foto" : "foto")+"-"+aImg+".jpg?v=1");
        setTimeout("showImg();",2000);
}

function showImg() {	
        $("#flash>img").fadeIn(2000);
        setTimeout("rollImg();",2000);
}
        
