window.onload = function(){
	// Global fade up/down speed
	var animation_speed = 200;
	
	// Add dynamic class to body
	$('body').addClass('dynamic');

	//--------------------------------------------------
	
	// Set up dynamic details on packshot thumbnails
	$('ul.image_grid_ul>li').hover(packshotin,packshotout);
	
	// Remove title attribute from packshot links
	// TODO this isn't working, but why not!?
	$('ul.image_grid_ul>li>a').attr('title','');
	
	function packshotin(event){
		
		// TODO offset position acccording to column in sidebar
		// TODO remove title attribute from packshot
		
		// grab first url link
		var first_link = $(this).find('a');
		first_link.attr('title','');
		var clickthrough_link = first_link.attr('href');

/*
		// fade up details for this packshot
		var my_dl = $(this).find('dl');
		my_dl.css('display','block');
		my_dl.css('opacity','0');
		my_dl.animate( {opacity:1}, animation_speed);
		
		// make details element clickable
		my_dl.click(function(){document.location = clickthrough_link;});
*/
		// fade up details for this packshot
		var info_el = $(this).find('.info');
		info_el.css('display','block');
		info_el.css('opacity','0');
		info_el.animate( {opacity:1}, animation_speed);
		
		// make details element clickable
		//my_p.click(function(){document.location = clickthrough_link;});

	}
	
	function packshotout(event){
		/*
		// hide dl for this packshot
		var my_dl = $(this).find('dl');
		my_dl.css('display','none');
		*/
		// hide details for this packshot
		var my_p = $(this).find('.info');
		my_p.css('display','none');

	}
	
	//--------------------------------------------------

	// get main body class
	var bodyAttributeClassSplit = $('body').attr('class').split(' ');
	var mainBodyClass = bodyAttributeClassSplit[0]=='wordpress'?bodyAttributeClassSplit[1]:bodyAttributeClassSplit[0];

	var currentMenuItemID = "nav_" + mainBodyClass;

	// add mouseover functionality to all menu li nodes except current & store
	$('div#nav>ul>li:not(#' + currentMenuItemID + ')').hover(mousein,mouseout);
			
	function mousein(event){
		// fade up a: element
		var my_link = $(this).find('a');
		my_link.css('opacity','0');
		my_link.animate( {opacity:1}, animation_speed);		
		$(this).addClass('over');
 	};
	
	function mouseout(event){
		var my_link = $(this).find('a');
		my_link.stop();
		my_link.css('opacity',null);
		$(this).removeClass('over');
	};
	
	// add special mouseover to submenu of store
	$('#nav_store>ul>li>a').hover(subMouseIn,subMouseOut);

	function subMouseIn(event){
		$(this).parent().parent().parent().addClass('over');
		return;
 	};
	
	function subMouseOut(event){
		return;
	};

}