function edit( element ) {
	var elements = $(element).getChildren();
	elements.each( function( element ) {
		if ( element.hasClass('viewonly') ) element.removeClass('viewonly');
		if ( element.getProperty('disabled') == true ) element.setProperty('disabled', false);
		if ( element.hasClass('invisible') ) element.removeClass('invisible');
	} );
}

function confirmDeletion( url, message ) {
	if ( message == null ) message = 'Etes-vous sûr de vouloir de supprimer cet élément ?';
	var bConfirm = confirm( message );
	if ( bConfirm ) document.location.href = url;
}

function updateFileUpload( id, skey ) {
	$(id).value = skey;
}

// Javascript function to return the position of the caret in an input control. 
// Returns an object containing the start and end position of the selection, plus the
// length of the selection. 
function getCaretPosition( control ) {
    var position = new Object();
    if ( control.selectionStart != undefined && control.selectionEnd != undefined ) {
        position.start = control.selectionStart;
        position.end = control.selectionEnd;
    } else {
        var range = document.selection.createRange();
        position.start = (range.offsetLeft - 1) / 7;
        position.end = position.start + (range.text.length);
    }
    position.length = position.end - position.start;
    return position;
}

