$(document).ready(function(){
	
	var t = false;

	$('#mainMenu > li').mouseover(function(){
		clearTimeout(t);
		$('#mainMenu ul').stop().animate({'top':'-300px'},400);
		$('#mainMenu > li').children('a').not('.selected').css('backgroundPosition','top right');
		$('#mainMenu > li.noBackground').children('a').not('.selected').css('backgroundPosition','-90px top');
		$(this).children('a').not('.selected').css('backgroundPosition',((findString('noBackground',$(this).attr('class'))==true)?'-90px bottom':'bottom right'));
		$(this).children('ul').stop().animate({'top':'53px'},400);
	}).mouseout(function(){
		var obj = $(this);
		t = setTimeout(function(){
			$(obj).children('a').not('.selected').css('backgroundPosition',((findString('noBackground',$(obj).attr('class'))==true)?'-90px top':'top right'));
			$(obj).children('ul').stop().animate({'top':'-300px'},400);
		},100);
	});
	
});

function findString(findStr,str){
	
	var returnVal = false;
	
	try{
		returnVal = (str.search(findStr)>=0) ? true : false
	}catch(e){}
	
	return returnVal;
}

