/**
 * All functions that need to be run "onload"
 */

window.onload = function onLoadRun() {
	try {
		setExternalLinks();
		setPrintLink();
		// 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";
		}
	}
}

function setPrintLink() {
	if (! document.getElementById) {
		return;
	}

	var oPrintLink = document.getElementById("printit");

	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	= "";
	}
}

function changeFontSize(iIncrementer) {
  // Affected tags
  var lTagsToResize	= "p,li,h2";
  var aTagsToResize;
  var oTagList;
  
  aTagsToResize	= lTagsToResize.split(',');
  
  for (var i = 0; i < aTagsToResize.length; i++) {  
    var oTagList	= document.getElementsByTagName(aTagsToResize[i]);

    for (var n=0; n < oTagList.length; n++) {
      if (oTagList[n].style.fontSize) {
         var iSizeCurrent	= parseInt(oTagList[n].style.fontSize.replace("px", "") );
      } else {
         var iSizeCurrent	= 13;
      }
      oTagList[n].style.fontSize	= iSizeCurrent + iIncrementer + 'px';
    }
  }
}

function changeFontSizeMyGoc(iIncrementer) {
  // Affected tags
  var lTagsToResize	= "p,li,h2,h3,dt,dd";
  var aTagsToResize;
  var oTagList;
  
  aTagsToResize	= lTagsToResize.split(',');
  
  // Only resize page body fonts
  for (var i = 0; i < aTagsToResize.length; i++) {  
  	var oPageBody 	= document.getElementById('layer-body');
    var oTagList	= oPageBody.getElementsByTagName(aTagsToResize[i]);

    for (var n=0; n < oTagList.length; n++) {
      if (oTagList[n].style.fontSize) {
         var iSizeCurrent	= parseInt(oTagList[n].style.fontSize.replace("px", "") );
      } else {
         var iSizeCurrent	= 12;
      }
      oTagList[n].style.fontSize	= iSizeCurrent + iIncrementer + 'px';
    }
  }
}
