function carousel_initCallback(carousel)
{
    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });
};

jQuery(document).ready(function() {
   
    jQuery('#headerCarousel').jcarousel({
        auto: 2,
        scroll: 1,
        wrap: 'both',
        animation: 1000,
        initCallback: carousel_initCallback
    });
   
   setCarousel();
    
    
    function setCarousel()
    {
        var leftOffset = $("#header_productCarousel").offset().left;
        var carouselSize = $(window).width() - leftOffset - ($(window).width()/10);
        $(".jcarousel-skin-tango .jcarousel-clip-horizontal").css("width",carouselSize+"px");
        
        //$("#header_productCarousel").scrollable();

    }
    
    $(window).resize(function() {
        setCarousel();
    });
    
});

    Brightness = function(color) {
        if(color.length==7){color=color.substring(1);}
        var R = parseInt(color.substring(0,2),16);
        var G = parseInt(color.substring(2,4),16);
        var B = parseInt(color.substring(4,6),16);
        return Math.sqrt(R * R * .241 + G * G * .691 + B * B * .068);
    }
    
    
    function setTextBright(pri,sec)
    {
        var brightModPri = Brightness(pri) < 130 ? '#FFFFFF' : '#000000';
        var brightModSec = Brightness(sec) < 130 ? '#FFFFFF' : '#000000';
        //$('#productHeader_topStrap h1, .sidebar_block h1, .productContent_feature h1, .sidebar_version').css('color',brightModPri);
       // $('#productHeader_bottomStrap h2, .sidebar_block li, .sidebar_version_date, .sidebar_newsItem').css('color',brightModSec);
    }
    
    /*
    jQuery.fn.highlight = function (str, className)
    {
        var regex = new RegExp(str, "g");
    
        return this.each(function ()
        {
            
            this.innerHTML = this.innerHTML.replace(regex, "<span class=\"" + className + "\"><a href=\"/wordpress/software/"+ str.toLowerCase() + " />"  + str + "</a></span>");
        });
    };
    */
   
    
    function contentTagReplace(tag_array,post_id)
    {
        for(var tag in tag_array)
        {
            //alert(post_id + "|" + tag)
            $("#post-"+post_id).highlight(tag,"highlight-"+tag)
            //$("#post-"+post_id).highlight(tag)
        }
    }




