//
// pageutils_ns4.js
// JavaScript functions for use on HOA site pages
// browser version variables come from the 'overlib.js' library, so this source must be used
//	in conjunction with it
// these functions should work with any version of 'pagemenu_*.inc' that uses a table of IMG objects
//	to present the menu buttons; currently tested browsers incldue: ns4, ns6, ie5.5 and ie6
//
var btnNormalFile;
var btnHoverFile;
var btnNormalImage;
var btnHoverImage;
var menuItemDivContent;

function buttonInit(argNormalFile, argHoverFile) {
btnNormalFile = argNormalFile;
btnHoverFile = argHoverFile;
btnNormalImage = new Image();
btnNormalImage.src = btnNormalFile;
btnHoverImage = new Image();
btnHoverImage.src = btnHoverFile;
}

function pageInit(argNormalFile, argHoverFile) {

if (ns4) {
	// need to initialize the menu_item div
	document.menu_item.document.write(menuItemDivContent);
	document.menu_item.document.close();
	document.menu_item.visibility = "show";
	}

overlib('initializing', FIXX, 0, FIXY, 0); nd();
overlib('initializing', FIXX, 0, FIXY, 0); nd();

}

// these functions change the button by swapping the IMG object src property
function miMouseOver(btnId) {
if (ie4 || ie5) {
	document.all[btnId].src = btnHoverImage.src;
	}
else {
	document[btnId].src = btnHoverImage.src;
	}
return true;
}

function miMouseOut(btnId) {
if (ie4 || ie5) {
	document.all[btnId].src = btnNormalImage.src;
	}
else {
	document[btnId].src = btnNormalImage.src;
	}
return true;
}

function popupWin(url) {
newPopupWin = window.open(url, 'newPopupWin', 'width=500,height=340,scrollbars');
newPopupWin.focus();
}

function changeImage(selectField, image) {
fileName = selectField.options[selectField.selectedIndex].value;
len = fileName.indexOf('-');
fileID = fileName.substring(0, len);
if (fileID == 0) {
	src = '/h-o-a-home/images/spacer.gif';
	src = '/h-o-a-home/images/no-picture.jpg';
	}
else {
	src = '../sendpic.html?fid=' + fileID + '&w=150';
	}
image.src = src;
}

function changeImage2(selectField, image) {
fileName = selectField.options[selectField.selectedIndex].value;
len = fileName.indexOf('-');
fileID = fileName.substring(0, len);
if (fileID == 0) {
	//src = '/h-o-a-home/images/spacer.gif';
	src = '/h-o-a-home/images/no-picture.jpg';
	}
else {
	src = 'sendpic.html?fid=' + fileID + '&w=150';
	}
image.src = src;
}

function fieldExists(theForm, fieldName) {
	for (var i = 0; i < theForm.length; i++) {
		if (theForm.elements[i].name == fieldName) {
			return true;
		}
	}
	return false;
}