/**
* @author Daniel Stockhammer, BSc
* @copyright 2011, Netzmühle Internetagentur OG
* @since 11.11.2011
*/

$(document).ready(function() {
    // config
    var width = 235;
    var imgHeight = 160;
    var boxHeight = imgHeight + 90;
    var textBoxHeight = 85;

    var widthInc = 150;
    var imgHeightInc = 50;
    var boxHeightInc = 180;


    $('ul.highlight-list li.hl-item').hoverIntent(function() {
        $(this).addClass('shadow');

        $(this).css({
            'z-index': 20
        });

        var properties = {
            width: width + widthInc,
            height: boxHeight + boxHeightInc
        };

        $(this).find('div.hl-arrow').hide();

        if ($(this).hasClass('secondrow')) {
            properties.top = boxHeight + 10 - boxHeightInc;
        }

        $(this).animate(properties, {
            duration: 'fast',
            complete: $.proxy(function() {
                $(this).css({
                    'z-index': 30
                });
            }, this)
        });

        $(this).find('img.hl-item').animate({
            width: width + widthInc,
            height: imgHeight + imgHeightInc
        }, 'fast');

        $(this).find('img.hl-item.small').hide();
        $(this).find('img.hl-item.large').show();


        $(this).find('div.hl-item').animate({
            width: width + widthInc - 10,
            height: textBoxHeight + boxHeightInc - imgHeightInc,
            top: imgHeight + imgHeightInc
        }, 'fast');

        $(this).find('div.teaser').fadeOut(400);
        $(this).find('div.content').fadeIn(400);
    }, function() {
        $(this).removeClass('shadow');

        $(this).css({
            'z-index': 10
        });

        var properties = {
            width: width,
            height: boxHeight
        };

        if ($(this).hasClass('secondrow')) {
            properties.top = boxHeight + 10;
        }

        $(this).animate(properties, {
            duration: 'fast',
            complete: $.proxy(function() {
                $(this).css({
                    'z-index': 1
                });
            }, this)
        });

        $(this).find('img.hl-item').animate({
            width: width,
            height: imgHeight
        }, 'fast');

        $(this).find('img.hl-item.large').hide();
        $(this).find('img.hl-item.small').show();

        $(this).find('div.hl-item').animate({
            width: width - 10,
            height: textBoxHeight,
            top: imgHeight
        }, {
            duration: 'fast',
            complete: $.proxy(function() {
                $(this).find('div.hl-arrow').fadeIn();
            }, this)
        });

        $(this).find('div.teaser').fadeIn('fast');
        $(this).find('div.content').fadeOut('fast');
    });
});
