﻿$(document).ready(function () {
    // Starta slideshow
    $('.bildspel').cycle({
        fx: 'fade',
        timeout: 11000,
        speed: 2000,
        delay: -10999
    });

    $(".fadein").fadeIn(800);

    $(".puff").animate({
        paddingLeft: "0px"
    }, 1500);

    $(".klick").mouseover(function (e) {
        $(this).addClass("hover");
        return false;
    }).mouseout(function (e) {
        $(this).removeClass("hover");
        return false;
    }).click(function (e) {
        $(this).find("a").each(function (e) {
            if ($(this).attr("href") != null) {
                document.location = $(this).attr("href");
                return false;
            }
        });
        return false;
    });

    /* Anv i rullgardsinsmenyer */
    $(".klick2").mouseover(function (e) {
        $(this).addClass("hover");
    }).mouseout(function (e) {
        $(this).removeClass("hover");
        return false;
    }).click(function (e) {
        $(this).find("a").each(function (e) {
            if ($(this).attr("href") != null) {
                document.location = $(this).attr("href");
                return false;
            }
        });
        return false;
    });

    $(".rull").mouseover(function (e) {
        $(this).addClass("hover");
        var MinGardin = $(this).attr("c4target");
        // $("#callander1").val(MinGardin); Detta blev inte så bra.
        // Göm alla andra menyer
        $(".gardin").each(function () {
            if ("#" + $(this).attr("id") != MinGardin) {
                $(this).hide(200);
            }
        });
        if (MinGardin != null) {
            $(MinGardin).show(200);
        }
        return false;
    }).mouseout(function (e) {
        $(this).removeClass("hover");
        var MinGardin = $(this).attr("c4target");
        // if ($("#callander1").val() == MinGardin) { Detta blev inte så bra
        //   $("#callander1").val("");
        // }
        if (MinGardin != null) {
            $(MinGardin).oneTime(7000,
            function () {
                if ($("#callander1").val() != MinGardin) {
                    $(MinGardin).hide(200)
                }
            });
        }
        return false;
    }).click(function (e) {
        $(this).find("a").each(function (e) {
            if ($(this).attr("href") != null) {
                document.location = $(this).attr("href");
            }
            return false;
        });
    });

    $(".gardin").mouseover(function (e) {
        $("#callander1").val("#" + $(this).attr("id"));
    })
    .mouseout(function () {
        $("#callander1").val("");
    });

    $(".c4reveal").click(function () {
        var mytarget = $(this).attr("c4target");
        var targetid = $(mytarget).attr("id");
        var myhide = $(this).attr("c4hide");
        if (myhide != null) {
            $(myhide).each(function () {
                if ($(this).attr("id") != targetid)
                //$(this).fadeOut(300);
                    $(this).hide();
            });
        }
        $(mytarget).fadeIn(500);
    })

    // Från Nico
    // Generell klickyta
    $(".klick3").mouseover(function (e) {
        $(this).addClass("hover");
    }).mouseout(function (e) {
        $(this).removeClass("hover");
    }).click(function () {
        var hide = $(this).attr("c4hide");
        $(hide).hide();
        var targetId = "#" + $(this).attr("c4target");
        if (!$(targetId).visible) {
            $(targetId).fadeIn(1500);
        }
        $(this).removeClass("c4slide");
    });

    // Pressbilds klickyta
    $(".pressbild").mouseover(function (e) {
        $(this).addClass("presshover");
    }).mouseout(function (e) {
        $(this).removeClass("presshover");
    }).click(function (e) {
        $(this).find("a").each(function (e) {
            if ($(this).attr("href") != null) {
                document.location = $(this).attr("href");
            }
        });
    });

    // Paging post right menu
    $(".getitems").load("/ajax/items.aspx", function () {
        $(this).slideDown(400);
    });
    $(".clicktofetch").click(function () {
        var y = $(this).attr("title");
        //$(this).hide();
        $(this).load("/ajax/items.aspx?y=" + y, function () {
            $(this).slideDown(400);
        });
    });
});