// Simple Image Gallery
// Tested to work with jQuery 1.2.6
// Old version using non-standard paths (".mainpiccontainer/img") that only worked with jQuery 1.1?

function initGallery()
{
	$(".mainpiccontainer > img").each(function(i){
			centreGalleryImg($(this));
		});
	
	$(".galleryblock > .thumbs > img").click(function(event)
	{
		var strID = event.target.id;
		
		//get the gallery block
		var strGalleryID = $(event.target).parents("div.galleryblock").attr('id');
		$("#"+strGalleryID+" > .mainpiccontainer > img[@id!='large"+strID+"']").hide();
	
		$('#large'+strID).fadeIn("slow");
		//$("#"+strGalleryID+"/.mainpiccontainer").height($('#large'+strID).height());

		/*
		$('#large'+strID).load(
			function()
			{
				centreGalleryImg($('#large'+strID));
			}
		);
		*/
		
	});
	
}

// This isn't needed, because we use image cropping to make sure the image fills the available space
function centreGalleryImg(oImage)
{
	/*
	// First element gets the correct height, others seems wrong.
		if (oImage.width() > 0 && oImage.height() > 0)
		{
			var intLeftMargin = Math.floor((575 - oImage.width())/2);
			if (intLeftMargin <= 1) intLeftMargin = 0;
	
			var intTopMargin = Math.floor((370 - oImage.height())/2);
			alert("Top"+intTopMargin+ " because of  height:"+oImage.height());
			if (intTopMargin <= 1) intTopMargin = 0;
			
			oImage.css("margin-left",intLeftMargin);
			oImage.css("margin-top",intTopMargin);
		}
	*/	
}

function initNav()
{
	$("#mainnavtab//td").hover(function(event)
 			{
				/*****************************
					MOUSE ON
				*****************************/

 				$(this).addClass("hoveron");
 				
 				// icon bit
 				//var targetid = getLIElement(event.target);
 				
 				
 			},
 			function(event)
 			{
				/*****************************
					MOUSE OFF
				*****************************/
				
				$(this).removeClass("hoveron");
				
				//var targetid = getLIElement(event.target);
 				
 			});
}