(function($)
	{
	$.fn.headerImages=function(o)
		{
		return this.each(function()
			{
			new d(this,o)
		}
		)
	};
	var c=
		{
		delay:6000,
		transition:1000
	};
	$.headerImages=function(e,o)
		{
		this.options=$.extend(
			{
		}
		,c,o||
			{
		}
		);
		this.list=null;
		this.list=$(e).find('#headerImage');
		var a=this;
		if($.browser.safari)
			{
			$(window).bind('load',function()
				{
				a.setup()
			}
			)
		}
		else
			{
			this.setup()
		}
	};
	var d=$.headerImages;
	d.fn=d.prototype=
		{
		headerImages:'1.0'
	};
	d.fn.extend=d.extend=$.extend;
	d.fn.extend(
		{
		setup:function()
			{
			this.lastItem=-1;
			this.nextItem=null;
			this.timer=null;
			var a=this.list.children('img');
			this.lastItem=a.size()-1;
			if(this.lastItem>-1)
				{
				//this.addHover();
				this.startAuto();
				this.nextItem=1;
				//this.animate(true)
			}
			else
				{
				return
			}
		}
		,animate:function(blnStart)
			{
			var b=this;
			if(blnStart)
				{
				b.list.children('img').hide();
				b.list.children('img:eq('+b.nextItem+')').fadeIn(b.options.transition);
				$("#imgCaption span").fadeIn(b.options.transition);
				$("#imgSchool span").fadeIn(b.options.transition);
			}
			else
				{
				tmpNext = b.nextItem;
				prevItem=b.nextItem-1;
				if(prevItem<0)
					{
					prevItem=b.lastItem
				}
				strAltString = b.list.children('img:eq('+tmpNext+')').attr("alt");
				strCaption = "";
				strSchool = "";
				if (strAltString != "") {
					arrString = strAltString.split(" _ ");
					strCaption = arrString[0];
					strSchool = arrString[1];
				}
				b.list.children('img').fadeOut(b.options.transition);
				$("#imgCaption span").fadeOut(
					b.options.transition/2,
					function(){
						$("#imgCaption span").text(strCaption);
						$("#imgCaption span").fadeIn(b.options.transition/2);
					}
				);
				$("#imgSchool span").fadeOut(
					b.options.transition/2,
					function(){
						$("#imgSchool span").text(strSchool);
						$("#imgSchool span").fadeIn(b.options.transition/2);
					}
				);
				b.list.children('img:eq('+tmpNext+')').fadeIn(b.options.transition)
			}
			b.nextItem=b.nextItem+1;
			if(b.nextItem>b.lastItem)
				{
				b.nextItem=0
			}
		}
		,startAuto:function()
			{
			if(this.timer!==null)
				{
				return
			}
			var a=this;
			this.timer=setInterval(function()
				{
				a.animate(false)
			}
			,this.options.delay)
		}
		,stopAuto:function()
			{
			if(this.timer===null)
				{
				return
			}
			clearTimeout(this.timer);
			this.timer=null
		}
		,addHover:function()
			{
			var a=this;
			this.list.children('img').each(function()
				{
				$(this).mouseenter(function()
					{
					$(a.img).stop(true,true);
					a.stopAuto();
				}
				);
				$(this).mouseleave(function()
					{
					a.startAuto()
				}
				)
			}
			)
		}
	}
	)
}
)(jQuery);

