var headerimages = new Array("headerimg1", "headerimg2", "headerimg3", "headerimg4");

$(function() {
	$("#header ul a").css({"background": "url('images/menuhover.gif') repeat-x left 50px"}).hover(
		function() {
			$(this).stop().animate({"backgroundPosition": "(0 40px)"}, "normal", "easeOutBack");
		}, 
		function() {
			$(this).stop().animate({"backgroundPosition": "(0 50px)"}, "fast");
		}
	);
	var imghtml = "";
	for (var i=0; i < headerimages.length; i++) {
		imghtml += '<img id="headerimg'+i+'" src="contentimages/'+headerimages[i]+'.jpg" width="605" height="185" alt="" />';
	};
	$("#headerimages").html(imghtml).find("img:gt(0)").hide();
	headerimg(0);
});

function headerimg(curimg) {
	$("#headerimg"+curimg).fadeOut(10000);
	curimg++;
	if (curimg >= headerimages.length || curimg < 0) {
		curimg = 0;
	}
	$("#headerimg"+curimg).fadeIn(10000, function() { headerimg(curimg) });
}

// Background Position
(function($){if(!document.defaultView||!document.defaultView.getComputedStyle){var e=jQuery.curCSS;jQuery.curCSS=function(a,b,c){if(b!=='backgroundPosition'||!a.currentStyle||a.currentStyle[b]){return e.apply(this,arguments)}var d=a.style;if(!c&&d&&d[b]){return d[b]}return e(a,'backgroundPositionX',c)+' '+e(a,'backgroundPositionY',c)}}})(jQuery);(function($){function toArray(a){a=a.replace(/left|top/g,'0px');a=a.replace(/right|bottom/g,'100%');a=a.replace(/([0-9\.]+)(\s|\)|$)/g,"$1px$2");var b=a.match(/(-?[0-9\.]+)(px|\%|em|pt)\s(-?[0-9\.]+)(px|\%|em|pt)/);return[parseFloat(b[1],10),b[2],parseFloat(b[3],10),b[4]]}$.fx.step.backgroundPosition=function(a){if(!a.bgPosReady){var b=$.curCSS(a.elem,'backgroundPosition');if(!b){b='0px 0px'}b=toArray(b);a.start=[b[0],b[2]];var c=toArray(a.options.curAnim.backgroundPosition);a.end=[c[0],c[2]];a.unit=[c[1],c[3]];a.bgPosReady=true}var d=[];d[0]=((a.end[0]-a.start[0])*a.pos)+a.start[0]+a.unit[0];d[1]=((a.end[1]-a.start[1])*a.pos)+a.start[1]+a.unit[1];a.elem.style.backgroundPosition=d[0]+' '+d[1]}})(jQuery);