var headerimages = new Array("headerimg1", "headerimg2", "headerimg3", "headerimg4");
var curimg = 1;
var curopacity = 0;

$(function() {
	$("#menubar>ul>li>a:not(.selected)").css({"background": "url('images/menuline.png') no-repeat -205px bottom"});
	$("#menubar>ul").delegate("#menubar>ul>li>a:not(.selected)", "hover", function(e) {
			$(this).stop().animate({"backgroundPosition": "("+(e.type == "mouseover" ? "0px" : "-205px")+" bottom)"}, "normal");
		});
	$("#headerimages").empty();
	for (var i=0; i < headerimages.length; i++) {
		$("<img />", {"id": "headerimg"+i, "src": "contentimages/"+headerimages[i]+".jpg", "width": 670, "height": 160, "alt": ""}).appendTo("#headerimages");
	};
	$("#headerimages").find("img:gt(0)").css({"opacity": 0, "z-index": 1});
	var himagetimer = setInterval(himageanimate, 100);
});

function himageanimate() {
	curopacity += 0.01;
	$("#headerimg"+curimg).css("opacity", curopacity);
	if (curopacity >= 1) {
		$("#headerimages img").filter(":not(#headerimg"+curimg+")").css("opacity", 0).end().css("z-index", 1);
		curimg = (curimg == headerimages.length-1 ? 0 : curimg+1);
		curopacity = 0;
		$("#headerimg"+curimg).css("z-index", 100);
	}
}

// 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);