var gAutoPrint = false; // Flag for whether or not to automatically call the print function

function printSpecial() {
    if (document.getElementById != null) {
        var html = '<html>\n<head>\n<title>\n';

        if (document.getElementsByTagName != null) {
            var headTags = document.getElementsByTagName("title");
            if (headTags.length > 0)
                html += headTags[0].innerHTML;
        }
        html += '\n</title>';
        html += '\n<link rel="stylesheet" type="text/css" href="http://cs.roosevelt.edu/homeStyle.css">';
        html += '\n</head>\n<body>\n<img src="http://www.roosevelt.edu/images/logo.jpg">';
        
        var printReadyElem = document.getElementById("printReady");
        
        if (printReadyElem != null)    {
                html += printReadyElem.innerHTML;
        } else {
            alert("Could not find the printReady section in the HTML");
            return;
        }
        
        html += '\n</body>\n</html>';
        
        var printWin = window.open("","printSpecial");
        printWin.document.open();
        printWin.document.write(html);
        printWin.document.close();
        if (gAutoPrint)
            printWin.print();
    } else {
        alert("Sorry, the print ready feature is only available in modern browsers.");
    }
}

function init() {
    if ((document.getElementById != null) && (document.getElementsByTagName != null)) {
		var printerFriendly = document.getElementById("printerFriendly");
		var i, links = printerFriendly.getElementsByTagName("a"), linksLen = links.length;
		for (i = 0; i < linksLen; i++) {
			if(links[i].href.indexOf(".pdf") == -1) {
				addEvent(links[i], "click", function(evt){printSpecial(); cancelEvent(evt, true);}, false);
			}
		}
	}
}
addEvent(window, "load", init, false);