// Menu-Related Functions
nNumMenus = 5;
document.onmouseover = hideAllMenus;

function showMenu(eventObj,nMenuNumber) {
    hideAllMenus();
	eventObj.cancelBubble = true;
    var sMenuName = 'menuNav' + nMenuNumber;
    if(changeObjectVisibility(sMenuName, 'visible')) {
		return true;
    } else {
		return false;
    }
}

function hideAllMenus() {
    for(nCounter = 1; nCounter <= nNumMenus; nCounter++) {
		changeObjectVisibility('menuNav' + nCounter, 'hidden');
    }
}

function showMenuOLD(eventObj,sMenuName) {
	eventObj.cancelBubble = true;
    if(changeObjectVisibility(sMenuName, 'visible')) {
		return true;
    } else {
		return false;
    }
}
function hideMenuOLD(eventObj, sMenuName) {
	eventObj.cancelBubble = true;
    if(changeObjectVisibility(sMenuName, 'hidden')) {
		return true;
    } else {
		return false;
    }
}

function getStyleObject(objectId) {
    // cross-browser function to get an object's style object given its id
    if(document.getElementById && document.getElementById(objectId)) {
		// W3C DOM
		return document.getElementById(objectId).style;
    } else if (document.all && document.all(objectId)) {
		// MSIE 4 DOM
		return document.all(objectId).style;
    } else if (document.layers && document.layers[objectId]) {
		// NN 4 DOM.. note: this won't find nested layers
		return document.layers[objectId];
    } else {
		return false;
    }
} // getStyleObject

function changeObjectVisibility(objectId, newVisibility) {
    // get a reference to the cross-browser style object and make sure the object exists
    var styleObject = getStyleObject(objectId);
    if(styleObject) {
		styleObject.visibility = newVisibility;
		return true;
    } else {
		//we couldn't find the object, so we can't change its visibility
		return false;
    }
} // changeObjectVisibility

// Appear/Disappear DIV functions

function ToggleBranch(nBranchNumber)
{
	var divStatus = document.getElementById('divStatus' + nBranchNumber);
	if (divStatus.style.display == "none")
	{
		divStatus.style.display = "";
	}
	else
	{
		divStatus.style.display = "none";
	}		
}

function ToggleBranchArrow(nBranchNumber)
{
	var divStatus = document.getElementById('divStatus' + nBranchNumber);
	var imgArrow = eval('document.imgArrow' + nBranchNumber);
	if (divStatus.style.display == "none")
	{
		divStatus.style.display = "";
		imgArrow.src = "../Images/arrow_dn.gif";
	}
	else
	{
		divStatus.style.display = "none";
		imgArrow.src = "../Images/arrow_up.gif";
	}		
}

function OpenWin(sURL) {
	var nWidth = 600;
	var nHeight = 500;
	//var nWidth = screen.width - 200;
	//var nHeight = screen.height - 100;
	wContent=window.open(sURL,'wContent','left=10,top=10,screenX=10,screenY=10,width=' + nWidth + ',height=' + nHeight + ',scrollbars=yes,location=no');
	wContent.focus();
}

function validateRegister() {
	if (document.txtNameFirst.value == "") {
		alert('You must provide a first name');
		document.txtNameFirst.focus();
		return false;
	}
	else if (document.txtNameLast.value == "") {
		alert('You must provide a last name');
		document.txtNameLast.focus();
		return false;
	}
	else if (document.txtEmail.value == "") {
		alert('You must provide an e-mail address');
		document.txtEmail.focus();
		return false;
	}
	else if (document.txtUsername.value == "") {
		alert('You must provide a username');
		document.txtUsername.focus();
		return false;
	}
	else if (document.txtPassword.value == "") {
		alert('You must provide a password');
		document.txtPassword.focus();
		return false;
	}
	else if (document.txtPassword.value != document.frmDefault.txtPasswordRepeat.value) {
		alert('The passwords you provided do not match each other');
		document.txtPasswordRepeat.focus();
		return false;
	}
	else if (document.chkOptIn.checked) {
		if (document.txtAddress.value == "") {
			alert('You must provide an address');
			document.txtAddress.focus();
			return false;
		}
		else if (document.txtCity.value == "") {
			alert('You must provide a city');
			document.txtCity.focus();
			return false;
		}
		else if (document.txtZIP.value == "") {
			alert('You must provide a ZIP Code');
			document.txtZIP.focus();
			return false;
		}
	}
	
	return true;
}

function validateMessage() {
	if (document.frmPostMessage.txtSubject.value == "") {
		alert('You must provide a subject.');
		document.frmPostMessage.txtSubject.focus();
		return false;
	}
	else if (document.frmPostMessage.txtBody.value == "") {
		alert('You must provide a message body.');
		document.frmPostMessage.txtBody.focus();
		return false;
	}
	return true;
}
