﻿// keep track of the popup div
var _popup;
var _source;

function showConfirm(source,elementId){
    this._source = source;
    this._popup = $find(elementId);
    
    //  find the confirm ModalPopup and show it    
    this._popup.show();
}

function okClick(){
    //  find the confirm ModalPopup and hide it    
    this._popup.hide();
    //  use the cached button as the postback source
    //__doPostBack(this._source.name, '');
    var srcCmd = this._source+'';
    eval(srcCmd.replace("javascript:",""));
}

function cancelClick(){
    //  find the confirm ModalPopup and hide it 
    this._popup.hide();
    //  clear the event source
    this._source = null;
    this._popup = null;
}

function cancelPopup(elementId){
    //  find the confirm ModalPopup and hide it 
    
    this._popup = $find(elementId);
    this._popup.hide();
}

function okClick(elementId){
    //  find the confirm ModalPopup and hide it   
    this._popup = $find(elementId); 
    this._popup.hide();
    //  use the cached button as the postback source
    //__doPostBack(this._source.name, '');
    var srcCmd = this._source+'';
    eval(srcCmd.replace("javascript:",""));
}

function ShowProgress()
{
    var img = document.getElementById("Spinner");
    if (img)
        img.style.display = "";
    var txt = document.getElementById("Progress");
    if (txt)
        txt.style.display = "";
}

function NotAgain(form)
{
    return false;
}

function SafeFormSubmission(form)
{
    ShowProgress();
    
    for (i = 1; i < form.elements.length; i++) {
        var ele = form.elements[i];
        if (ele.type == "image" || ele.type == "submit")
        {
            if (ele.className != "SubmitButton")
                ele.style.display = "none";
            ele.disabled = true;
        }
    }
    
    SafeFormSubmission = NotAgain;
    return true;
}