﻿// page timer
///////////////////////////////

	var intervalID;
	var nextLoc = "";
	var timeOutSec = 0;

	function idleExpire() {
		if (nextLoc != "") {
			checkStatus();
		}
	}

	function startTimer() {
		if (timeOutSec > 29) {
			var timeOutMs = timeOutSec * 1000;
			intervalID = window.setInterval("idleExpire()", timeOutMs);
		}
	}

	function resetTimer() {
		window.clearInterval(intervalID);
		startTimer();
	}


// ajax
///////////////////////////////

	// xmlHttp obj
	function getXmlHttpObject() {
		var tmpObj = null;

		try {
			// ie
			tmpObj = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) {
			
			try {
				tmpObj = new ActiveXObject("Microsoft.XMLHTTP");
			} catch (e) {
				
				try {
					// firefox, opera 8.0+, safari
					tmpObj = new XMLHttpRequest();
				} catch (e) {
					// ajax not supported
				}
			}
		}
		return tmpObj;
	}
	
	function checkStatus_StateChanged() {
		
		if (xmlHttp.readyState == 4) {
			var reOk = /^(OK - )/;
			if (reOk.test(xmlHttp.responseText)) {
				window.location = nextLoc;
			}
		}
	}
	
	function checkStatus() {
		xmlHttp = getXmlHttpObject();
		
		if (xmlHttp != null) {
			var sURL = "ping.aspx";
			xmlHttp.onReadyStateChange = checkStatus_StateChanged;
			xmlHttp.open("get", sURL, true);
			xmlHttp.send(null);
		} else {
			// no ajax - go to next loc
			window.location = nextLoc;
		}
	}


// img rollover
///////////////////////////////

	// preload imgs
	function preloadImg() {
		for (i = 0; i < _imgArr.lengt; i++) {
			var tmpImg = new Image();
			tmpImg.src = _imgArr[i];
			_imgArr = tmpImg;
		}
	}
	
	// swap img
	function swapImg(elem, keyName) {
		elem.src = _imgArr[keyName];
	}
