function check_inquiry(form) {

	if (isBlank(form.amount, "Please fill in judgment amount.")) { return false; }	
	if (isBlank(form.collected, "Please fill in the amount of judgment collected.")) { return false; }	
	if (isBlank(form.judgment_date, "Please fill in the judgment date.")) { return false; }	
	if (isBlank(form.judgment_state, "Please fill in the judgment state.")) { return false; }	
	if (isBlank(form.debtor, "Please fill in the debtor name.")) { return false; }	
	if (isBlank(form.debtor_address, "Please fill in the debtor's last know address.")) { return false; }	
	if (isBlank(form.debtor_address2, "Please fill in the debtor's last know city, state and zip.")) { return false; }	
	
	if (isBlank(form.name, "Please fill in your name.")) { return false; }
	if (isBlank(form.phone, "Please fill in your phone number.")) { return false; }
	if (isBlank(form.email, "Please fill in your email address.")) { return false; }
	if (!isValidEmail(form.email.value)) {
		showMessage(form.email, "Please fill in a valid email address.");
		return false;
	}	
	
	if (isBlank(form.description, "Please fill in a case description.")) { return false; }		

	return true;
}


function isBlank(obj, message) {
	if (obj.value == "") {
		alert(message);
		obj.focus();
		return true;
	}
	
	return false;
}

function isValue(obj, value, message) {
	if (obj.value == value) {
		alert(message);
		obj.focus();
		return true;
	}
	
	return false;
}

function isValidAddress(addr) {
	index1 = addr.indexOf("@");
	if (index1 <= 0) {
		return false;
	}
	index2 = addr.indexOf(".", index1);
	if (index2 < index1) {
		return false;
	}
	
	//must be at least a period and 2 characters at the end
	if (index2 == addr.length-1 || index2 == addr.length-2) {
		return false;
	}
	return true;
}

function isValidDate(test) {		
	var date = test.split("/"); 	
	if (date.length != 3) {
		return false;
	}

	var month = date[0];
	var day = date[1];	
	var year = date[2];
	var daysInMonth= new Array(31, 0, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
	daysInMonth[1] = (year % 4 == 0 && year % 100 != 0) ? 29 : 28;
	
	if (month > 12 || month < 1) {
		return false;
	}else if (day < 1 ||day > daysInMonth[month - 1]) {
		return false;
	}else if (year < 1900 ||year > 2100) {	
		return false;
	}

	return true;
}

function isValidEmail(addr) {
	index1 = addr.indexOf("@");
	if (index1 <= 0) {
		return false;
	}
	index2 = addr.indexOf(".", index1);
	if (index2 < index1) {
		return false;
	}
	
	//must be at least a period and 2 characters at the end
	if (index2 == addr.length-1 || index2 == addr.length-2) {
		return false;
	}
	return true;
}

function isBeforeToday(date) {
	if (!isValidDate(date)) {
		return false;
	}
	var d1 = date.split("/");
	var d2 = new Date();
	var test = getGMT(new Date(d1[2],d1[0] - 1,d1[1]).getTime());
	var today = getGMT(d2.getTime());

	if (test >= today) {
		return false;
	}
	
	return true;
}

function isToday(date) {
	if (!isValidDate(date)) {
		return false;
	}
	var d1 = date.split("/");
	var d2 = new Date();
	var test = getGMT(new Date(d1[2],d1[0] - 1,d1[1]).getTime());
	var today = getGMT(d2.getTime());
	if (test == today) {
		return true;
	}
	
	return false;
}

function getFullYear(obj) {
	if ((navigator.appName == "Netscape")&&(document.layers)) {	
 		return obj.getYear() + 1900;
 	}else {
 		return obj.getYear();
 	}
}

function getGMT(date) {
	var d = new Date(date);
	var gmt = Date.UTC(getFullYear(d), d.getMonth(), d.getDate());
	return gmt;
}

function showMessage(field, message) {
	alert(message);
	field.focus();
	field.select();
}





