function minimize(field) {
	value = field.value;
	field.value = value.toLowerCase();
}

function formatPhone(field) {
	value = field.value;
	if ( value.length == 10 && !isNaN(value) ) {
		areaCode = value.substring(0,3);
		num1 = value.substring(3,6);
		num2 = value.substring(6,8);
		num3 = value.substring(8);
		field.value = "("+areaCode+")"+" "+num1+" "+num2+" "+num3
	}
}

function unFormatPhone(value) {
	value = value.replace("(","");
	value = value.replace(")","");
	value = value.replace(" ","");
	value = value.replace(" ","");
	value = value.replace(" ","");
	return value;
}

function formatURL(field) {
	value = field.value;
	if ( value.length > 0 && value.substring(0,7) != "http://" ) {
		field.value = "http://" + value.toLowerCase();
	}
	else
		field.value = value.toLowerCase();
}

function ismaxlength(obj) {
	var mlength = obj.getAttribute ? parseInt(obj.getAttribute("maxlength")) : ""
	if (obj.getAttribute && obj.value.length > mlength)
		obj.value = obj.value.substring(0,mlength)
}

function y2k(number) { return (number < 1000) ? number + 1900 : number; }
function isDate (day,month,year) {
// checks if date passed is valid
// will accept dates in following format:
// isDate(dd,mm,ccyy), or
// isDate(dd,mm) - which defaults to the current year, or
// isDate(dd) - which defaults to the current month and year.
// Note, if passed the month must be between 1 and 12, and the
// year in ccyy format.

    var today = new Date();
    year = ((!year) ? y2k(today.getYear()):year);
    month = ((!month) ? today.getMonth():month-1);
    if (!day) return false
    var test = new Date(year,month,day);
    if ( (y2k(test.getYear()) == year) &&
         (month == test.getMonth()) &&
         (day == test.getDate()) )
        return true;
    else
        return false
}
