if ( !self.SMM ) { self.SMM = new Object(); self.SMM.wcomp = new Object(); }
self.SMM.wcomp.search = {
 run: function () {
	var o = this;
	var g = self.SMM.wcomp.gen;
	if ( !g.DOMok ) { return }
	o.term = document.getElementById( 'term' );
	if ( o.term ) {
	    o.term.onfocus = o.onfocus_select;
	    if ( o.term.form ) o.term.form.onsubmit = o.onsubmit_check;
	}
 },

 onfocus_select: function () {
	this.select();
 },

 onsubmit_check: function () {
	var o = self.SMM.wcomp.search;
	var e = new Array ();
	self.SMM.wcomp.gen.norm_ws( o.term );
	var vl = o.term.value;
	if ( !vl ) { e[ e.length ] = 'Empty search term (or search term is only whitespace)' }
	else {
	 if ( !vl.match( /^[a-zA-Z0-9_ "()*?:-]+$/ ) ) {
		e[ e.length ] = 'Invalid characters in search term - please use only letters, digits, spaces and the characters _*?:-"()';
	 }
	 if ( vl.match( /[*].*[*]/ ) ) { e[ e.length ] = 'Multiple * wildcards are not allowed' }
	 if ( vl.match( /([?].*[*])|([*].*[?])/ ) ) { e[ e.length ] = 'Both * and ? wildcards are not allowed in the same search' }
	}
	if ( e[0] ) { return self.SMM.wcomp.forms.form_error( e, o.term, o.term.form ) }
	return true;
 }
};

