$(function(){
	
	
	var timeout;
	
	$("#topmenu2 > ul > li").mouseenter(function(){
		
		clearTimeout(timeout);
		
		if($(this).find(".submenu").length){
			//$(".submenu").hide();
			$(this).find("ul:first").slideDown("fast");
			
			
			$(".submenu").attr("show", 1);
			$(this).find("ul:first").attr("show", 2);
			
			$("ul[show=1]").hide();
			
			
			$("#flash").children(":first").hide();
			
			
			if ($.browser.msie && $.browser.version.substr(0,1)<=7) {
				$("#slideshow").hide();
			}			
			
		} else {
			
			timeout = setTimeout(function(){
				$(".submenu").hide();
				$("#flash").children(":first").show();
				$("#slideshow").show();
			}, 500);
			
			
			
			
		}
		
	});
	$("#topmenu2 > ul > li > ul").mouseleave(function(){
		clearTimeout(timeout);
		
		
		timeout = setTimeout(function(){
			$(".submenu").hide();
			$("#flash").children(":first").show();
			$("#slideshow").show();
		}, 500);
		
		
	});
	
	$('#social .socialicons a img').each(function(index, value){
		$(value).addClass('color').hide();
		
		var img = new Image();
		img.onload = function() {
			Pixastic.process(img, "desaturate", {average : false});
		}
		$(img).appendTo($(value).parent()).addClass('grey');
		img.src = $(value).attr('src');
	});
	
	$('#social .socialicons a').hover(function(){
		$(this).find('.grey').hide();
		$(this).find('.color').show();
	}, function(){
		$(this).find('.grey').show();
		$(this).find('.color').hide();
	});
	
});
