var gAutoPrint = true; // Tells whether to automatically call the print function

function printSpecial(element, header) {
    //alert(document.getElementById("printlink").href);
    //document.getElementById("printlink").href = "Javascript:window.print(); return false;"

    if (document.getElementById != null) {
        var html = '<HTML>\n<HEAD>\n';
    }
    /*
    if (document.getElementsByTagName != null) {
        var headTags = document.getElementsByTagName("head");
        var headTags = document.getElementById("printhead").innerHTML;
        alert(headTags);
        if (headTags.length > 0) {
            html += headTags[0].innerHTML;
            html += headTags;
        }
    }
    */
    html += '<link rel="STYLESHEET" href="nrk-dpi2.css" type="text/css">';
    html += '\n</HEAD>\n<BODY onload="window.focus();">\n';
    //html += "<p><a href='#' onClick='window.print();window.close();return false;'>print</a></p>"
    html += header;
    //var printReadyElem = document.getElementById("printReady");
    var printReadyElem = document.getElementById(element);
    if (printReadyElem != null) {
        html += printReadyElem.innerHTML;
        html += "<p style=\"margin-top:30pt;\"><hr color=\"#C0C0C0\"><font color=\"#C0C0C0\" style=\"font-size:7pt;\">Deze informatie is onderdeel van de website \"Innoveer met polymeer\", te vinden op <b>http://www.innoveermetpolymeer.nl</b>. Federatie NRK en alle andere partijen die aan deze website hebben bijgedragen geven geen garantie voor de juistheid en/of volledigheid van gegevens, ontwerpen, constructies, producten of productiemethoden voorkomende of beschreven op deze website, noch voor de geschiktheid daarvan voor enige bijzondere toepassing. De praktijkvoorbeelden zijn uitsluitend bedoeld ter informatie. De keuze impliceert geen goedkeuring van de zijde van de Federatie NRK.</font></p>"
    } else {
        alert("Er is een fout opgetreden, probeer het opnieuw.");
        return;
    }

    html += '\n</BODY>\n</HTML>';

    var printWin = null;
    w = 800;
    h = 600;
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
    printWin = window.open("", 'printversie', settings);

    //var printWin = window.open("","printSpecial");
    //printWin.document.open();

    printWin.document.write(html);
    printWin.document.close();
    if (gAutoPrint) {
        printWin.print();
        printWin.close();
    } else {
        alert("Alleen als u een Internet Explorer gebruikt wordt de pagina vanzelf afgedrukt.\nAls dat niet het geval is kunt u met de rechterknop van uw muis in het venster klikken en dan kiezen voor de optie 'Afdrukken';");
    }

}

function printSpecial2(element, header) {
    //alert(document.getElementById("printlink").href);
    //document.getElementById("printlink").href = "Javascript:window.print(); return false;"

    if (document.getElementById != null) {
        var html = '<HTML>\n<HEAD>\n';
    }
    if (document.getElementsByTagName != null) {
        var headTags = document.getElementsByTagName("head");
        if (headTags.length > 0) {
            html += headTags[0].innerHTML;
        }
    }
    html += '\n<SCRIPT language="JavaScript1.2" src="js/tooltip.js" type="text/javascript"></SCRIPT>';
    html += '\n</HEAD>\n<BODY onload="window.focus();">\n';
    html += '<DIV id="TipLayer" style="visibility:hidden;position:absolute;z-index:1000;top:-100;"></DIV>\n';
    html += '<SCRIPT language="JavaScript1.2" src="js/tooltipstyle.js" type="text/javascript"></SCRIPT>';

    //html += "<p style='margin-left:20pt;'><b><a href='#' onClick='window.print();window.close();return false;'>print</a></b></p>"
    //html += "<table width='100%'><tr><td align='left'>"+header+"</td><td>";
    //html += "<td align='right'><b><a href='#' onClick='window.print();window.close();return false;'>Klik hier om deze pagina af te drukken.</a></b></td></tr></table>";
    html += "<p style='margin-bottom:20pt;margin-top:10pt;margin-left:30px'><b><a href='#' onClick='window.print();window.close();return false;'>» Klik nu hier om deze pagina af te drukken</a></b></p>";
    html += header


    var printReadyElem = document.getElementById(element);
    if (printReadyElem != null) {
        html += printReadyElem.innerHTML;
    } else {
        alert("Could not find the printReady function");
        return;
    }

    html += '\n</BODY>\n</HTML>';

    var printWin = null;
    w = 800;
    h = 600;
    LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
    TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
    settings ='height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars=yes,resizable';
    printWin = window.open("", 'printversie', settings);

    //var printWin = window.open("","printSpecial");
    //printWin.document.open();

    printWin.document.write(html);
    printWin.document.close();
    if (gAutoPrint) {
        //printWin.print();
        //printWin.close();
    } else {
        alert("The print ready feature is only available if you are using an browser. Please update your browswer.");
    }

}
