/*
 $Id: functions.js,v 1.5 2010/01/15 13:10:18 petr Exp $
 Common JavaSript Functions
 */
var popWin;

function Del(){
    return confirm("Chcete data opravdu smazat?");
}

function DelAll(){
    q = confirm("POZOR! Bude se mazat skupina dat!");
    if (q) 
        q = Del();
    return q;
}

function openWIN(target, x, y){
    popWin = window.open('', target, 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + x + ',height=' + y + ',left=10,top=10');
    popWin.focus();
}

function openWinURL(url, target, x, y){
    popWin = window.open(url, target, 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + x + ',height=' + y + ',left=10,top=10');
    popWin.focus();
}

function test_and_openWIN(url, target, x, y){
    if (!window.openedWin) {
        window.openedWin = window.open(url, target, 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + x + ',height=' + y + ',left=30,top=30');
    }
    window.openedWin.focus();
}

// ----- Otevreni noveho okna ve stredu obrazovky -----
function openWINcenter(page, target, dx, dy){
    x = (screen.width - dx) / 2;
    y = (screen.height - dy) / 2;
    openWINxy(page, target, dx, dy, x, y);
}

function openImageWIN(target, x, y){
    var popWin = window.open('', target, 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=0,resizable=1,width=' + x + ',height=' + y + ',left=10,top=10');
    popWin.focus();
}


function openImageFullWIN(target, image_url){

    x = self.window.screen.availWidth - 20;
    y = self.window.screen.availHeight - 40;
    popWin = window.open('?acc=preview&image=' + image_url, target, 'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width=' + x + ',height=' + y + ',left=5,top=0');
    popWin.focus();
}

// ----- Otevreni noveho okna na pozici [x,y] -----
function openWINxy(page, target, dx, dy, x, y){
    popWin = window.open(page, target, 'toolbar=no,location=no,directories=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,width=' + dx + ',height=' + dy + ',left=' + x + ',top=' + y);
    popWin.focus();
}

function getObj(id) {
	return document.getElementById(id);
}

function getContent(url, target) {
	return getRequest(url, target);
}

// ----- Zobrazi/skryje objekt -----
function display_swap(id) {
	obj = getObj(id);
	if (obj!='undefined' && obj!=null) {
		if (obj.style.display == 'none') {
			obj.style.display = 'block';
		} else {
			obj.style.display = 'none';
		}
	}
}