$(function() {
    startFrontpage()
});

mainMenu1Cur = 1;
var gsi = 1;
var s = 2200;
var cs = 220;
var __int = 4500;
var t = 0;
var cstop = 0;
var last = 5;
var first = 1;
var prev = a;
var maxN = 3;
var speed = 100;
var cl = true;
var inviteBlock = 0;

$(document).ready(function() {
    $("#gsn_" + gsi).addClass("grande_spot_nav_activ");
    $(".grande_spot_nav").click(function() {
        grandeClick($(this).attr("id"))
    });
    if (a > 1) {
        t = setTimeout("grandeSpot(a,0)", __int);
        $(".grande_spot_holder").hover(function() {
            grandeSpotStop()
        },
        function() {
            grandeSpotGo()
        })
    }
    $(".grande_spot_holder").hover(function() {
        $(".grande_spot_image").fadeTo(90, 0.93)
    },
    function() {
        $(".grande_spot_image").fadeTo(90, 1)
    });
});

function startFrontpage() {
    $(".grande_spot_nav").click(function() {
        grandeClick($(this).attr("id"))
    });
    $("#gsn_" + gsi).addClass("grande_spot_nav_activ");
    $(".r_n_holder").click(function() {
        lng = $("#lng").val();
        window.top.location = "/" + lng + "/frontpage/rss"
    });
    $(".grande_spot_nav").css("cursor", "pointer")
}
function clear(A, B) {
    if (A == (B - 1)) {
        $(".knt li").each(function(D, C) {
            var E = $(C).offset();
            alert(E.left);
            if (E.left < 0) {
                $(C).remove()
            }
        });
        $(".knt li").each(function(D, C) {
            if (D >= A) {
                $(C).remove()
            }
        });
        cl = true
    }
}
function grandeSpot(B, A) {
    if (B > 1) {
        if (A > 0) {
            if (c == gsi) {} else {
                prev = gsi;
                next = A;
                $("#gs_" + next).clone(true).attr("id", "gsv_" + next).insertBefore("#gsv_" + prev);
                $("#gsv_" + prev).fadeOut(cs).queue(function() {
                    $(this).remove()
                });
                setTimeout("$('.grande_spot_nav').removeClass(\"grande_spot_nav_activ\")", cs / 2);
                setTimeout("$('#gsn_'+next).addClass(\"grande_spot_nav_activ\")", cs / 2);
                gsi = next;
                t = setTimeout("grandeSpot(a,0)", __int)
            }
        } else {
            if (gsi >= B) {
                prev = B;
                next = 1;
                gsi = 1
            } else {
                prev = gsi;
                next = gsi + 1
            }
            $("#gs_" + next).clone(true).attr("id", "gsv_" + next).insertBefore("#gsv_" + prev);
            $("#gsv_" + prev).fadeOut(s).queue(function() {
                $(this).remove()
            });
            setTimeout("$('.grande_spot_nav').removeClass(\"grande_spot_nav_activ\")", s / 2);
            setTimeout("$('#gsn_'+next).addClass(\"grande_spot_nav_activ\")", s / 2);
            gsi = next;
            t = setTimeout("grandeSpot(a,0)", __int)
        }
    }
}
function grandeSpotStop() {
    pr = $("#gsv_" + prev).css("opacity");
    if (pr != null) {
        if (pr < 0.4) {
            $("#gsv_" + prev).stop()
        } else {
            grandeClick("gsn_" + prev)
        }
    }
    clearTimeout(t)
}
function grandeSpotGo() {
    t = setTimeout("grandeSpot(a,0)", __int)
}
function grandeClick(A) {
    clearTimeout(t);
    c = parseInt(A.replace("gsn_", ""));
    grandeSpot(a, c)
}
