if ( !self.SMM ) { self.SMM = new Object(); self.SMM.wcomp = new Object(); }
self.SMM.wcomp.contact = {
 run: function () {
	var o = this;
	if ( !self.SMM.wcomp.gen.DOMok ) { return }
	o.n = document.getElementById( 'name' );
	o.e = document.getElementById( 'email' );
	o.m = document.getElementById( 'message' );
	if ( !o.n || !o.e || !o.m || !o.n.form ) { return }
	o.n.form.onsubmit = o.onsubmit_check;
	if ( !'txt'.match ) { return }
	o.defs = new Object();
	o.defs[ o.n.name ] = 'Your Name';
	o.defs[ o.e.name ] = 'Your Email Address';
	o.defs[ o.m.name ] = 'Your Message';
	o.reset();
	o.n.onfocus = o.e.onfocus = o.m.onfocus = o.onfocus_elt;
	o.n.onblur = o.e.onblur = o.m.onblur = o.onblur_elt;
	o.r = document.getElementById( 'resetform' );
	if ( !o.r ) { return }
	o.r.onclick = o.onclick_reset;
 },

 reset: function () {
	var o = this;
	o.setclass( o.n );
	o.setclass( o.e );
	o.setclass( o.m );
 },

 setclass: function ( elt ) {
	var o = this;
	elt.className = ( elt.value == o.defs[ elt.name ] ) ? 'off' : 'on';
 },

 onsubmit_check: function () {
	var o = self.SMM.wcomp.contact;
	var er = new Array ();
	self.SMM.wcomp.gen.norm_ws( o.n );
	self.SMM.wcomp.gen.norm_ws( o.e );
	var val = o.m.value;
	if ( val.replace ) { val = val.replace( /^\s+/, '' ); val = val.replace( /\s+$/, '' ); o.m.value = val; }

	var focus = o.n;
	var n = o.n.value;
	if ( n == o.defs[ o.n.name ] ) n = '';
	if ( !n ) { er[ er.length ] = 'Missing name' }
	var em = o.e.value;
	if ( em == o.defs[ o.e.name ] ) em = '';
	if ( !em ) { er[ er.length ] = 'Missing email address'; if ( er.length == 1 ) { focus = o.e } }
	else if ( em.match && !em.match( /.@./ ) ) {
		er[ er.length ] = "Your email address doesn't appear to be valid";
		if ( er.length == 1 ) { focus = o.e }
	}   
	var m = o.m.value;
	if ( m == o.defs[ o.m.name ] ) m = '';
	if ( !m ) { er[ er.length ] = 'Missing message text'; if ( er.length == 1 ) { focus = o.m } }
	else if ( m.length > 5000 ) {
		er[ er.length ] = 'Message text should have 5000 characters or fewer - yours is ' + m.length + ' characters long';
		if ( er.length == 1 ) { focus = o.m }
	}

	if ( er[0] ) { return self.SMM.wcomp.forms.form_error( er, focus, o.n.form ) }
	return true;
 },

 onfocus_elt: function () {
	var o = self.SMM.wcomp.contact;
	if ( this.value == o.defs[ this.name ] ) this.value = '';
	o.setclass( this );
 },

 onblur_elt: function () {
	var o = self.SMM.wcomp.contact;
	if ( this.value.match( /^\s*$/ ) ) this.value =  o.defs[ this.name ];
	o.setclass( this );
 },

 onclick_reset: function () {
	var o = self.SMM.wcomp.contact;
	o.n.form.reset();
	o.reset();
	return false;
 }
};
