// JavaScript Document


// START
//"Print this page" function

var gAutoPrint = true; // Flag for whether or not to automatically call the print function

function printSpecial()
{
	if (document.getElementById != null)
	{
		var html = '<HTML>\n<HEAD>\n';  
		var stylesheet = '<link href="/css/printPage.css" rel="stylesheet" type="text/css" />\n';    
		var header = '<img src="/images/Print_Banner-UofM.gif" alt="Print Ready U of M Header">\n<img src="/images/Print_Banner-CTSthin.jpg" alt="Print Ready CTS-Thin Header">\n<img src="/images/Print_Banner-ITS.jpg" alt="Print Ready ITS Institute Header">';
		var footer = '<img src="/images/Print_Footer.gif" alt="Print Ready Footer">\n';

		html +=  stylesheet + '</HE' + 'AD>\n<BODY>\n';
		
		var printReadyElem = document.getElementById("centerColumn");
		
		if (printReadyElem != null)
		{
				html += header;
				html += printReadyElem.innerHTML;
				html += footer;
				
		}
		else
		{
			alert("Could not find the centerColumn section in the HTML");
			
			return;
		}
			
		

		
		html += '\n</BO' + 'DY>\n</HT' + 'ML>';
		
		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 Internet Explorer 4+ and Netscape 6+.");
	}
}

// END
//"Print this page" function




// START
// "E-mail this page" function


function promptAndEmail() {

	var BodyText='You may be interested in reading more about ' +document.title + ' from the Inteligent Transportation Systems (ITS) Institute at the University of Minnesota: ' +window.location;
	var name= prompt('Please enter your name for the e-mail',' ');
	var SubjectLine='ITS Institute Web page sent by '+name;
	var url = 'mailto:?SUBJECT='+(SubjectLine)+'&BODY='+(BodyText);
	window.location = url;

}

// END
// "E-mail this page" function

// START
// "Fact Sheet Printing" function
/*
addPrintLink function by Roger Johansson, www.456bereastreet.com
*/
var addPrintLink = {
	init:function(sTargetEl,sLinkText) {
		if (!document.getElementById || !document.createTextNode) {return;} // Check for DOM support
		if (!document.getElementById(sTargetEl)) {return;} // Check that the target element actually exists
		if (!window.print) {return;} // Check that the browser supports window.print
		var oTarget = document.getElementById(sTargetEl);
		var oLink = document.createElement('a');
		oLink.id = 'print-link'; // Give the link an id to allow styling
		oLink.href = '#'; // Make the link focusable for keyboard users
		oLink.appendChild(document.createTextNode(sLinkText));
		oLink.onclick = function() {window.print(); return false;} // Return false prevents the browser from following the link and jumping to the top of the page after printing
		oTarget.appendChild(oLink);
	},
/*
addEvent function included here for portability. Replace with your own addEvent function if you use one.
*/
/* addEvent function from http://www.quirksmode.org/blog/archives/2005/10/_and_the_winner_1.html */
	addEvent:function(obj, type, fn) {
		if (obj.addEventListener)
			obj.addEventListener(type, fn, false);
		else if (obj.attachEvent) {
			obj["e"+type+fn] = fn;
			obj[type+fn] = function() {obj["e"+type+fn](window.event);}
			obj.attachEvent("on"+type, obj[type+fn]);
		}
	}
};
addPrintLink.addEvent(window, 'load', function(){addPrintLink.init('article','Print this page');});

// END
// "Fact Sheet Printing" function
