function getRandomInt(min, max)
{
  return Math.floor(Math.random() * (max - min + 1)) + min;
}


$(document).ready(function(){
	
	// Add "enhanced" class to body for progressive enhancement
	$("body").addClass('enhanced');
	
	// add a span for hover effect
	$(".sidebar li.page_item a").each(function(){
		$(this).append("<span></span>");
	});

	// init variables for randomness effect
	var posL = 0;
	
	// animate sidebar underline effect, random left position
	$(".sidebar li.page_item a").hover(
		// Over
		function(){
			posL = getRandomInt(-12, 0);
			$(this).find("span").stop().css({left: posL}).animate( { width: "100%"}, 200 );
			
		},
		// Out
		function(){
			$(this).find("span").stop().animate( { width: "0"}, 100 );
		}
	);
	
	// side menu dropdown
	var top_menu = $("body:not(.page-parent):not(.page-child) #primary ul li li:has(ul)");
	top_menu.find("a").each(function() {
		$(this).removeAttr("title");
	});
	
	top_menu.hover(function() {
		$(this).addClass('hover').find("ul").slideDown(200);
	}, function() {
		//$(this).toggleClass('hover').find("ul").slideUp(200)
	});
	
	var all_menu = $("body:not(.page-parent):not(.page-child) #primary").hover(function() {
		
	}, function() {
		$(this).find('.hover').removeClass("hover").find("ul").slideUp(200);
		
	});

	
});

// sIFR3 stuff -> IE borks if put inside $.document.ready() loop.
/*
var fell = { src: '/wp-content/themes/ssupub/js/fell.swf' };
sIFR.activate(fell);
sIFR.replace(fell, {
  selector: 'h2',
  css: [
		'.sIFR-root { background-color:#ffffff; color:#555555; font-size:26px; letter-spacing:2;}'
		,'a {color:#555555; text-decoration:none;}'
		,'a:hover {text-decoration:underline; color:#222222;}'
	],
  wmode: 'transparent'
});

//*/