var dotmod,timer;
var mstime=0;



/* inserting text */
/* inserting text */
/* inserting text */
// IE only - wraps selected text with lft and rgt
  function WrapIE(lft, rgt) {
    strSelection = document.selection.createRange().text;
    if (strSelection!="") {
      document.selection.createRange().text = lft + strSelection + rgt;
    }
  }

// Moz only - wraps selected text with lft and rgt
  function wrapMoz(txtarea, lft, rgt) {
    var selLength = txtarea.textLength;
    var selStart = txtarea.selectionStart;
    var selEnd = txtarea.selectionEnd;
    if (selEnd==1 || selEnd==2) selEnd=selLength;
    var s1 = (txtarea.value).substring(0,selStart);
    var s2 = (txtarea.value).substring(selStart, selEnd)
    var s3 = (txtarea.value).substring(selEnd, selLength);
    txtarea.value = s1 + lft + s2 + rgt + s3;
  }
  
// Chooses technique based on browser
  function wrapTag(txtarea, lft, rgt) {
    lft = unescape(lft);
    rgt = unescape(rgt);
    if (document.all) {
      WrapIE(lft, rgt);
    }
    else if (document.getElementById) {
      wrapMoz(txtarea, lft, rgt);
    }
  } 

// IE only - Insert text at caret position or at start of selected text
  function insertIE (txtarea, text) {
    if (txtarea.createTextRange && txtarea.caretPos) { 
      var caretPos = txtarea.caretPos; 
      caretPos.text = caretPos.text.charAt(caretPos.text.length - 1) == ' ' ? text+caretPos.text + ' ' : text+caretPos.text;
    } else {
      txtarea.value = txtarea.value + text; 
    }
    return;
  } 

// Moz only - Insert text at caret position or at start of selected text
  function insertMoz(txtarea , lft) {
    var rgt="";
    wrapTag(txtarea, lft, rgt);
    return;
  }

// Switch function based on browser - Insert text at caret position or at start of selected text
  function insertTag(txtarea , lft) {
    if (document.all) {
      insertIE(txtarea, lft);
    }
    else if (document.getElementById) {
      insertMoz(txtarea, lft);
    }
  }
  

// IE only - stores the current cursor position on any textarea activity
  function storeCaret (txtarea) { 
    if (txtarea.createTextRange) { 
      txtarea.caretPos = document.selection.createRange().duplicate();
    } 
  }

function vloztext(text)
{
	insertTag (document.formular.text,text);
}
/* end inserting text */
/* end inserting text */
/* end inserting text */


/* quick search engine */
/* quick search engine */
/* quick search engine */

timerID=null;
lastValue="";

function QuickSearch(){
	for (i=0;i<document.myform.label.length;i++){
		if ( (document.myform.label.options[i].text.toLowerCase().indexOf(document.myform.quicklabel.value.toLowerCase())==0) 
				&& (document.myform.quicklabel.value!="") ){
			document.myform.label.options[i].selected=true;
			return;
		}
	}
	if (document.myform.label.selectedIndex>-1)
		document.myform.label.selectedIndex=-1;
}
function ChangeCheckerLabel(){
//document.myform.quicklabel.blur();// doplnek pro netscape
	if (document.myform.quicklabel.value.toLowerCase()!=lastValue){
		lastValue=document.myform.quicklabel.value.toLowerCase();
		QuickSearch();
	}
//document.myform.quicklabel.focus(); // doplnek pro netscape
	timerID=setTimeout("ChangeCheckerLabel()",100);
}

/* quick search engine */
/* quick search engine */
/* quick search engine */

//THNX to Medhi from blueboard.cz for the next two js functions :)
function zmenObrazek(jaky, co, naco)
{
    if (document.images[jaky].src.indexOf(co) > -1)
    {
        document.images[jaky].src = naco;
    }
    else
    {
        document.images[jaky].src = co;
    }
}
function prepni(co){
  var el = document.getElementById(co);
  el.style.display = (el.style.display == "none"? "": "none"); 
}


function showbox(id){
menu=document.getElementById(id);
menu.style.display = "block";
}
function hidebox(id){
menu=document.getElementById(id);
menu.style.display = "none";
}

function checkall()
{
  f= document.forms['posta'];
  e= f.elements;
  for(i= 0; i<e.length; i++)
    if(e[i].type=="checkbox")
      e[i].checked= !e[i].checked;
}
function obrazek(obr,ext){
	window.open("obrazek.php?obr="+obr+"."+ext,"_blank","top=21px,left=0,width=1024, height=768,scrollbars,resizable");
}