<!--

	function trim(stringToTrim) {
		return stringToTrim.replace(/^\s+|\s+$/g,"");
	}

	function setInputValue(idInput, inputValue) {
	    document.getElementById(idInput).value = inputValue;       
	 }

    function setInputValueAndSubmitForm(form, idInput, inputValue) {
    	setInputValue(idInput, inputValue);       
        form.submit();
    }
	
    function clearInput(idInput) {
		document.getElementById(idInput).value='';
	}
	
	function setInputValueIfEmpty(idInput, value) {
		if (document.getElementById(idInput).value=='')
			document.getElementById(idInput).value=value;
	}
	
	function setSelectedOption(selectId, optionValue) {
		select = document.getElementById(selectId);
		for ( i = 0; i < select.options.length; i++) {
			if ( select.options[i].value == optionValue) {
				select.options[i].selected = true;
				return;
			}
		} 
	}
	
	function confirmAction(confirmText) {
		return confirm(confirmText);
	}
	
	function confirmActionAndSubmitForm(form, confirmText) {
		if (confirmAction(confirmText)) {
			form.submit();
		}
	}
    
	function getPromptValue(idInput, dialogText) {
		var response = prompt(dialogText, "");
		if (response != null) {
       		document.getElementById(idInput).value = response;
       		return true;
		}
		return false;
	}    

	function getPromptValueWithDefault(idInput, dialogText, inputValue) {
		var response = prompt(dialogText, inputValue);
		if (response != null) {
       		document.getElementById(idInput).value = response;
       		return true;
		}
		return false;
	}    
		
	function setSpanTextFromSelectOptionTitle(spanId, select, defaultMessage) {
		if(!document.getElementById(spanId)) return;
		
		var selectOptionTitle=select.options[select.selectedIndex].title;
		var spanMessage="";
		if(selectOptionTitle) { spanMessage = selectOptionTitle; }
						 else { spanMessage = defaultMessage; }
		document.getElementById(spanId).innerHTML = spanMessage;
	}

	function setInputValueFromSelectOptionTitle(inputId, select) {
		if(!document.getElementById(inputId)) return;
		var selectOptionTitle=select.options[select.selectedIndex].title;
		document.getElementById(inputId).value = selectOptionTitle;
	}
	
	function setSpanTextFromSelectOptionAttribute(spanId, select, attributeName, defaultMessage) {
		if(!document.getElementById(spanId)) return;
		
		var selectOption = eval('select.options[select.selectedIndex].' + attributeName);
		var spanMessage = "";
		if(selectOption) { spanMessage = selectOption; }
				    else { spanMessage = defaultMessage; }
		document.getElementById(spanId).innerHTML = spanMessage;
	}
	
	
	function focusAndSelectElement(elementId) {
		element = document.getElementById(elementId);
   		element.focus();
		element.select();
	}
	
	function focusAndSelectElementByName(elementName) {
		element = document.getElementsByName(elementName)[0];
		element.focus();
		element.select();
	}
	
	function syncronizeCheckboxes(masterCheckbox, destinationCheckboxesName) {

		masterCheckboxChecked = masterCheckbox.checked;

		var listDestinationCheckboxes = document.getElementsByName(destinationCheckboxesName);
	    for(var i=0; i<listDestinationCheckboxes.length; i++)
	    {
	    	listDestinationCheckboxes[i].checked = masterCheckboxChecked;
		}
	}
	
	function setCheckboxesValue(checkBoxPrefixName, checkedValue){
		var listDestinationControls = document.getElementsByTagName("input");
	    for(var i=0; i<listDestinationControls.length; i++)
	    {
	    	if(listDestinationControls[i].type == "checkbox" && 
	    	   listDestinationControls[i].name.indexOf(checkBoxPrefixName) != -1) {
	    		listDestinationControls[i].checked = checkedValue;
	    	}
		}
	}
	
	function deleteItemsFromSelect(selectId){
		var select = document.getElementById(selectId);
		var i;
		for (i = select.length - 1; i>=0; i--) {
		    if (select.options[i].selected) {
		    	select.remove(i);
		    }
		}  
	}   
	
	function copyCheckboxValue(checkBoxInputElementId, hiddenInputId){
		checkBoxInputElement = document.getElementById(checkBoxInputElementId);
		hiddenInputElement = document.getElementById(hiddenInputId);
		if (checkBoxInputElement.checked != 1) {
			hiddenInputElement.value='false'; 
		} else {
			hiddenInputElement.value='true';	
		}
	}
	
    function disableElement(element) {
    	try {
    		element.disabled = true;
    	}catch(err){}
  		if (element.childNodes && element.childNodes.length > 0) {
    		for (var x = 0; x < element.childNodes.length; x++) {
    			disableElement(element.childNodes[x]);
    		}
    	}
    }

    function enableElement(element) {
    	try {
    		element.disabled = false;
    	}catch(err){}
  		if (element.childNodes && element.childNodes.length > 0) {
    		for (var x = 0; x < element.childNodes.length; x++) {
    			enableElement(element.childNodes[x]);
    		}
    	}
    }
    
    function jumpField(element, nextElementId) {
    	//set focus to next element
    	if ( element.value.length == element.maxLength) {
        	var nextElement = document.getElementById(nextElementId);
            if (nextElement != null) {
            	nextElement.focus();
            }
        }
    }
        
	
// -->

