/*
 * utility functions.
 */
(function($){

	$(window).load(function(){

		// set rollover.
		$('img.over, input.over').each(function(){
			var img = new Image();
			img.src = this.src.replace(/^(.+)(\.[a-z]+)$/, '$1_over$2');
			$(this)
				// store images.
				.data('image', {
					defaultSrc: this.src,
					hoverSrc: img.src
				})
				// hover handler.
				.hover(
					function(){
						this.src = $(this).data('image').hoverSrc;
					},
					function(){
						this.src = $(this).data('image').defaultSrc;
					}
				)
			;
		});

		// open with new window.
		$('a[rel=external]').click(function(){
			window.open(this.href, '_blank');
			return false;
		});

		// category nav.
		$('#categoryarea')
			// hide nav without first.
			.find('ul:gt(0)')
				.hide()
			.end()
			// toggle nav by clicking.
			.find('h3')
				.css({ cursor: 'pointer' })
				.click(function(){
					$(this).next().slideToggle();
				})
			.end()
		;

	});

})(jQuery);
