/**
 * All functions that need to be run "onload"
 */

window.onload = function onLoadRun() {
	try {
		setExternalLinks();
		setPrintLink();
		setImageAlignment();
		// any other "onLoad" functions should be loaded here
	} catch (e) {
		var error_functiondoesntexist = 1;
	}
}


function setExternalLinks() {
	if (! document.getElementsByTagName) {
		return;
	}

	var anchors = document.getElementsByTagName("a");

	for (var i=0; i<anchors.length; i++) {
		var anchor = anchors[i];

	 	if (anchor.getAttribute("href") && 	anchor.getAttribute("rel") == "external") {
			anchor.target	= "_blank";
			anchor.title	= anchor.title + " (opens a new window)";
		}
	}
}


function setImageAlignment() {
	if (! document.getElementById) {
		return;
	}
	if (! document.getElementsByTagName) {
		return;
	}

	// Only images found on this layer will be modified
	var sLayer				= "columns";
	var oLayerMain		= document.getElementById(sLayer);
	var oImgNodeset	= oLayerMain.getElementsByTagName("img");

	for (var i=0; i<oImgNodeset.length; i++) {
		var oImg = oImgNodeset[i];

	 	if (oImg.getAttribute("align") ) {
	 		if (oImg.getAttribute("align") == "left") {
				oImg.className	= "left";
	 		}
	 		if (oImg.getAttribute("align") == "right") {
				oImg.className	= "right";
	 		}
			oImg.removeAttribute("align");
		}
	}
}

function setPrintLink() {
	if (! document.getElementById) {
		return;
	}

	var oPrintLink	= document.getElementById("printit");

	if (oPrintLink) {
		oPrintLink.href	= "javascript:window.print()";
	}
}


function setDefaultText(oInput) {
	// Based on a concept that the title attribute holds the same text as the default value
	if (! oInput.title) {
		return false;
	}
	
	if (oInput.value == oInput.title) {
		oInput.value	= "";
	}
}