jQuery(document).ready(function () {
    // Home page carousel
    jQuery(function () {
        jQuery('#carousel-items').cycle({
            fx: 'scrollHorz',
            timeout: 9000,
            before: onBefore,
            pause: 1,
            next: '#cnext',
            prev: '#cprev',
            delay: 7000,
            speed: 700,
            pager: '#pager',
            pagerAnchorBuilder: pagerBuild
        });
    });

    function pagerBuild(idx, slide) {
        ct = idx + 1;
        if (jQuery(slide).is('.txt')) {
            ct = 'info';
        }
        //return '<a href="#">' + ct + '</a>';
        return '<a href="#"><img src="http://www.stand.org/view.image?Id=1806" width="10" height="10"></a>';
    }
    function onBefore() {
        if (jQuery('#output1').is(':visible')) {
            jQuery('#output1').fadeOut('slow');
            jQuery('#output2').html(this.title);
            if (jQuery(this).attr('href') == '#' || jQuery(this).attr('href') == null) {
                jQuery(this).removeAttr('href');
            } else {
                jQuery('#output2').html('<a href="' + this.href + '">' + this.title + '</a>');
            }
            jQuery('#output2').fadeIn('slow');
        } else {
            jQuery('#output2').fadeOut('slow');
            jQuery('#output1').html(this.title);
            if (jQuery(this).attr('href') == '#' || jQuery(this).attr('href') == null) {
                jQuery(this).removeAttr('href');
            } else {
                jQuery('#output2').html('<a href="' + this.href + '">' + this.title + '</a>');
            }
            jQuery('#output1').fadeIn('slow');
        }
    }
});
