﻿/*    
    print.js
    ===============================================================
    NSU - Print functions
    
    Created 24.03.2009 by DS    
    Last Updated: See SVN        
    
    @ print_page    
    @ add_print_button
    _______________________________________________________________
*/
    var printable = true; // optional flag that could be set on a per-page basis, eg in the page header
    function print_page()
    {
        window.print();
    }    
    
    function add_print_button()
    {
        if (!document.getElementById || !document.getElementsByTagName || !document.createElement || !document.replaceChild)
        {
            return;
        }        
        if (document.getElementById('print'))
        {
            return;
        }
        
        if ((document.getElementById('toolsNav')) && (printable))
        {        
            var print_li = document.createElement('li');
                    print_li.setAttribute('id', 'print');            
            var button = document.createElement('button');
                    button.setAttribute('type', 'button');        
                    button.setAttribute('alt', 'Print page. ');                            
                    add_event(button, 'click', print_page, false);                
                    
            var img = document.createElement('img');
                    img.setAttribute('src', '/Resources/Common/ft_print.gif');
                    img.setAttribute('width', '102');
                    img.setAttribute('height', '32');        
                    img.setAttribute('alt', 'Print page. ');    
            
                    button.appendChild(img);                    
                    print_li.appendChild(button);                    
            var backtotop = document.getElementById('toolsNav').getElementsByTagName('li')[0];
            backtotop.parentNode.insertBefore(print_li,backtotop);        
        }
    }    
    
    add_load_event(add_print_button);