/**
 * Title: BBCWORLDWIDE_CPLAT.LoginOverlay
 * Copyright: Copyright (c) 2008
 * Company: BBC Worldwide Ltd
 * Description: Login Screen to handle CPLAT login overlay panel
 * @author: NgAW1
 * @version: $Revision: $
 * @date: 10 June 2008 16:51:45
 */


/**
 * This define the BBCWORLDWIDE_CPLAT.LoginOverlay Class, which override the singleton object 
 * from BBCWORLDWIDE_CPLAT.AjaxOverLayScreenManager.
 * @param base {@link BBCWORLDWIDE_CPLAT.AjaxOverLayScreenManager}
 * @return  BBCWORLDWIDE_CPLAT.Registration {@link  BBCWORLDWIDE_CPLAT.Registration}
 */
BBCWORLDWIDE_CPLAT.LoginOverlay = function(base, p_oParams) {

    base.setclientConfigParams(p_oParams);

    // Override the parentThickBoxAjaxSuccess by hooking to screen specific validation
    var parentOverLayWindowBoxAjaxSuccessHook = base.overLayWindowAjaxSuccessHook;
    base.overLayWindowAjaxSuccessHook = function (overLayWindow, fCloseOverlayFunc) {
        var oSubmitButton = overLayWindow.find("input[type='submit']");
        var oForm = BBCWORLDWIDE_CPLAT.retrieveFormElement(overLayWindow, oSubmitButton.get(0));
				
				$('<a href="#" class="cplat-closeLoginOverlay">Close</a>').insertAfter(oSubmitButton).click(base.closeOverlay);
				
        // Hijax forgot-password link, and replace with new forgot pwd overlay when clicked
        // $(overLayWindow).find("a[title='forgot-password']").click(function() {
        //     BBCWORLDWIDE_CPLAT.ForgotPasswordOverlay(base, base.getClientConfigParams()).handleLinkClick(this);
        //     return false;
        // });

        // Hijax register link, and replace with new registration overlay when clicked
        // $(overLayWindow).find("a[title='register']").click(function() {
        //     BBCWORLDWIDE_CPLAT.RegistrationOverlay(base, base.getClientConfigParams()).handleLinkClick(this);
        //     return false;
        // });


        // Intercept update-email link
        // $(overLayWindow).find("a[title='change-email']").click(function() {
        //     BBCWORLDWIDE_CPLAT.LoginOverlay(base, base.getClientConfigParams()).handleLinkClick(this);
        //     return false;
        // });

        // Intercept resend-email link
        // $(overLayWindow).find("a[title='resend-email']").click(function() {
        //     BBCWORLDWIDE_CPLAT.LoginOverlay(base, base.getClientConfigParams()).handleLinkClick(this);
        //     return false;
        // });

        // Delegate back to parent Thick Box to complete SuccessHook
        //parentOverLayWindowBoxAjaxSuccessHook(overLayWindow, fCloseOverlayFunc);
    };

    return base;
};
