

// -------------------------------------------------------------------
// autoComplete (text_input, select_input, ["text"|"value"], [true|false])
//   Use this function when you have a SELECT box of values and a text
//   input box with a fill-in value. Often, onChange of the SELECT box
//   will fill in the selected value into the text input (working like
//   a Windows combo box). Using this function, typing into the text
//   box will auto-select the best match in the SELECT box and do
//   auto-complete in supported browsers.
//   Arguments:
//      field = text input field object
//      select = select list object containing valid values
//      property = either "text" or "value". This chooses which of the
//                 SELECT properties gets filled into the text box -
//                 the 'value' or 'text' of the selected option
//      forcematch = true or false. Set to 'true' to not allow any text
//                 in the text box that does not match an option. Only
//                 supported in IE (possible future Netscape).
// -------------------------------------------------------------------
function autoComplete (field, select, property, forcematch) {
	var found = false;
	for (var i = 0; i < select.options.length; i++) {
	if (select.options[i][property].toUpperCase().indexOf(field.value.toUpperCase()) == 0) {
		found=true; break;
		}
	}
	if (found) { 
	select.selectedIndex = i; 
	}
	else { 
	select.selectedIndex = -1; 
	}
	if (field.createTextRange) {
		if (forcematch && !found) {
			field.value=field.value.substring(0,field.value.length-1); 
			return;
			}
		var cursorKeys ="8;46;37;38;39;40;33;34;35;36;45;";
		if (cursorKeys.indexOf(event.keyCode+";") == -1) {
			var r1 = field.createTextRange();
			var oldValue = r1.text;
			var newValue = found ? select.options[i][property] : oldValue;
			if (newValue != field.value) {
				field.value = newValue;
				var rNew = field.createTextRange();
				rNew.moveStart('character', oldValue.length) ;
				rNew.select();
				}
			}
		}
	}

	function checkLength(field, countfield, maxlimit) {
		if (field.value.length > maxlimit) // if too long...trim it!
			field.value = field.value.substring(0, maxlimit);
		// otherwise, update 'characters left' counter
		else
			countfield.value = maxlimit - field.value.length;
	}
	
	function openNewWindow(url) {    
		window.open(url,'newPage','scrollbars=no,resizable=no,width=400,height=400');   
	}
	
function checkAll()
{
	var boxes = cBoxes.getElementsByTagName("input");
	for (var i = 0; i < boxes.length; i++) {
		myType = boxes[i].getAttribute("type");
		if ( myType == "checkbox") {
			boxes[i].checked=1;
		}
	}
}
function checkNone()
{
	var boxes = cBoxes.getElementsByTagName("input");
	for (var i = 0; i < boxes.length; i++) {
		myType = boxes[i].getAttribute("type");
		if ( myType == "checkbox") {
			boxes[i].checked=0;
		}
	}
}

function MsgBox (textstring) {
alert (textstring) }





