function FieldError( field, message ) {
	if ( field.length )
	{
		document.forms[ Screen ].elements[ field ].select();
		document.forms[ Screen ].elements[ field ].focus();
	}

	alert( message );
}

function SetStep( number ) {
	document.forms[ Screen ].elements[ 'Step' ].value = number;
	document.forms[ Screen ].submit();
}

function SetAction( action ) {
	document.forms[ Screen ].elements[ 'Action' ].value = action;
	document.forms[ Screen ].submit();
}

function SetActionModule( action, module ) {
	document.forms[ Screen ].elements[ 'Action' ].value = action;
	document.forms[ Screen ].elements[ 'Module' ].value = module;
	document.forms[ Screen ].submit();
}

function NewWindow(mypage,myname,w,h) {
	var winl = ( ( ( screen.width - w ) / 2 ) / 2 ) * 3;
	var wint = ( ( screen.height - h ) / 2 ) / 2;
	winprops = 'width=' + w + ',height=' + h + ',top=' + wint + ',left=' + winl + ',scrollbars=yes,resizable,status=no';
	win = window.open( mypage, myname, winprops );

	if ( parseInt( navigator.appVersion ) >= 4 ) {
		win.window.focus(); 
	}
}

function addSearchOptions(select, variable, output) {
	var display=document.getElementById(output);
	var option = select.options[select.selectedIndex];
	var ul = display.getElementsByTagName('ul')[0];

	if (!ul) {
		ul = document.createElement("ul");
		ul.setAttribute('class', 'options');
		display.innerHTML = '';
		display.appendChild(ul);
	}

	var choices = ul.getElementsByTagName('input');

	for (var i = 0; i < choices.length; i++) {
		if (choices[i].value == option.value) {
			return;
		}
	}

	var li = document.createElement('li');
	var input = document.createElement('input');
	var text = document.createTextNode(option.firstChild.data);

	input.type = 'hidden';
	input.name = variable;
	input.value = option.value;

	if (input.value!=null && input.value!="") {
		li.appendChild(input);
		li.appendChild(text);
		li.setAttribute('onclick', 'removeSearchOptions(this,\'' + output + '\');');

		ul.appendChild(li);
	}
}

function removeSearchOptions(select, output) {
	var display=document.getElementById(output);
	var ul = display.getElementsByTagName('ul')[0];

	select.parentNode.removeChild(select);

	if ( ul.getElementsByTagName('li').length == 0 ) {
		display.innerHTML = '<p class="hint">&lt;Blank&gt;</p>';
	}
}

