﻿var currentWindow = null;
var showRadWindowCounter = 0;
function showRadWindow(clientID, url) {
    try {
        var radWindow = $find(clientID);
        hideRadWindow();

        if (url && url != '') {
            radWindow.setUrl(url);
        }

        radWindow.show();
        currentWindow = radWindow;
        showRadWindowCounter = 0;
    }
    catch (e) {
        // $find noch nicht verfuegbar
        showRadWindowCounter++;
        if (showRadWindowCounter < 10) {
            currentTimeout = window.setTimeout('showRadWindow(\'' + clientID + '\', \'' + url + '\')', 100);
        }
    }
}

function hideRadWindow() {
    if (currentWindow) {
        currentWindow.hide();
        currentWindow = null;
    }
}

function ShowRadToolTipImage(rttClientId, targetId, imgClientId, newSrc) {
    var img = document.getElementById(imgClientId);
    img.src = newSrc;
    ShowRadToolTip(rttClientId, targetId);
}


function ShowRadToolTipWithPostBack(rttClientId, targetId, postBackElement) {
    document.getElementById(postBackElement).click();
    //ShowRadToolTip(rttClientId, targetId);
}

var activeToolTip = null;
function ShowRadToolTip(rttClientId, targetId) {
    var radToolTip = $find(rttClientId);
    radToolTip.set_targetControlID(targetId);

    activeToolTip = rttClientId;
    radToolTip.show();
}

function DetectNEnter(e, btn) {
    var characterCode;
    if (e && e.which) {
        // NN4 specific code
        e = e;
        characterCode = e.which;
    }
    else {
        // IE specific code
        e = event
        characterCode = e.keyCode;
    }

    if (characterCode == 13) //// Enter key is 13
    {
        e.returnValue = false;
        e.cancelBubble = true;
        document.getElementById(btn).click();
    }
}

function WindowCallBack(sender, args) {
    if (args != "null" && args != null) {
        window.location = args;
    }
}