// JavaScript Document

$(function() {
	setInterval("rotateImages()", 5000);
});

function rotateImages() {
	var CurrentPhoto = $('#headerPhoto div.current');
	var NextPhoto = CurrentPhoto.next();
	if (NextPhoto.length == 0)
		NextPhoto = $('#headerPhoto div:first');
	
	CurrentPhoto.removeClass('current').addClass('previous');
	NextPhoto.css({ opacity: 0.0 }).addClass('current').animate({ opacity: 1.0 }, 1000,
		function() {
			CurrentPhoto.removeClass('previous');
		});
}

var xhr = false;

function loadPage(aPage,target,as) {
	if (window.XMLHttpRequest) {
		xhr = new XMLHttpRequest();
	}
	else {
		if (window.ActiveXObject) {
			try {
				xhr = new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e) { }
		}
	}

	if (xhr) {
		xhr.onreadystatechange = function () {
			if (xhr.readyState == 4) {
					if (xhr.status == 200) {
						var retMsg = xhr.responseText;
					}
					else {
						var retMsg = "There was error in the request. Error: " + xhr.status;
					}
					var pContent = document.getElementById(target);
					pContent.innerHTML = retMsg;
				}
			}	
		if (as.trim() != "POST") {
			xhr.open("GET", aPage, true);
		} else {
			xhr.open("POST", aPage, true);
		}
		xhr.send(null);
	}
	else {
		alert("There was error creating an XMLHttpRequest");
	}
	return false;
}

