function atoprint(aId) {
	var atext = document.getElementById(aId).innerHTML;
    var captext = window.document.title;
    var alink = window.document.location;
	
	atext = atext.replace('<a onclick="atoprint(\'print-d\');return false;" href="#"><img src="/img/des/fileprint.png" width="25"></a>', "");
	atext = atext.replace(/<a href="javascript:history\.back.*<\/a>/ig, "");
	
	var str = atext;
	var re =  /(\d{3,4})px/gi;
	var res;
	while ( (res = re.exec(str)) != null) {
		atext = atext.replace(res[0], "");	
		//alert("Найдено " + res[0] );
		//alert("Дальше ищу с позиции "+re.lastIndex);
	}
	
	var prwin = window.open();
prwin.document.open();  // Открываем документ для записи
prwin.document.writeln('<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">');

prwin.document.writeln('<html><head><meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /><title>Версия для печати<\/title><\/head><body text="#000000" bgcolor="#FFFFFF"><div onselectstart="return false;" oncopy="return false;" style="width:900px; border:0px solid red;">');
    prwin.document.writeln('<div style="margin-bottom:5px;"><a href="javascript://" onclick="window.print();">Печать<\/a> • <a href="javascript://" onclick="window.close();">Закрыть окно<\/a><\/div><hr>');
    prwin.document.writeln('<h1>'+captext+'<\/h1>');
    prwin.document.writeln(atext);
    prwin.document.writeln('<hr>');
    prwin.document.writeln('<div style="font-size:8pt;">Страница материала: '+alink+'<\/div>');
    prwin.document.writeln('<div style="margin-top:5px;"><a href="javascript://" onclick="window.print();">Печать<\/a> • <a href="javascript://" onclick="window.close();">Закрыть окно<\/a><\/div>');
    prwin.document.writeln('<\/div><\/body><\/html>');
	prwin.document.close();
return false;

}
