﻿$(document).ready(function() {
	/* Scrolling News Section (sitewide) */

	/* Check to see if you are on the homepage */
	/* Sets auto = to 7000 so that the carousel will rotate ONLY on the homepage */
	var h = location.pathname.toLowerCase();
	var a = 0;

	if (h == '/' || h == '/default.aspx') {
		a = 7000;
	}

	if ($('#newsSection ul li').length > 0) {
		$('#newsContainer').jCarouselLite({
			easing: 'easeinout',
			btnPrev: '#newsNavPrev',
			btnNext: '#newsNavNext',
			visible: 1,
			auto: a
		});
	}

	if ($('#jobSection ul li').length > 0) {
		$('#jobContainer').jCarouselLite({
			easing: 'easeinout',
			btnPrev: '#jobNavPrev',
			btnNext: '#jobNavNext',
			visible: 1,
			auto: a
		});
	}

	//$("#nav").lavaLamp({fx: "backout", speed: 700, click: function(event, menuItem) {return true;}, linum: 4});

	//do rollover for everyone except ie6
	if ($.browser.msie) {
		if ($.browser.version > 6) {
			SB.rollover.init();
		} else {
			//don't do it.
		}
	} else {
		SB.rollover.init();
	}

	// tracking for outgoing links
	jQuery("a[href*='http://']:not([href*='" + window.location.hostname + "'])").bind('click', function(e) {
		if (pageTracker) {
			pageTracker._trackEvent('Outbound', jQuery(this).context.hostname, jQuery(this).attr('href'));
		}
	});
});


SB = {};

SB.rollover =
{
	init: function() {
		this.preload();

		$(".button").hover(
         function() { $(this).attr('src', SB.rollover.newimage($(this).attr('src'))); },
         function() { $(this).attr('src', SB.rollover.oldimage($(this).attr('src'))); }
      );
	},

	preload: function() {
		$(window).bind('load', function() {
			$('.button').each(function(key, elm) { $('<img>').attr('src', SB.rollover.newimage($(this).attr('src'))); });
		});
	},

	newimage: function(src) {
		return src.substring(0, src.search(/(\.[a-z]+)/)) + '_h' + src.match(/(\.[a-z]+)/)[0];
	},

	oldimage: function(src) {
		return src.replace(/_h/, '');
	}
};