Drupal.page_init = new Object();

Drupal.behaviors.page_init = function(context) {
	if ($('ul.primary-links').length > 0) {
		$('#center .south').attr('style', 'padding-top: 3em;');
	}
	/* add page load code here */
  $("ul.primary-links li").bind("mouseover", function() {
    $(this).addClass("active");
		$(this).children("a").addClass("active");
		$(this).children("img").show();
		if (!$(this).hasClass('active-trail')) {
			$("ul.primary-links li.active-trail img").hide();
		}
  });
  $("ul.primary-links li").bind("mouseout", function() {
    $(this).removeClass("active");
		$(this).children("a").removeClass("active");
		$(this).children("img").hide();		
		$("ul.primary-links li.active-trail img").show();		
  });
}

/**
 * String trimming functions
 */
function trim(str, chars) {
	return ltrim(rtrim(str, chars), chars);
}

function ltrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("^[" + chars + "]+", "g"), "");
}

function rtrim(str, chars) {
	chars = chars || "\\s";
	return str.replace(new RegExp("[" + chars + "]+$", "g"), "");
}
