$(document).ready(function(){
	//main menu dropdowns	
	$("ul.sub").hide();
	$("a.main").mouseover(function(){
		$(".sub").hide();
		$("a.main").removeClass("selected");
		$(this).addClass("selected");
	});
	$("a.main").mouseout(function(){
		$("a.main").removeClass("selected");
	});
	$("a.submenu").mouseover(function(){
		$(".sub").hide();
		$(this).siblings(".sub").show();
		$("#mm-about").removeClass("selected");
		$("#mm-services").removeClass("selected");
		$("#mm-clients").removeClass("selected");
		$(this).addClass("selected");
	});
	$("body").click(function(){
		$(".sub").hide();
		$("#mm-about").removeClass("selected");
		$("#mm-services").removeClass("selected");
		$("#mm-clients").removeClass("selected");
	});
	$("ul.sub, ul.sub a").mouseover(function(){
		$(this).siblings(".submenu").addClass("selected");
	});
	
	
	//articles menu 
	$("#articles li a").mouseover(function(){
		$(this).parent().addClass("over");
	});
	$("#articles li a").mouseout(function(){
		$(this).parent().removeClass("over");
	});
	
	$(".articles li a").mouseover(function(){
		$(this).parent().addClass("over");
	});
	$(".articles li a").mouseout(function(){
		$(this).parent().removeClass("over");
	});
	
	//clients -> specific cases
	$(".case-content").hide();
	$(".case-header").mouseover(function(){
		$(this).addClass("hover");
	});
	$(".case-header").mouseout(function(){
		$(this).removeClass("hover");
	});
	$(".case-hide, .case-show").mouseover(function(){
		$(this).parent().addClass("hover");
	});
	
	var cases = new Array(0, 0, 0, 0);
	$(".case-header").click(function(){
		var i = $(this).children("a.case-show").attr("rel");
		if(cases[i] == 1){
			$(this).siblings(".case-content").hide();
			cases[i] = 0;
		} else {
			$(this).siblings(".case-content").show();
			cases[i] = 1;
		}
	});
	$(".case-hide").click(function(){
		$(this).parent().siblings(".case-content").hide();
		cases[$(this).attr("rel")] = 0;
		return false;
	});
	$(".case-show").click(function(){
		$(this).parent().siblings(".case-content").show();
		cases[$(this).attr("rel")] = 1;
		return false;
	});
	
	
	//testimonials
	
	//preload color images
	img1 = new Image(100, 100);
	img1.src = "../images/clients-color/client01.jpg";
	img2 = new Image(100, 100);
	img2.src = "../images/clients-color/client02.jpg";
	img3 = new Image(100, 100);
	img3.src = "../images/clients-color/client03.jpg";
	img4 = new Image(100, 100);
	img4.src = "../images/clients-color/client04.jpg";
	img5 = new Image(100, 100);
	img5.src = "../images/clients-color/client05.jpg";
	img6 = new Image(100, 100);
	img6.src = "../images/clients-color/client06.jpg";
	img7 = new Image(100, 100);
	img7.src = "../images/clients-color/client07.jpg";
	img8 = new Image(100, 100);
	img8.src = "../images/clients-color/client08.jpg";
	img9 = new Image(100, 100);
	img9.src = "../images/clients-color/client09.jpg";
	img10 = new Image(100, 100);
	img10.src = "../images/clients-color/client10.jpg";
	img11 = new Image(100, 100);
	img11.src = "../images/clients-color/client11.jpg";
	img12 = new Image(100, 100);
	img12.src = "../images/clients-color/client12.jpg";
	img13 = new Image(100, 100);
	img13.src = "../images/clients-color/client13.jpg";
	img14 = new Image(100, 100);
	img14.src = "../images/clients-color/client14.jpg";
	img15 = new Image(100, 100);
	img15.src = "../images/clients-color/client15.jpg";
	//swap images on rollover
	$(".client-text").hide();
	$("#clients img").mouseover(function(){
		$(this).attr("src", "images/clients-color/" + $(this).attr("id") + ".jpg");
		$(this).css("cursor", "pointer");
		$("#overview").hide();
		$(".client-text").hide();
		$("#"+$(this).attr("id")+"-text").show();	
	});
	$("#clients img").mouseout(function(){
		$(this).attr("src", "images/clients-bw/" + $(this).attr("id") + ".jpg");
		$(this).css("cursor", "default");
	});
	
	//external links
	$("#articles a").attr("title", "External link - opens in a new window/tab");
	
	//no-javascript links
	$(".no-js").hide();
});