var rp, pn;

//------------------------------- Modal Popups
function OpenProcessing() {
    ModalPopups.Indicator("idPleaseWait",  
            "Please wait...",   
            "<br /><table width='300'><tr><td align='center'><img src='../images/spinner.gif'></td></tr></table><br />",   
            {  
                width: 300,  
                height: 100,
                titleBackColor: "#FFF1C3"
            }  
        );    
}

function CloseProcessing() {
    ClosePopUp("idPleaseWait");
}

//------------------------------- General Close Pop-Up
function ClosePopUp(id) {
    ModalPopups.Close(id);
}


//------------------------------- General Message
function AlertMessage(msg,title) {  
  ModalPopups.Alert("mpAlertMessage",  
      title,  
      "<div style='padding:25px;'>" + msg + "</div>",   
      {  
          okButtonText: "Close",
          titleBackColor: "#FFF1C3"
      }  
  );  
}  


//------------------------------- Load Page
function LoadPage(page, title, w, h, pageName, closeButtonText, refreshPage) {

    if(w == null || w == 0) w = 500;
    if(h == null || h == 0) h = 300;
    if(pageName == null || pageName == '') pageName = "mpLoadPage";
    if(closeButtonText == null || closeButtonText == '') closeButtonText = "Close";
    rp = refreshPage;
    pn = pageName;
    
    ModalPopups.Alert(pageName,  
        title,  
        "<br /><br /><br /><center><span><img src='../images/spinner.gif'><br />Processing...</span></center>", 
        {  
            okButtonText: closeButtonText,  
            loadTextFile: page,  
            width: w,  
            height: h + 10,
            titleBackColor: "#FFF1C3",
            onOk: 'ModalProcessOK(\"' + pageName + '\")'
        }
    );  
}

function ModalProcessOK(pageName) { 
    if(rp != null)
        window.location.reload(); 
    ModalPopups.Cancel(pageName);   
} 


//------------------------------- Load YouTube video
function LoadYouTubeVideo(page, title, w, h, pageName, closeButtonText) {

    if(w == null || w == 0) w = 500;
    if(h == null || h == 0) h = 300;
    if(pageName == null || pageName == '') pageName = "mpLoadPage";
    if(closeButtonText == null || closeButtonText == '') closeButtonText = "Close";
    
    ModalPopups.Alert(pageName,  
        title,  
        "loading...", {  
            okButtonText: closeButtonText,  
            loadTextFile: page,  
            width: w,  
            height: h,
            titleBackColor: "#FFF1C3"
            }
    );  
}


//------------------------------- A general modal pop-up 
function GeneralModal(msg, title, w, h, pageName, closeButtonText, loadFile) {   
    if(w == null || w == 0) w = 500;
    if(h == null || h == 0) h = 300;
    if(pageName == null || pageName == '') pageName = "mpLoadPage";

    // No close button
    if(closeButtonText == null || closeButtonText == '') {
        // Don't load a file
        if(loadFile == null || loadFile == '') {
            ModalPopups.Custom(pageName,
                title,   
                msg,    
                {   
                    width: w,
                    height: h,   
                    buttons: "",  
                    titleBackColor: "#FFF1C3"
                }   
            );          
        } 
        // Load a file so have a generic processing image display.
        else {
            ModalPopups.Custom(pageName,
                title,   
                "<br /><br /><br /><center><span><img src='../images/spinner.gif'><br />Processing...</span></center>",    
                {   
                    width: w,
                    height: h,   
                    buttons: "",
                    titleBackColor: "#FFF1C3",
                    loadTextFile: loadFile
                }   
            );          
        }
    } 
    // Yes to a close button
    else {
        // Don't load a file
        if(loadFile == null || loadFile == '') {
            ModalPopups.Custom(pageName,
                title,   
                msg,    
                {   
                    width: w,
                    height: h,   
                    buttons: "ok",   
                    okButtonText: closeButtonText,   
                    titleBackColor: "#FFF1C3"
                }   
            );   
        } 
        // Load a file so have a generic processing image display.
        else {
            ModalPopups.Custom(pageName,
                title,   
                "<br /><br /><br /><center><span><img src='../images/spinner.gif'><br />Processing...</span></center>",    
                {   
                    width: w,
                    height: h,   
                    buttons: "ok",   
                    okButtonText: closeButtonText,   
                    titleBackColor: "#FFF1C3",
                    loadTextFile: loadFile
                }   
            );   
        }
    }
}   

function RefreshScreen() {window.location.reload();}


// Find a friend pop-up
//            titleBackColor: "#A1B376",   
//            titleFontColor: "white",   
//            popupBackColor: "#E9E8CF",   
//            popupFontColor: "black",   
//            footerBackColor: "#A1B376",   
//            footerFontColor: "white" 

function PromptForFindMember() {   
    ModalPopups.Prompt("idPrompt1",   
        "Prompt",   
        "Please enter your ID number",     
        {   
            width: 300,   
            height: 100,   
            onOk: "ModalPopupsPromptOk()",   
            onCancel: "ModalPopupsPromptCancel()"  
        }   
    );   
}   
function ModalPopupsPromptOk()   
{   
    if(ModalPopups.GetPromptInput("idPrompt1").value == "") {   
        ModalPopups.GetPromptInput("idPrompt1").focus();   
        return;   
    }   
    alert("You pressed OK\nValue: " + ModalPopups.GetPromptInput("idPrompt1").value);   
    ModalPopups.Close("idPrompt1");   
}   
function ModalPopupsPromptCancel() {   
    alert("You pressed Cancel");   
    ModalPopups.Cancel("idPrompt1");   
}  

