﻿//Disable the client-side scroll to event so that the dialog validation summary use does not cause page shifts that put the modal dialog out of view.
window.scrollTo = function () { }

function ShowReviewDialog(Id) {
    //Reset internal positioning coordinates and recalculate alignment for the new window height.(window height can change by AJAX)
    ReviewDialog.beginUpdate();
    ReviewDialog.set_x(0);
    ReviewDialog.set_y(0);
    ReviewDialog.set_alignment('MiddleCentre')
    ReviewDialog.endUpdate();
    //Delay the show just a bit. This is needed for the scenario when the dialog is loaded with the page.
    setTimeout('ReviewDialog.Show();', 10);
}


function ReviewForm_DialogClose() {
    $('div[id$="divReviewMainPanel"]').show();
    $('div[id$="divReviewSuccess"]').hide();
}

//Try to, in some small, way prevent people from attempting to submit html.
function cvContentFormat_Validate(sender, args) {
    var markupMatcher = new RegExp("(<[\\\/]*\\w{1,50}[^>]*>)", "im");
    if (markupMatcher.exec(args.Value)) {
        args.IsValid = false;
    }
    else {
        args.IsValid = true;
    }
}

function DialogShow(dialog) {
    FixModalMask();
}

function FixModalMask() {
    var verticalScroll = document.documentElement.scrollTop;
    $('*[id$=_ModalTable]').css('top', verticalScroll + 'px');
    $('*[id$=_ModalMask]').css('top', verticalScroll + 'px');
}
