function svetly(Image) {
  Image.src=Image.src.substring(0,Image.src.lastIndexOf("_")+4)+"2"+Image.src.substring(Image.src.lastIndexOf("_")+5,Image.src.length)
}

function tmavy(Image) {
  Image.src=Image.src.substring(0,Image.src.lastIndexOf("_")+4)+"1"+Image.src.substring(Image.src.lastIndexOf("_")+5,Image.src.length)
}

function runClock() {
  today=new Date();
  day=today.getDate();
  month=today.getMonth()+1;
  year=today.getFullYear();
  hours=today.getHours();
  minutes=today.getMinutes();
  seconds=today.getSeconds();
  timeValue=day+". "+month+". "+year+" ";
  timeValue+=hours;
  timeValue+=((minutes<10) ? ":0" : ":")+minutes;
  timeValue+=((seconds<10) ? ":0" : ":")+seconds;
  if (document.getElementById("hodiny").nodeValue != timeValue) domInnerText(document.getElementById("hodiny"), timeValue);
  setTimeout("runClock()",100);
  return timeValue;
}

function domInnerText(node, text) {
  while (node.hasChildNodes()) {
    node.removeChild(node.firstChild);
  }
  node.appendChild(document.createTextNode(text));
}

function email(node, adrpred, adrza) {
  while (node.hasChildNodes()) {
    node.removeChild(node.firstChild);
  }
  elem = document.createElement("a");
  elem.setAttribute("href", "mailto:"+adrpred+"%40"+adrza);
  node.appendChild(elem);
  elem.appendChild(document.createTextNode(adrpred+"@"+adrza));
}

function winH() {
   if (window.innerHeight)
      return window.innerHeight;
   else if
   (document.documentElement &&
   document.documentElement.clientHeight)
      return document.documentElement.clientHeight;
   else if
   (document.body && document.body.clientHeight)
      return document.body.clientHeight;
   else
      return null;
}

function winW() {
   if (window.innerWidth)
      return window.innerWidth;
   else if
   (document.documentElement &&
   document.documentElement.clientWidth)
      return document.documentElement.clientWidth;
   else if
   (document.body && document.body.clientWidth)
      return document.body.clientWidth;
   else
      return null;
}

// Copyright © 2001 by Apple Computer, Inc., All Rights Reserved.
//
// You may incorporate this Apple sample code into your own code
// without restriction. This Apple sample code has been provided "AS IS"
// and the responsibility for its operation is yours. You may redistribute
// this code, but you are not permitted to redistribute it as
// "Apple sample code" after having made changes.

// ugly workaround for missing support for selectorText in Netscape6/Mozilla
// call onLoad() or before you need to do anything you would have otherwise used
// selectorText for.
var ugly_selectorText_workaround_flag = false;
var allStyleRules;
// code developed using the following workaround (CVS v1.15) as an example.
// http://lxr.mozilla.org/seamonkey/source/extensions/xmlterm/ui/content/XMLTermCommands.js
function ugly_selectorText_workaround() {
	if((navigator.userAgent.indexOf("Gecko") == -1) ||
	   (ugly_selectorText_workaround_flag)) {
		return; // we've already been here or shouldn't be here
	}
	var styleElements = document.getElementsByTagName("style");

	for(var i = 0; i < styleElements.length; i++) {
		var styleText = styleElements[i].firstChild.data;
		// this should be using match(/\b[\w-.]+(?=\s*\{)/g but ?= causes an
		// error in IE5, so we include the open brace and then strip it
		allStyleRules = styleText.match(/\b[\w-.]+(\s*\{)/g);
	}

	for(var i = 0; i < allStyleRules.length; i++) {
		// probably insufficient for people who like random gobs of
		// whitespace in their styles
		allStyleRules[i] = allStyleRules[i].substr(0, (allStyleRules[i].length - 2));
	}
	ugly_selectorText_workaround_flag = true;
}

// setStyleById: given an element id, style property and
// value, apply the style.
// args:
//  i - element id
//  p - property
//  v - value
//
function setStyleById(i, p, v) {
	var n = document.getElementById(i);
	n.style[p] = v;
}

// getStyleById: given an element ID and style property
// return the current setting for that property, or null.
// args:
//  i - element id
//  p - property
function getStyleById(i, p) {
	var n = document.getElementById(i);
	var s = eval("n.style." + p);

	// try inline
	if((s != "") && (s != null)) {
		return s;
	}

	// try currentStyle
	if(n.currentStyle) {
		var s = eval("n.currentStyle." + p);
		if((s != "") && (s != null)) {
			return s;
		}
	}

	// try styleSheets
	var sheets = document.styleSheets;
	if(sheets.length > 0) {
		// loop over each sheet
		for(var x = 0; x < sheets.length; x++) {
			// grab stylesheet rules
			var rules = sheets[x].cssRules;
			if(rules.length > 0) {
				// check each rule
				for(var y = 0; y < rules.length; y++) {
					var z = rules[y].style;
					// selectorText broken in NS 6/Mozilla: see
					// http://bugzilla.mozilla.org/show_bug.cgi?id=51944
					ugly_selectorText_workaround();
					if(allStyleRules) {
						if(allStyleRules[y] == i) {
							return z[p];
						}
					} else {
						// use the native selectorText and style stuff
						if(((z[p] != "") && (z[p] != null)) ||
						   (rules[y].selectorText == i)) {
							return z[p];
						}
					}
				}
			}
		}
	}
	return null;
}

function kontrola() {
      if (document.getElementById('prisp').jmeno.value == "") {
            alert("Položka se jménem musí být vyplněna.");
            document.getElementById('prisp').jmeno.focus();
            return false;
      }
      else if (document.getElementById('prisp').zprava.value == "") {
            alert("Zpráva musí obsahovat text.");
            document.getElementById('prisp').zprava.focus();
            return false;
      }
      else return true;
}

var slen = 999;

function countit()
{
   str = document.getElementById('prisp').zprava.value;
   strlength = str.length;
   domInnerText(document.getElementById("kolik"), slen - strlength);

   if (slen-strlength < 0) {
     dimInnerText(document.getElementById("kolik"), '0');
     document.prisp.zprava.value = document.prisp.zprava.value.substring(0, slen);
   }
}

function vlozRet(myField, myValue, bbCode1, bbCode2) {
  var bbb;
  if (document.selection) {
    // Internet Explorer
    //var str = document.selection.createRange().text;
    myField.focus();
    if (myValue == '') myValue = document.selection.createRange().text;
    sel = document.selection.createRange();
    sel.text = bbCode1 + myValue + bbCode2;
    if (myValue == '') {
      bbb = bbCode2.length;
      sel.moveStart('character',-bbb); sel.moveEnd('character',-bbb);
    }
    sel.select();
    return;
  }
  else if (myField.selectionStart || myField.selectionStart == '0') {
    // Gecko
    var startPos = myField.selectionStart;
    var endPos = myField.selectionEnd;
    var bbb2, bbV;
    if (myValue == '') myValue = myField.value.substring(startPos, endPos);
    myField.value = myField.value.substring(0, startPos) + bbCode1 + myValue + bbCode2 + myField.value.substring(endPos, myField.value.length);
    if (myValue == '') {
      bbb = bbCode1.length;
      myField.selectionStart = startPos+bbb;
      myField.selectionEnd = endPos+bbb;
    }
    else {
      bbb = bbCode1.length;
      bbb2 = bbCode2.length;
      bbV = myValue.length;
      myField.selectionStart = startPos+bbV+bbb+bbb2;
      myField.selectionEnd = myField.selectionStart;
    }
    myField.focus();
    myField.scrollTop = myField.scrollHeight;
    return;
  } else {
    myField.value += myValue;
    return;
  }
}

function vyberRet(objekt) {
  vyber = '';
  if (window.getSelection) {
    objekt.thisSel = window.getSelection()+'';
    vyber = objekt.thisSel.toString();
  }
  else if (document.getSelection) vyber = document.getSelection()+'';
  else if (document.selection) vyber = document.selection.createRange().text;
  return vyber;
}

function oznText()
{
    var txt = '';
    if (window.getSelection)
    {
        txt = window.getSelection();
             }
    else if (document.getSelection)
    {
        txt = document.getSelection();
            }
    else if (document.selection)
    {
        txt = document.selection.createRange().text;
            }
    else return;
    return txt;
}

function JustSoPicWindow(imageName,imageWidth,imageHeight,alt,bgcolor,hugger,hugMargin,lang) {
// by E Michael Brandt of ValleyWebDesigns.com - Please leave these comments intact.
// version 3.0.4

        if (bgcolor=="") {
                bgcolor="#FFFFFF";
        }
        var adj=10;
        var w = screen.width;
        var h = screen.height;
        var byFactor=1;

        if(w<740){
          var lift=0.90;
        }
        if(w>=740 & w<835){
          var lift=0.91;
        }
        if(w>=835){
          var lift=0.93;
        }
        if (imageWidth>w){
          byFactor = w / imageWidth;
          imageWidth = w;
          imageHeight = imageHeight * byFactor;
        }
        if (imageHeight>h-adj){
          byFactor = h / imageHeight;
          imageWidth = (imageWidth * byFactor);
          imageHeight = h;
        }

        var scrWidth = w-adj;
        var scrHeight = (h*lift)-adj;

        if (imageHeight>scrHeight){
            imageHeight=imageHeight*lift;
          imageWidth=imageWidth*lift;
        }

        var posLeft=0;
        var posTop=0;

        if (hugger == "hug image"){
          if (hugMargin == ""){
            hugMargin = 0;
          }
          var scrHeightTemp = imageHeight - 0 + 2*hugMargin;
          if (scrHeightTemp < scrHeight) {
                scrHeight = scrHeightTemp;
          }
          var scrWidthTemp = imageWidth - 0 + 2*hugMargin;
          if (scrWidthTemp < scrWidth) {
                scrWidth = scrWidthTemp;
          }

          if (scrHeight<100){scrHeight=100;}
          if (scrWidth<100){scrWidth=100;}

          posTop =  ((h-(scrHeight/lift)-adj)/2);
          posLeft = ((w-(scrWidth)-adj)/2);
         }

        if (imageHeight > (h*lift)-adj || imageWidth > w-adj){
                imageHeight=imageHeight-adj;
                imageWidth=imageWidth-adj;
        }
        posTop = parseInt(posTop);
        posLeft = parseInt(posLeft);
        scrWidth = parseInt(scrWidth);
        scrHeight = parseInt(scrHeight);

        var agt=navigator.userAgent.toLowerCase();
        if (agt.indexOf("opera") != -1){
          var args= new Array();
          args[0]='parent';
          args[1]=imageName;
          var i;
          document.MM_returnValue = false;
          for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
        } else {
        newWindow = window.open("","newWindow","width="+scrWidth+",height="+scrHeight+",left="+posLeft+",top="+posTop);
        newWindow.document.open();
        newWindow.document.write('<html><title>'+alt+'</title><body leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" bgcolor='+bgcolor+' onmousedown="if (event.button == 1 || event.which == 1) du = 1" onmouseup="if ((event.button == 1 || event.which == 1) && du) self.close(); else du = 0" onmouseout="du = 0">');
        newWindow.document.write('<table width='+imageWidth+' border="0" cellspacing="0" cellpadding="0" align="center" height='+scrHeight+'><tr><td>');
        newWindow.document.write('<script type="text/javascript">var du = 0;</script>');
        newWindow.document.write('<img src="'+imageName+'" width='+imageWidth+' height='+imageHeight+' alt="'+(lang ? 'Close the window by clicking it.' : 'Kliknutím zavřete okno.')+'" />');
        newWindow.document.write('</td></tr></table></body></html>');
        newWindow.document.close();
        newWindow.focus();
        }
        return false;

}