﻿var browser = navigator.appName;    
var browser_version=navigator.appVersion;   
var ipa_text;

function modalPopup_showAlert(headerText, contentText) {    
    $('#ctl00_modalAlert_pnlModalPopup_header').html(headerText); 
    $('#ctl00_modalAlert_modalpopup_alert_text').html(contentText);
    $find('ModalPopupBehavior_Alert').show();  
    document.getElementById("ctl00_modalAlert_btnOK").focus();    
}

function modalPopup_hideAlert() {
    $find('ModalPopupBehavior_Alert').hide();   
}

function modalPopup_showAlertWOptions(headerText, contentText) {    
    $('#ctl00_modalAlertWOptions_pnlModalPopup_header').html(headerText); 
    $('#ctl00_modalAlertWOptions_modalpopup_alertwoptions_text').html(contentText);    
    $find('ModalPopupBehavior_AlertWOptions').show();      
}

function modalPopup_hideAlertWOptions() {
    $find('ModalPopupBehavior_AlertWOptions').hide();       
}
function modalPopup_showLoading(headerText, loadingText) {        
    $('#ctl00_modalLoading_pnlModalPopup_header').html(headerText); 
    $('#panelModalPopup_loadingtext').html(loadingText);  
    $('#panelModalPopup_loading_img').html("<img src='../../images/loading_red.gif' />");
    $find('ModalPopupBehavior_Loading').show(); 
}

function modalPopup_hideLoading() {            
    $find('ModalPopupBehavior_Loading').hide();        
}

function modalPopup_showDialog(headerText, alertText) {
    $('#ctl00_modalDialog_pnlModalPopup_header').html(headerText); 
    $('#ctl00_modalDialog_panelModalPopup_dialog_text').html(alertText);
    $find('ModalPopupBehavior_Dialog').show();
}

function modalPopup_showDialogDelete(headerText, alertText) {
    $('#ctl00_modalDialogDelete_pnlModalPopup_header').html(headerText); 
    $('#ctl00_modalDialogDelete_panelModalPopup_dialog_text').html(alertText);
    $find('ModalPopupBehavior_Dialog_Delete').show();
}

/************************************************************************/

/* LABO-OXF367 - 18/05/09 - RPO - close modal popup if esc or enter is pressed */
function modalPopup_onkeyPress(event, modal) {    
    if (event == 13 || event == 27) {
        $find(modal).hide();
    }    
}

function modalPopup_showContainer(headerText, html) {
    setMainModalPanels();
    
    $("#pnlModalPopupContainer_Header").html(headerText);
    $("#pnlModalPopupContainer_Body").html(html);
    $find('pnlModalPopupContainer_ModalPopupBehavior').show();
}

function modalPopup_hideLoading_() {        
    setMainModalPanels();
    
    $find('panelModalPopup_ModalPopupBehavior').hide();        
}

function dragPanel(yn,ctrl){    
    if (yn=='n'){
        $("#" + ctrl).draggable('disable');  
    }
    else{
        $("#" + ctrl).draggable('enable');
    }    
}

function dragEndRequest(){
    $("#ctl00_panelModalPopup").draggable();
    $("#ctl00_pnlModalDialog").draggable();
    $("#ctl00_pnlModalDialogServer").draggable();
}

/* LABO-OXF263 - RPO - 06/04/09 - set modal panels on load */
function setMainModalPanels() {        
    $('#modalpopup_controls').css('visibility','visible');
}

function showModalPopup(sourceHTML, data, headerText) {    
    modalPopup_showLoading(headerText, 'Loading ' + headerText + ' data');
    $.ajax({
        url: sourceHTML,
        global: false,
        type: "POST",
        data: data,
        dataType: "html",
        error: function(msg) {    
            modalPopup_hideLoading();                    
            alert(msg);
        },
        success: function(msg){
            modalPopup_hideLoading();
            $("#ctl00_modalpopup1_panelModalPopup_content").html(msg);
            $("#ctl00_modalpopup1_pnlModalPopup_header").html(headerText);
            $find('modalPopup').show(); 
        }
    });
}


function loadModalPopup(sourceHTML, headerText, projectName) {
    modalPopup_showLoading(headerText, "Loading data..");
    
    $("#ctl00_modalpopup1_panelModalPopup_content").load(sourceHTML, 
        function() {                
            initialize_ClientSide_Validation(projectName);
            $("#ctl00_modalpopup1_pnlModalPopup_header").html(headerText);
            
            modalPopup_hideLoading();
            $find('modalPopup').show(); 
        }
    );
}

function hideModalPopup() {
    $("#ctl00_modalpopup1_panelModalPopup_content").html("")
    $find('modalPopup').hide(); 
}

function showModalPopup_current() {
    $find('modalPopup').show();
}