﻿$(document).ready(function () {
    var expanderaTjanster = false;

    // Starta slideshow
    $('.c4sliderandom').cycle({
        timeout: 1550000,
        speed: 1000,
        random: 1
    });

    $('.c4sliderandom').fadeIn(200);

    $(".c4delay").oneTime(1600, function () {
        $(this).animate({
            right: '5'
        }, 2000);
    });

    $(".c4delays3").oneTime(1600, function () {
        $(this).animate({
            right: '80'
        }, 2000, function () {
            // Refresha objektet (streamio kräver detta)
            var text = $(this).html();
            $(this).html(text);
            $('.anim1').animate({
                left: '25',
                width: '325',
                top: '60'
            }, 1500);
        });
    });

    $(".anim1").fadeIn(200);
    $(".anim1").oneTime(2000, function () {
        $(this).animate({
            left: '27',
            width: '390',
            top: '60'
        }, 2000);
    });

    $(".anim2").oneTime(5000, function () {
        $(this).fadeIn(70).fadeOut(10).fadeIn(70).fadeOut(10).fadeIn(70).fadeOut(10).fadeIn(70);
    });

    $(".fadein").fadeIn(600);

    $(".fadein1").fadeIn(800);
    $(".fadein2").oneTime(300, function () {
        $(this).fadeIn(800);
    });
    $(".fadein3").oneTime(600, function () {
        $(this).fadeIn(800);
    });
    $(".fadein4").oneTime(900, function () {
        $(this).fadeIn(800);
    });

    $('.c4click')
    .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");
            }
        });
    });

    $('.superfilter').corner("6px");
    $('.puffouter').corner("6px");
    $('.bigbg2').corner("6px");
    $('.svcbox').corner("6px");

    var ishovering = false;
    $('.svcbox').hover(function () {
        ishovering = true;
        var titel = $(this).attr('title');
        var targetheight = $(this).attr('custom1');
        $('.svcbox').animate({ opacity: "0.4" }, 150);
        $(this).animate({ opacity: "1" }, 10);
        $(this).css('zIndex', 1000);
        if (expanderaTjanster) {
            $(this).animate({ height: targetheight }, 250, null, function () {
                // Callback
                $(this).children('.content').css("height", $(this).innerHeight());
                $(this).css('zIndex', 700);
            });
        }
        //return false;
    }, function () {
        ishovering = false;
        $(this).children('.content').css("height", 140);
        $(this).animate({ height: "184" }, 190, null, function () {
            // Callback
            $(this).css('zIndex', '500');
            if (!ishovering) {
                $('.svcbox').animate({ opacity: "1" }, 500);
            }
            $(this).children('.content').css("height", 140);
        });
        //return false;
    });
});

// analys online
function targetWindow(url) {
    var hwnd = ""
    var qvwinparams = "toolbar=0,location=0,directories=0,status=0,menubar=no,scrollbars=yes,copyhistory=0,dependent=yes,resizable=yes"
    screenWidth = screen.width
    screenHeight = screen.height
    qwinWidth = screenWidth * 0.9
    qvwinparams = qvwinparams + ",width=" + qwinWidth
    qwinHeight = screenHeight * 0.9
    qvwinparams = qvwinparams + ",height=" + qwinHeight
    qwinTop = (screenWidth * 0.1) / 2
    qvwinparams = qvwinparams + ",top=" + qwinTop
    qwinLeft = (screenHeight * 0.1) / 2
    qvwinparams = qvwinparams + ",left=" + qwinLeft
    hwnd = window.open(url, 'QlikView', qvwinparams);
    hwnd.focus();
}


var addthis_config =
{
    ui_cobrand: "PAR AB (www.par.se)",
    ui_header_color: "#fff",
    ui_header_background: "#333",
    data_track_clickback: true
}
