//alert('includes.js loaded');

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://archives.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('about-us.html', 'imageHere', 'About Us');
	mainNavArray[1] = new Array('visit.html', 'imageHere', 'Visit');
	mainNavArray[2] = new Array('search.html', 'imageHere', 'Search');
	mainNavArray[3] = new Array('research/browse.html', 'imageHere', 'Browse');
	mainNavArray[4] = new Array('research/index.html', 'imageHere', 'Research');
	mainNavArray[5] = new Array('recordsmanagement/index.html', 'imageHere', 'Records Management');
	mainNavArray[6] = new Array('src/src-members.html', 'imageHere', 'State Records Committee');
	mainNavArray[7] = new Array('public-notice.html', 'imageHere', 'Public Notices');
	mainNavArray[8] = new Array('USHRAB/index.html', 'imageHere', 'USHRAB');

var recordsmanagementNavArray = new Array();
	recordsmanagementNavArray[0] = new Array('index.html', 'imageHere', 'Archives Home');
	recordsmanagementNavArray[1] = new Array('search.html', 'imageHere', 'Search');
	recordsmanagementNavArray[2] = new Array('recordsmanagement/transferring-records.html', 'imageHere', 'Records Storage');
	recordsmanagementNavArray[3] = new Array('recordsmanagement/retention-schedule-menu.html', 'imageHere', 'Retention Schedules');
	recordsmanagementNavArray[4] = new Array('recordsmanagement/training.html', 'imageHere', 'Training');
	recordsmanagementNavArray[5] = new Array('micrographics/preservation-menu.html', 'imageHere', 'Preservation & Micrographics');
	recordsmanagementNavArray[6] = new Array('recordsmanagement/government-records-law.html', 'imageHere', 'Laws');
	recordsmanagementNavArray[7] = new Array('recordsmanagement/forms/forms.html', 'imageHere', 'Forms');
	recordsmanagementNavArray[8] = new Array('ask-us.html', 'imageHere', 'Contact Us');
	recordsmanagementNavArray[9] = new Array('recordsmanagement/guides-policies-menu.html', 'imageHere', 'Policies and Procedures');
	recordsmanagementNavArray[10] = new Array('emp/index.html', 'imageHere', 'Employee Portal');

var srcNavArray = new Array();
	srcNavArray[0] = new Array('index.html', 'imageHere', 'Archives Home');
	srcNavArray[1] = new Array('search.html', 'imageHere', 'Search');
	srcNavArray[2] = new Array('src/src-members.html', 'imageHere', 'SRC Members');
	srcNavArray[3] = new Array('src/src-meeting-notice.html', 'imageHere', 'Meeting Notices');
	srcNavArray[4] = new Array('src/srcappeals-1992-1994.html', 'imageHere', 'Decisions and Orders');
	srcNavArray[5] = new Array('http://archives.state.ut.us/cgi-bin/src.cgi?RUN-WHAT=SRC', 'imageHere', 'Pending Retention Schedules');
	srcNavArray[6] = new Array('http://www.rules.utah.gov/publicat/code/r035/r035.htm', 'imageHere', 'Administrative Rules');
	srcNavArray[7] = new Array('ask-us.html', 'imageHere', 'Contact Us');
	srcNavArray[8] = new Array('recordsmanagement/guides-policies-menu.html', 'imageHere', 'Policies and Procedures');
	srcNavArray[9] = new Array('emp/index.html', 'imageHere', 'Employee Portal');

var researchNavArray = new Array();
	researchNavArray[0] = new Array('index.html', 'imageHere', 'Archives Home');
	researchNavArray[1] = new Array('search.html', 'imageHere', 'Search');
	researchNavArray[2] = new Array('research/guides/index.html', 'imageHere', 'Research Guides');
	researchNavArray[3] = new Array('research/inventories/index.html', 'imageHere', 'Inventories');
	researchNavArray[4] = new Array('research/catalog.html', 'imageHere', 'Online Catalog');
	researchNavArray[5] = new Array('research/agencyhistories/index.html', 'imageHere', 'Agency Histories');
	researchNavArray[6] = new Array('research/indexes/index.html', 'imageHere', 'Name Indexes');
	researchNavArray[7] = new Array('digital/index.html', 'imageHere', 'Digital Archives');
	researchNavArray[8] = new Array('http://historyresearch.utah.gov', 'imageHere', 'Research Center');
	researchNavArray[9] = new Array('ask-us.html', 'imageHere', 'Contact Us');
	researchNavArray[10] = new Array('research/links/index.html', 'imageHere', 'Links');
	researchNavArray[11] = new Array('emp/index.html', 'imageHere', 'Employee Portal');

var ushrabmainNavArray = new Array();
	ushrabmainNavArray[0] = new Array('USHRAB/grant-menu.html', 'imageHere', 'Grant Program');
	ushrabmainNavArray[1] = new Array('USHRAB/forms-menu.html', 'imageHere', 'Forms');
	ushrabmainNavArray[2] = new Array('USHRAB/repositories-menu.html', 'imageHere', 'Repositories');
	ushrabmainNavArray[3] = new Array('USHRAB/consortium-menu.html', 'imageHere', 'Consortium');
	ushrabmainNavArray[4] = new Array('USHRAB/about-USHRAB-menu.html', 'imageHere', 'About USHRAB');
	ushrabmainNavArray[5] = new Array('USHRAB/links-menu.html', 'imageHere', 'Links and Resources');

var sampleNavArray = new Array();
	sampleNavArray[0] = new Array('index.html', 'imageHere', 'Archives Home');
	sampleNavArray[1] = new Array('about-us.html', 'imageHere', 'About the Archives');
	sampleNavArray[2] = new Array('search.html', 'imageHere', 'Search');
	sampleNavArray[3] = new Array('research/index.html', 'imageHere', 'Research');
	sampleNavArray[4] = new Array('recordsmanagement/index.html', 'imageHere', 'Records Management');
	sampleNavArray[5] = new Array('src/src-members.html', 'imageHere', 'State Records Committee');
	sampleNavArray[6] = new Array('public-notice.html', 'imageHere', 'Public Notices');
	sampleNavArray[7] = new Array('USHRAB/index.html', 'imageHere', 'Utah State Historical Records Advisory Board');
	sampleNavArray[8] = new Array('recordsmanagement/guides-policies-menu.html', 'imageHere', 'Policies and Procedures');
	sampleNavArray[9] = new Array('emp/index.html', 'imageHere', 'Employee Portal');

var ushrabsampleNavArray = new Array();
	ushrabsampleNavArray[0] = new Array('index.html', 'imageHere', 'Archives Home');
	ushrabsampleNavArray[1] = new Array('USHRAB/index.html', 'imageHere', 'USHRAB Home');

var secondaryNavArray = new Array();
	secondaryNavArray[0] = new Array('http://www.das.utah.gov', 'imageHere', 'DAS Home');
	secondaryNavArray[1] = new Array('about-us.html', '', 'About the Archives');
	secondaryNavArray[2] = new Array('FY2010-DAS-Archives-Service-Plan.pdf', '', 'Service Plan');
	secondaryNavArray[3] = new Array('search.html', 'imageHere', 'Search');
	secondaryNavArray[4] = new Array('research/browse.html', 'imageHere', 'Browse');
	secondaryNavArray[5] = new Array('research/index.html', 'imageHere', 'Research');
	secondaryNavArray[6] = new Array('recordsmanagement/index.html', 'imageHere', 'Records Management');
	secondaryNavArray[7] = new Array('src/src-members.html', 'imageHere', 'State Records Committee');
	secondaryNavArray[8] = new Array('public-notice.html', 'imageHere', 'Public Notices');
	secondaryNavArray[9] = new Array('USHRAB/index.html', 'imageHere', 'Utah State Historical Records Advisory Board');
	secondaryNavArray[10] = new Array('archivistresources.html', 'imageHere', 'Resources for Archivists');
	secondaryNavArray[11] = new Array('recordsmanagement/guides-policies-menu.html', 'imageHere', 'Policies and Procedures');
	secondaryNavArray[12] = new Array('emp/index.html', 'imageHere', 'Employee Portal');

var divisionNavArray = new Array();
 divisionNavArray[0] =  new Array('http://das.utah.gov', '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', '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', 'Navajo Royalties Holding Fund');

var footerNavArray = new Array();
	footerNavArray[0] =  new Array('', 'imageHere', 'Site Map');
	footerNavArray[1] =  new Array('ask-us.html', 'imageHere', 'Contact Us');
	footerNavArray[2] =  new Array('how-to-find-us.html', '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('search.html', 'imageHere', 'Search');
	sampleEmpNavArray[1] = new Array('emp/administration/administration.html', 'imageHere', 'Administration');
	sampleEmpNavArray[2] = new Array('emp/micrographics/micrographics.html', 'imageHere', 'Micrographics');
	sampleEmpNavArray[3] = new Array('emp/processing/processing.html', 'imageHere', 'Processing');
	sampleEmpNavArray[4] = new Array('emp/research/research.html', 'imageHere', 'Research');
	sampleEmpNavArray[5] = new Array('emp/recordsanalysis/recordsanalysis.html', 'imageHere', 'Records Analysis');
	sampleEmpNavArray[6] = new Array('emp/recordscenter/recordscenter.html', 'imageHere', 'Records Center');
	sampleEmpNavArray[7] = new Array('emp/src/src.html', 'imageHere', 'State Records Committee');

var empNavArray = new Array();
	empNavArray[0] = new Array('index.html', 'imageHere', 'Archives Home');
	empNavArray[1] = new Array('emp/appx/appx.html', 'imageHere', 'APPX');
	empNavArray[2] = new Array('emp/asrs/asrs.html', 'imageHere', 'ASRS');
	empNavArray[3] = new Array('emp/contentdm/contentdm.html', 'imageHere', 'CONTENTdm');
	empNavArray[4] = new Array('emp/phones/phones.html', 'imageHere', 'Phones');
	empNavArray[5] = new Array('emp/publicnoticewebsite/publicnoticewebsite.html', 'imageHere', 'Public Notices');
	empNavArray[6] = new Array('emp/stylemanual/stylemanual.html', 'imageHere', 'Style Manual');
	empNavArray[7] = new Array('emp/versatile/versatile.html', 'imageHere', 'Versatile');


/* ------------------------------------------------   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", "Archives 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-2"); 
 pageTracker._trackPageview(); 
}

function buildAddress() {
	var htmlCode = '';
	htmlCode += '<address>' + currentYear + ' &copy; Utah State Archives and Records Service<br />';
	htmlCode += 'Administrative Offices: 346 South Rio Grande, Salt Lake City, UT 84101-1106<br />';
	htmlCode += 'Research Center: 300 South Rio Grande, Salt Lake City, UT 84101-1106<br />';
	htmlCode += 'Phone: 801-531-3848 / Research Center Phone: 801-533-3535 / Fax: 801-531-3854 </address>';
	document.write(htmlCode);

}

function buildFooter() {
	var htmlCode = '';
	
	buildTextMenu(footerNavArray, 'no', 'no', 'dividerBrown');
	document.write('<br />');
	buildTextMenu(divisionNavArray, 'no', 'no', 'dividerBrown');
	document.write('<br />');
	buildTextMenu(uiiFooterNavArray, 'no', 'no', 'dividerBrown');
	
	//htmlCode += '<br />Copyright &#169; 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]-->';
	
	document.write(htmlCode);
}



/* ------------------------------------------------   UII Loader   ------------------------------------------------ */
function checkUIIblock() {
	if (uiiOverride == true) {
		document.getElementById('uiiStage').innerHTML = '<img src="common/images/uii/uiiLeft.gif" alt="Utah.gov" title="Utah.gov" />';
	}
}

function loadUII(pleaseLoad) {
 var htmlCode =  '';
 
 if (pleaseLoad == true && uiiOverride == false) {
  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>*/


































