/* Scripts written by Matthew Ring, 2004
 * For use with the Portfolio edition of www.theringworx.com
 */

/* These functions are for use with the top navigational menu */

var menuID = 'mDesc';	// this is a one-spot change if the element ID is modified
var blank;	// hold the empy string value of the element's firstChild data
var menuDesc = new Array();
	menuDesc[0] = "The main welcome page";
	menuDesc[1] = "Course information, transcripts and anything else pertaining to my academic career";
	menuDesc[2] = "Projects that I\'ve worked on, primarily for academic projects / homework";
	menuDesc[3] = "Experiences and skills that I\'ve gained out in the real world";
	menuDesc[4] = "A personal reflection of my college career";


/* onMouseOver event for top navigation */
function onMenuDesc( num ) {
	blank = document.getElementById(menuID).firstChild.data;
	document.getElementById(menuID).firstChild.data = menuDesc[num];
}

/* onMouseOut event for top navigation */
function offMenuDesc(idName) {
	document.getElementById(menuID).firstChild.data = blank;
}


/* These functions validate the Contact form for the Black and Chrome Sales website */

function validateEmail(ctrl) {
	/* only check if value is not blank */
	if (!ctrl.value == "") {
		ValidEmail(ctrl.value);
	}
}

function validateForm() {
	var ErrMsg = new String("Please enter the following information:");
	var initMsgSize = ErrMsg.length;
	
	/* check Name field */
	if (document.frmContact.txtName.value == "") {
		ErrMsg = ErrMsg + " Name,";
	}
	/* check Email field */
	if (document.frmContact.txtEmail.value == "") {
		ErrMsg = ErrMsg + " E-mail,";
	}
	/* check Subject field */
	if (document.frmContact.txtSubj.value == "") {
		ErrMsg = ErrMsg + " Subject,";
	}
	/* check Message field */
	if (document.frmContact.txtMsg.value == "") {
		ErrMsg = ErrMsg + " Message,";
	}
	/* check for error message - if exists, cut off last ',' */
	if (ErrMsg.length != initMsgSize) {
		ErrMsg = ErrMsg.substr(0, ErrMsg.length-1);
		alert(ErrMsg);
		return false; /* don't process e-mail */
	}
	/* at this point, we've passed all tests */
	alert("Thank you for contacting us. We will respond to you as soon as possible.")
	return true;		
}

