function specialty_center_program_init() {
	//scp-hero slideshow
	$('div.hero.scp-hero ul').innerfade({
		speed: 1000,
		timeout: 5000,
		type: 'sequence',
		containerheight: '236px'
	});
	
	
	//News Ticker
	com_doctorsofusc_home_feed_timer = function(cursor) {
	    if (cursor != com_doctorsofusc_home_feed.cursor) return;
	    com_doctorsofusc_home_feed.next();
	};
	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);
	} };
	
	
	var $clone = $('div.scp-callouts-form:eq(0)').html();
	
	$('div.scp-callouts-control > a').click(function(){
		var cl = $($clone);
		$('input:text, textarea', cl).val('');
		// alert( $('div.scp-callouts-form').length );
		
		var wrap = $("<div></div>").addClass('scp-callouts-form').append(cl);
		$('h4 span', wrap).html( ($('div.scp-callouts-form').length + 1) );
		
		$(this).parent().before(wrap);
		return false;
	});
	
	if ($('#scp-news').length) {
		if (typeof com_doctorsofusc_customfeed_items == 'undefined' || !com_doctorsofusc_customfeed_items) {
			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();
		            console.log(com_doctorsofusc_home_feed.items);
		        }
		    });
		} else {
			if (com_doctorsofusc_customfeed_items.length > 5) {
				com_doctorsofusc_customfeed_items = com_doctorsofusc_customfeed_items.slice(0,5);
	    	}
	        com_doctorsofusc_home_feed.items = com_doctorsofusc_customfeed_items;
	        com_doctorsofusc_home_feed.next();
		}
		
		// Next link
		$('#news a.next').click(function() {
			com_doctorsofusc_home_feed.next();
			return false;
		});

	}
	
	$('span.scp-news-cbk').click(function(){
		if (! $('input', this).attr('checked')) {
			$('div.form-checkboxes input:checkbox', $(this).parent()).removeAttr('checked');
			$('span', this).text('Select All');
		} else {
			$('div.form-checkboxes input:checkbox', $(this).parent()).attr('checked', 'checked');
			$('span', this).text('De-Select All');
		}
	});
}

var scp_callouts = {
	reorderHeadings : function(){
		$i = 0;
		$('div.scp-callouts-form').each(function(){
			$i++;
			$('h4 span', this).html($i);
		});
	},
	remove : function(el){
		if (! confirm("Are you sure you want to remove the callout?")) {
			return false;
		}
		$(el).parent().remove();
		this.reorderHeadings();
		return false;
	},
	promote : function(el){
		var par = $(el).parent();
		var c = par.prevAll('div.scp-callouts-form').length;
		if (c == 0) {
			return false;
		}
		$('div.scp-callouts-form', par.parent()).eq(c-1).before($(par).clone());
		$(par).remove();
		this.reorderHeadings();
		return false;
	},
	demote : function(el){
		var par = $(el).parent();
		
		if (par.nextAll('div.scp-callouts-form').length == 0) {
			return false;
		}
		
		var c = par.prevAll('div.scp-callouts-form').length;
		
		$('div.scp-callouts-form', par.parent()).eq(c+1).after($(par).clone());
		$(par).remove();
		this.reorderHeadings();
		return false;
	}
};



/* */
/* Search form and drop-down tabs */
/* */
function com_srausc_searchForm_init() {
	// Search form
	$('#search input[id!=edit-usc-search-block-form-form-token][id!=edit-usc-search-block-form]').val('search').addClass('empty').focus(function() {
		if( $(this).val()=='search' ) $(this).val('').removeClass('empty');
	}).blur(function() {
		if( $(this).val()=='' ) $(this).val('search').addClass('empty');
	});
	$('#search .top')
		.keyup(com_srausc_searchForm_timerStart)
		.after('<a href="#" class="submit"></a>')
		.after('<a href="#" class="cancel"></a>');

	
	$('.block-usc_search a.submit').click(function(e) {
		e.preventDefault();
		$('#usc-search-block-form').trigger('submit');
	});

	$('.block-usc_search a.cancel').click(function(e) {
		e.preventDefault();
		$('#usc-search-block-form #edit-usc-search-block-form-keys').val('search').addClass('empty');
	});
}


$(function() {
    /* Tickbox */
    $('a.tickbox').click(function() {
        tb_show("", this.href, false);
        
        return false;
    });
    
    /*
     * Have to add first and last classes with JS because
     * ....
     */
    $menus = $('#foot').find('ul.menu');
    $menus.find('li:last-child').addClass('last-child');
    $menus.find('li:first-child').addClass('first-child');
    /*
    $items   = $('#specialty_list').find('li');
    $buttons = $items.find('.button');
    $buttons.click(function() {
        var $button = $(this);
        var $item   = $button.parents('li').eq(0);
        
        if ($item.hasClass('closed')) {
            $items.removeClass('open').addClass('closed');
            $item.removeClass('closed').addClass('open');
        }
        else {
            $item.removeClass('open').addClass('closed');
        }
        
        return false;
    });*/
});

var com_doctorsofusc_home_feed_scp_timeout = false;
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);
    
    clearTimeout(com_doctorsofusc_home_feed_scp_timeout);
    com_doctorsofusc_home_feed_scp_timeout = setTimeout("com_doctorsofusc_home_feed_timer(" + this.cursor + ")", 5000);
} };




$(document).ready(function() {

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

	// Navigation
	$('#navb div.content > ul > li:gt(3)').remove();
	$('#navb div.content > ul > li')
		.each(function() {
			$(this).addClass('navb-top');
		    /*var id = 'navb_'+$(this).children('a').text().toLowerCase();
		    id = id.replace(/ /g, '_').replace(/\&/g, '_').replace(/&amp;/g, '_');
		    $(this).attr('id', id);
*/
		    $(this).children('a').addClass('parent');
		});
/*		.hover(function() {
			$(this).addClass('hover');
		},function() {
			$(this).removeClass('hover');
		});*/
	$('#navb div.content > ul li')
		.hover(function() {
			$(this).addClass('hover');
		},function() {
			$(this).removeClass('hover');
		});
	$('#navb div.content > ul ul.menu li:first-child').addClass('first-child');
	$('#navb div.content > ul ul.menu').append('<li class="last-child"></li>');

	// USC Urology code
	//alert($("#specialty_center_filter_form").children("div").children("ul").children("li").children("a").text());
	$("#specialty_center_filter_form").children("div").children("ul").children("li").children("a").click(function(){
		var val = "?filterId=" + $("#specialty_center_filter").val();
		var form = $("#specialty_center_filter_form");
		form.attr("action", form.attr("action") + val).submit();
	});
	
	$('#quickLinks div').css('z-index', '100');
	$('#myHealthLogin a.panel').css('z-index', '1000000');
	
	$('.menu .expanded').children('a').after('<span class="menu_marker"> </span>');	

    $(".menutree-page .menu li:not(.active)").children("ul").hide();
    $(".menutree-page").children(".menu li").click(function(){
        $(".menutree-page").children(".menu li").children("ul").hide();        
        $(this).children("ul").toggle();
    });

    if (typeof(FRONTPAGE) == 'undefined')
    {
        FRONTPAGE = false;
    }
    
    if (!FRONTPAGE)
    {
    	$('.menu a.active').parents('.navb-top').addClass('navb-current');        
    }

    // Sidebar menu actions
    $(".menutree-page .menu li:not(.active)").children("ul").hide();

    $("#ask_question_form input:text, textarea").one("click", function(){
       $(this).val(""); 
    });
    
    $("#request_appointment_link").click(function(){
        $("#make_appointment").trigger('click');
        return false;
    });
    
    $("#refer_patient_link").click(function(){
        $("#refer_patient").trigger('click');
        return false;
    });
    
    // Request appointment callout
	$('#email_button', '#front-sidebar').click(function() {
		$("#make_appointment").trigger('click');
		return false;
	});
        

    specialty_center_program_init();
});

