﻿

function EditEU(EUID) {
    // Make sure you have a radwindowmanager first
    var oWnd = window.radopen("/Popup/EventRegEdit.aspx?Edit=Y&EUID=" + EUID, "Edit Event Registration");
    oWnd.set_title('Edit Event Registration');
    //oWnd.autoSize();
    ShowPopupWin(oWnd, 580, 540);
}

function ShowModalWin(url, title, width, height) {
    if (window.showModalDialog) {
        window.showModalDialog(url,title, "dialogWidth:" + width +  ";dialogHeight:" + height + "px");
    }
    else {
        window.open(url, title ,
                        "width=" + width + ",height=" + height + "toolbar=no,directories=no,status=no,menubar=no,scrollbars=no,resizable=no,modal=yes");
    }
}


function OpenMember(UID) {
    // Make sure you have a radwindowmanager first
    var oWnd = window.radopen("/Popup/Profile.aspx?UID=" + UID, "View Member");
    oWnd.set_title('View Member Profile');
    //oWnd.autoSize();
    ShowPopupWin(oWnd, 600, 540);
}

function OpenFileUpload(OT, OID) {
    // Make sure you have a radwindowmanager first
    var oWnd = window.radopen("/popup/UploadFile.aspx?OT=" +OT +  "&OID=" + OID, "Upload File");
    oWnd.set_title('Upload File');
    oWnd.set_behaviors(Telerik.Web.UI.WindowBehaviors.Move
                + Telerik.Web.UI.WindowBehaviors.Reload
                + Telerik.Web.UI.WindowBehaviors.Resize
                + Telerik.Web.UI.WindowBehaviors.Pin
            );
    //None, Resize, Minimize, Close, Pin, Maximize, Move, Reload, Default

    ShowPopupWin(oWnd, 640, 500);
    return oWnd;
}

function OpenOrg(OID) {
    // Make sure you have a radwindowmanager first
    var oWnd = window.radopen("/Popup/Org_Profile.aspx?OID=" + OID, "View Org");
    oWnd.set_title('View Organization Profile');
    //oWnd.autoSize();
    ShowPopupWin(oWnd, 660, 590);
}

function OpenPublicOrg(OID) {
    // Make sure you have a radwindowmanager first
    var oWnd = window.radopen("/popup/ViewOrg.aspx?OID=" + OID, "View Org");
    oWnd.set_title('View Organization Profile');
    ShowPopupWin(oWnd, 540, 400);
}

function ShowPopupWin(oWnd, W, H) {
    //oWnd.autoSize();
    oWnd.setSize(W, H);
    oWnd.center();
    CheckWindow(oWnd);
}

function CheckWindow(oWnd) {
    var bounds = oWnd.getWindowBounds();
    var x = bounds.x; //returns the current left position of the RadWindow
    var y = bounds.y; //returns the current top position of the RadWindow
    var MoveWin = false;
    if (x < 0) {
        x = 0; MoveWin = true;
    }
    if (y < 20) {
        y = 20; MoveWin = true;
    }
    if (MoveWin)
        oWnd.moveTo(x, y);

}
function PopUpShowing(sender, eventArgs) {
    // Centers the editing form for radGrid.
    // To Use:  Setup Edit Form Heights first and then add
    //        <ClientSettings>
    //                <ClientEvents OnPopUpShowing="PopUpShowing" />
    //        </ClientSettings>
    //                
    var popUp;
    popUp = eventArgs.get_popUp();
    var gridWidth = sender.get_element().offsetWidth;
    var gridHeight = sender.get_element().offsetHeight;
    var popUpWidth = popUp.style.width.substr(0, popUp.style.width.indexOf("px"));
    var popUpHeight = popUp.style.height.substr(0, popUp.style.height.indexOf("px"));
    var NewLeft = ((gridWidth - popUpWidth) / 2 + sender.get_element().offsetLeft);
    var NewTop = ((gridHeight - popUpHeight) / 2 + sender.get_element().offsetTop);

    if (NewLeft < 0)
        NewLeft = 0;
    if (NewTop < 20)
        NewTop = 20;

    popUp.style.left = NewLeft.toString() + 'px';
    popUp.style.top = NewTop.toString() + 'px';
}
    
