// --- dialog pro potvrzeni smazani --------------------------------------------
function DeleteQuestion(item)
{
	return confirm("Opravdu chcete smazat tuto položku? \n\n " + item);
}
// -----------------------------------------------------------------------------

// --- zobrazi pop up okno ----------------------------------------------------
function nwindow(cURL, x, y, addImgHref)
{
	LeftPosition = (screen.width) ? (screen.width-x)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-y)/2 : 0;
	//left = screen.width - 15 - x;
	x = x + 5;
	show_window(cURL, "WebCamLive", addImgHref,
              "height="+y+",scrollbars, resizable=yes, " +
              "width="+x+", left="+LeftPosition+", top="+TopPosition);
}
// ----------------------------------------------------------------------------

// --- zobrazi okno ---------------------------------------------------------
function show_window(cURL,cName,addImgHref,cParam)
{
	var new_window = window.open(cURL,cName,cParam);

	if(addImgHref)
	{
		new_window.document.write("<html><head><style>body{margin:0} "+
		"img{border:none}<\/style>"+
		"</head><body><a href=\"javascript:window.close()\">"+
		"<img src=\"" + cURL + "\"\/><\/a><script type=\"text\/javascript\">"+
		"var gaJsHost = ((\"https:\" == document.location.protocol) ? "+
		"\"https:\/\/ssl.\" : \"http:\/\/www.\");"+
		"document.write(unescape(\"%3Cscript src='\" + gaJsHost + "+
		"\"google-analytics.com\/ga.js' type='text\/javascript'%3E%3C\/script%3E\"));"+
		"<\/script>"+
		"<script type=\"text\/javascript\">"+
		"try {"+
		"var pageTracker = _gat._getTracker(\"UA-12054869-1\");"+
		"pageTracker._trackPageview();"+
		"} catch(err) {}<\/script><\/body><\/html>");
		new_window.document.close();
	}
	new_window.focus();

	return false;
}
// --------------------------------------------------------------------------

// --- nacteni streamu ------------------------------------------------------
function stream(cURL, x, y, addImgHref)
{
	setCookie('rozliseni', x+"x"+y, '');
	
	LeftPosition = (screen.width) ? (screen.width-x)/2 : 0;
	TopPosition = (screen.height) ? (screen.height-y)/2 : 0;
	
	show_window(cURL, "WebCamLive", addImgHref,
    	"height="+y+",scrollbars, resizable=yes, " +
        "width="+x+", left="+LeftPosition+", top="+TopPosition);
}
function setCookie(name, value, expire) 
{
	strCookie = name + "=" + escape(value);
	if (expire)
	    strCookie += "; expires=" + expire.toGMTString();
	
  document.cookie = strCookie;
}
// --------------------------------------------------------------------------

// --- zobrazi vyber regionu ---------------------------------------------------
function showRegionSelector()
{
    elem = document.getElementById("regionSelect");
    if (elem) elem.style.display = "block";
}
// -----------------------------------------------------------------------------

// --- checkbox (de)aktivujici vsechny ostatni ---------------------------------

function checkUncheckAll(checkBox) 
{
	var checkForm = checkBox.form, x = 0;
	for(x=0; x<checkForm.length;x++) {
		if(checkForm[x].type == 'checkbox' && checkForm[x].name != 'checkAll') {
			checkForm[x].checked = checkBox.checked;
		}
	}
}
// -----------------------------------------------------------------------------

// --- checkbox deaktivujici checkbox vsech ostatnich --------------------------

function uncheckAllCheckbox() {
			document.forms.kameryForm.tall.checked = false;
}
// -----------------------------------------------------------------------------

// --- bublina s napovedou pro vyber typu kamer --------------------------------

function camerasHelpBubble(timeout) {
	bublina = document.getElementById("helpBubbleBlock");
	otaznik = document.getElementById("otaznik");
	bublina.style.left = getX(otaznik)+15+"px";
	bublina.style.display="block";
	bublina.style.top = getY(otaznik)-bublina.offsetHeight+"px";
	if (timeout>0) {
		bublinaCasovac = window.setTimeout("camerasHelpBubbleClose()", timeout*1000);
	}
			
}

function camerasHelpBubbleClose() 
{
	clearTimeout(bublinaCasovac);
	document.getElementById("helpBubbleBlock").style.display="none";
}
// -----------------------------------------------------------------------------


// --- funkce vracejici absolutni pozici pro kazdou osu v px -------------------

function getX( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetLeft;
oElement = oElement.offsetParent;
}
return iReturnValue;
}

function getY( oElement )
{
var iReturnValue = 0;
while( oElement != null ) {
iReturnValue += oElement.offsetTop;
oElement = oElement.offsetParent;
}
return iReturnValue;
} 
// -----------------------------------------------------------------------------
 
// *** UKAZATEL STAVU NACITANI SNIMKU Z ARCHIVU ******************************** 

// --- zobrazeni stavu ---------------------------------------------------------
function archivDisplayStatus()
{
	if (imgCount == 0)
	{
		clearInterval(progressTimer);
		setTimeout("archiveDone()", 10);	
	}

	var completed = 0;
	for(i=0;i<document.images.length;i++)
	{
		if (document.images[i].name.substr(0,6) == "archiv")
			if (document.images[i].complete) completed++;
	}

	div = document.getElementById("progressPercentage");
	var state = completed / imgCount;
	div.innerHTML = parseInt(state*100) + "%";
	
	w =  (400 * state);
	
	//alert(bgpos);
	
	bar = document.getElementById("progressBarInside");
	bar.style.width = parseInt(w) + "px";
	
	
	if (imgCount == completed)
	{
		clearInterval(progressTimer);
		setTimeout("archiveDone()", 1000);
	}
}

function archiveDone()
{
	bubble = document.getElementById("progress");
	bubble.style.display = "none";
}

function displayBlock(elemId)
{
	element = document.getElementById(elemId);
	element.style.display = "block";
}
// -----------------------------------------------------------------------------


