﻿function LocalizeTelerik() {
    Telerik.Web.UI.RadWindowUtils.Localization =
        {
            "Close": "Закрыть",
            "Minimize": "Минимизировать",
            "Maximize": "Развернуть",
            "Reload": "Обновить",
            "PinOn": "Закрепить",
            "PinOff": "Снять закрепление",
            "Restore": "Восстановить",
            "OK": "OK",
            "Cancel": "Отмена",
            "Yes": "Да",
            "No": "Нет"
        };
}

function GetResultList(result, context) {
    var open = result.split("|")[0];
    var url = result.split("|")[1];
    var ss = result.split("|")[2];

    LocalizeTelerik();
    
    if (open == "1") {        
        var wnd = window.radopen(url, "newWindow");
        
        wnd.setSize(950, 600);
        wnd.center();
        //var frame = wnd.GetContentFrame();
        //frame.style.overflowX = "hidden";
        
        //alert(getIframeDocument(frame).getElementById("grey").innerHTML);
        //getIframeDocument(frame).getElementById("grey").style.display = "block";
        
       // ShowLoading("newWindow");
    }
    else if (open == "2")
        window.location.href = url;
    else {
        var wnd = window.radopen(url, null);
        
        wnd.setSize(950, 600);
        wnd.center();
    }
    
    //var wnd = window.radopen("http://www.google.com", null);         
    //                wnd.setSize(400,400);
    
    //window.open (url,"mywindow","menubar=1,resizable=1,width=950,height=600"); 

    ReplaceReload();
    
    if (ss != undefined && ss != '')
        setTimeout('__doPostBack(\'' + ss + '\',\'\')', 0)
    
    return false;
}

// когда возникает ошибка при ajax-запросе
function Error1(result, context) {
    alert('Ошибка:\r\n' + result.split("|")[0]);
}

function getIframeDocument(iframeNode) {
  if (iframeNode.contentDocument) return iframeNode.contentDocument
  if (iframeNode.contentWindow) return iframeNode.contentWindow.document
  return iframeNode.document
}

function ShowLoading(name)
{
    var container = document.getElementById("RadWindowWrapper_" + name);
    
    var frame = container.getElementsByTagName("iframe");
    if (frame == null || frame.length <= 0)
        return;    
    
    //var radwindow = GetRadWindow();
    //var doc = getIframeDocument(frame[0]);
    //doc.style.overflowX = "hidden";
    //doc.style.overflowY = "hidden";
    //alert(frame[0].contentWindow.document.innerHTML);
    
    //getIframeDocument(GetRadWindow().GetContentFrame()).getElementById("grey").style.display = "block";
    //container.getElementById("grey").style.display = "block";
    //Находим дивку и показываем её
    //var divGrey = container.getElementById("grey");
    //divGrey.style.display = "block";
}

function HideLoading(name)
{
   /* var container = document.getElementById("RadWindowWrapper_" + name);
    var frame = container.getElementsByTagName("iframe");
    
    if (frame == null || frame.length <= 0)
        return;
    
    frame[0].style.overflow = "hidden";
    
    //Находим дивку и показываем её
    var divGrey = container.getElementById("grey");
    divGrey.style.display = "none";*/
}
