// Hack for Mac FF
function com_srausc_contactus_macfirefox() {
    if( $('#TB_window').length > 0 ) {
        $('#hero object').hide();
        $('#hero #flashcontainer-backup').show();
    }
    else {
        $('#hero object').show();
        $('#hero #flashcontainer-backup').hide();
    }
    setTimeout("com_srausc_contactus_macfirefox()", 500);
}

// News Ticker
function com_doctorsofusc_home_feed_timer(cursor) {
    if (cursor != com_doctorsofusc_home_feed.cursor) return;
    com_doctorsofusc_home_feed.next();
}
var com_doctorsofusc_home_feed = { "cursor" : -1, "items" : [], "next" : function(){
    if (typeof this.items == 'undefined' || this.items.length == 0) {
        $('#news-ticker span.container-item').html('Error loading the news.');
		$('#news-ticker a.next').remove();
        return;
    }
    this.cursor++;
    if (this.cursor >= this.items.length) this.cursor = 0;
    var item = this.items[this.cursor];
	var itemDesc = item.description.replace(/<p>/, '');
	if (item.title.length > 80) {
		item.title = item.title.substr(0,80) + '...';
	}
    var itemHtml = '<a href="' + item.id + '">' + item.title + '</a>';
    $('#news-ticker span.container-item').html(itemHtml);
    setTimeout("com_doctorsofusc_home_feed_timer(" + this.cursor + ")", 5000);
} };

$(document).ready(function() {
    jQuery.getFeed({
        url: '/uscurology/about/press-room/rss/78001/10',
        success: function(feed) {
        	if (feed.items.length > 5) {
        		feed.items = feed.items.slice(0,5);
        	}
            com_doctorsofusc_home_feed.items = feed.items;
            com_doctorsofusc_home_feed.next();
        }
    });

    // Next link
	$('#news-ticker a.next').click(function() {
		com_doctorsofusc_home_feed.next();
		return false;
	});

	// If Mac Firefox
	if( $.browser.mozilla && navigator.platform == "MacPPC" ) {
	    $('#hero').append('<div id="flashcontainer-backup"></div>');
	    com_srausc_contactus_macfirefox();
	}
});
