/**
 * Layout Module - Amedia Creative
 *
 * @category   Layout
 * @package    Amedia_Layout
 * @author     Ever Daniel Barreto <e.barreto@amediacreative.com>
 * @copyright  Copyright (c) 2011 Amedia Creative, Inc. (http://www.amediacreative.com)
 * @version    $Id$
 */

// Define Layout Namespace
amedia.layout = amedia.layout || {};

/**
 * Module Methods
 */

amedia.layout.start = function() {

    // Setup the Home page Dynamic Lead
    amedia.layout.homeDynamicLeadSetup();
        
}

/**
 * Setup Home Page Dynamic Lead
 */
amedia.layout.homeDynamicLeadSetup = function() {

    // Dynamic Lead Setup
    if ($('#dl').length > 0)
        $('#dl').cycle({
            fx:      'scrollVert',
            pager:   '#nav',
            speed:   500,
            timeout: 6000
        });

    // If user clicks on a slide, pause the animation
    if ($('#nav a').length > 0)
        $('#nav a').bind('click', function() {
            $('#dl').cycle('pause');
        });
        
}

/**
 * Center Images vertically
 */
amedia.layout.centerImages = function() {
    // Iterate through all images
    $('img.center-image').each(function() {
        // Get current height
        var imageHeight = $(this).attr('height');
        // If height is bigger than 120px
        if (imageHeight > 120)
        {
            // Center the Image
            var marginTop = parseInt((120 - imageHeight) / 2);
            $(this).css({'margin-top': marginTop + 'px'});
        }
    });
}
