function lightPopup(id){
	if((lp=$('js_Popup_'+id))!=null){
		try{
			lp.show().select('a.link_Close')[0].observe('click',function(event){event.element().up().hide();});
		}catch(exception){}
	}
	return false;
}

function MSHUpcase(myfield) {
	    if (myfield.inchange) return;
	    myfield.inchange = true;
	    myfield.value = myfield.value.toUpperCase();
	    myfield.inchange = false;
	}

function MSHLowcase(myfield) {
    if (myfield.inchange) return;
    myfield.inchange = true;
    myfield.value = myfield.value.toLowerCase();
    myfield.inchange = false;
}

function MSHlimitText(limitField, limitNum) {
	if (limitField.value.length > limitNum) {
		limitField.value = limitField.value.substring(0, limitNum);
	}
}

/*
	"FACT-Finder Integration" operation:
	Select or deselect all elements of specified form with specified name (or part of the name)
	according to specified "checking status" (i.e. true/false)
	N.B. Taken from "selectAll()" JavaScript function in "inc/GlobalJavaScript" template of "sld_enterprise_app" cartridge
	@author Triboo
*/
function selectAll(formID, partOfFormElementName, checkingStatus) {
	var selectedForm = document.getElementById(formID);

	if (selectedForm != null)
	{
		var formElements = selectedForm.elements;

		for (var i = 0; i < formElements.length; i++)
		{
			if (	( -1 != formElements[i].name.indexOf(partOfFormElementName) ) &&
					( formElements[i].disabled == false ) &&
					( ( formElements[i].type == "checkbox" ) || ( formElements[i].type == "radio" ) )
				)
			{
				formElements[i].checked = checkingStatus;
			}
		}
	}
}

/*
	"FACT-Finder Integration" operation:
	Submit specified form or redirect to alternative URL if it does not exist
	@author Triboo
*/
function submitForm(formID, submitTypeName, submitTypeValue, alternativeURL)
{
	// get specified form
	var selectedForm = document.getElementById(formID);

	if (selectedForm != null)
	{
		if (submitTypeName != "")
		{
			// generate hidden input field with required code for dispatch node
			var input = document.createElement("input");
			input.setAttribute("type", "hidden");
			input.setAttribute("name", submitTypeName);
			input.setAttribute("value", submitTypeValue);
			selectedForm.appendChild(input);
		}

		// submit specified form
		selectedForm.submit();
	}
	else
	{
		// redirect to alternative URL
		window.location.href = alternativeURL;
	}
}

