$(document).ready(function () {

    // When page loads...

    // *** Menu - Navigation ***
    $(" #nav a:last").css({ borderRight: 0 });

    $(" #nav ul ").css({ display: "none" }); // Opera Fix

    $(" #nav li").hover(function () {
        var fade = $(this).find('ul:first');
        if (fade.is(':animated')) {
            fade.css({ visibility: "visible", display: "none" }).show();
        } else {
            fade.css({ visibility: "visible", display: "none" }).show(200);
        }
    }, function () {
        var fade = $(this).find('ul:first');
        if (fade.is(':animated')) {
            fade.hide().css({ visibility: "hidden" });
        } else {
            fade.hide(200, function () { $(this).css({ visibility: "hidden" }) });
        }
    });

    $("#nav li a").hover(
            function () { $(this).addClass('nav_a_hover'); },
            function () { $(this).removeClass('nav_a_hover'); }
            );

    $("#nav li a.dblad").hover(
            function () { $(this).removeClass().addClass('nav_a_dblad_hover'); },
            function () { $(this).removeClass().addClass('dblad'); }
            );

    $("#nav > li > ul:eq(0) a").hover(
            function () { $("#nav > li:eq(2) a:first").removeClass().addClass('nav_a_dblad_hover'); },
            function () { $("#nav > li:eq(2) a:first").removeClass().addClass('dblad'); }
            );

    $("#nav > li > ul:eq(1) a").hover(
            function () { $("#nav > li:eq(3) a:first").removeClass().addClass('nav_a_dblad_hover'); },
            function () { $("#nav > li:eq(3) a:first").removeClass().addClass('dblad'); }
            );

    // *** Sliding - News ***
    $(".slidetabs").tabs(".images > div", {
        // enable "cross-fading" effect
        effect: 'slide',
        fadeOutSpeed: 'fast',
        // start from the beginning after the last tab
        rotate: true
        // use the slideshow plugin. It accepts its own configuration
        // }).slideshow({ autoplay: true, interval: 30000, clickable: false });
    });

    // *** Round Picture - Menu-Navi with Fisheyish behavior ***
    $("#picnav > a").hover(
            function () {
                var picindex = ($(this).index() + 1);
                // var img = $('> img', this);
                var infotext = $(' span:eq(4)', this);
                // var imgfile = 'jpg/CircleNavi0' + picindex + '_1.jpg';

                infotext.stop(true, true).fadeIn();
                $(this).css({ cursor: "hand" });
                // img.stop(true, true).animate({ width: 160, height: 160, marginTop: 0, marginRight: 0, marginLeft: 0 }, 300);
            },
            function () {
                var picindex = ($(this).index() + 1);
                // var img = $('> img', this);
                var infotext = $(' span:eq(4)', this);
                // var imgfile = 'jpg/CircleNavi0' + picindex + '.jpg';

                infotext.stop(true, true).fadeOut();
                $(this).css({ cursor: "normal" });
                // img.stop(true, true).animate({ width: 140, height: 140, marginTop: 10, marginRight: 10, marginLeft: 10 }, 230);
            }
        );

    // *** Hovered Picture - Link Fisheyish behavior for Stopper ***
//    $("#stopperHover").hover(
//            function () {
//                var img = $('a img', this);
//                img.stop(true, true).animate({ width: 186, height: 85, marginTop: 0, marginRight: 0, marginBottom: 0, marginLeft: 0 }, 200);
//            },
//            function () {
//                var img = $('a img', this);
//                img.stop(true, true).animate({ width: 174, height: 75, marginTop: 6, marginRight: 6, marginBottom: 6, marginLeft: 6 }, 200);
//            }
//        );

    // *** Hovered Picture - Link Fisheyish behavior for Webshop ***
    $("#webshopHover").hover(
            function () {
                var img = $('a img', this);
                img.stop(true, true).animate({ width: 216, height: 150, marginTop: 0, marginRight: 0, marginBottom: 0, marginLeft: 0 }, 200);
            },
            function () {
                var img = $('a img', this);
                img.stop(true, true).animate({ width: 204, height: 138, marginTop: 6, marginRight: 6, marginBottom: 6, marginLeft: 6 }, 200);
            }
        );


    //        $.each(jQuery.browser, function (i, val) {
    //            if (i == 'msie' && val == true && $.browser.version.substr(0, 1) <= 8) {
    //                $("#navtext1").css("filter", "alpha(opacity=1)");
    //            }

    // *** News-Detailed POP-UP window ***
    $(function () {
        $("#apple a.more[rel]").overlay({ effect: 'apple', fadeInSpeed: 'slow', closeOnClick: true });
    });

    $(function () {
        $("#stopper a.more[rel]").overlay({ effect: 'apple', fadeInSpeed: 'slow', closeOnClick: true });
    });

    $(function () {
        $("div.popup a.more[rel]").overlay({ effect: 'apple', fadeInSpeed: 'slow', closeOnClick: true });
    });

    //    $(function () {
    //        $("#body").stop(true, true).fadeIn(2000);
    //    });

});

