﻿// JScript File
function onSelection_FocusChange( control, oldStyle ) { control.className = control.className == oldStyle ? control.className + ' selected' : oldStyle; }

// Highlight a control when it receives focus
function Control_onFocus( control, style ) { control.className = style + ' selected'; }

// Remove control highlights
function Control_onBlur( control, style ) {	control.className = style; }

// Change the color of a control for mousing over/out
function Control_onMouse( control, color ) { control.style.backgroundColor = color; }

// Change the text of a button when clicked.
function Control_onClick( control, text ) { this.value = text; }

// change the display setting when method is called
function Control_toggleDisplay( targetControlId, targetLabelId )
{
    var target = document.getElementById( targetControlId );
    var label = document.getElementById( targetLabelId );
    var display = target.style.display;
    target.style.display = display != 'none' ? 'none' : 'block'
    label.innerHTML = target.style.display != 'none' ? 'Hide' : 'Show';
}

// enable maxlength for text areas.
function Control_onKeyPress( control, maxlength)
{
    if (control.value.length > maxlength)
    {
        control.value = control.value.substring( 0,maxlength )
        return false;
    }
}