	$(document).ready(function(){

		$("#mlist li a").click(function(e)	{
			e.preventDefault();
			
			totalNumber = $("#mlist li").size()-1;
			modelToShow = $("#mlist li a").index(this);
			currentModel = $("#mlist li").index($(".selected-model"));
			
			if(modelToShow != currentModel)	{
				
				
				if(modelToShow === 0)	{
					
					if (currentModel != 1)	{
						$("#mapper img:visible").fadeOut();
						$("#mapper-info p").fadeOut();
						
						modelToShow = currentModel-1;
						// need to offset as the links have the prev and next elements add to the index
						$("#mapper img:eq("+(modelToShow-1)+")").fadeIn();
						$("#mapper-info p:eq("+(modelToShow-1)+")").fadeIn();
						$("#mlist li:eq("+currentModel+")").removeClass("selected-model");
						$("#mlist li:eq("+modelToShow+")").addClass("selected-model");
					}
					return false;
					
				}
				else if (modelToShow === totalNumber)	{
					
					//alert(currentModel + " " + totalNumber)
					
					if (currentModel != ((totalNumber-1)))	{
						
						$("#mapper img:visible").fadeOut();
						$("#mapper-info p").fadeOut();
						
						modelToShow = currentModel+1;
						// need to offset as the links have the prev and next elements add to the index
						$("#mapper img:eq("+(modelToShow-1)+")").fadeIn();
						$("#mapper-info p:eq("+(modelToShow-1)+")").fadeIn();
						
						$("#mlist li:eq("+currentModel+")").removeClass("selected-model");
						$("#mlist li:eq("+modelToShow+")").addClass("selected-model");
					}
					return false;
					
				}
				else	{
				
					$("#mapper img:visible").fadeOut();
					$("#mapper-info p").fadeOut();
					
					// need to offset as the links have the prev and next elements add to the index
					$("#mapper img:eq("+(modelToShow-1)+")").fadeIn();
					$("#mapper-info p:eq("+(modelToShow-1)+")").fadeIn();
					
					$("#mlist li:eq("+currentModel+")").removeClass("selected-model");
					$("#mlist li:eq("+modelToShow+")").addClass("selected-model");
				}
				
				
			}
			
		})	
	
	})
