
/* FOR carousel COMPONENT */
function mycarousel_videos_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    $.get(
        base_url + 'module/recent_videos',
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_videos_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        }
    );
};

function mycarousel_videos_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));
    jQuery('image', xml).each(function(i) {
        carousel.add(first + i, mycarousel_videos_getItemHTML($(this).attr('img_url'), $(this).attr('title'), $(this).attr('site_url')));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_videos_getItemHTML(img_url, title, site_url)
{
	//need to change this after checking with steve
	var playImage;
	playImage = "./images/img_play_pic.gif";

	return '<table border="0" cellspacing="0" cellpadding="0"><tr><td align="center" valign="top"><a href="' + site_url + '"><img src="' + img_url + '" border="0" height="90" width="120"></a><div style="width:100px;height:0px;position:relative;left:0px;top:-50px;color:white;"><a href="' + site_url + '"><img src="'+ playImage +'" alt="play" border="0" height="21" width="24"></a></div></td></tr><tr><td align="center"><a href="' + site_url + '" class="link">'+ title +'</a></td></tr></table>';

};

jQuery(document).ready(function() {
    jQuery('#mycarousel_videos').jcarousel({
        // Uncomment the following option if you want items
        // which are outside the visible range to be removed
        // from the DOM.
        // Useful for carousels with MANY items.

        // itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
        itemLoadCallback: mycarousel_videos_itemLoadCallback
    });
});
/* FOR carousel COMPONENT */

/* FOR carouse2 COMPONENT */
function mycarousel_sites_itemLoadCallback(carousel, state)
{
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    $.get(
        base_url + 'module/recent_sites',
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_sites_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        }
    );
};

function mycarousel_sites_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));
    jQuery('image', xml).each(function(i) {
        carousel.add(first + i, mycarousel_sites_getItemHTML($(this).attr('logo'), $(this).attr('name'), $(this).attr('site_url')));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_sites_getItemHTML(logo, name, site_url)
{
    return '<table border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><a href="' + site_url + '"><img src="' + logo + '" border="0" width="120" height="100"/></a></td></tr><tr><td align="center"><a href="' + site_url + '" class="link">'+ name +'</a></td></tr></table>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel_sites').jcarousel({
        // Uncomment the following option if you want items
        // which are outside the visible range to be removed
        // from the DOM.
        // Useful for carousels with MANY items.

        // itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
        itemLoadCallback: mycarousel_sites_itemLoadCallback
    });
});
/* FOR carouse2 COMPONENT */


/* start carousel for competitor sites on summary page */

function mycarousel_competitor_sites_itemLoadCallback(carousel, state)
{
    site_id = document.summary_competitors.find_competitors_for.value;
    // Check if the requested items already exist
    if (carousel.has(carousel.first, carousel.last)) {
        return;
    }

    $.get(
        base_url + 'module/crousel_competitor_sites/' + site_id,
        {
            first: carousel.first,
            last: carousel.last
        },
        function(xml) {
            mycarousel_competitor_sites_itemAddCallback(carousel, carousel.first, carousel.last, xml);
        }
    );
};

function mycarousel_competitor_sites_itemAddCallback(carousel, first, last, xml)
{
    // Set the size of the carousel
    carousel.size(parseInt(jQuery('total', xml).text()));
    jQuery('image', xml).each(function(i) {
        carousel.add(first + i, mycarousel_competitor_sites_getItemHTML($(this).attr('logo'), $(this).attr('name'), $(this).attr('site_url')));
    });
};

/**
 * Item html creation helper.
 */
function mycarousel_competitor_sites_getItemHTML(logo, name, site_url)
{
    return '<table border="0" cellspacing="0" cellpadding="0"><tr><td align="center"><a href="' + site_url + '"><img src="' + logo + '" border="0" width="120" height="100"/></a></td></tr><tr><td align="center"><a href="' + site_url + '" class="link">'+ name +'</a></td></tr></table>';
};

jQuery(document).ready(function() {
    jQuery('#mycarousel_competitor_sites').jcarousel({
        // Uncomment the following option if you want items
        // which are outside the visible range to be removed
        // from the DOM.
        // Useful for carousels with MANY items.

        // itemVisibleOutCallback: {onAfterAnimation: function(carousel, item, i, state, evt) { carousel.remove(i); }},
        size:3,
        visible:3,
        itemLoadCallback: mycarousel_competitor_sites_itemLoadCallback
    });
});

/* end crousel for competitor sites on summary page */


