<!--

function addListener(obj, event, f) {
	if (obj.addEventListener)  // W3C DOM
		obj.addEventListener(event, f, false);
	else if (obj.attachEvent)  // IE DOM
		obj.attachEvent("on"+event, f);
}

// Header Image Variables
	var headerImgTop, headerImgBot;
	var headerState=true; // true = play, false = pause
	var headerFadeTimer=null;
	var headerRunTimer;
	var headerControlsTimer;

function hdr_init() {
	if (!document.getElementById) return;

	headerImgTop = document.getElementById("hdr_image_top");
	headerImgBot = document.getElementById("hdr_image_bot");
	headerImgTop.xOpacity=1.0;
	headerImgBot.xOpacity=0.0;
	headerImgBot.style.display = "inline";

	// preload the fade images, but we can do that after the page finishes loading
	for (x in headerImages) {
		headerImages[x][1].src = headerImages[x][0];
	}
	headerRunTimer = setTimeout(headerFadeRun,3000);
	headerControlsTimerheader = setTimeout(headerControlsDeactivateDelay, 4000);
}
addListener(window, "load", hdr_init);

function doFade() {
	function setOpacity(obj) {
		if (obj.xOpacity>.99) obj.xOpacity = 1.0;
		else if (obj.xOpacity < 0.01) obj.xOpacity = 0.0;

		obj.style.opacity = obj.xOpacity;
		obj.style.MozOpacity = obj.xOpacity;
		obj.style.filter = "alpha(opacity=" + (obj.xOpacity*100) + ")";
	}
	
	if (headerFadeTimer) clearTimeout(headerFadeTimer);

	headerImgTop.xOpacity += 0.05;
	headerImgBot.xOpacity -= 0.05;

	setOpacity(headerImgTop);
	setOpacity(headerImgBot);
	
	if (headerImgTop.xOpacity > 0.99) {
		headerFadeTimer = null;
	} else {
		headerFadeTimer = setTimeout(doFade,75);
	}
}

function headerFadeRun() {
	headerRunTimer = setTimeout(headerFadeRun,13000);/*
	if (photoCurrentImage != null) {
		var myPadding = photos[photoCurrentImage][2].height - photoLoading.height;
		img.style.paddingTop = (myPadding / 2) + "px";
		img.style.paddingBottom = (myPadding - (myPadding / 2)) + "px";
		myPadding = photos[photoCurrentImage][2].width - photoLoading.width;
		img.style.paddingLeft = (myPadding / 2) + "px";
		img.style.paddingRight = (myPadding - (myPadding / 2)) + "px";
	}
*/
	next_img = next_img + 1;
	if (next_img == headerImages.length) next_img = 0;
	headerImgBot.src = headerImgTop.src;
	headerImgTop.src = headerImages[next_img][1].src;
	headerImgTop.xOpacity=0.0;
	headerImgBot.xOpacity=1.0;

	doFade();
}/*
	if (photoCurrentImage != null) {
		var myPadding = photos[photoCurrentImage][2].height - photoLoading.height;
		img.style.paddingTop = (myPadding / 2) + "px";
		img.style.paddingBottom = (myPadding - (myPadding / 2)) + "px";
		myPadding = photos[photoCurrentImage][2].width - photoLoading.width;
		img.style.paddingLeft = (myPadding / 2) + "px";
		img.style.paddingRight = (myPadding - (myPadding / 2)) + "px";
	}
*/

function headerPause(obj) {
	headerState = !headerState;
	if (headerState) {
		headerFadeRun();
		obj.setAttribute("class", "pause");
	}
	else {
		clearTimeout(headerRunTimer);
		obj.setAttribute("class", "play");
	}
}

function headerControlsDeactivateDelay() {
	controls = document.getElementById("header_controls");
	if (controls) controls.style.display = "none";
}
function headerControlsActivate() {
	clearTimeout(headerControlsTimer);
	controls = document.getElementById("header_controls");
	if (controls) controls.style.display = "inline"; 
}
function headerControlsDeactivate() {
	headerControlsTimer = setTimeout(headerControlsDeactivateDelay, 2000);
}

// ----------------------------------------------------------------------------
// section AJAX 
// ----------------------------------------------------------------------------

//Gets the browser specific XmlHttpRequest Object 
function getXmlHttpRequestObject() {
	var req;
	
	if (window.XMLHttpRequest) {  //Mozilla, Safari ...
		req = new XMLHttpRequest();
		if (req.overrideMimeType)  req.overrideMimeType('text/xml');
		
	} else if (window.ActiveXObject) { //IE
		try {
			req = new ActiveXObject("Microsoft.XMLHTTP"); 
		} catch (e) {
			try {
				req = new ActiveXObject("Microsoft.XMLHTTP");
			} 
			catch (e) {}
		}
	}
	return req;
}

//Initiate the AJAX post
function makePost(url, param, callback, callbackParam) {
	var req = getXmlHttpRequestObject();
	
	//Set the function that will be called when the XmlHttpRequest objects state changes
	req.onreadystatechange = function() { ajaxStateChange(req, callback, callbackParam); };
	
	if (param) param = "ajax=t&" + param;
	else       param = "ajax=t";
	//Set up the connection. True sets the request to asyncronous(default) 
	req.open("POST", url, true);

	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.setRequestHeader("Content-length", param.length);
	req.setRequestHeader("Connection", "close");

	req.send(param);
}

//Initiate the AJAX request
function makeRequest(url, param, callback, callbackParam) {
	var req = getXmlHttpRequestObject();
	
	//Set the function that will be called when the XmlHttpRequest objects state changes
	req.onreadystatechange = function() { ajaxStateChange(req, callback, callbackParam); };
	
	if (param) url = url + "?ajax=t&" + param;
	else       url = url + "?ajax=t";
	//Set up the connection. True sets the request to asyncronous(default) 
	req.open("GET", url, true);

	//Add HTTP headers to the request
	req.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
	req.setRequestHeader("Connection", "close");

	req.send('');
}
//Called every time our XmlHttpRequest objects state changes
function ajaxStateChange(req, callback, param) {
	//Check if our response is ready
	if (req.readyState == 4) {
		if (req.status == 200)
			callback(req.responseText, param);
		else
			callback("Error: " + req.estatus, param);
	}
}
function updateId(txt, id) {
	document.getElementById(id).innerHTML = txt;
}
function makeIdRequest(url, param, id) {
	makeRequest(url, param, updateId, id);
}
function makeIdPost(url, param, id) {
	makePost(url, param, updateId, id);
}
// Section changing with Ajax
/*
function changeSection() {
	makeRequest (this.href, 'body');
	return false;
}

var ajaxOK = (getXmlHttpRequestObject() != null);
function setupSectionAJAX() {
	if (ajaxOK) {
		var header_links = document.getElementById('header_links').getElementsByTagName("A");
		for (i = 0; i < header_links.length; i++) {
			header_links.item(i).onclick = changeSection;
		}
	}
}
*/
//window.addEventListener?window.addEventListener("load",setupSectionAJAX,false):window.attachEvent("onload",setupSectionAJAX);

-->