// <![CDATA[
$(document).ready(function() {
	// Break out of frames.
	//if (self.location != top.location) {
		//top.location = self.location;
	//}

	// Search query box.
	$('#header input[type="text"]').focus(function() {
		if ($(this).attr('value') == 'Search') {
			$(this).attr('value', '');
		}
	}).blur(function() {
		if ($(this).attr('value') == '') {
			$(this).attr('value', 'Search');
		}
	});

	// Lightbox.
	var domain = document.location.protocol + '//' + document.domain;

	/*$('a[rel*=lightbox]').lightBox({
		imageLoading:	domain + '/i/lightbox/ico-loading.gif',
		imageBtnPrev:	domain + '/i/lightbox/blank.gif',
		imageBtnNext:	domain + '/i/lightbox/blank.gif',
		imageBtnClose:	domain + '/i/lightbox/btn-close.gif',
		imageBlank:		domain + '/i/lightbox/blank.gif'
	});

	// External links.
	$('a[rel*=external]').attr('target', '_blank');*/
	
	setInterval('rotateImages()', 4000);
	
});

// Image loader.
$.fn.image = function(src, f) {
	return this.each(function() {
		var i = new Image();
		i.src = src;
		i.onload = f;
		return;
	});
}
// ]]>

var showFor = 4000;
var fadeFor = 1000;


function rotateImages()
{
  var $active = $('#rotator .showing');
  var $next = ($('#rotator .showing').next().length > 0) ? $('#rotator .showing').next() : $('#rotator img:first');
  $next.css('z-index',2);                                     //move the next image up the pile
  $active.fadeOut(1500,function(){                            //fade out the top image
    $active.css('z-index',1).show().removeClass('showing');   //reset the z-index and unhide the image
    $next.css('z-index',3).addClass('showing');               //make the next image the top one
  });
}

