﻿$(document).ready(function () {

    $('.fwHeader .TopMenu > ul > li,.fwHeader .TopMenu > ul > li > ul > li,.fwHeader .TopMenu > ul > li > ul > li > ul > li,.fwHeader .TopMenu > ul > li > ul > li > ul > li> ul >li').hover(function () {
        $(this).children().show();
    }, function () {
        $(this).find('ul').hide();
    });

    $(".ContentProduct .Ingress h2:empty").parent().css({ 'display': 'none' });
    $('ul.ListProduct li div.Image a:empty').parent().parent().hide();
    $('.ContentWebfolder h2:empty').hide();
    $('ul li.searchItem h4,ul li.searchItem h3').hover(function () {
        $(this).parent().find('div.searchItem_show').show();
    }, function () {
        $(this).parent().find('div.searchItem_show').hide();
    });



    $('div.contentprodetail .imageleft .top .Title .Image').each(function () {
        if ($(this).children().length < 1) {
            $(this).css('display', 'none');
        }
    });

    $('div.categoryLinkLine').each(function () {
        if ($(this).children().length < 1) {
            $(this).css('display', 'none');
        }
    });

    
    $('div.bannerzone .Horizontal > div').each(function () {
        if ($(this).hasClass('ElementCell')) {
            $('div.bannerzone').css('display', 'block');
            $('div.fwRoot').css('float', 'left');
        }
    });


});

// ---------------------------------- slide banner---------------------------------------

frontSlideImage = function (strSelector, strSelectorButton, timeDelay) {
    var tOut;
    var curindex = 0;
    var maxindex = 0;
    var preIndex = 0;
    maxindex = $(strSelector).length;
    if (maxindex >= 2) {
        autochange($(strSelector + ":eq(" + curindex + ")"));
    }
    else {
        $(strSelectorButton + ":eq(" + curindex + ")").addClass("active");
        $(strSelector + ":eq(" + curindex + ")").fadeIn(800);
    }
    $(strSelectorButton).click(function () {
        $(strSelector + ":eq(" + preIndex + ")").fadeOut(1000);
        $(strSelector + ":eq(" + curindex + ")").css("z-index", 0);
        curindex = $(strSelectorButton).index($(this));
        autochange($(strSelector + ":eq(" + curindex + ")"));
    });
    function autochange(obj) {
        clearTimeout(tOut);
        $(obj).css("z-index", 1)
        preIndex = curindex;
        $(strSelectorButton + ".active").removeClass("active");
        $(strSelectorButton + ":eq(" + curindex + ")").addClass("active");
        $(obj).fadeIn(800, function () {
            tOut = setTimeout(function () {
                $(strSelector + ":eq(" + preIndex + ")").fadeOut(1000);
                $(strSelector + ":eq(" + curindex + ")").css("z-index", 0);
                curindex++;
                if (curindex == maxindex) curindex = 0;
                autochange($(strSelector + ":eq(" + curindex + ")"));
            }, timeDelay);
        });
    }
};



