function ow ( title, url, w, h, b_scrollbars, b_resizable, typ )
{
        var twidth = w;
        var theight = h;

	var i_scrollbars = b_scrollbars ? 1 : 0;
	var i_resizable = b_resizable ? 1 : 0;

        if(twidth > screen.width - 40) twidth = screen.width - 40;
        if(theight > screen.height - 40) theight = screen.height - 40;

        var pos_x = (screen.width - twidth - 10)/2;
        var pos_y = (screen.height - theight - 29)/2;

        if(typeof(document_nahlad_obrazku) == "undefined" || document_nahlad_obrazku.closed)
        document_nahlad_obrazku = window.open('','document_nahlad_obrazku','status=no,menubar=0,toolbar=0,location=0,scrollbars=' + i_scrollbars + ',screenX='+pos_x+',screenY='+pos_y+',left='+pos_x+',top='+pos_y+',width='+twidth+',height='+theight+',resizable=' + i_resizable );

        document_nahlad_obrazku.resizeTo(w+10,h+29);
        document_nahlad_obrazku.moveTo(pos_x,pos_y);

        var doc = document_nahlad_obrazku.document;
        doc.open('text/html');

        tmp = '<html>\n<head>\n<title>' + title + '</title>\n</head>\n<body style="margin:0; padding: 0" onclick="self.close()">\n';

        if(typ == 1)
        {
                tmp += '<object type="application/x-shockwave-flash" data="' + url + '" width="' + w + '" height="' + h + '">\n';
                tmp += '<param name="movie" value="' + url + '">\n';
                tmp += '</object>\n';
        }else tmp += '<img src="' + url + '" alt="">\n';

        tmp += '</body>\n</html>';

        doc.write(tmp);
        doc.close();

        document_nahlad_obrazku.focus();
}

function oo ( title, url, w, h )
{
	ow ( title + ', Turčianska knižnica v Martine', url, w, h, 0, 1, 0 );
}

function conv_calc(o)
{
	var parita = 30.126;
	var from = parseFloat ( o.value.replace ( ",", "." ) );

	if ( o.name == "conv_from" )
	{
		var from_valuta = 1;
		var to_valuta = parita;
		var out = o.form.conv_to;
	}else
	{
		var from_valuta = parita;
		var to_valuta = 1;
		var out = o.form.conv_from;
	}

	if ( isNaN ( from ) )
	{
		out.value = '';
	}else
	{
		result = from * from_valuta / to_valuta;
		if ( isNaN ( result ) )
		{
			out.value = '';
		}else
		{
			rr = Math.round ( result * 10000 ) / 10000;
			srr = String ( rr );
			srr = srr.replace ( ".", "," );

			var pos = srr.indexOf ( "," );

			if ( pos == -1 )
			{
				srr += ",0000";
			}else
			{
				var len = 6 - srr.length + pos;
				if ( len > 0 )
				{
					var zeros = new Array( len ).join ( "0" );
					srr += zeros;
				}
			}
			out.value = srr;
		}
	}
}

function PripravLinky ()
{
	var anchors = document.getElementsByTagName ( "a" );

	for ( var i = 0; i < anchors.length; i++ )
	{
		var anchor = anchors[i];
		var relAttribute = String(anchor.getAttribute("rel"));
		if (anchor.getAttribute("href"))
		{
			if ( relAttribute.match ( /^oo/ ) )
			{
				eval ( "anchor.onclick = function () { " + relAttribute + "; return false; }" );

				anchor.href = "javascript:void(0)";
			}
		}
	}
}

if (window.addEventListener) {

	window.addEventListener("load",PripravLinky,false);

} else if (window.attachEvent) {

	window.attachEvent("onload",PripravLinky);

} else {

	window.onload = function() {PripravLinky();}

}

