function mainmenu(){
$("ul#nav ul ").css({display: "none"}); // Opera Fix
$("ul#nav li").hover(function(){
var w = $(this).width();
$(this).find('ul:first').css({width:w, visibility: "visible",display: "none"}).slideDown(200);
},function(){
$(this).find('ul:first').css({visibility: "hidden"});
});
}

$(function() {
	mainmenu();
	
	
	$('.tabButton1').click(function() {
		$('.tabButton').removeClass('active');
		$(this).addClass('active');
		$('.tab').hide();
		$('.tab1').fadeIn(400);
	});
	
	$('.tabButton2').click(function() {
		$('.tabButton').removeClass('active');
		$(this).addClass('active');
		$('.tab').hide();
		$('.tab2').fadeIn(400);
	});
	
	
	$('.imagegallery .mainimage li').hide();
	$('.imagegallery .mainimage li:first').show();
	$('.imagegallery .mainimage li:first').attr("rel","shadowbox");
	
	$('.imagegallery .thumbs a').click(function() {
		var n = $('.imagegallery .thumbs li a').index($(this));
		$('.imagegallery .mainimage li').fadeOut(600);
		$('.imagegallery .mainimage li:eq('+n+')').fadeIn((600));
		return false;
	});

	$('.imagegallery2 .mainimage li').hide();
	$('.imagegallery2 .mainimage li:first').show();
	$('.imagegallery2 .mainimage li:first').attr("rel","shadowbox");
	
	$('.imagegallery2 .thumbs a').click(function() {
		var n = $('.imagegallery2 .thumbs li a').index($(this));
		$('.imagegallery2 .mainimage li').fadeOut(600);
		$('.imagegallery2 .mainimage li:eq('+n+')').fadeIn((600));
		return false;
	});


	
	$('.imagegallery3 .mainimage li').hide();
	$('.imagegallery3 .mainimage li:first').show();
	$('.imagegallery3 .mainimage li:first').attr("rel","shadowbox");
	
	$('.imagegallery3 .thumbs a').click(function() {
		var n = $('.imagegallery3 .thumbs li a').index($(this));
		$('.imagegallery3 .mainimage li').fadeOut(600);
		$('.imagegallery3 .mainimage li:eq('+n+')').fadeIn((600));
		return false;
	});

	
	$('ul#nav li ul li:first').addClass('addBackground');
	$('ul#nav li ul li:last').css({"border":"none"});
	
	
});
