function print_version() {
    var divs = getElementsByClassName("printable", "div");
    if (divs.length > 0) {
        var now = new Date();
        newwindow = window.open('', 'print'+now.getTime(), '');
        newwindow.document.writeln('<html><head>');
        newwindow.document.writeln('<meta http-equiv="Content-Type" content="text/html; charset=windows-1251"></meta>');
        newwindow.document.writeln('<title>Версия для печати</title>');

        newwindow.document.writeln('<link href="/styles/print.css" rel="stylesheet" type="text/css" />');

        newwindow.document.writeln('</head>');
        newwindow.document.writeln('<body>');
        for (var i=0; i<divs.length; i++) {
            newwindow.document.writeln('<div id="'+divs[i].id+'">');
            newwindow.document.writeln(KillLinks(divs[i]).innerHTML);
            newwindow.document.writeln('</div>');
        }
        newwindow.document.writeln('</body></html>');
        newwindow.document.close();
        if (window.focus) { newwindow.focus(); }
        return false;
    }
}
function KillLinks(el)
{
    var d=el.cloneNode(true);
    //alert(d.innerHTML);
    var list=d.getElementsByTagName("a");
    for(var i=0;i<list.length;i++)
    {
        list[i].href="javascript:;";
        list[i].onclick=new Function("");
	}
    return d;
}
function init_printver() {
    if ($('print_version') && $('print_version').firstChild) {
        addEvent($('print_version').firstChild, 'click', print_version, false);
    }
}

addEvent(window, 'load', init_printver, false);
