﻿function PickerOverlay(Id, ClientId, CloseId, ShowClose, ShowMask, Width, Height, MaxWidth, MaxHeight, ContentId, AutoShow, ClientHandlerId, SetFocusId, PickerRblId, PickerErrId) {
    this.base = new ConfirmationOverlay(Id, ClientId, CloseId, ShowClose, ShowMask, Width, Height, MaxWidth, MaxHeight, ContentId, AutoShow, ClientHandlerId, SetFocusId);
    this.Confirm = this.base.Confirm;
    this.Cancel = this.base.Cancel;
    this.ReturnValue = "";
    this.PickerRblId = PickerRblId;
    this.PickerErrId = PickerErrId;
    this.PickerErrMsg = $(PickerErrId);
    this.Validate = new Event();
    return this;
}
PickerOverlay.prototype.Init = function() {
    try {
        var clientVar = eval(GetOverallBase(this).ClientHandlerId);
        clientVar.AddHandlers(this);
    } catch (e) { }
}

PickerOverlay.prototype.OnConfirm = function() {
    this.ReturnValue = this.GetSelectedValue();
    if (this.OnValidate())    
        this.base.OnConfirm();
}
PickerOverlay.prototype.OnCancel = function() {
    this.base.OnCancel();
}

PickerOverlay.prototype.GetSelectedValue = function() {
    var value = "";
    var choices = $(this.PickerRblId).getElementsByTagName("INPUT");
    for (var i = 0; i < choices.length && value.length == 0; i++)
        if (choices[i].checked)
            value = choices[i].value;
    return value;
}

PickerOverlay.prototype.OnValidate = function() {
    this.Validate.Execute(this);
    return this.ReturnValue.length > 0;
}
PickerOverlay.prototype.ShowValidationMessage = function() {
    //GetOverallBase(this).ContentContainer.style.height = "auto";
    this.PickerErrMsg.style.display = "block";
    GetOverallBase(this).Reposition();
}

PickerOverlay.prototype.OnHide = function(RaiseCloseEvent) {
    GetOverallBase(this).OnHide(RaiseCloseEvent);
}

PickerOverlay.prototype.Escape = function(event) {
    GetOverallBase(this).Escape(event);
}