/* Start Header ------------------------------------------------------------

    Kodak Graphic Communications Canada Company
    Burnaby B.C. Canada
    V5G 4M1

    Copyright (C) 2008 Kodak Graphic Communications Canada Company
    
    Reproduction or disclosure of this file or its contents without the
    prior written consent of Kodak Graphic Communications Canada Company
    is prohibited.

 * End Header --------------------------------------------------------------
 */
 
// =========================================== WebForm_AutoFocus
// Overrides the built in WebForm_AutoFocus
// because it doesn't work in IFrames.
// ===========================================
function WebForm_AutoFocus( strControlId )
{
    // The built in WebForm_AutoFocus implementation fires too early in the
    // page loading cycle.  When loading in an IFrame we can't set the focus 
    // until the onLoad even fires, so just register our focus script to
    // fire at that time.
    CSWFunctions_AddLoadEvent( function(){ GiveFocusToControl( strControlId ); } );
}

// =========================================== GiveFocusToControl
// ===========================================
function GiveFocusToControl( strControlId )
{
    var objControl;
    if ( strControlId ) 
    {
        objControl = document.getElementById( strControlId );
        if ( (objControl != null) && (objControl.type != "hidden") && (!objControl.disabled) )
        {
            objControl.focus();
            if ( (objControl.type == "text") && (objControl.value.length > 0) )
            {
                objControl.select();
            }
        }
    }
}

