﻿var Logos = Logos ? Logos : {};
Logos.InternalBibleSearchBar = {
	onFocus: function(el) {
		if (el.value == 'Search the Bible')
			el.value = '';
		el.className = '';
	},
	onBlur: function(el) {
		if (el.value == '') {
			el.value = 'Search the Bible';
			el.className = 'lbxBlurred';
		}
	},
	onSubmit: function(el) {
		var q = el.elements['query'].value;
		q = q.replace(/^\s+/, '');
		q = q.replace(/\s+$/, '');
		el.elements['query'].value = q;
		if (q == '' || q == 'Search the Bible') {
			el.elements['query'].blur();
			return false;
		}
	}
};
(function() {
	var oldonload = window.onload;
	window.onload = function() {
		if (oldonload)
			oldonload();
		var lbxSearchQuery = document.getElementById('lbxBibleSearchQuery');
		if (lbxSearchQuery) {
			lbxSearchQuery.onfocus = function() { Logos.InternalBibleSearchBar.onFocus(this); };
			lbxSearchQuery.onblur = function() { Logos.InternalBibleSearchBar.onBlur(this); };
			if (lbxSearchQuery.value != 'Search the Bible')
				lbxSearchQuery.className = '';
			var lbxSearchForm = document.getElementById('lbxBibleSmallSearchForm');
			lbxSearchForm.onsubmit = function() { return Logos.InternalBibleSearchBar.onSubmit(this); };
		}
	};
})();
