$(document).ready(function() {

    // Hide all elements
    $('#module_newsletter ul li div').hide();
    $('#module_tips').hide();
    $('#module_tips').css("height", 0);
    $('#module_tips').css("margin-top", 0);

    // onClick module_newsletter
    $('#module_newsletter ul li a').click(
    function() {
        var element = $(this).next();

        if (element.is(':visible')) {
            element.slideUp('slow', function() {
                $(this).parent().removeClass('active');
            });
        } else {
            $('#module_newsletter ul li div:visible').slideUp('slow', function() {
                $(this).parent().removeClass('active');
            });
            element.slideDown('slow', function() {
                $(this).parent().addClass('active');
            });
        }
        return false;
    }
  );

    $('#module_tips #berichtTxt').click(
    function() {
        $(this).val("");
    }
  );
    $('#module_tips #emailTxt').click(
    function() {
        $(this).val("");
    }
  );
    $('#module_directchat #vraagTxt').click(
    function() {
        $(this).val("");
    }
  );

    $('.tips').click(
    function() {
        $("#module_tips").animate({
            marginTop: "-225px",
            height: "300px"
        }, 500);
        //$('#module_tips').slideDown('fast');
        return false;
    }
  );

    $('#module_tips #close').click(
    function() {
        $("#module_tips").animate({
            marginTop: "0px",
            height: "0px"
        }, 500, function() {
            $('#module_tips').hide();
        });
        return false;
    }
  );
    if ($("#myMovie").val() != undefined) {
        $("#mainmenu li").hover(
      function() {
          thisMovie("myMovie").menuOver($('a', this).attr('rel'));
      }, function() {
          thisMovie("myMovie").mouseOut($('a', this).attr('rel'));
      });
    }

    // Floating topOfPage link
    topOfPage();
});

// Floating topOfPage link
function topOfPage() {
    // Show topOfPage link if content exceeds browser height and exceeds height of footer and right column (else there's no room for the link)
    try {
        if (($(document).height() > $(window).height()) && ($(document).height() > 785)) {
            //$(".topOfPage").css("display","block");
            $(window).scroll(function() {
                if ($(".topOfPage").css("display") == "none") {
                    $(".topOfPage").css("display", "block");
                }
                offset = ($(document).scrollTop() + $(window).height() - 40);
                // Not too high or low?
                if (offset < 650) offset = 650;
                if ($(document).height() - offset < 135) offset = $(document).height() - 135;
                // Let's go...
                $(".topOfPage").animate({ top: offset + "px" }, { duration: 500, queue: false });
            });
        }
    } catch (ex) {
        //alert(ex);
    }
}
