﻿var img = 0;
function getNextImage() {
    $(".homeimage").children("img").fadeOut(500);
    setTimeout(function() { $(".homeimage img:eq(" + img + ")").fadeIn("normal"); }, 750);
    if (img == 3) {
        img = 0;
    } else {
        img++;
    }
}

$(document).ready(function() {
    setInterval(function() { getNextImage() }, 5000);
    var items = $(".mainmenu  .center .fr .frx").size();
    for (i = 0; i < items; i++) {
        if (i == 0) {
            $(".mainmenu .center .fr .frx:eq(" + i + ")").children("ul").css({ 'margin-right': 6 + 'px' });
        } else if (i == 1) {
            $(".mainmenu .center .fr .frx:eq(" + i + ")").children("ul").css({ 'margin-right': 85 + 'px' });
        } else if (i == 2) {
            $(".mainmenu .center .fr .frx:eq(" + i + ")").children("ul").css({ 'margin-right': 198 + 'px' });
        } else if (i == 3) {
            $(".mainmenu .center .fr .frx:eq(" + i + ")").children("ul").css({ 'margin-right': 322 + 'px' });
        } else if (i == 4) {
            $(".mainmenu .center .fr .frx:eq(" + i + ")").children("ul").css({ 'margin-right': 422 + 'px' });
        } else if (i == 5) {
            $(".mainmenu .center .fr .frx:eq(" + i + ")").children("ul").css({ 'margin-right': 524 + 'px' });
        }
    }
    $(".mainmenu .center .frx").mouseenter(function() {
        //alert($(this).width());
        $(this).children("ul").fadeIn("fast");
    });
    $(".mainmenu .center .frx").mouseleave(function() {
        $(this).children("ul").fadeOut("fast");
    });
    $(".mainmenu .center .frx li").mouseenter(function() {
        //alert($(this).width());
        $(this).children("ul").show();
    });
    $(".mainmenu .center .frx li").mouseleave(function() {
        $(this).children("ul").hide();
    });
    //acc
    $(".acc > li").click(function() {
        if ($(this).hasClass("opened")) {
        } else {
            $(".acc > li > ul").slideUp("normal");
            $(".acc > li").removeClass("opened");
            $(this).addClass("opened");
            $(this).children("ul").slideDown("normal");
        }

    });
    $(".acc > li > ul > li").click(function() {
        if ($(this).hasClass("opened")) {
        } else {
            $(".acc > li > ul > li > ul").slideUp("normal");
            $(".acc > li > ul > li").removeClass("opened");
            $(this).addClass("opened");
            $(this).children("ul").slideDown("normal");
        }

    });
});
