
// ------------------------------ formatovani textu ----------------------------

  function AddBold(frm,field)
  {
    pridej_tag(frm,field,0);
  }
  function AddItalic(frm,field)
  {
    pridej_tag(frm,field,1);
  }
  function AddAnchor(frm,field)
  {
    pridej_tag(frm,field,2);
  }
  function AddCite(frm,field)
  {
    pridej_tag(frm,field,3);
  }
  function AddHref(frm,field)
  {
    pridej_tag(frm,field,4);
  }
  function AddMail(frm,field)
  {
    pridej_tag(frm,field,5);
  }
  function AddImage(frm,field)
  {
    pridej_tag(frm,field,6);
  }


  //zjistovani verzi pocitace klienta
  var clientPC = navigator.userAgent.toLowerCase(); // Get client info
  var clientVer = parseInt(navigator.appVersion); // Get browser version

  var is_ie = ((clientPC.indexOf("msie") != -1) && (clientPC.indexOf("opera") == -1));
  var is_nav = ((clientPC.indexOf('mozilla')!=-1) && (clientPC.indexOf('spoofer')==-1)
                  && (clientPC.indexOf('compatible') == -1) && (clientPC.indexOf('opera')==-1)
                  && (clientPC.indexOf('webtv')==-1) && (clientPC.indexOf('hotjava')==-1));
  var is_moz = 0;

  var is_win = ((clientPC.indexOf("win")!=-1) || (clientPC.indexOf("16bit") != -1));
  var is_mac = (clientPC.indexOf("mac")!=-1);
  //vlastni script
  var tagy = new Array('[b] [/b]','[i] [/i]','[zkrat=vysvetleni zkratky] [/zkrat]','[quote=jmeno citovaneho] [/quote]','[url=http://www.neco.cz]Text odkazu[/url]','[mail=jmenno@neco.cz]Text odkazu[/mail]','[img]adresa obrazku[/img]');
  var parove_tagy = new Array('[b]','[/b]','[i]','[/i]','[zkrat=vysvetleni zkratky]','[/zkrat]','[quote=jmeno citovaneho]','[/quote]','[url=http://www.neco.cz]','[/url]','[mail=jmenno@neco.cz]','[/mail]','[img]','[/img]');
  var pouzite = new Array(false,false,false,false,false,false);	//ted se nevyuziva zatim

  function pridej_tag(frm,field,jaky)
  {
    var text_prisp;

    text_prisp = frm[field];

    if ((clientVer >= 4) && is_ie && is_win)
  	{
       text_prisp.focus();
  	   theSelection = document.selection.createRange().text;
  		 if (theSelection)
  		 {
  	   		 document.selection.createRange().text = parove_tagy[jaky*2] + theSelection + parove_tagy[(jaky*2)+1];
      		 text_prisp.focus();
  		 }
  	}
  	else
  	{ ///script pro mozilu
  	   if (text_prisp.selectionEnd && (text_prisp.selectionEnd - text_prisp.selectionStart > 0))
  		 {
  		    mozWrap(text_prisp,parove_tagy[jaky*2],parove_tagy[(jaky*2)+1]);
  				theSelection=true;
  				return;
  		 }
  		 theSelection=false;
  	}
  	if (!theSelection)
    {
  	    text_prisp.value=text_prisp.value+tagy[jaky];
  	  	//zapamatovat ze se ma priste vlozit koncovy tag
  	}


  }
  // From http://www.massless.org/mozedit/
  function mozWrap(txtarea, open, close)
  {
  	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 + open + s2 + close + s3;
  	return;
  }


// -----------------------------------------------------------------------------

    function FORUM_AddReaction(parrent_id,nadpis)
    {
      document.forum_add_reaction_form.parent_id.value   = parrent_id;
      document.forum_add_reaction_form.add_caption.value  = "Re: "+nadpis;
      document.forum_add_reaction_form.add_caption.focus();
      if (!IE) setTimeout("document.forum_add_reaction_form.add_text.focus();",10);
    }
    

    function DeleteItem(item_id)
    {
      document.location = 'index.php?delete_item=true&parrent_id={PARRENT_ID}&top_parrent_id={TOP_PARRENT_ID}&current_thread={CURRENT_THREAD}&item_id='+item_id;
    }

    function ShowHideItemContent(row_id)
    {
      elm_head = document.getElementById("head_"+row_id);
      elm_cont = document.getElementById("cont_"+row_id);
      if (elm_cont.style.display=="none")
      {
        elm_head.style.color   = "#db7e4d";
        elm_cont.style.display = "";
      }
      else
      {
        elm_head.style.color   = "";
        elm_cont.style.display = "none";
      }
    }



// -----------------------------------------------------------------------------

  function FORUM_CheckForm()
  {
    check_vars  = "";
    check_vars += "add_caption:Předmět;";
    check_vars += "add_text:Text;";
    check_vars += "add_name:Jméno";
    
    return CheckForm(document.forum_add_reaction_form, check_vars);

  }