if ( !self.SMM ) { self.SMM = new Object(); self.SMM.wcomp = new Object(); }
self.SMM.wcomp.nesttest = {
 run: function () {
	var o = this;
	if ( !self.SMM.wcomp.gen.DOMok ) { return }
	o.p_elt = document.getElementById( 'parent' );
	o.c_elt = document.getElementById( 'child' );
	if ( !o.p_elt || !o.c_elt || !o.p_elt.form || !o.Ve['a'] ) { return }
	o.p_elt.form.onsubmit = o.onsubmit_check;
	o.p_elt.onchange = o.c_elt.onchange = o.onchange_check;
	if ( !o.p_elt.form.firstChild.appendChild ) { return }
	var swp = self.SMM.wcomp.gen.cElt( 'button', '', '', 'Swap Fields' );
	o.p_elt.form.firstChild.appendChild( swp );
	swp.onclick = o.onclick_swap;
 },

 onchange_check: function () {
	self.SMM.wcomp.gen.norm_ws( this );
	var val = this.value; if ( !val ) { return }
	val = val.toLowerCase();
	if ( val == 'pcdata' ) { val = 'PCDATA' }
	this.value = val;
 },

 onsubmit_check: function () {
	var o = self.SMM.wcomp.nesttest;
	var e = new Array ();
	var focus = o.c_elt;
	var pval = o.p_elt.value;
	if ( !pval ) { focus = o.p_elt; e[ e.length ] = 'No parent element specified' }
	else {
	 if ( !pval.match( /^[a-zA-Z0-9]+$/ ) ) { focus = o.p_elt; e[ e.length ] = 'Invalid parent format - please use only letters and digits with no whitespace' }
	 else if ( pval.toUpperCase() == 'PCDATA' ) { focus = o.p_elt; o.p_elt.value = 'PCDATA'; e[ e.length ] = 'PCDATA can never be a parent' }
	 else if ( !o.Ve[ pval ] ) { focus = o.p_elt; e[ e.length ] = 'The parent element does not exist' }
	}
	var cval = o.c_elt.value;
	if ( !cval ) { e[ e.length ] = 'No child element specified' }
	else {
	 if ( !cval.match( /^[a-zA-Z0-9]+$/ ) ) { e[ e.length ] = 'Invalid child format - please use only letters and digits with no whitespace' }
 	 else if ( !o.Ve[ cval ] ) { e[ e.length ] = 'The child element does not exist' }
	}
	if ( e[0] ) { return self.SMM.wcomp.forms.form_error( e, focus, o.p_elt.form ) }
	return true;
 },

 onclick_swap: function () {
	var o = self.SMM.wcomp.nesttest;
	var tmp = o.p_elt.value; o.p_elt.value = o.c_elt.value; o.c_elt.value = tmp;
	return false;
 },

 Ve: {
PCDATA: 1,
a: 1,
abbr: 1,
acronym: 1,
address: 1,
area: 1,
b: 1,
base: 1,
bdo: 1,
big: 1,
blockquote: 1,
body: 1,
br: 1,
button: 1,
caption: 1,
cite: 1,
code: 1,
col: 1,
colgroup: 1,
dd: 1,
del: 1,
dfn: 1,
div: 1,
dl: 1,
dt: 1,
em: 1,
fieldset: 1,
form: 1,
h1: 1,
h2: 1,
h3: 1,
h4: 1,
h5: 1,
h6: 1,
head: 1,
hr: 1,
html: 1,
i: 1,
img: 1,
input: 1,
ins: 1,
kbd: 1,
label: 1,
legend: 1,
li: 1,
link: 1,
map: 1,
meta: 1,
noscript: 1,
'object': 1,
ol: 1,
optgroup: 1,
option: 1,
p: 1,
param: 1,
pre: 1,
q: 1,
rb: 1,
rbc: 1,
rp: 1,
rt: 1,
rtc: 1,
ruby: 1,
samp: 1,
script: 1,
select: 1,
small: 1,
span: 1,
strong: 1,
style: 1,
sub: 1,
sup: 1,
table: 1,
tbody: 1,
td: 1,
textarea: 1,
tfoot: 1,
th: 1,
thead: 1,
title: 1,
tr: 1,
tt: 1,
ul: 1,
'var': 1
 }
};
