$(document).ready(function() {
	
	$(".numbers a").hover(function() {
		 var strNumberClass = $(this).attr("class");
		 $(".numbers a."+strNumberClass).css("background-position","0 -30px");
			
		}, function() {
			var strNumberClass = $(this).attr("class");
			$(".numbers a."+strNumberClass).css("background-position","0 0");
		});
	
	$(".numbers div.show a").each(function(e) {
		var strOverlay = $(this).attr("href");
		
		if (strOverlay == "#smt") {
			$(this).fancybox({ frameHeight: 495});
		
		} else if (strOverlay == "#smtSetup") {
			$(this).fancybox({ frameHeight: 400});
		
		
		} else  {
			$(this).fancybox();
		}
		
	});
	
	$("#key ul li.show a").each(function(e) {
		var strOverlay = $(this).attr("href");
		if (strOverlay == "#smt") {
			$(this).fancybox({ frameHeight: 495});
			
		} else if (strOverlay == "#smtSetup") {
			$(this).fancybox({ frameHeight: 400});
			
		
			
		} else  {
			$(this).fancybox();
		}
		
	});	
	
	showSelectedStates();
});		




function showSelectedStates() {
	$(".numbers a").click(function(e) {

		var strNumber = $(this).attr("class");

		$(".numbers a").css("background-position","0 0");
		
		$(".numbers a").removeClass("selected");
		$("#key ul li a").removeClass("selected");
		
		$(this).addClass("selected");
		$("#key ul li a." + strNumber).addClass("selected");
		
		//rotating images
		$("#fancy_content .overlayPhotos").innerfade();
		e.preventDefault();
		
	});
	
	
	$("#key ul li a").click(function(e) {

		var strNumber = $(this).attr("class");

		$("#key ul li a").removeClass("selected");
		$(".numbers a").removeClass("selected");
		$(this).addClass("selected");
		$(".numbers a." + strNumber).addClass("selected");
		
		//rotating images
		$("#fancy_content .overlayPhotos").innerfade();
		e.preventDefault();
	});
}
		


