  function Init()
  {
    iView.document.designMode = 'On';
  }
  
  function Init2()
  {
    iView2.document.designMode = 'On';
  }  
    
  function selOn(ctrl)
  {
  ctrl.style.borderColor = '#000000';
  ctrl.style.backgroundColor = '#B5BED6';
  ctrl.style.cursor = 'hand'; 
  }
  
  function selOff(ctrl)
  {
  ctrl.style.borderColor = '#000000';  
  ctrl.style.backgroundColor = '#c0eaf6';
  }
  
  function selDown(ctrl)
  {
  ctrl.style.backgroundColor = '#8492B5';
  }
  
  function selUp(ctrl)
  {
    ctrl.style.backgroundColor = '#B5BED6';
  }

  function doBold()
  {
  iView.document.execCommand('bold', false, null);
  }

  function doBold2()
  {
  iView2.document.execCommand('bold', false, null);
  }  

  function ProcessText()
  {
  var htmlCode=iView.document.body.innerHTML;
  document.form1.text.value=htmlCode;
  return true;
  }
  
  function ProcessPodminky()
  {
  var htmlCode=iView.document.body.innerHTML;
  document.form1.podminky.value=htmlCode;
  return true;
  }  
  
  function ProcessPodminkyPrijeti()
  {
  var htmlCode=iView2.document.body.innerHTML;
  document.form1.podminky_prijeti.value=htmlCode;
  return true;
  }  

  function Enc(Word,Tag,Etag)
  {
  a = Word.indexOf(Tag);
  if(a != -1)   
  {
  totallen = Word.length;  
  len = Tag.length;
  c = Word.substring(0, a);
  d = Word.substring((a + len), totallen);
  Word = c + Etag + d;
  tagCheck = Word.indexOf(Tag);
  if(tagCheck != -1)
  {
   Word = Enc(Word,Tag,Etag);
  }
  }
  return Word;
  }

  function Del(Word)
  {
  a = Word.indexOf("<");
  b = Word.indexOf(">");
  len = Word.length;
  c = Word.substring(0, a);
  if(b == -1)
  b = a;
  d = Word.substring((b + 1), len);
  Word = c + d;
  tagCheck = Word.indexOf("<");
  if(tagCheck != -1)
  {
   Word = Del(Word);
  }
  return Word;
  }

  function Check()
  {
  ToCheck = iView.document.body.innerHTML;
  Encoded = Enc(ToCheck,'<STRONG>','STRONG__S');
  Encoded = Enc(Encoded,'</STRONG>','STRONG__E');
  Encoded = Enc(Encoded,'<BR>','BR__S');
  Encoded = Enc(Encoded,'<B','B__S<');
  Encoded = Enc(Encoded,'</B>','B__E');
  Encoded = Enc(Encoded,'<P','P__S<');
  Encoded = Enc(Encoded,'</P>','P__E');
  Checked = Del(Encoded);
  Decoded = Enc(Checked,'STRONG__S','<STRONG>');
  Decoded = Enc(Decoded,'STRONG__E','</STRONG>');
  Decoded = Enc(Decoded,'B__S','<B>');
  Decoded = Enc(Decoded,'B__E','</B>');
  Decoded = Enc(Decoded,'BR__S','<BR>');
  Decoded = Enc(Decoded,'P__S','<P>');
  Decoded = Enc(Decoded,'P__E','</P>');
  iView.document.body.innerHTML = Decoded;
  }

  function Check2()
  {
  ToCheck = iView2.document.body.innerHTML;
  Encoded = Enc(ToCheck,'<STRONG>','STRONG__S');
  Encoded = Enc(Encoded,'</STRONG>','STRONG__E');
  Encoded = Enc(Encoded,'<BR>','BR__S');
  Encoded = Enc(Encoded,'<B','B__S<');
  Encoded = Enc(Encoded,'</B>','B__E');
  Encoded = Enc(Encoded,'<P','P__S<');
  Encoded = Enc(Encoded,'</P>','P__E');
  Checked = Del(Encoded);
  Decoded = Enc(Checked,'STRONG__S','<STRONG>');
  Decoded = Enc(Decoded,'STRONG__E','</STRONG>');
  Decoded = Enc(Decoded,'B__S','<B>');
  Decoded = Enc(Decoded,'B__E','</B>');
  Decoded = Enc(Decoded,'BR__S','<BR>');
  Decoded = Enc(Decoded,'P__S','<P>');
  Decoded = Enc(Decoded,'P__E','</P>');
  iView2.document.body.innerHTML = Decoded;
  }
