$(document).ready(function () {

	$("#vimmsImage").load(function () {
		$("#vimmsLoadMsg").html("&nbsp;");
	}).error(function () {
		$("#vimmsLoadMsg").html("Error Loading Image");
	})

	$("div.content").click(function(e){
				
		cId = $(e.target).attr("class");
		
		if (cId.substr(0,4) == "area"){
			
			cNum = cId.substr(4,2);
			cMod = cId.substr(6);
			cMapName = $("map").attr("name").substr(3);
			if (cMapName.length > 0)
				cMapName = "Map";
			else
				cMapName = "MapZ";			
			
			$("#vimmsLoadMsg").html("Loading Image&nbsp;&nbsp;<img src='/images/loading2.gif' alt='loading...' />");
			cExt = $("#vimmsImage").attr("src").substr($("#vimmsImage").attr("src").length-3);
			$("#vimmsImage").attr("src","/images/Vulcan_Tech_Center/vimms_mod_"+cMod+"_"+cNum+"."+cExt);
			$("#vimmsImage").attr("usemap","#" + cMapName);

			$("#vimmsText").fadeTo(50, 0, function(){
												   
				cFile = "/content_v2/tech/p8vimms.text."+cMod+"."+cNum+".htm";
				
				// Must call ajax func to converts links
				$.post("./", { dofunc: "ajax_convert_links", file: cFile }, function(data){
					if (data){
						$("#vimmsText").html(data);
						$("#vimmsText").fadeTo(200, 1, function(){														  
						});								
					} else {
						$("#vimmsText").html("<p class='clsErrorMsg'>Error loading document.</p>");
					}
					
				});								
			});		
			
			$("#vimmsImageMap").load("/content_v2/tech/p8vimms.imgmap."+cMod+"."+cNum+".htm",function(response, status, xhr){				 
				// George, you may be tempted to consolidate the setting of map name, but this won't work.  The setting must 
				// occur after the page loads.
				if (status == "error"){
					$("#vimmsImageMap").load("/content_v2/tech/p8vimms.imgmap."+cMod+".01.htm",function(response, status, xhr){																											  						$("map").attr("name", cMapName);
					});
				} else {
					$("map").attr("name", cMapName);
				}				
			});			
		}
	});		
});
