$(window).load(function(){
    //LAVALAMP MENU
    $('#nav ul#lavaLampBasicImage').lavaLamp({
        fx: "easeOutExpo",
        autoResize:true,
        speed: 700
    });
});

$(function(){
    //SOCIAL MEDIA HOVER
    if (navigator.appName != "Microsoft Internet Explorer") {
        $('.socialIcon').fadeTo(0, 1);
        $('.socialIcon').hover( function() {
            $(this).stop(true, true).fadeTo(300, 0.6);
        }, function() {
            $(this).stop(true, true).fadeTo(300, 1);
        });
    }

    //CYCLE ARTIKEL HOME
    $('#homeTeaser').cycle({
        fx: 'fade',
        timeout: 4500,
        before: function(slide, next){
            $('.homeActive').removeClass('homeActive');
            $("#"+$(next).attr('rel')).addClass('homeActive');
        }
    });

  //CYCLE ARTIKEL HOME
    $('#header_cycle').cycle({
        fx: 'fade',
        timeout: 4500
    });

    //CYCLE NEWS ARCHIVE
    $('#newsArchive').cycle({
        fx: "scrollVert",
        timeout: 0,
        startingSlide:   0,
        pager:  '.pager',
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#"> &bull; </a>';
        },

        before: function(slide,next){
                $("#newsArchive").animate({
                'height' :  $(next).height()
                }, 1000);
        }
    }, 500);

  $('.oddeven:odd').css("background-color", "#e8f3f9");

    //CYCLE GUESTBOOK
    $('.cycle').cycle({
        fx: "scrollVert",
        timeout: 0,
        startingSlide:   0,
        pager:  '.pager',
        pagerAnchorBuilder: function(idx, slide) {
            return '<a href="#"> &bull; </a>';
        },

        before: function(slide,next){
                $(".cycle").animate({
                'height' :  $(next).height()
                }, 1000);
        }
    }, 500);

    //FANCYBOX
    $(".fancybox").fancybox();
    $(".ifancybox").fancybox({
            type: 'iframe',
            width: '80%',
            height: '80%'
    });

    $(".gallery").fancybox();

    //FANCYBOX FLOORPLANNER
    $("a.fancyboxIframe").fancybox({
        'width'        : '85%',
        'height'      : '85%',
        'autoScale'       : false,
        'transitionIn'    : 'none',
        'transitionOut'    : 'none',
        'type'        : 'iframe'
    });

    //DROPDOWN
    $('#nav ul li').hover( function() {
        $(this).children('ul').stop(true, true).fadeIn(200);
    }, function() {
        $(this).children('ul').stop(true, true).fadeOut(200);
    });

    //CUFON
    Cufon.replace('h1')('h3');
    Cufon.replace('#nav a', { hover : true });

    //hover,active fix navigation
    if ($('#nav ul li.selectedLava').length) {
        $('#nav ul .inactive').hover( function() {
            $('#nav ul .active').css("color","#0079bf");
            Cufon.refresh('#nav a');
        }, function() {
            $('#nav ul .active').css("color","#D9EBF5");
            Cufon.refresh('#nav a');
        });
    } else {
        $('#nav ul li a:first').css("color","#D9EBF5");
    }

    //SUBMIT COUNTRY
    $('#country').change(function(e){
        e.preventDefault();
        window.location = "index.php?mod=content&section=Dealers&id=148#" + $(this).attr('value');
    });

    //RIGHT HEIGHT
    if ($('.contentHeight').height() < $('.right').height()) {
        $('.contentHeight').height($('.right').height());
    } else {
        $('.right').height($('.contentHeight').height() + 50);
    }
});

