/* $Id: functions.js,v 1.10 2011-05-12 15:18:09 petr Exp $ */

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 DelBind(num){
	if(parseInt(num)==0){
		return Del();
	}
	alert("Data nelze smazat!\nCelkem svázáno záznamů: "+num);
	return false;
}
function Dupl(){
	return confirm("Chcete data opravdu duplikovat?");
}

function openWIN(target,x,y) {

	var left = 10;
	var top = 10;

	// check dest screen size
	if (x > (self.window.screen.availWidth - left))
		x = self.window.screen.availWidth - left;
	if (y > (self.window.screen.availHeight - top))
		y = self.window.screen.availHeight - top;

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

function openWinURL(url,target,x,y) {

	var left = 10;
	var top = 10;

	// check dest screen size
	if (x > (self.window.screen.availWidth - left))
		x = self.window.screen.availWidth - left;
	if (y > (self.window.screen.availHeight - top))
		y = self.window.screen.availHeight - top;

	popWin=window.open(url,target,'toolbar=0,location=0,directories=0,status=1,menubar=0,scrollbars=1,resizable=1,width='+x+',height='+y+',left='+left+',top='+top);
	popWin.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);
}

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

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

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

// link
function link(url) {
	document.location.href=url;
}

// zobrazi/skryje seznam objektu
function display_swap() {
	if(arguments.length>0) {
		for(var i=0; i<arguments.length; i++) {
			var obj = getObj(arguments[i]);
			if (obj!='undefined' && obj!=null) {
				if (obj.style.display=='none') {
					obj.style.display = 'block';
				} else {
					obj.style.display = 'none';
				}
			}
		}
	}
}

// prvni objekt skryje, ostatni zobrazi
function display_show() {
	if(arguments.length>0) {
		getObj(arguments[0]).style.display = 'none';
		for(var i=1; i<arguments.length; i++) {
			getObj(arguments[i]).style.display = 'block';
		}
	}
}

// vypis zprav do konzole
function log(txt) {
	try {console.log(txt);} catch(e) {}
}

