// English Page Utilites

// Print window function
function printPage() {
dcsMultiTrack('DCS.dcsuri','/print'+document.location.pathname,'WT.ti','PRINT:'+document.title,'WT.dl','0');
	window.print();
	return false;
}


var addthis_pub = 'usagov';
var addthis_clickout = true;

function addAddthisLink(utilList) {
	var addthisLI = document.createElement("li");
	var addthisLink = document.createElement("a");
	var addthisImage = document.createElement("img");
	
	if ( typeof(preview) != "undefined" && preview ) {
		addthisImage.setAttribute("src","/gsacma/secure/content/previewStatic.jsp?path=/images/bookmark-addthis.gif");
	}
	else {
		addthisImage.setAttribute("src","/images/bookmark-addthis.gif");
	}
	addthisImage.setAttribute("width","125");
	addthisImage.setAttribute("height","19");
	addthisImage.setAttribute("border","0");
	addthisImage.setAttribute("alt","Bookmark this page");
	addthisImage.setAttribute("style","padding-top: 5px");
	
	addthisLink.setAttribute("href","http://www.addthis.com/bookmark.php");
	addthisLink.setAttribute("target","_blank");
	addthisLink.onclick = function() {
		addthis_url = location.href; 
		addthis_title = document.title; 
		return addthis_click(this);
	}
	
	addthisLink.appendChild(addthisImage);
	addthisLI.appendChild(addthisLink);
	utilList.appendChild(addthisLI);
	
	addthisScript = document.createElement("script");
	addthisScript.setAttribute("type","text/javascript");
	addthisScript.setAttribute("src","http://s9.addthis.com/js/widget.php?v=10");

	utilList.parentNode.appendChild(addthisScript);
}

// Define existing elements in the document
var utilDiv = document.getElementById('util');

var unorderedList;
var secondLi;
//For browsers that treat new lines as text nodes, need to check if utilDiv.firstChild is an element
//nodeType of 1 means it's an element
if (utilDiv.firstChild.nodeType != 1) { 
//if utilDiv.firstChild is not an element, get it's sibling (treat new lines as nodes)
	unorderedList = utilDiv.firstChild.nextSibling;
	secondLi = unorderedList.childNodes[2];
}
else{ 
//else utilDiv.firstChild is an element, so good to go
	unorderedList = utilDiv.firstChild;
	secondLi = unorderedList.childNodes[1];
}
	
// Change font size section
var fontDiv = document.createElement('div');
var fontText = document.createTextNode('Change text size: ');
var anchorOne = document.createElement('a');
var anchorTwo = document.createElement('a');
var anchorThree = document.createElement('a');

fontDiv.setAttribute('id', 'text_Size');

//check current selected font size
var curA = Get_Cookie("styleSuffix");

if (curA != null && curA != '') {
	anchorOne.setAttribute('href', '#');
	anchorOne.onclick = function() { changeStyle(0); };
}
else {
	anchorOne.onclick = function() { return false; };
}
anchorOne.setAttribute('id', 'normalFont');
anchorOne.setAttribute('title', 'Set page to normal font size');
anchorOne.appendChild(document.createTextNode('A'));

if (curA != '-125') {
	anchorTwo.setAttribute('href', '#');
	anchorTwo.onclick = function() { changeStyle(1); };
}
else {
	anchorTwo.onclick = function() { return false; };
}
anchorTwo.setAttribute('id', 'mid');
anchorTwo.setAttribute('title', 'Increase font size by 150 percent');
anchorTwo.appendChild(document.createTextNode('A'));

if (curA != '-150') {
	anchorThree.setAttribute('href', '#');
	anchorThree.onclick = function() { changeStyle(2); };
}
else {
	anchorThree.onclick = function() { return false; };
}
anchorThree.setAttribute('id', 'large');
anchorThree.setAttribute('title', 'Increase font size by 200 percent');
anchorThree.appendChild(document.createTextNode('A'));

fontDiv.appendChild(fontText);
fontDiv.appendChild(anchorOne);
fontDiv.appendChild(document.createTextNode('\u00a0'));
fontDiv.appendChild(anchorTwo);
fontDiv.appendChild(document.createTextNode('\u00a0'));
fontDiv.appendChild(anchorThree);

// Print this page section
var printLi = document.createElement('li');
var printAnchor = document.createElement('a');
var printTitle = 'Print this page';
var printText = document.createTextNode(printTitle);

printAnchor.setAttribute('href', '#');
printAnchor.setAttribute('title', printTitle);
printAnchor.onclick = printPage;

printAnchor.appendChild(printText);
printLi.appendChild(printAnchor);

// Write the new elements to the page
utilDiv.parentNode.insertBefore(fontDiv, utilDiv);
unorderedList.insertBefore(printLi, secondLi);

addAddthisLink(unorderedList);
