//alert('includes.js loaded');

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://unrhf.utah.gov/' //this is the path to root that we can use for building common elements

var uiiOverride = false; //false allows the uii banner to load. true turns it off. used with the loadUII() function below

var bannerSourceXML = globalPath + 'common/randomBanner/banners.xml'; // the source for the xml banners. this is used with loadBanner() below.

var theDate = new Date();
var currentYear = theDate.getYear();
if (currentYear < 2000) {
	currentYear += 1900;
}
//alert('currentYear = ' + currentYear);


var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");  //google analytics stuff
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); 



/* ------------------------------------------------   Menu Arrays   ------------------------------------------------ */
//in the arrays below, the first set of quotes is the url, the second is the graphical button, the third is the alt attribute and title value.
var mainNavArray = new Array();
	mainNavArray[0] = new Array('organization/index.html', 'imageHere', 'Organization');
	mainNavArray[1] = new Array('transparency/index.html', 'imageHere', 'Transparency');
	mainNavArray[2] = new Array('scholarships/index.html', 'imageHere', 'Scholarships and Financial Aid');
	mainNavArray[3] = new Array('programs/index.html', 'imageHere', 'Programs');
	mainNavArray[4] = new Array('projects/index.html', 'imageHere', 'Project Updates');
	mainNavArray[5] = new Array('links/index.html', 'imageHere', 'Native American Links');
	
var secondaryNavArray = new Array();
	secondaryNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	secondaryNavArray[1] = new Array('index.html', 'imageHere', 'UNRHF Home');
	secondaryNavArray[2] = new Array('trustees/index.html', 'imageHere', 'Board of Trustees');
	secondaryNavArray[3] = new Array('demographics/index.html', 'imageHere', 'Demographics');
	secondaryNavArray[4] = new Array('college/index.html', 'imageHere', 'Colleges & Universities');
	secondaryNavArray[5] = new Array('royalties/index.html', 'imageHere', 'Royalties');
	/*secondaryNavArray[6] = new Array('conference/index.html', 'imageHere', 'Annual Planning Conference');*/
	
	

var divisionNavArray = new Array();
	divisionNavArray[0] =  new Array('http://das.utah.gov/index.html', 'imageHere', 'DAS');
	divisionNavArray[1] =  new Array('http://archives.utah.gov', 'imageHere', 'Archives');
	divisionNavArray[2] =  new Array('http://debt.utah.gov', 'imageHere', 'Debt');
	divisionNavArray[3] =  new Array('http://dfcm.utah.gov', 'imageHere', 'Facilities');
	divisionNavArray[4] =  new Array('http://finance.utah.gov', 'imageHere', 'Finance');
	divisionNavArray[5] =  new Array('http://fleet.utah.gov', 'imageHere', 'Fleet');
	divisionNavArray[6] =  new Array('http://purchasing.utah.gov', 'imageHere', 'Purchasing');
	divisionNavArray[7] =  new Array('http://das.utah.gov/pd/index.html', 'imageHere', 'Parental Defense');
	divisionNavArray[8] =  new Array('http://risk.utah.gov', 'imageHere', 'Risk');
	divisionNavArray[9] =  new Array('http://rules.utah.gov', 'imageHere', 'Rules');
	divisionNavArray[10] = new Array('http://unrhf.utah.gov', 'imageHere', 'Utah Navajo Royalties Holding Fund');

var sampleNavArray = new Array();
	sampleNavArray[0] = new Array('', 'imageHere', 'sampleLink00');
	sampleNavArray[1] = new Array('', 'imageHere', 'sampleLink01');
	sampleNavArray[2] = new Array('', 'imageHere', 'sampleLink02');
	sampleNavArray[3] = new Array('', 'imageHere', 'sampleLink03');
	sampleNavArray[4] = new Array('', 'imageHere', 'sampleLink04');
	sampleNavArray[5] = new Array('', 'imageHere', 'sampleLink05');
	
var footerNavArray = new Array();
	footerNavArray[0] =  new Array('', 'imageHere', 'Site Map');
	footerNavArray[1] =  new Array('contact/index.html', 'imageHere', 'Contact Us');
	footerNavArray[2] =  new Array('', 'imageHere', 'Public Parking');

var uiiFooterNavArray = new Array();
	uiiFooterNavArray[0] =  new Array('http://www.utah.gov/', 'imageHere', 'Utah.gov Home');
	uiiFooterNavArray[1] =  new Array('http://www.utah.gov/disclaimer.html', 'imageHere', 'Utah.gov Terms of Use');
	uiiFooterNavArray[2] =  new Array('http://www.utah.gov/privacypolicy.html', 'imageHere', 'Utah.gov Privacy Policy');
	uiiFooterNavArray[3] =  new Array('http://www.utah.gov/accessibility.html', 'imageHere', 'Utah.gov Accessibility Policy');


/* ---------------  employee section  --------------- */
var sampleEmpNavArray = new Array();
	sampleEmpNavArray[0] = new Array('', 'imageHere', 'sampleEmpLink00');
	sampleEmpNavArray[1] = new Array('', 'imageHere', 'sampleEmpLink01');
	sampleEmpNavArray[2] = new Array('', 'imageHere', 'sampleEmpLink02');
	sampleEmpNavArray[3] = new Array('', 'imageHere', 'sampleEmpLink03');
	sampleEmpNavArray[4] = new Array('', 'imageHere', 'sampleEmpLink04');
	sampleEmpNavArray[5] = new Array('', 'imageHere', 'sampleEmpLink05');



/* ------------------------------------------------   Menu Functions   ------------------------------------------------ */
// !! this uses an array to build menu items. it relies on the global variable called globalPath (defined at top of page) to point to the current domain.
// Provide the array you want to build.
// Answer 'yes' to hardReturn if you want the menu organized as paragraphs
// Answer 'yes' to listItem if you want the menu organized as a list
function buildTextMenu(theArray, hardReturn, listItem, divider) { 
	var htmlCode = '';
	
	var listOpen = '';
	var listClose = '';
	var listItemBegin = '';
	var listItemEnd = '';
	var hardReturnBegin = '';
	var hardReturnEnd = '';
	var dividerClass = '';
	
	if (hardReturn == 'yes') {
		hardReturnBegin = '<p>';
		hardReturnEnd = '</p>';
	}
	
	if (listItem == 'yes') {
		listOpen = '<ul class="menuList">';
		listClose = '</ul>';
		listItemBegin = '<li>';
		listItemEnd = '</li>';
	}
	
	if (divider != 'none') {
		dividerClass = divider;
	}
	
	htmlCode += listOpen;
	
	for(i=0; i<theArray.length; i++) {
		if(i == theArray.length-1) {
			dividerClass = '';	
		}
		
		if( theArray[i][0].indexOf('http://') != -1 || theArray[i][0].indexOf('https://') != -1){ //check for absolute url
			htmlCode += hardReturnBegin + listItemBegin + '<a href="' + theArray[i][0] + '" alt="' + theArray[i][2] + '" title="' + theArray[i][2] + '" class="' + dividerClass + '">' + theArray[i][2] + '</a>' + listItemEnd + hardReturnEnd;
		} else { //if url is not absolute, then add the global path
			htmlCode += hardReturnBegin + listItemBegin + '<a href="' + globalPath + theArray[i][0] + '" alt="' + theArray[i][2] + '" title="' + theArray[i][2] + '" class="' + dividerClass + '">' + theArray[i][2] + '</a>' + listItemEnd + hardReturnEnd;
		}
	}
	
	htmlCode += listClose;
	//alert(htmlCode);
	
	document.write(htmlCode);
}


//buildGraphicMenu(mainNavArray);
function buildGraphicMenu(theArray) { // !! this uses an array to build menu items. it relies on the global variable called globalPath (defined at top of page) to point to the current domain. 
	var htmlCode = '';

	for(i=0; i<theArray.length; i++) {
		if( theArray[i][0].indexOf('http://') != -1 ){ //check for absolute url
			htmlCode += '<a href="' + theArray[i][0] + '"><img src="' + globalPath + theArray[i][1] + '" alt="' + theArray[i][2] + '" title="' + theArray[i][2] + '" /></a>';
		} else { //if url is not absolute, then add the global path
			htmlCode += '<a href="' + globalPath + theArray[i][0] + '"><img src="' + globalPath + theArray[i][1] + '" alt="' + theArray[i][2] + '" title="' + theArray[i][2] + '" /></a>';
		}
	}
	
	document.write(htmlCode);
}



/* ------------------------------------------------   Content   ------------------------------------------------ */
function loadBanner(sectionNumber) {
	var htmlCode = '';
	
	htmlCode += '<div id="flashBanner">';
	htmlCode += '<img src="' + globalPath + 'common/images/banners/bannerDefault.jpg" alt="Utah Department of Administrative Services" title="Utah Department of Administrative Services" />';
	htmlCode += '</div>';
	document.write(htmlCode);

	var so = new SWFObject(globalPath + "common/randomBanner/banner.swf", "UNTF Banner", "960", "73", "8", "#FFFFFF");
	so.addVariable("whatBannerSection", sectionNumber);
	so.addVariable("xmlSource", bannerSourceXML);
	so.write("flashBanner");
}



function addAnalytics() { //adds google anayltics
	var pageTracker = _gat._getTracker("UA-5219135-10"); 
	pageTracker._trackPageview(); 
}


function buildAddress() {
	var htmlCode = '';
	htmlCode += '<address>' + currentYear + ' &copy; Utah Navajo Royalties Holding Fund<br />';
	htmlCode += '151 East 500 North/Blanding, UT 84511<br />';
	htmlCode += 'Phone: 800-378-2050 / Fax: 435-678-1464</address>';
	document.write(htmlCode);

	
	
	
}


function buildFooter() {
	var htmlCode = '';
	
	buildTextMenu(footerNavArray, 'no', 'no', 'divider197C8A');
	document.write('<br />');
	buildTextMenu(divisionNavArray, 'no', 'no', 'divider197C8A');
	document.write('<br />');
	buildTextMenu(uiiFooterNavArray, 'no', 'no', 'divider197C8A');
	
	//htmlCode += '<br />Copyright © 2008 State of Utah - All rights reserved.';
	//document.write(htmlCode);
	
	addAnalytics();
}



/* ------------------------------------------------   IE Style   ------------------------------------------------ */
function ieStyle() {
	//alert('ieStyle() fired');
	var htmlCode = '';
	htmlCode += '<!--[if IE 5]><link href="' + globalPath + 'common/css/ieStyle.css" rel="stylesheet" type="text/css"><![endif]-->';
	htmlCode += '<!--[if IE 6]><link href="' + globalPath + 'common/css/ieStyle.css" rel="stylesheet" type="text/css"><![endif]-->';
	htmlCode += '<!--[if IE 7]><link href="' + globalPath + 'common/css/ieStyle7.css" rel="stylesheet" type="text/css"><![endif]-->';
	
	document.write(htmlCode);
}




/* ------------------------------------------------   UII Loader   ------------------------------------------------ */
function checkUIIblock() {
	if (uiiOverride == true) {
		document.getElementById('uiiStage').innerHTML = '<img src="' + globalPath + 'common/images/uii/uiiLeft.gif" alt="Utah.gov" title="Utah.gov" />';
	}
}

function loadUII(pleaseLoad) {
	var htmlCode =  '';

	if (pleaseLoad == true && uiiOverride == false) {
		//alert("pleaseLoad = true");
		document.getElementById('uiiBanner').innerHTML = document.getElementById('uiiStage').innerHTML;
		setTimeout("document.getElementById('uiiStage').innerHTML = '&nbsp;'", 400);
	}
}
/*<script language="javascript" src="http://www.utah.gov/nav/fluidheader.js" type="text/javascript"></script>*/


































