//Created by Marv Rubenstein 3/02/06 for the CCC membership information system.

// Checks for null values.
function isEmpty(itemValue, item, itemDesc) {
	var strMsg
	if (item.name == "email") {
		strMsg = "Email is for club e-newsletter and messages. If not wanted, enter x@x to avoid this message."
	} else {
	  	strMsg = "The " + itemDesc + " item can't be blank."
	}
	if (itemValue == "") {
	   alert(strMsg) 
		item.focus()
		return true
	}
	return false
}
// Checks for both length of string and null value
function isBadLen(itemVal, item, itemDesc, itemLen) {
 	var strInput, strLength, strMsg
	strValue = itemVal.toString()
 	strLength = itemLen.toString()
	if (item.name == "phone") {
	   strMsg = "The Phone item is either blank or not formatted 'xxx-xxx-xxxx'"
	} else {
	  strMsg = "The " + itemDesc + " item is either blank or has less than " + itemLen + " characters."
	}
	if (strValue.length < strLength) {
 		alert(strMsg)
		item.focus()
		item.select()
 		return true
 		}
 	return false
 }
 //Outputs current date in format yyyy-mm-dd for input to mySQL table.
 function getToday() {
	var now = new Date();
	var months = new Array('01','02','03','04','05','06','07','08','09','10','11','12');
   var year = now.getYear();
	var date = ((now.getDate()<10) ? "0" : "")+ now.getDate();
   return(year + "-" + months[now.getMonth()] + "-" + date);
}
