﻿$(function () {
    $("#background").cycle({
        fx: 'scrollHorz',
        timeout: 10000,
        next: '#next',
        prev: '#prev',
        before: onBefore,
        after: onAfter
    });

    $("#news li").hover(
        function () {
            $(this).children('img').stop(true).animate({ top: '-42px' }, 100);
        },
        function () {
            $(this).children('img').stop(true).animate({ top: '0px' }, 100);
        }
    )

    $("#news .details .more").click(function (e) {
        e.preventDefault();

        var clicked = $(this)
        clicked.next().slideToggle(100, function () {
            if ($(this).is(":visible")) {
                clicked.children('span').css("background-position", "-126px 0");
            } else {
                clicked.children('span').css("background-position", "-84px 0");
            }
        });
    });
});

function windowWidth() {
    return $(window).width();
}

function onBefore(curr, next, opts) {
    $('#client-copy section').fadeOut("slow");
}

function onAfter(curr, next, opts) {
    $('#client-copy #' + next.className).fadeIn("slow");
}
