function viewSource()
{
var body,d,t1,t2,reg;
d = document;
var html_hr   = d.createElement("HR");
var html_form = d.createElement("FORM");
var html_b    = d.createElement("B");
var html_butt = d.createElement("BUTTON");
var html_area = d.createElement("TEXTAREA");
var html_sub  = d.createElement("SUB");
var html_br   = d.createElement("BR");
t1 = d.createTextNode("Zdrojovy kod prikladu: (+document.write) ");
t2 = d.createTextNode("Pouzijte radeji menu: Zobrazit - zdrojovy kod");
body = d.getElementsByTagName("BODY")[0];
html_form.name = 'formSourceCode'
html_butt.innerHTML = 'Select all';
html_butt.onclick   = selectAll;
reg  = new RegExp("\\n\\<script [^>]*src\\=\\\"view-source\\.js\\\"[^>]*\\>\<\\\/script\\>","i");
//alert(reg.source);
html_area.name  = 'areaSourceCode';
html_area.cols  = 60;
html_area.rows  = 10;
html_area.value = "<html>\n" + d.getElementsByTagName("HTML")[0].innerHTML + "\n</html>";
html_area.value = html_area.value.replace(reg,"");
html_b.appendChild(t1);
html_b.appendChild(html_butt);
html_sub.appendChild(t2); 
html_form.appendChild(html_hr);
html_form.appendChild(html_b);
html_form.appendChild(html_area);
html_form.appendChild(html_br);
html_form.appendChild(html_sub);
body.appendChild(html_form);
}

function findName(tag,name)	//for IE
{
// IE bug for name
var i,x; x = document.getElementsByTagName(tag);
for (i in x) {if (x[i] && x[i].name==name) {return x[i];}}
return null;
}

function selectAll()
{
var c,f,t;
f = findName('FORM','formSourceCode');
if (f)	{
	if (f.focus()) {f.focus()};
	findName('TEXTAREA','areaSourceCode').select();
	}
return false;
}

viewSource();
