function fNewPDFWindows ()
{
	if (!document.getElementsByTagName) return false;
	var links = document.getElementsByTagName("a");
	for (var eleLink=0; eleLink < links.length; eleLink ++) {
		if ((links[eleLink].href.indexOf('.pdf') !== -1) || (links[eleLink].getAttribute("rel") == "external")) {
			links[eleLink].onclick = function() {
 				window.open(this.href,'PDF','resizable,scrollbars');
 				return false;
			}
			if (links[eleLink].href.indexOf('.pdf') !== -1) {
				pdfWarn = "[PDF] ";
			} else {
				pdfWarn = "";
			}
			if (links[eleLink].getAttribute("title")) { // try to get attribute - if null or empty, will return false. This has much better compatibility than hasAttribute or other methods.
				existTitle = links[eleLink].getAttribute("title") + " ";
			} else {
				existTitle = "";
			}
			links[eleLink].setAttribute("title", existTitle + pdfWarn + "(opens in a new window)");
			for (var i=0; i < links[eleLink].childNodes.length; i ++) {
				thiscNode = links[eleLink].childNodes[i];
				if (thiscNode.nodeType == 1 && /img/i.test(thiscNode.nodeName))
				{
					if (thiscNode.getAttribute("alt")) {
						existAlt = thiscNode.getAttribute("alt") + " ";
					} else {
						existAlt = "";
					}
					if (thiscNode.getAttribute("title")) {
						existTitle = thiscNode.getAttribute("title") + " ";
					} else {
						existTitle = "";
					}
					thiscNode.setAttribute("alt", existAlt + pdfWarn + "(opens in a new window)");
					thiscNode.setAttribute("title", existTitle + pdfWarn + "(opens in a new window)");
				} else {
					var img = document.createElement("img");
 					img.setAttribute("src", "/images/structure/new-win-icon.gif");
 					img.setAttribute("alt", "(opens in a new window)");
 					links[eleLink].appendChild(img);
				}
			}
		}
	}
}

function addLoadEvent(func)
{
	var oldonload = window.onload;

	if (typeof window.onload != 'function')

	{
		window.onload = func;
	} else {
		window.onload = function()
		{
			oldonload();
			func();
 		}
	}
}
addLoadEvent(fNewPDFWindows);

