function add_print_link(navID) { var nav = document.getElementById(navID); if (nav) { var lnk = document.createElement('a'); lnk.onclick = function(){ setPrintCSS(true); }; lnk.setAttribute('href', '#print'); lnk.style.border = 0; lnk.appendChild(document.createTextNode('Версия для печати')); nav.appendChild(lnk); } } function setPrintCSS(isPrint) { if (document.getElementsByTagName) x = document.getElementsByTagName('link'); else if (document.all) x = document.all.tags('link'); else { alert('Простите, этот скрипт не работает в Вашем браузере'); return; } for (i = 0, len = x.length; i < len; i++) { if(x[i].title == 'print') x[i].disabled = !isPrint; if(x[i].title == 'screen') x[i].disabled = isPrint; } if (isPrint) { var center = document.getElementById('center'); if (center) { var pTop = document.createElement('div'); pTop.id = 'ptop'; var lnk1 = document.createElement('a'); lnk1.onclick = function(){ setPrintCSS(false); }; lnk1.setAttribute('href', '#header'); lnk1.appendChild(document.createTextNode('Вернуться к стандартному виду страницы')); var lnk2 = document.createElement('a'); lnk2.onclick = function(){ window.print(); }; lnk2.setAttribute('href', '#'); lnk2.appendChild(document.createTextNode('Распечатать')); pTop.appendChild(lnk1); pTop.appendChild(lnk2); center.parentNode.insertBefore(pTop, center); } } else { var pTop = document.getElementById('ptop'); pTop.parentNode.removeChild(pTop); } } function stripe() { var table = document.getElementsByTagName('table'); for (i = 0, len1 = table.length; i < len1; i++) { if (table[i].className == 't1' || table[i].className == 't2') { var trs = table[i].getElementsByTagName('tr'); for (k = 0, len2 = trs.length; k < len2; k+=2) { trs[k].className += ' even'; } } } } function rowstolinks() { var table = document.getElementsByTagName('table'); for (i = 0, len1 = table.length; i < len1 ; i++) { if (table[i].className == 't1') { var trs = table[i].getElementsByTagName('tr'); for (k = 0, len2 = trs.length; k < len2; k++) { var link = trs[k].getElementsByTagName('a') if (link.length == 1) { trs[k].onclick = new Function("document.location.href='" + link[0].href + "'"); trs[k].onmouseover = new Function("this.className='highlight'; window.status='" + link[0].href + "';"); trs[k].onmouseout = new Function("this.className='" + trs[k].className + "'; window.status='';"); } } } } } function pop(iUrl, winW, winH, winN) { var iWidth = (winW)? winW : 600; var iHeight = (winH)? winH : 500; var iTitle = (winN)? winN : 'popupWin'; var scrollB = 'no'; var posCode = ''; if(screen) { var scrW = screen.width ? screen.width - 100 : 0; var scrH = screen.height ? screen.height - 100 : 0; if( scrW < iWidth ) { scrollB = 'yes'; iWidth = scrW; } else { scrW = screen.width } if( scrH < iHeight ) { scrollB = 'yes'; iHeight = scrH; } else { scrH = screen.height } var posX = Math.round( ( scrW - iWidth ) / 2 ); var posY = Math.round( ( scrH - iHeight ) / 2 ); posCode = ',left='+posX+',top='+posY; } iOptions = 'width=' + iWidth + ',height=' + iHeight + ',scrollbars=' + scrollB + ',resizable=yes,toolbar=no,status=yes' + posCode; if(iUrl.match(/\.(gif|jpe?g|png)$/i)) { popWin = window.open('', '_blank', iOptions); popWin.document.open(); popWin.document.write('' + iTitle + '' + '
' + '
' ); popWin.document.close(); } else { popWin = window.open(iUrl, iTitle, iOptions); } popWin.focus(); return false; } function runScripts() { add_print_link('nav1'); stripe(); rowstolinks(); if (document.location.hash == '#print') setPrintCSS(true); } window.onload = runScripts;