jQuery(document).ready(function() {
	// apply hover and box linking to content list elements
	$("div.pod-news li").hover(function () {
		$(this).addClass("hover")},function () {
			$(this).removeClass("hover");
		}).click(function(){
			window.location=$(this).find("a").attr("href");
			return false;
	});

	// apply class to linked files to show icon
	$(".content-body a[href$='.pdf'],.content-body a[href$='.PDF']").addClass("pdf");
	$(".content-body a[href$='.doc'],.content-body a[href$='.DOC'],.content-body a[href$='.docx'],.content-body a[href$='.DOCX']").addClass("doc");  
	$(".content-body a[href$='.xls'],.content-body a[href$='.XLS'],.content-body a[href$='.xlsx'],.content-body a[href$='.XLSX']").addClass("xls");
  

	// force files to open in a new browser window
	$("A[href$=.pdf]").click(function() {
		window.open(this.href);
		return false;
	});

	// force external links to open in a new browser window
	$('a').filter(function() {
		return this.hostname && this.hostname !== location.hostname;
	}).addClass("external").attr("target","_blank");

	// set up pod scroller controls
	pod_scroller_init('#col-left div.pod-news');
	pod_scroller_init('#col-left div.pod-cal');
	pod_scroller_init('#col-right div.pod-news');
	pod_scroller_init('#col-main div.pod-news');
	pod_scroller_init('#col-main div.pod-news.wide');
	pod_scroller_init('#col-main div.pod-cal');

	$("#nav-sub > ul > li").not(".selected").addClass('n1');
	$("#nav-sub > ul > li.selected").addClass('n1-sel');

	$("#nav-sub > ul > li").not(".selected").hover(function ()
		{ $(this).addClass("n1-hover") },function () { $(this).removeClass("n1-hover");
	});

	$("#col-right .links a").each(function() {
		$(this).attr('title', 'Open this web site in a new browser window');
	});

	$("#col-right .contact a").each(function() {
		$(this).attr('title', 'Send an email to this address');
	});

	$('.rate-toggle').click(function() {
		$('#rating').slideToggle();
	});
	$('#rating').each(function() {
	 $rater = $(this);
	 var ratingData = $rater.attr('rel').split(',');
	 $('#rating').rater({
	   url: '/base/ScRestLibrary/SetNodeRating/'+ratingData[0]+'/[rating].aspx',
	   mediapath: '/assets/img/',
	   value: ratingData[1],
	   postcallback: function(value) {
	     window.setTimeout(function() {$rater.slideUp()}, 1000);
	   }
	 });
	});

});

function pod_scroller_init(pod_selector)
{
	$(pod_selector+' .scrollable').scrollable({ vertical: true, mousewheel: true, next: pod_selector+' a.next', prev: pod_selector+' a.prev' });
	$('a.next,a.prev').disableTextSelect();
}
