/*Javascript pro zobrazení náhledu*/

function zoom(cislo,x,y)
{
var okno=window.open('','okno','width='+x+',height='+y+',resizble=0,menubar=0,toolbar=0,left=10,top=10,directories=0,location=0,scroolbars=0,copyhistory=0,status=0');
okno.document.open();
okno.document.writeln('<html>\n<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">\n<head>\n<title>Náhled fotky</title>\n</head>\n<body bgcolor="#FFFFF" topmargin="0" leftmargin="0">');
okno.document.writeln('<img src="./screen/NF'+cislo+'.jpg" alt="">\n');
okno.document.writeln('<center><input type="button" class="button" onClick="window.close()" value="Zavřít okno"></center>');
okno.document.writeln('</body>\n</html>');
okno.document.close();
}

function ukazs(jmeno, x, y, popis) {
    na_novinku=window.open('./screen/'+jmeno+'.jpg',"HLASKA",
    "toolbar=no, location=no, directories=no, status=no, menubar=no,"+
    "scrollbars=no, resizable=no, copyhistory=no, width="+x+", height="+y+", "+
    "top=30, left=30");
  }

function ukaztree(jmeno, x, y) {
    na_novinku=window.open('./pics/'+jmeno+'_tree.jpg',"HLASKA",
    "toolbar=no, location=no, directories=no, status=no, menubar=no,"+
    "scrollbars=yes, resizable=no, copyhistory=no, width="+x+", height="+y+", "+
    "top=30, left=30");
  };

function narod(kod)
{
 if(kod == "us")
    return "US Navy";
 if(kod == "uk")
    return "Royal Navy";
 if(kod == "km")
    return "Kriegsmarine";
 if(kod == "jap")
    return "Imperial Navy";
 if(kod == "neut")
    return "Neutral";
}

function reaguj(info,cislo)
{
  document.getElementById('text_reakce').value = cislo;
  document.getElementById('show_reakce').value = info;
  document.getElementById('text').focus();
}

function validate(formular)
{
     if ((document.getElementById("text").value==""))
      {
       alert("Musíte vyplnit potřebná pole.");
       document.getElementById("text").focus();
       return false;
      }
     return true;
}

function validate_cislo(formular)
{
     if ((document.getElementById("pocet_ot").value.length==0) || isNaN(parseInt(document.getElementById("pocet_ot").value)) )
     {
       alert('Vyplňte prosím číselnou hodnotu do pole pro počet otázek.');
       focus();
       return false;
     }
     return true;
}

function vypni()
{
  for (i=0; i<document.save.elements.length; i++)
  {
    if (document.save.elements[i].name == "adresati[]")
    {
      document.save.elements[i].checked=false;
    }
  }
}

function vyberVse()
{
  if(document.vzkazy.all.checked == true || document.vzkazy.all_top.checked == true)
  {
    for (i=0; i<document.vzkazy.elements.length; i++)
    {
      if (document.vzkazy.elements[i].name == "vzkazy[]")
        document.vzkazy.elements[i].checked = true;
    }
  }
  else
  {
    for (i=0; i<document.vzkazy.elements.length; i++)
    {
      if (document.vzkazy.elements[i].name == "vzkazy[]")
        document.vzkazy.elements[i].checked = false;
    }
  }
}

function vyberVsechnyNovinky()
{
  if(document.novinky.all.checked == true)
  {
    for (i=0; i<document.novinky.elements.length; i++)
    {
      if (document.novinky.elements[i].name == "temata[]")
        document.novinky.elements[i].checked = true;
    }
  }
  else
  {
    for (i=0; i<document.novinky.elements.length; i++)
    {
      if (document.novinky.elements[i].name == "temata[]")
        document.novinky.elements[i].checked = false;
    }
  }
}

//myField accepts an object reference, myValue accepts the text strint to add
function insertAtCursor(myField, myValue)
{
	//IE support
	if (document.selection)
	{
		myField.focus();

		//in effect we are creating a text range with zero
		//length at the cursor location and replacing it
		//with myValue
		sel = document.selection.createRange();
		sel.text = myValue;
	}

	//Mozilla/Firefox/Netscape 7+ support
	else if (myField.selectionStart || myField.selectionStart == '0')
	{
		//Here we get the start and end points of the
		//selection. then we create substrings up to the
		//start of the selection and from the end point
		//of the selection to the end of the field value.
		//then we concatenate the first substring, myValue,
		//and the second substring to get the new value.
		var startPos = myField.selectionStart;
		var endPos = myField.selectionEnd;
		myField.value = myField.value.substring(0, startPos)+ myValue+ myField.value.substring(endPos, myField.value.length);
	}
	else
	{
		myField.value += myValue;
	}
}

function windowOpener() {
   msgWindow=window.open("","Time map",
    "toolbar=no, location=no, directories=no, status=no, menubar=no,"+
    "scrollbars=no, resizable=no, copyhistory=no, width=492, height=292");
   msgWindow.document.write
      ("<HEAD><TITLE>Time map</TITLE></HEAD><CENTER>");
   msgWindow.document.write
      ('<embed src="http://www.clocklink.com/clocks/world001-gray.swf?TimeZone=GMT0100&" width="480" height="250"'+
       'wmode="transparent" type="application/x-shockwave-flash">');
   msgWindow.document.write
      ('<br /><button onclick="window.close();">Zavřít okno</button></CENTER>');
}

function odkazyFocusIn(element)
{
  var style='text-decoration: underline; text-align: left; vertical-align: middle; padding: 10px 5px 10px 5px; width:62%';
  document.getElementById(''+element+'').style=''+style+'';
}

function odkazyFocusOut(element)
{
  var style='text-decoration: none; text-align: left; vertical-align: middle; padding: 10px 5px 10px 5px; width:62%';
  document.getElementById(''+element+'').style=''+style+'';
}

function potvrdit()
{
  var potvrzeni = window.confirm('Opravdu chcete tuto akci provést?');
  if (potvrzeni)
	  event.returnValue = true;
  else
  {
	  return;
	}
}

function fixImgs(whichId, maxW) {
var pix=document.getElementById(whichId).getElementsByTagName('img');
  for (i=0; i<pix.length; i++) {
    w=pix[i].width;
    h=pix[i].height;
    if (w > maxW) {
      f=1-((w - maxW) / w);
      pix[i].width=w * f;
      pix[i].height=h * f;
    }
  }
}

function getCurrUrl()
{
  return window.location.href;
}
