﻿
function returnObjById(id) {
    var returnVar;
    if (document.getElementById)
        returnVar = document.getElementById(id);
    else if (document.all)
        returnVar = document.all[id];
    else if (document.layers)
        returnVar = document.layers[id];
    return returnVar;
}

function checkOptionButton(buttonOption) {
    returnObjById(buttonOption).checked = true;
    return false;
}

// return the value of the radio button that is checked
// return an empty string if none are checked, or
// there are no radio buttons
function getCheckedValue(radioObj) {
    if (!radioObj)
        return "";
    var radioLength = radioObj.length;
    if (radioLength == undefined)
        if (radioObj.checked)
        return radioObj.value;
    else
        return "";
    for (var i = 0; i < radioLength; i++) {
        if (radioObj[i].checked) {
            return radioObj[i].value;
        }
    }
    return "";
}

function setTextBoxTextByRadioButton(txtBox, radioButtonGroup) {
    returnObjById(txtBox).value = getCheckedValue(returnObjById(radioButtonGroup));
}

function OpenImageSelection(OrderNumber) {
    var order = OrderNumber.toString();
    var oWnd = radopen("/ImageSelectionControl.aspx?OrderNumber=" + order, null);
    oWnd.Center();
}

function returnImageSelectionControlToParent(ImageID, MemberID) {
    //create the argument that will be returned to the parent page
    var oArg = new Object();
    oArg.ImageID = ImageID;
    oArg.MemberID = MemberID;

    //get a reference to the current RadWindow
    var oWnd = GetRadWindow();
    
    //Close the RadWindow and send the argument to the parent page
    oWnd.close(oArg);
}

function BioMemberApprovalOnClientClose(oWnd, args) {
    //get the transferred arguments
    var arg = args.get_argument();
    if (arg) {
        var memberID = arg.MemberID;
        var imageID = arg.ImageID;
        document.getElementById('BioMemberApproval_HF_ImageID').value = imageID;
        document.getElementById('BioMemberApproval_HF_MemberID').value = memberID;
        document.getElementById('BioMemberApproval_HF_ImageSelectionStatus').value = "Submitted";
    }
    else {
        document.getElementById('BioMemberApproval_HF_ImageSelectionStatus').value = "Cancel";
    }
    document.getElementById('BioMemberApproval_BTN_SaveImageSelection').click();
}
//]]>

function BioMemberDataOnClientClose(oWnd, args) {
    //get the transferred arguments
    var arg = args.get_argument();
    if (arg) {
        var memberID = arg.MemberID;
        var imageID = arg.ImageID;
        document.getElementById('BioMemberData_HF_ImageID').value = imageID;
        document.getElementById('BioMemberData_HF_MemberID').value = memberID;
        document.getElementById('BioMemberData_HF_ImageSelectionStatus').value = "Submitted";
    }
    else {
        document.getElementById('BioMemberData_HF_ImageSelectionStatus').value = "Cancel";
    }
    document.getElementById('BioMemberData_BTN_SaveImageSelection').click();
}

function changeCursor()
{ document.body.style.cursor = (document.body.style.cursor == "wait") ? "default" : "wait"; }


function GetRadWindow() {
    var oWindow = null;
    if (window.radWindow)
        oWindow = window.radWindow; //Will work in Moz in all cases, including clasic dialog      
    else if (window.frameElement.radWindow)
        oWindow = window.frameElement.radWindow; //IE (and Moz as well)      
    return oWindow;
}

function Close() {
    GetRadWindow().Close();
}

function AdjustRadWidow() {
    setTimeout(function() { GetRadWindow().autoSize(true) }, 500);
}

function initSpellChecker() {
    GetRadSpell('BioData_RadSpellFinal').startSpellCheck();
    return false;
}

function SpellCheckDone() {
    document.getElementById("BioData_BTN_SpellCheckFinished").click();
}

//<![CDATA[
function openWin(args) {
    var arg = args.toString();
    var oWnd = null;
    var CoordInfoURL = null;
    if (arg == "Image Selection") {
        var AdminErrorStatsURL = document.getElementById("HF_AdminErrorStatsURL").value;
        oWnd = radopen(AdminErrorStatsURL, "AdminErrorStats");
    }
    else if (arg == "Coordinator Info") {
        CoordInfoURL = document.getElementById("HF_CoordInfoURL").value;
        oWnd = radopen(CoordInfoURL, "CoordInfo");
    }
    else if (arg == "Contact Olan Mills") {
        CoordInfoURL = document.getElementById("HF_ContactOlanMillsURL").value;
        oWnd = radopen(CoordInfoURL, "ContactOlanMills");
    }
}


