function ShraniKurzor(pozicija)
{
  if (pozicija.createTextRange)
    pozicija.PozicijaKurzorja = document.selection.createRange().duplicate();
}

function Dodajtekst(kaj)
{
  if (document.forma.message.createTextRange && document.forma.message.PozicijaKurzorja) {
    document.forma.message.PozicijaKurzorja.text = document.forma.message.PozicijaKurzorja.text.charAt(document.forma.message.PozicijaKurzorja.text.length - 1) == ' ' ? kaj + ' ' : kaj;
  } else {
    document.forma.message.value += kaj;
  }
  document.forma.message.focus();
}

function brskalnik() {
  if (navigator.userAgent.indexOf('Opera') != -1)
    return 'Opera';
  else if (navigator.userAgent.indexOf("Gecko") != -1)
    return 'Mozilla';
  else
    return 'IE';
}

function krepko() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[b]'+document.selection.createRange().text+'[/b]');
    document.selection.clear;
  } else if (brskalnik() == 'Mozilla' && document.getSelection) {
    Dodajtekst('[b]'+document.getSelection()+'[/b]');
  } else {
    var odebeljeno = prompt('Your Text [b]:', '');
    if (odebeljeno != '' && odebeljeno != null)
      Dodajtekst('[b]'+odebeljeno+'[/b]');
  }
}

function posevno() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[i]'+document.selection.createRange().text+'[/i]');
    document.selection.clear;
  } else {
    var postrani = prompt('Your Text [i]:', '');
    if (postrani != '' && postrani != null)
      Dodajtekst('[i]'+postrani+'[/i]');
  }
}
function highlight(high) {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[' + high + ']'+document.selection.createRange().text+'[/' + high + ']');
    document.selection.clear;
  } else {
    var hlight = prompt('Your Text [' + high + ']:', '');
    if (hlight != '' && hlight != null)
      Dodajtekst('[' + high + ']'+hlight+'[/' + high + ']');
  }
}


function povezava() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[url counter="no" url="'+document.selection.createRange().text+'"]'+document.selection.createRange().text+'[/url]');
    document.selection.clear;
  } else {
    var url = prompt('Your URL:', 'http://');
    var povezava = prompt('URL Title:', '');
    if (url != '' && url != null && povezava != '' && povezava != null)
      Dodajtekst('[url counter="no" url="'+url+'"]'+povezava+'[/url]');
  }
}


function email() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[email]'+document.selection.createRange().text+'[/email]');
    document.selection.clear;
  } else {
    var postrani = prompt('Your Email:', '');
    if (postrani != '' && postrani != null)
      Dodajtekst('[email]'+postrani+'[/email]');
  }
}
function slika() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[img align="center"]'+document.selection.createRange().text+'[/img]');
    document.selection.clear;
  } else {
    var url = prompt('URL of the pic :', 'http://');
    if (url != '' && url != null)
      Dodajtekst('[img align="center"]'+url+'[/img]');
  }
}

function flash() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[flash width="60" height="60"]'+document.selection.createRange().text+'[/flash]');
    document.selection.clear;
  } else {
    var url = prompt('URL of the flash file :', 'http://');
    if (url != '' && url != null)
      Dodajtekst('[flash width="60" height="60"]'+url+'[/flash]');
  }
}

function citat() {
  if (brskalnik() == 'IE' && document.selection.type == 'Text') {
    Dodajtekst('[start]'+document.selection.createRange().text+'[end]');
    document.selection.clear;
  } else
    Dodajtekst('[start]  [end]');
}

function word(kaj)
{
  if (document.write_review.form_comment.createTextRange && document.write_review.form_comment.PozicijaKurzorja)
    document.write_review.form_comment.PozicijaKurzorja.text = document.write_review.form_comment.PozicijaKurzorja.text.charAt(documentwrite_review.form_comment.PozicijaKurzorja.text.length - 1) == ' ' ? kaj + ' ' : kaj;
  else
    document.write_review.form_comment.value += kaj;
  document.write_review.form_comment.focus();
}

function smile(oznaka)
{
	Dodajtekst(' ' + oznaka + ' ');
}