function init_external_control (carousel) {
    var control = jQuery("ul#subTab2Control");
    var control_items = control.find("> li a");

    control_items.each(function (index) {
        var el = jQuery(this);

        el.bind("click", function (evt) {
            var prev_active_el = control.find("> li a.Active");
            prev_active_el.removeClass("Active"); //clear Active
            el.addClass("Active"); //add current Active
            carousel.scroll(index+1); //scroll to
			if ( (/MSIE 6\.0/).test(navigator.userAgent) && !(/MSIE 7\.0/).test(navigator.userAgent) ) {
				DD_belatedPNG.applyVML(prev_active_el.get(0));
				DD_belatedPNG.applyVML(el.get(0));
			}
            return false; //prevent default action and stop propagation
        });
    });

    //inti state when load, find control_item has Active class and scroll to the appropriated tab content
    var active_item = control.find("> li a.Active");
    var active_index = jQuery.inArray(active_item.parent().get(0), control.find("li"));

    setTimeout(function () {
        carousel.scroll(active_index+1, false);
    }, 1);
}
function animation_callback (carousel) {
    var active_index = carousel.first-1;

    //Active corresponding tab
    var prev_active_el = jQuery("ul#subTab2Control > li a.Active");
    var active_el = jQuery("ul#subTab2Control > li").eq(active_index).find("a");

    prev_active_el.removeClass("Active");
    active_el.addClass("Active");
	if ( (/MSIE 6\.0/).test(navigator.userAgent) && !(/MSIE 7\.0/).test(navigator.userAgent) ) {
		DD_belatedPNG.applyVML(prev_active_el.get(0));
		DD_belatedPNG.applyVML(active_el.get(0));
	}
}

//on page ready
jQuery(document).ready(function () {
    jQuery('#mycarousel').jcarousel({
        scroll: 1,
        initCallback: init_external_control,
        onButtonAfterAnimationCallBack: animation_callback
    });
});