﻿$(document).ready(function() {
    $("#bg1").show(0).animate({ opacity: 0 }, 0).animate({ backgroundPosition: "(-172px -490px)", opacity: "1" }, 3500);
    $(".fadein").fadeIn(1000);

    $("#cykel").cycle({ timeout: 15000 });

    // Generell klickyta
    $(".klick").mouseover(function(e) {
        $(this).addClass("hover");
    }).mouseout(function(e) {
        $(this).removeClass("hover");
    }).click(function(e) {
        $(this).find("a").each(function(e) {
            if ($(this).attr("href") != null) {
                document.location = $(this).attr("href");
            }
        });
    });
    $(".klick3").click(function(e) {
        $(this).find("a").each(function(e) {
            if ($(this).attr("href") != null) {
                document.location = $(this).attr("href");
            }
        });
    });

    // Generell klickyta
    $(".klick2").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");
    });

    // Generell "revealer"
    $(".c4slide").click(function() {
        var targetId = "#" + $(this).attr("c4target");
        if (!$(targetId).visible) {
            $(targetId).slideDown(300);
        }
        $(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");
            }
        });
    });

    // kontakt - language select
    $("#contactlang").change(function() {
        var val = $("#contactlang").val();
        if (val != "USA") {
            $("#con_us").hide();
            $("#con_se").fadeIn(300);
        }
        else {
            $("#con_se").hide();
            $("#con_us").fadeIn(300);
        }
    });
});
