function runScript()
	{
	if (document.getElementsByTagName('textarea')[0])
		{
		txttext=document.getElementsByTagName('textarea')[0].value;
		}
	else
		{
		txttext=htmlIt(removeHTMLTags(document.getElementsByTagName('pre')[0].innerHTML));
		}

	scriptWin=window.open("","_scriptwin","widht=640, height=480, status=1, menubar=1, toolbar=1, resizable=1, location=1");
	if (scriptWin)
		{
//		scriptWin.focus();
		scriptWin.document.open();
		scriptWin.document.writeln(txttext);
		scriptWin.onerror=new Function("alert('Ve scriptu došlo k chybě.');");
		scriptWin.opener=self;
		scriptWin.document.close();
		}
	else
		{
		alert("Aplikace zabranila zobrazení popup okna s výsledným scriptem. Spus»te ho manuálně kliknutím na tlačtko \"Provést zadaný kód\".");
		document.getElementById("customscriptOk").focus();
		return false;
		}
	}


function edit(obj)
	{
	obj.parentNode.removeChild(obj);
	obj.disabled=true;
	obj=document.getElementsByTagName("pre")[0];
	kont=document.createElement("div");
	text=document.createElement("textarea");
	text.setAttribute("rows",15);
	text.setAttribute("cols",70);
	text.style.border="1px solid #555";
	text.style.overflow="auto";
	text.style.width="100%";
	text.style.padding="0";
	text.value=htmlIt(removeHTMLTags(obj.innerHTML));

	kont.appendChild(text);
	obj.parentNode.insertBefore(kont,obj);
	obj.style.display="none";
	}

function removeHTMLTags(strInputCode)
	{
	/* http://robertnyman.com/roblab/javascript-remove-tags.htm */
	var strTagStrippedText = strInputCode.replace(/<\/?[^>]+(>|$)/g, "");
	return strTagStrippedText;
	}	


function htmlIt(strInputCode)
  {
/*  tag=/&gt;/gi;
  str=str.replace(tag, ">");

  tag=/&lt;/gi;
  str=str.replace(tag, "<");
*/
  strInputCode = strInputCode.replace(/&(lt|gt);/g, function (strMatch, p1){
			return (p1 == "lt")? "<" : ">";
		});

  return strInputCode;
  }
