$(function() {
	// Define what happens when the textbox comes under focus
	// Remove the watermark class and clear the box
	$("#txtBibleSearch").focus(function() {

		$(this).filter(function() {

			// We only want this to apply if there's not 
			// something actually entered
			return $(this).val() == "" || $(this).val() == "Enter a passage or word(s)..."

		}).removeClass("watermarkOn").val("");

	});

	// Define what happens when the textbox loses focus
	// Add the watermark class and default text
	$("#txtBibleSearch").blur(function() {

		$(this).filter(function() {

			// We only want this to apply if there's not
			// something actually entered
			return $(this).val() == ""

		}).addClass("watermarkOn").val("Enter a passage or word(s)...");

	});
	
	$("button").button();
});

function SearchBible() {
	if($("#txtBibleSearch").val() != '' && $("#txtBibleSearch").val() != 'Enter a passage or word(s)...') {
		$("#quicksearch").val($("#txtBibleSearch").val());
		$("#formBibleGateway").submit();
	}
	else {
		 alert("You must enter something to search for.");
	}
}

function ValidDate(dateID, validateBlank) {
	var isValid = true;
	var dateValue = $('#'+dateID).val();

	if(jQuery.trim(dateValue) == '') {
		isValid = false;
	}
	else {
		try {
			var tmpDate = jQuery.datepicker.parseDate('mm/dd/yy', dateValue);
			$('#'+dateID).val(jQuery.datepicker.formatDate('mm/dd/yy', tmpDate));
		}
		catch(ex) {
			isValid = false;
		}
	}
	
	return isValid;
}
