﻿function ConfirmDialog(msg) {
	return window.confirm(msg)
}

//skryje nebo ukaze objekt dle jeho id
//nejprve hleda serverovy objekt, pote klientsky
function ShowHide(id) {

    var o = document.getElementById(id_prefix + id);
    if (!o) o = document.getElementById(id);
    if (!o) {
        return;
    }
    
    if (o.style.display == 'none' || o.style.display == 'NONE')
        o.style.display = 'block';
    else
        o.style.display = 'none';
    
}

function ShowHideMsg(id) {

    var o = document.getElementById(id_prefix + id);
    if (!o) o = document.getElementById(id);
    if (!o) {
        alert('Control not found: ' + id);
        return;
    }
    
    if (o.style.display == 'none' || o.style.display == 'NONE')
        o.style.display = 'block';
    else
        o.style.display = 'none';
    
}

function GetMyElementById(id) {

    var o = document.getElementById(id_prefix + id);
    if (!o) o = document.getElementById(id);
    return o;

}


var windowShowTreeSimple = "";

function ShowTreeSimple(clientId) {

    var url = "TreeSimple.aspx?targetId=" + clientId;
    
    if (!windowShowTreeSimple.close && windowShowTreeSimple.location) {
        windowShowTreeSimple.location.href = url;
    }
    else {
        windowShowTreeSimple = window.open(url, "_blank", "height=500,width=400,resizable=no,toolbar=no,menubar=no,titlebar=no,status=no,scrollbars=yes", "false");
        if (!windowShowTreeSimple.opener) { windowShowTreeSimple = self; }
    }
    
    if (window.focus) {windowShowTreeSimple.focus()}
	return false;
}

var windowShowTreeAction = "";

function ShowTreeAction(clientId,akce) {

    var url = "TreeAction.aspx?targetId=" + clientId+"&akce=" + akce;
    
    if (!windowShowTreeAction.close && windowShowTreeAction.location) {
        windowShowTreeAction.location.href = url;
    }
    else {
        windowShowTreeAction = window.open(url, "_blank", "height=500,width=400,resizable=no,toolbar=no,menubar=no,titlebar=no,status=no,scrollbars=yes", "false");
        if (!windowShowTreeAction.opener) { windowShowTreeAction = self; }
    }
    
    if (window.focus) {windowShowTreeAction.focus()}
	return false;
}

function GoToLink(id) {

    var obj = GetMyElementById(id);
    if (obj) {
        obj.scrollIntoView(true);
    }

}



function MyRemoveSelectItems(o) {
    for (var i = o.options.length-1; i > 0; i--) {
        if (o.options.remove) 
            o.options.remove(i) //IE
        else
            o.options[i] = null; //firefox
    }
}

function MyAddSelectItem(o, text) {
    var item = document.createElement('option');
    o.options.add(item);
    item.text = text;
    return item;
}

function MyAddSelectItem2(o, text, val) {
    var item = document.createElement('option');
    o.options.add(item);
    item.text = text;
    item.value = val;
    return item;
}