﻿

var command = "";

var browser=navigator.appName;
var IsIE = true;
if (browser=="Netscape")
{
 IsIE = false;
}

function InitToolbarButtons() {
  var kids = document.getElementsByTagName('DIV');

  for (var i=0; i < kids.length; i++) {
    if (kids[i].className == "imagebutton") {
      kids[i].onmouseover = tbmouseover;
      kids[i].onmouseout = tbmouseout;
      kids[i].onmousedown = tbmousedown;
      kids[i].onmouseup = tbmouseup;
      kids[i].onclick = tbclick;
    }
  }
}


function tbmousedown(e)
{
  var evt = e ? e : window.event; 

  this.firstChild.style.left = 2;
  this.firstChild.style.top = 2;
  this.style.border="inset 2px";
  if (evt.returnValue) {
    evt.returnValue = false;
  } else if (evt.preventDefault) {
    evt.preventDefault( );
  } else {
    return false;
  }
}

function tbmouseup()
{
  this.firstChild.style.left = 1;
  this.firstChild.style.top = 1;
  this.style.border="outset 2px";
}

function tbmouseout()
{
  this.style.border="solid 2px #C0C0C0";
}

function tbmouseover()
{
  this.style.border="outset 2px";
}


function tbclick()
{
   if (this.id == "createimage") {
        strImageName = "Images/Editor/bold.gif#attr";
        document.getElementById('edit').contentWindow.document.execCommand("InsertImage", false, strImageName);
   }
   else
   {
       document.getElementById('edit').contentWindow.document.execCommand(this.id, false, null);
   }
   document.getElementById('edit').contentWindow.document.body.innerHTML = document.getElementById('edit').contentWindow.document.body.innerHTML.replace("#attr","\" width=\""+ImgWidth+"px\"");
}

function tbimageclick(URLImage,ImgWidth)
{
    document.getElementById('edit').contentWindow.focus();
    document.getElementById('edit').contentWindow.document.execCommand('InsertImage', false, URLImage);
    document.getElementById('edit').contentWindow.document.body.innerHTML = document.getElementById('edit').contentWindow.document.body.innerHTML.replace("#attr","\" width=\""+ImgWidth+"px\" align=\"left\" style=\"border-width:0px;margin:10px\"");
}


function Select(selectname)
{
  var cursel = document.getElementById(selectname).selectedIndex;
  /* First one is always a label */
  if (cursel != 0) {
    var selected = document.getElementById(selectname).options[cursel].value;
    document.getElementById('edit').contentWindow.document.execCommand(selectname, false, selected);
    document.getElementById(selectname).selectedIndex = 0;
  }
  document.getElementById("edit").contentWindow.focus();
}


function vlozit_do_editoru() {
    if (IsIE)
    {
        document.getElementById('edit').contentWindow.document.body.innerHTML = document.getElementById('ctl00$PlaceDetail$textarea_editor').value;
        document.getElementById('edit').contentWindow.document.body.innerHTML = document.getElementById('ctl00$PlaceDetail$textarea_editor').value;
    }
    else    
        document.getElementById('edit').contentWindow.document.body.innerHTML = document.getElementById('ctl00_PlaceDetail_textarea_editor').value;
} 


function nacist_z_editoru()
{
  if (IsIE)
    document.getElementById('ctl00$PlaceDetail$textarea_editor').value = document.getElementById('edit').contentWindow.document.body.innerHTML;
  else    
    document.getElementById('ctl00_PlaceDetail_textarea_editor').value = document.getElementById('edit').contentWindow.document.body.innerHTML;
}


function Start() {
  if (!document.getElementById('edit'))
    return;
  document.getElementById('edit').contentWindow.document.designMode = "on";
  try {
    document.getElementById('edit').contentWindow.document.execCommand("undo", false, null);
  }  catch (e) {
    alert("This demo is not supported on your level of Mozilla.");
  }

  InitToolbarButtons();
}

