var Search =
{
	baseUrl: null,

	init: function()
	{
		Search.baseUrl = location.protocol + '//' + location.hostname + '/';
		var url = location.pathname;
		if (location.hostname == 'devsys2.gaslightmedia.com') {
			var urlParts = url.split('/');
			Search.baseUrl += urlParts[1] + '/';
		} else if (location.hostname == 'kanga.acrewoods.com') {
			var site = location.pathname.split('/');
			var urlParts = url.split('/');
			Search.baseUrl += urlParts[1] + '/' + site[2] + '/';
		}

		$('.search-result-item').mouseover(Search.highlightMember);
		$('.search-result-item').mouseout(Search.lowlightMember);
		$('.search-result-item').click(Search.goToMember);
	},

	highlightMember: function(event)
	{
		var link = $(this).find("a[title='More Info']");
		if (link.attr('href')) {
			$(this).addClass('search-result-item-on');
		}
	},

	lowlightMember: function(event)
	{
		$(this).removeClass('search-result-item-on');
	},

	goToMember: function(event)
	{
		//	If we click on another link, then we don't want
		//	to actually go to the member, so return.
		if (event.target.nodeName == 'A') {
			return;
		}
		var link = $(this).find("a[title='More Info']");
		if (link.attr('href')) {
			document.location.href = link.attr('href');
		}
	}
};

$(document).ready(Search.init);
