﻿//<![CDATA[
var mycarousel_itemList = [
    { url: 'images/factory/1.png', title: 'ASUS', link: 'http://es.asus.com/', extra: 'target="_blank"' },
    { url: 'images/factory/2.png', title: 'FUJITSU', link: 'http://www.fujitsu.com/es/', extra: 'target="_blank"' },
    { url: 'images/factory/3.png', title: 'INTEL', link: 'http://www.intel.com/', extra: 'target="_blank"' },
    { url: 'images/factory/4.png', title: 'LG', link: 'http://es.lge.com/', extra: 'target="_blank"' },
    { url: 'images/factory/5.png', title: 'GIGABYTE', link: 'http://www.giga-byte.es/', extra: 'target="_blank"' },
    { url: 'images/factory/6.png', title: 'APPLE', link: 'http://www.apple.com/es/', extra: 'target="_blank"' },
    { url: 'images/factory/7.png', title: 'D-LINK', link: 'www.dlink.es/', extra: 'target="_blank"' },
    { url: 'images/factory/8.png', title: 'KASPERSKY', link: 'http://www.kaspersky.com/', extra: 'target="_blank"' },
    { url: 'images/factory/9.png', title: 'LEXMARK', link: 'http://www.lexmark.es/', extra: 'target="_blank"' },
    { url: 'images/factory/10.png', title: 'BROTHER', link: 'http://www.brother.es/', extra: 'target="_blank"' }
];

/* circular loop functions */
function mycarousel_itemVisibleInCallback(carousel, item, i, state, evt)
{
    // The index() method calculates the index from a
    // given index who is out of the actual item range.
    var idx = carousel.index(i, mycarousel_itemList.length);
    carousel.add(i, mycarousel_getItemHTML(mycarousel_itemList[idx - 1]));
};
function mycarousel_itemVisibleOutCallback(carousel, item, i, state, evt)
{
    carousel.remove(i);
};

/* auto advance functions */
function mycarousel_initCallback(carousel)
{
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_getItemHTML(item)
{
    return '<a href="' + item.link + '" ' + item.extra + '><img src="' + item.url + '" width="213" height="96" alt="' + item.title + '" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel').jcarousel({
        wrap: 'circular',
        itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
        itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
        auto: 7,
        initCallback: mycarousel_initCallback
    });
});

//]]>