/**
 * We use the initCallback callback
 * to assign functionality to the controls
 */
function mycarousel_initCallback1(carousel) {
    jQuery('.jcarousel-control1 a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll1 select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options
[this.selectedIndex].value);
        return false;
    });
};
function mycarousel_initCallback2(carousel) {
    jQuery('.jcarousel-control2 a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll2 select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options
[this.selectedIndex].value);
        return false;
    });
};
function mycarousel_initCallback3(carousel) {
    jQuery('.jcarousel-control3 a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll3 select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options
[this.selectedIndex].value);
        return false;
    });
};
function mycarousel_initCallback4(carousel) {
    jQuery('.jcarousel-control4 a').bind('click', function() {
        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
        return false;
    });

    jQuery('.jcarousel-scroll4 select').bind('change', function() {
        carousel.options.scroll = jQuery.jcarousel.intval(this.options
[this.selectedIndex].value);
        return false;
    });
};



// Ride the carousel...
jQuery(document).ready(function() {
    jQuery("#mycarousel1").jcarousel({
        buttonNextHTML: null,
        buttonPrevHTML: null,
        initCallback: mycarousel_initCallback1,
		itemVisibleInCallback:  highlight,
		itemVisibleOutCallback: removehighlight,
        scroll: 1
    });

    jQuery("#mycarousel2").jcarousel({
        scroll: 1,
        initCallback: mycarousel_initCallback2,
        itemVisibleInCallback:  highlight2,
		itemVisibleOutCallback: removehighlight2,
        scroll: 1
    });
        
	jQuery("#mycarousel3").jcarousel({
		initCallback: mycarousel_initCallback3,
		itemVisibleInCallback:  highlight3,
		itemVisibleOutCallback: removehighlight3,
        scroll: 1
    });
    
    jQuery("#mycarousel4").jcarousel({
        initCallback: mycarousel_initCallback4,
        scroll: 1
    });
});

function highlight(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control1 a:nth-child('+ liindex +')').attr("class","selected");
};
// it will remove last selected slide from 
// 1 to 1
function removehighlight(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control1 a:nth-child('+ liindex +')').removeAttr("class","selected");
};


function highlight2(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control2 a:nth-child('+ liindex +')').attr("class","selected");
};
// it will remove last selected slide from 
// 1 to 1
function removehighlight2(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control2 a:nth-child('+ liindex +')').removeAttr("class","selected");
};


function highlight3(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control3 a:nth-child('+ liindex +')').attr("class","selected");
};
// it will remove last selected slide from 
// 1 to 1
function removehighlight3(carousel, obejctli,liindex,listate){
     jQuery('.jcarousel-control3 a:nth-child('+ liindex +')').removeAttr("class","selected");
};

