jQuery.noConflict();
jQuery.noConflict();
jQuery(document).ready(function(){

    var $heroBanners = jQuery("#heroBanners li")
    var current = 0;
    var next = 1;
    var speed = 10000
    var transitionSpeed = 3000;
    var $heroBannerThumbs = jQuery("#heroBannerThumbs li");
    var thumbTransparency = 0.3;
    jQuery("#heroBannerThumbs li:not(:first)").fadeTo("700", thumbTransparency);
    jQuery("#heroBanners li:not(:first)").hide();

    var heroInterval = setInterval(cycleHeros, speed);

    function cycleHeros() {
        jQuery($heroBannerThumbs[current]).fadeTo(transitionSpeed, thumbTransparency);
        jQuery($heroBannerThumbs[next]).fadeTo(transitionSpeed, 1);
        jQuery($heroBanners[current]).fadeOut(transitionSpeed);
        jQuery($heroBanners[next]).fadeIn(transitionSpeed, function() {
	        current = current + 1;
	        if ( current > $heroBanners.length - 1 ) {
	            current = 0;
	        } else {
	        }
	        next = next + 1;
	        if ( next > $heroBanners.length - 1 ) {
	            next = 0;
	        }
        });
    }

    $heroBannerThumbs.mouseover(function() {
        clearInterval(heroInterval);
        var thisElem = jQuery(this);
        jQuery("#heroBannerThumbs li:not(this)").stop().animate({
            opacity: 0.3
        });
        thisElem.stop().animate({
            opacity: 1
        });
        var slideIndex =  thisElem.attr("rel");
        if ( slideIndex != current ) {
	        jQuery($heroBanners[current]).stop().animate({ opacity: 0 }, function() {
	            jQuery(this).hide();
	        });
            jQuery($heroBanners[slideIndex]).stop().css({ display: "block", opacity: 0 }).animate({ opacity: 1 });
        }
        current = slideIndex;
    });


});
