String.prototype.reverse = new Function("return this.split('').reverse().join('')");

function showFormula(latex) {
	
	var height = latex.length*0.4>20?latex.length*0.4<400?latex.length*0.4:400:20; // aukstis, dinamiskai pagal formules ilgi. 20-400 px.
	var nw = window.open('','','menubar=0,scrollbars=0,width=500,height='+height+',location=0,resizable=1,status=0,top=150,left=200');
		
	nw.document.writeln(
	'<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
	'<html><head>',
	'<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />',
	'<style type="text/css">',
		'html, body { margin: 0px; padding: 0px; height: 100%; }',
		'code { font-family: Consolas, monospace; font-size: 15px; margin: 10px; display: block;}',
	'</style>',
	'<title>LaTeX</title></head>',
	'<body>',
	'<code>'+unescape(latex).replace(/}/g,"}<wbr/>")+'</code>',
	'</body></html>');

	nw.document.close();
}

function email(user,domain,mailto) {
	return String(mailto?'mailto:':'')+String(user).reverse()+'@'+String(domain).reverse();
}

function unfocus_links() {
	var aTags = document.getElementsByTagName('a');
	for (var i=0; i<aTags.length; i++) {
		aTags[i].onfocus = new Function("this.blur()");
	}
}

window.onload = new Function("unfocus_links()");