$(document).ready(function(){


/* target _blank
--------------------------*/
$("a.blank").attr('target', '_blank');


/* document vertical align
--------------------------*/
var wHeight = $(window).height();
if (wHeight > 674) {
    wHeight = (wHeight - 674) / 2;
    $("#wrap").css("margin-top", wHeight);
}


/* navigation
--------------------------*/
$("#nav>li:first").addClass("first");
$("#nav>li:last").addClass("last");

$("#nav>li>ul").each(function(){
    var liWidth = $(this).parent().width() + 14;
    var ulLeft = (liWidth - 196) / 2;
    $(this).css("left", ulLeft);
});

$("#nav>li>.fakeA").hover(
    function(){
        $(this).css("color", "#d2232a");
        $(this).parent("li").find("ul").fadeIn(350);
    },
    function(){
    }
);

/* hover */
$("#nav>li").hover(
    function(){
    },
    function(){
        $(this).children(".fakeA").not(".current").css("color", "white");
        $(this).find("ul").fadeOut(100);
    }
);

/* current */
var pathname = window.location.href;
var folder = pathname.split("/", 6);
var folder2 = folder[3].split(".");

if (folder2[0] != "") {
    var current = "." + folder2[0] + " .fakeA";
    $(current).css("color", "#D2232A").addClass("current");
}



/* css styl
--------------------------*/
$(".news .items .block:first-child").addClass("main");

$(".inner-block>:first-child").css("margin-top", 0);
$(".inner-block .subpage_nav2").css("margin-top", 45);


/* scrolling
--------------------------*/

// set width of #block-wrap
var wWidth = $(window).width();
if (wWidth > 940) {
    var wLeft = -(wWidth - 940) / 2;
    $("#block-wrap").css({
        "width": wWidth,
        "left": wLeft
    });
}

// srollable
var total = 0;
var totalWidth = 0;
while (940 > totalWidth && total <= ($(".items>div").size() - 1)){
    totalWidth += $(".items>div").eq(total).width();
    total ++;
}

if (totalWidth > 940) {
    $(function() {
        $("#flowpanes").scrollable({mousewheel: true, circular: false});
    });
} else {
    $(".arrow").hide();
}

// scroll to beginning
$("#scroll-back").click(function(){
    $("#flowpanes").scrollable().begin(800);
});


/* sound effect
--------------------------*/
var cookieOptions = {expires: 7, path: '/'};

if ($.cookie("sound") == "soundOff") {
    $("#sound").text("zapnout zvuk").addClass("soundOn");
} else {
    $("#sound").text("vypnout zvuk").addClass("soundOff");
        swfobject.embedSWF("/public/themes/wolf/sound/shuter.swf", "sound-holder", "0", "0", "10");
}

$("#sound").click(function(){
    if ($.cookie("sound") == "soundOff") {
        $.cookie("sound", "soundOn", cookieOptions);
        $(this).removeClass("soundOn").addClass("soundOff");
    } else {
        $.cookie("sound", "soundOff", cookieOptions);
        $(this).removeClass("soundOff").addClass("soundOn");;
    }
    $(this).text() == "zapnout zvuk" ? $(this).text("vypnout zvuk") : $(this).text("zapnout zvuk");
    return false;
});

















});


