var dotmod,timer;
var mstime=0;
/*
function doTT(e,num){
 if(document.getElementById){
  elm=document.getElementById("tt"+num);
  if(document.all && !window.opera){x=event.clientX+document.body.scrollLeft-180;y=event.clientY+document.body.scrollTop-30;}else{x=e.pageX-10;y=e.pageY-10;}
  if(document.all && !window.opera){elm.style.pixelLeft=x;elm.style.pixelTop=y;}else{elm.style.left=x+"px";elm.style.top=y+"px";}
  dotmod=elm;
  timer=setTimeout('showTT()',mstime);
 }
}

function showTT(){
	dotmod.style.display='block';
}

function hideTT(num){
	if(document.getElementById){elm=document.getElementById("tt"+num);elm.style.display="none";clearTimeout(timer);}
}
*/


/* 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)
{
    //document.forum.text.value = document.forum.text.value + ' ' + what + ' ';
	//document.forum.text.focus();
	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 for posta */

function QuickSearchPosta(){
	for (i=0;i<document.formular.seznam.length;i++){
		if ( (document.formular.seznam.options[i].text.toLowerCase().indexOf(document.formular.quickuser.value.toLowerCase())==0) 
				&& (document.formular.quickuser.value!="") ){
			document.formular.seznam.options[i].selected=true;
			return;
		}
	}
	if (document.formular.seznam.selectedIndex>-1)
		document.formular.seznam.selectedIndex=-1;
}

function ChangeCheckerPosta(){
//document.myform.quicklabel.blur();// doplnek pro netscape
	if (document.formular.quickuser.value.toLowerCase()!=lastValue){
		lastValue=document.formular.quickuser.value.toLowerCase();
		QuickSearchPosta();
	}
//document.myform.quicklabel.focus(); // doplnek pro netscape
	timerID=setTimeout("ChangeCheckerPosta()",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 changeupload(file) {
    if (file) {
        document.getElementById('ftp').style.display='none';
        document.getElementById('urlsetu').style.display='block';
    } else {
        document.getElementById('ftp').style.display='block';
        document.getElementById('urlsetu').style.display='none';
    }
}
function show(id){
	menu=document.getElementById(id);
	menu.style.display="block";
	showp = "show_"+id;
	hidep = "hide_"+id;
	menu=document.getElementById(showp);
	menu.style.display="none";
	menu=document.getElementById(hidep);
	menu.style.display="block";	
}
function hide(id){
	menu=document.getElementById(id);
	menu.style.display="none";
	showp = "show_"+id;
	hidep = "hide_"+id;
	menu=document.getElementById(showp);
	menu.style.display="block";
	menu=document.getElementById(hidep);
	menu.style.display="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 a(){}*/

					 
function zobrazhelp(){
menu=document.getElementById("help");
menu.style.display = "block";
menu=document.getElementById("odkr1a");
menu.style.display = "none";
menu=document.getElementById("odkr1b");
menu.style.display = "block";
}
function schovathelp(){
menu=document.getElementById("help");
menu.style.display = "none";
menu=document.getElementById("odkr1b");
menu.style.display = "none";
menu=document.getElementById("odkr1a");
menu.style.display = "block";
}

function showhelp(a) {
   document.getElementById('helper').style.visibility='visible';
   document.getElementById('helper').style.display='block'; 
   document.getElementById('helper').innerHTML=a;

}
//funkce nuluje  title a alt
function hideAltTitle(obj){
    obj.alt = '';
    obj.title ='';
}

function hidehelp() {
   document.getElementById('helper').style.visibility='hidden';
   document.getElementById('helper').style.display='none';
}
/*
function enabledisable(){
	if(document.formname.checkboxname.checked)
	{
	document.formname.textname.disabled=false;
	}
	
	else
	{
	document.formname.textname.disabled=true;
	}
}
*/
function vlozrok(rok){
	document.myform.rok.value = rok;
}

function addprijemce(pritel){
	if (pritel=="nikdo"){
		seznam = document.formular.seznam.value;
	}else{
		seznam = pritel;
	}
	komu = document.formular.komu.value;
	if (komu == ""){
		komu = seznam;
	}else{
		komu = komu+";"+seznam;
	}
	document.formular.komu.value = komu;
}

function confirmLink(theLink, theSqlQuery)
{
    // Confirmation is not required in the configuration file
    // or browser is Opera (crappy js implementation)
    if (confirmMsg == '' || typeof(window.opera) != 'undefined') {
        return true;
    }

    var is_confirmed = confirm(confirmMsg + ' :\n' + theSqlQuery);
    if (is_confirmed) {
    	if ( typeof(theLink.href) != 'undefined' ) {
            theLink.href += '&is_js_confirmed=1';
        } else if ( typeof(theLink.form) != 'undefined' ) {
            theLink.form.action += '?is_js_confirmed=1';
        }
    }

    return is_confirmed;
} // end of the 'confirmLink()' function

function vypni(od,co){
	if(document.getElementById(od).checked == 1){
		for(i=0;i<co.length;i++){
    		document.getElementById(co[i]).disabled = true;
		}
	}else{
		for(i=0;i<co.length;i++){
    		document.getElementById(co[i]).disabled = false;
		}
	}
}

