var Sands = {};
Sands.preload_images = function () {
	Sands._preloaded = [];
	$('img').each(function () {
		var self = this;
		var img = new Image();
		img.onload = function () {
			$(self).bind('mouseover', Sands.image_swap);
			$(self).bind('mouseout', Sands.image_swap);
		}
		img.src = this.src.replace(/\.(gif|png|jpg)/, "-over.$1");
	});
}
Sands.image_swap = function (event) {
	if (event.type == 'mouseover') {
		this.src = this.src.replace(/\.(gif|png|jpg)/, "-over.$1");
	} else {
		this.src = this.src.replace('-over', '');
	}
}
// Initialize row hover effect on search results
Sands.init_hover_styles = function () {
	$('.SearchResults tr.e, .SearchResults tr.o')
		.bind('mouseover', function () { $(item).addClass('hover') })
		.bind('mouseout', function () { $(item).removeClass('hover') })
		.bind('click', function (event) { if (event.target.nodeName == 'A') { return; }; window.location.href=$(event.currentTarget).find('a').get(0).href; });
}

// Focus the first input box in the content area.
Sands.focus_first = function () {
	$('#Content input.error, #Content select.error')
		.add('#Content input[type=text], #Content select')
		.eq(0)
		.focus();
}
$(Sands.preload_images);
$(Sands.init_hover_styles);
//$(Sands.focus_first);

