
// Displays a confirm dialog and performs other tasks when
// a user attempts to delete data.  Uses the supplied message
// string for the delete confirmation.
function onDelete(pDelMsg)
{
	// Display a confirm message and capture the result.
	var doSubmit = ConfirmDelete(pDelMsg);
	
	// Return the result to the caller (true or false);
	return doSubmit;
}
			
// Displays a confirm dialog using the supplied message and returns
// the value indicating if the message was confirmed or not.
function ConfirmDelete(pMsg)
{
	// Display the confirmation dialog and return true or false.
	if (confirm(pMsg))
	{		
		return true;
	}
	else
	{
		return false;
	}
}

// Checks whether the supplied textarea has a value length more
// than the supplied value.  If so, false is returned.  This 
// should typically be called in the onkeypress event.
function checkForMaxNoteLength_onKeyPress(srcTextArea, maxLength, e)
{
    var KeyID = (window.event) ? event.keyCode : e.keyCode;

    switch (KeyID)
    {
        case 8: // Backspace
            return true;
        case 37: // Up
            return true;
        case 38: // Left
            return true;
        case 39: // Right
            return true;
        case 40: // Down
            return true;            
        case 46: // Delete
            return true;
        default:
	        // Get the note value.
	        var note = srcTextArea.value;	
        	
	        // Check if the note value exceeded supplied max length
	        if (note.length >= maxLength)
	        {
		        return false;
	        }
	        else
	        {
		        return true;
	        }
	}
}

// Checks whether the supplied textarea has a value length more
// than the supplied value.  If so, the value is truncated.  This
// Should typically be called in the onblur event.
function checkForMaxNoteLength_onBlur(srcTextArea, maxLength)
{
	// Get the note value.
	var note = srcTextArea.value;
	
	// Check if the note value exceeded the supplied max length.
	if (note.length > maxLength)
	{
		// Truncate the value.
		srcTextArea.value = srcTextArea.value.substring(0, maxLength);
	}
}

// Sets the supplied label Id to the length of the value of the supplied textarea.
function updateMessageLengthLabel(srcTextArea, labelId)
{
	// Get the note value.
	var note = srcTextArea.value;
	
	// Set the label value using the note length.
	document.getElementById(labelId).innerHTML = note.length;
}

// Hides the finish buttons panel on wizards.
function displayProgressIndicator(hiddenPanel, targetPanel)
{
    document.getElementById(hiddenPanel).style.visibility = 'hidden';
    document.getElementById(targetPanel).innerHTML = "<img src='/mygolfleaguemanager/Images/Icons/indicator.gif' />";
}