var mycarousel_itemList = [
	{url: 'assets/images/clients/toyota.jpg', title: 'Toyota Tsusho Electronics (Thailand) co.,ltd', target: 'http://www.toyota.co.th/'},
	{url: 'assets/images/clients/gsb-bank.gif', title: 'ธนาคารออมสิน (30 สาขา)', target: 'http://www.gsb.or.th/'},
	{url: 'assets/images/clients/nonthavej-hospital.jpg', title: 'โรงพยาบาลนนทเวช', target: 'http://www.nonthavej.co.th/'},
	{url: 'assets/images/clients/bangkok-hospital.gif', title: 'โรงพยาบาลกรุงเทพ พระราม 9', target: 'http://www.bangkokhospital.com/'},
	{url: 'assets/images/clients/pathumwan-princess-hotel.gif', title: 'โรงแรม ปทุมวันพริ้นซ์เซส', target: 'http://www.pprincess.com/'},
	{url: 'assets/images/clients/pan-pacific-hotel.gif', title: 'โรงแรม แพนแปซิฟิค', target: 'http://www.panpacific.com/'},
	{url: 'assets/images/clients/rama-garden-hotel.gif', title: 'โรงแรม รามาการ์เด้นท์', target: 'http://www.ramagardenshotel.com/'},
	{url: 'assets/images/clients/aot.gif', title: 'การท่าอากาศยานแห่งประเทศไทย', target: 'http://www.airportthai.co.th/'},
	{url: 'assets/images/clients/ku.gif', title: 'มหาวิทยาลัยเกษตรศาสตร์ (บางเขน)', target: 'http://www.ku.ac.th/'},
	{url: 'assets/images/clients/homeworks.gif', title: 'ห้างสรรพสินค้าโฮมเวิร์ค เซ็นทรัล พลาซ่า รัตนาธิเบศร์', target: 'http://www.homeworks.co.th/'},
	{url: 'assets/images/clients/sf-cinema.gif', title: 'โรงภาพยนตร์ เอส เอฟ (ห้างสรรพสินค้า เดอะมอลล์ บางแค)', target: 'http://www.sfcinemacity.co.th/'},
	{url: 'assets/images/clients/europion-food.gif', title: 'บริษัท ยูโรเปี้ยนฟู้ด จำกัด', target: 'http://www.eurofood.co.th/'}
];

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);
};

/* */
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.target + '" rel="nofollow" target="_blank" ><img height="40" src="' + item.url + '" border="0" title="' + item.title + '" /></a>';
};

jQuery(document).ready(function() {
    jQuery('#client').jcarousel({
		vertical: false,
		scroll: 2,//scroll lenght
		animation:1200,
		auto: 1.5,//auto speed
		wrap: 'circular',
		itemVisibleInCallback: {onBeforeAnimation: mycarousel_itemVisibleInCallback},
		itemVisibleOutCallback: {onAfterAnimation: mycarousel_itemVisibleOutCallback},
		initCallback: mycarousel_initCallback
    });
});
