// globalsvar curSelVal = "";var startPos = 0;var endPos = 0;// functionsfunction storeCurVal(obj, start, end) 
{	// function not called if IE 4+	curSelVal = document.update_form.tekst.value;  	startPos = obj.selectionStart;	endPos = obj.selectionEnd;}function getSel(tag){  var oldString = "";	  var i = 0;
    if(document.selection)
  {  		oldString = document.selection.createRange().text;
  				if(oldString != "") 
		{			document.selection.createRange().text = '[' + tag + ']' + oldString + '[/' + tag + ']';		}  } 
  else if(window.getSelection)
  {		oldString = curSelVal;		var newString = "";		var finalString = "";		var len = curSelVal.length; // length of current string

				if(len > 0 && document.update_form.tekst.value.length > 0) 
		{			// get from beginning of string to start position			var firstPart = oldString.substring(0, startPos);			// get from end of selection to end of total string			var lastPart = oldString.substring(endPos, len);				// store the new string			for (i=startPos; i<endPos; i++) 
			{				newString += oldString[i];			}			// surround it with the proper tag			finalString = '[' + tag + ']' + newString + '[/' + tag + ']';				// rewrite it back into the textarea			document.update_form.tekst.value = firstPart + finalString + lastPart;		} 
		else 
		{			curSelVal = "";		}
  } 
  else if(document.getSelection)
  { 
		// don't know which browser would actually call this		txt = obj.setSelectionRange(obj.selectionStart, obj.selectionEnd);  } }function swap(theId, newSrc) 
{	document.getElementById(theId).src = newSrc;}

