/* Author: Patrik Åkerman von Knorring, Heshewe HB */
jQuery(document).ready(function(){
	jQuery('.moduleGroup').each(function(){
		resizeModuleGroup(this);
	});
});

function resizeModuleGroup(moduleGroupElement) {
	var groupHeight = jQuery(moduleGroupElement).height();
	if (jQuery(moduleGroupElement).children('.module:not(.unframed)').size() > 1) {
		jQuery(moduleGroupElement).children('.module:not(.unframed)').each(function(){
			var moduleHeaderHeight = jQuery(this).children('.moduleHeader').outerHeight(true);
			var moduleFooterHeight = jQuery(this).children('.moduleFooter').outerHeight(true);
			var moduleBodyWrapHeight = groupHeight - moduleHeaderHeight - moduleFooterHeight;
			jQuery(this).children('.moduleBodyWrap').height(moduleBodyWrapHeight + 'px');
		});
	}
}


$(function(){
	// Set span in topmenu
	$("ul#topMenu li a").html(function(i, text) {
		return text.replace(/\w+\s/, function(match){
			return '<span>' + match + '</span>';
		})
	})

   // Change the image of hoverable images
   $(".imgHoverable").hover( function() {
       var hoverImg = HoverImgOf($(this).attr("src"));
       $(this).attr("src", hoverImg);
     }, function() {
       var normalImg = NormalImgOf($(this).attr("src"));
       $(this).attr("src", normalImg);
     }
   );
   
});

function HoverImgOf(filename)
{
   var re = new RegExp("(.+)\\.(gif|png|jpg)", "g");
   return filename.replace(re, "$1_hover.$2");
}
function NormalImgOf(filename)
{
   var re = new RegExp("(.+)_hover\\.(gif|png|jpg)", "g");
   return filename.replace(re, "$1.$2");
}
























