<!--
ns4 = (document.layers)?true:false;
ie4 = (document.all)?true:false;

function getName(oItem)
{
	sName = "";
	  
	if( !isNull(oItem) )
		sName = oItem.name;

	return sName;
}

function getType(oItem)
{
	sType = "";
	  
	if( !isNull(oItem) )
		sType = oItem.type;
	    
	return sType;
}

function isEqualType(oItem, sType)
{
	bResult = ( sType == getType(oItem) );
	return bResult;
}

function isTextBox(oItem)
{
	return isEqualType(oItem, "text");
}

function isTextArea(oItem)
{
	return isEqualType(oItem, "textarea");
}

function isRadio(oItem)
{
	return isEqualType(oItem, "radio");
}

function isCheckBox(oItem)
{
	return isEqualType(oItem, "checkbox");
}

function isReset(oItem)
{
	return isEqualType(oItem, "reset");
}

function isSubmit(oItem)
{
	return isEqualType(oItem, "submit");
}

function isButton(oItem)
{
	return isEqualType(oItem, "button");
}

function isSelectOne(oItem)
{
	return isEqualType(oItem, "select-one");
}

function isUndefined(oItem)
{
	bResult = isEqualType(oItem, "undefined");
	return bResult;
}

function isValidType(oItem)
{
	bResult = ( isTextBox(oItem)   || 
				isTextArea(oItem)  ||
				isRadio(oItem)     ||
				isCheckBox(oItem)  ||	
				isReset(oItem)     ||
				isSubmit(oItem)    ||
				isButton(oItem)    ||
				isSelectOne(oItem) );

	return bResult;
}

function setVisibility(oItem, bVisible)
{
	if( !isNull(oItem) )
	{
		if( ie4 )
		{
			if( bVisible )
				oItem.style.visibility = "visible";
			else
				oItem.style.visibility = "hidden";
		}
		else
		{
			if( bVisible )
				oItem.visibility = "show";
			else
				oItem.visibility = "hide";
		}
	}
}

function visibleControl(oItem)
{
	setVisibility(oItem, true);
}

function invisibleControl(oItem)
{
	setVisibility(oItem, false);
}

function setVisibilities(theForm, bVisible)
{
	if( !isNull(theForm) )
	{
		for( i=0; i<theForm.elements.length; i++ )
		{
			oItem = theForm.elements[i];
			if( bVisible )
				visibleControl(oItem);
			else
				invisibleControl(oItem);
		}
	}
}

function visibleControls(theForm)
{
	setVisibilities(theForm, true);
}

function invisibleControls(theForm)
{
	setVisibilities(theForm, false);
}

function setValue(oItem, sValue)
{
	if( !isNull(oItem) )
	{
		oItem.value = sValue;
	}
}

function getValue(oItem)
{
	sValue = "";

	if( !isNull(oItem) )
		sValue = oItem.value;

	return sValue;
}

function setSelectedItem(oItem, nIndex)
{
	if( isSelectOne(oItem) )
	{
		oItem.options[nIndex].selected = true;
	}
}

function getDisableColor()
{
	return "gainsboro";
}

function getEnableColor()
{
	return "white";
}

function getDefaultFormColor()
{
	return "#EFEFEF";
}

function setBackgroundColor(oItem, sColor)
{
	if( !isNull(oItem) )
	{
		oItem.style.backgroundColor = sColor;
	}
}

function setDisability(oItem, bDisable)
{
	if( !isNull(oItem) )
	{
		if( bDisable )
		{
			if( !isRadio(oItem) &&
				!isReset(oItem) &&
				!isSubmit(oItem) &&
				!isButton(oItem) )
			{
				setValue(oItem, "");
			}
		      
			oItem.disabled  = true;
		      
			if( !isRadio(oItem) && 
				!isCheckBox(oItem) &&
				!isReset(oItem) &&
				!isSubmit(oItem) &&
				!isButton(oItem) )
			{
				setBackgroundColor(oItem, getDisableColor());
			}


			if( isCheckBox(oItem) )
			{
				oItem.checked = false;
			}
		}
		else
		{
			oItem.disabled  = false;

			if( !isRadio(oItem) &&
				!isCheckBox(oItem) &&
				!isReset(oItem) &&
				!isSubmit(oItem) &&
				!isButton(oItem) )
			{
				setBackgroundColor(oItem, getEnableColor());
			}

			if( isSelectOne(oItem) )
			{
				setSelectedItem(oItem, 0);
			}
		}
	}
}

function disableControl(oItem)
{
	setDisability(oItem, true);
}

function enableControl(oItem)
{
	setDisability(oItem, false);
}

function setDisabilities(theForm, bDisable)
{
	if( !isNull(theForm) )
	{
		for( i=0; i<theForm.elements.length; i++ )
		{
			oItem = theForm.elements[i];
			if( bDisable )
				disableControl(oItem);
			else
				enableControl(oItem);
		}
	}
}

function disableControls(theForm)
{
	setDisabilities(theForm, true);
}

function enableControls(theForm, bDisable)
{
	setDisabilities(theForm, false);
}
function readOnlyControl(oItem, bReadOnly)
{
	oItem.readOnly = bReadOnly;

	if( bReadOnly )
		setBackgroundColor(oItem, getDisableColor());
	else
		setBackgroundColor(oItem, getEnableColor());
}

function getControlsInfo(theForm)
{
	sMsg  = "Type" + "\t\t" + "     Name" + "\n"
	sMsg += "--------" + "\t\t" + "--------------------" + "\n"
		
	if( !isNull(theForm) )
	{
		for( i=0; i<theForm.elements.length; i++ )
		{
		sMsg += theForm.item(i).type + "\t\t" + theForm.item(i).name + "\n"
		}
	}
	   
	return sMsg;
}

function resetLablesColor(theForm)
{
	if( !ie4 )
	{
		sMsg = "";
		if( !isNull(theForm) )
		{
			for( i=0; i<theForm.elements.length; i++ )
			{
				oItem = theForm.elements[i];
				sMsg += getType(oItem) + "\n";
			    
				if( isUndefined(oItem) )
				{
					setBackgroundColor(oItem, getDefaultFormColor());
				}
			}
		}
		alert( sMsg );
	}
}

function textCounter(oItem, limit)
{
	if( oItem.value.length > limit )
	{
		oItem.value = oItem.value.substring(0, limit);
	}
}

function keySort(dropdownlist, caseSensitive) 
{
	if( dropdownlist == null )
		return false;
		
	// check the keypressBuffer attribute is defined on the dropdownlist 
	var undefined; 
	if (dropdownlist.keypressBuffer == undefined) 
	{ 
		dropdownlist.keypressBuffer = ''; 
	} 
	// get the key that was pressed 
	var key = String.fromCharCode(window.event.keyCode); 
	dropdownlist.keypressBuffer += key;
	if (!caseSensitive) 
	{
		// convert buffer to lowercase
		dropdownlist.keypressBuffer = dropdownlist.keypressBuffer.toLowerCase();
	}
	// find if it is the start of any of the options 
	var optionsLength = dropdownlist.options.length; 
	for (var n=0; n < optionsLength; n++) 
	{ 
		var optionText = dropdownlist.options[n].text; 
		if (!caseSensitive) 
		{
			optionText = optionText.toLowerCase();
		}
		if (optionText.indexOf(dropdownlist.keypressBuffer,0) == 0) 
		{ 
			dropdownlist.selectedIndex = n; 
			return false; // cancel the default behavior since 
			// we have selected our own value 
		} 
	} 
	// reset initial key to be inline with default behavior 
	dropdownlist.keypressBuffer = key; 
	return true; // give default behavior 
} 

//-->