function f_filterResults(n_win, n_docel, n_body) {
	var n_result = n_win ? n_win : 0;
	if (n_docel && (!n_result || (n_result > n_docel)))
		n_result = n_docel;
	return n_body && (!n_result || (n_result > n_body)) ? n_body : n_result;
}
function f_scrollLeft() {
	return f_filterResults (
		window.pageXOffset ? window.pageXOffset : 0,
		document.documentElement ? document.documentElement.scrollLeft : 0,
		document.body ? document.body.scrollLeft : 0
	);
}
function f_scrollTop() {
	return f_filterResults (
		window.pageYOffset ? window.pageYOffset : 0,
		document.documentElement ? document.documentElement.scrollTop : 0,
		document.body ? document.body.scrollTop : 0
	);
}
function f_clientWidth() {
	return f_filterResults (
		window.innerWidth ? window.innerWidth : 0,
		document.documentElement ? document.documentElement.clientWidth : 0,
		document.body ? document.body.clientWidth : 0
	);
}
function f_clientHeight() {
	return f_filterResults (
		window.innerHeight ? window.innerHeight : 0,
		document.documentElement ? document.documentElement.clientHeight : 0,
		document.body ? document.body.clientHeight : 0
	);
}
function BTypes() { //v3.0
	var isIE  = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
	var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
	var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
}

var toh, im, im_src;
function focusOn(button) { //call onfocus
	toh=setTimeout("setDisplay('"+button+"', '')", 8000);
}
function blurOn(button) { //call onblur
	clearTimeout(toh);
	toh=setTimeout("setDisplay('"+button+"', 'none')", 100);
}

function getClientInfo() { //call on interval set by setClientInfo
	var dt = new Date();
	//alert('time reloaded');
	im.src = im_src+'&DesktopWidth='+screen.width+'&DesktopHeight='+screen.height+'&WindowWidth='+f_clientWidth()+'&WindowHeight='+f_clientHeight()+'&visitCorrection=1&dt='+dt.getTime();
	return true;
}

function setClientInfo() { //call onload
//alert('page loaded');
	im=document.getElementById('statTracker');
	im_src=im.src;
	if (getClientInfo()) {
		setInterval('getClientInfo()', 60000);
	}
}

function setDisplay(id, di) { //call to display or hide things
//alert('page loaded');
	fm=document.getElementById(id);
	fm.style.display=di;
}

function isEnter(e) { //call onkeypress
	if (window.event && window.event.keyCode == 13) {
		return true;
	} else if (e.which == 13) {
		return true;
	} else {
		return false;
	}
}

function setCountry(e) { //call onkeypress
	var aState = document.getElementById('addressState');
	var aCountry = document.getElementById('addressCountry');
	if (aState.value.length == 0) {
		alert('You must select a valid State or Providence');
		aState.selectedIndex = 0;
	} else if (aState.value.length == 1) {
		var aState_value = prompt('prompt', '');
		var optn = document.createElement("OPTION");
		optn.text = aState_value;
		optn.value = aState_value;
		aState.options.add(optn);
		aState.selectedIndex = aState.length - 1;
		aCountry.focus();
	} else if (aState.value.length == 2) {
		aCountry.value = 'USA';
	} else if (aState.value.length == 3) {
		aCountry.value = 'Canada';
	}
}
