
/* Initialize everything when page is ready */
$(document).ready(function() {
	// Fix IE6 flicker problem
	try {
		document.execCommand('BackgroundImageCache', false, true);
	} catch(e) {};
	
	$("#slideshow").cycle( {
		fx: "fade",
		speed: 1000,
		timeout: 6000
	});
	
	// Random student profile
	$('#left_col_inner img').addClass('flush');
	var profiles = $('#left_col_inner table tr');
	var randomProfile = Math.floor(Math.random() * profiles.length);
	var $prev = $('p.profile_scroll a:first');
	var $next = $('p.profile_scroll a:last');
	var numProfiles = profiles.length - 1;
	
	$(profiles).each(function() { if ($(profiles).index(this) == randomProfile) $(this).addClass('visprofile'); });	
	$prev.click(function() { scrollProfile(-1); return false; });
	$next.click(function() { scrollProfile(1); return false; });
	
	function scrollProfile(move) {
		var newVis = 0;
		$(profiles).each(function() { 
		    if ($(this).attr('class') == 'visprofile') {
	    		newVis = $(profiles).index(this) + move;
			}
	    });
		if (newVis != null) {
			if (newVis < 0) newVis = numProfiles;
			if (newVis > numProfiles) newVis = 0;
			$(profiles).removeClass();
			$(profiles).each(function() { if ($(profiles).index(this) == newVis) $(this).addClass('visprofile'); });	
		}
	}
	
	
	var _gaq = _gaq || [];
		_gaq.push(['_setAccount', 'UA-11003676-1']);
		_gaq.push(['_trackPageview']);
	
	  var ga = document.createElement('script'); 
		  ga.type = 'text/javascript'; 
		  ga.async = true;
		  ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
	  var s = document.getElementsByTagName('script')[0]; 
		  s.parentNode.insertBefore(ga, s);
	
});