﻿
$(document).ready(function() {

    $.getScript("/include/general.js", function() {

        $("#txtSearch").focus().bind("keypress", function(e) {
            if (e.keyCode == 13) {
                e.preventDefault();
                search($("#txtSearch").val());
            }
        });

        // Fix images with align=right by adding float
        $("img[align=right]").css("float", "right");

        // Set external links
        $('a[rel=external]').attr('target', '_blank');

        $("#btnSearch").click(function() {
            search($("#txtSearch").val());
        });

        // Calendar list "show all" function
        $("#calListShowAll").bind("click", function() {
            if ($(this).text() == "Visa alla") {
                $("#calListAllEvents").show("slow");
                $(this).text("Återställ");
            }
            else {
                $("#calListAllEvents").hide("slow");
                $(this).text("Visa alla");
            }
        });

        $("#newsArchiveMenuPage1").show()

        $("#newArchiveMenuListBottonLinks a").each(function(i) {
            $(this).bind('click', { index: i }, function(e) {
                $(".newsArchiveMenuPage").hide();
                var index = e.data.index + 1;
                $("#newsArchiveMenuPage" + index).show();
            });
        });

        // Hover functionality for class "hoverButton"
        $(".hoverButton").hover(
               function() {
                   $(this).addClass("hover");
                   return false;
               },
               function() {
                   $(this).removeClass("hover");
                   return false;
               }
            );

        // Login menu show/hide
        $(".loginMenuSwitch").click(function() {
            $("#loginMenuExpanded").toggleClass("hidden");
        });


        loadEvents();
    });
});

