function HighValueTask(signInMessage, taskCode)
{
    IsUserSignedIn(function()
    {
        taskCode();
    },
    function()
    {
        // if there is no sign in message passed in, use the standard
        if(signInMessage == "")
        {
            jQuery('#content_signInNowPromo').html(content_masterPage81);
        }
        else
        {
            jQuery('#content_signInNowPromo').html(signInMessage);
        }
        
        //if the user is not signed in initiate the sign in process
        if (jQuery.cookie('rememberMe') != null)
        {
            jQuery("#txtUserEmail").attr('value', jQuery.cookie('rememberMe'));
            
            jQuery("#chkRememberMe").attr('checked', true);
        }
        jQuery('#modalSignIn').jqmShow();

        HVTSignInModal(taskCode);
        HVTRegisterModal(taskCode);
    });
}

function HVTSignInModal(taskCode)
{
    jQuery("#modalSignIn").jqm(
    {
        modal:true,
        onHide: function(hash)
        {
            newFieldHide(hash);

            IsUserSignedIn(function()
            {
                //execute the code for the high value task if the user has been signed in
                taskCode();
            },
            function()
            {
                //do nothing if modal is closed
            });
            
            //reset modals from HVT
            SetupSignIn();
        },
        onShow: function(hash)
        {
            newFieldShow(hash);
        }, 
        toTop:true
    });
}

function HVTRegisterModal(taskCode)
{
    jQuery("#dialog").jqm(
    {
        modal:true,
        onHide: function(hash)
        {
            newFieldHide(hash);

            IsUserSignedIn(function()
            {
                //execute the code for the high value task if the user has been signed in
                taskCode();
            },
            function()
            {
                //do nothing if modal is closed
            });
            
            //reset modals from HVT
            SetupRegistration();
        },
        onShow: function(hash)
        {
            newFieldShow(hash);
        }
    });
}
