//alert('includes.js loaded');

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://finance.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('aboutus/index.html', 'imageHere', 'About Us');
	mainNavArray[1] = new Array('payroll/index.html', 'imageHere', 'Payroll');
	mainNavArray[2] = new Array('finet/index.html', 'imageHere', 'FINET');
	mainNavArray[3] = new Array('forms/index.html', 'imageHere', 'Forms');
	mainNavArray[4] = new Array('travel/index.html', 'imageHere', 'Travel');
	mainNavArray[5] = new Array('http://finance.utah.gov/warehouse/index.html', 'imageHere', 'Data Warehouse');
	mainNavArray[6] = new Array('reporting/index.html', 'imageHere', 'Financial Reporting');
	mainNavArray[7] = new Array('training/index.html', 'imageHere', 'Training');
	mainNavArray[8] = new Array('debt/index.html', 'imageHere', 'Debt Collection');
	/*mainNavArray[8] = new Array('transparency/index.html', 'imageHere', 'Transparency');*/
	mainNavArray[9] = new Array('http://efinance.utah.gov/evendor/', 'imageHere', 'eVendor');

var secondaryNavArray = new Array();
	secondaryNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	secondaryNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	secondaryNavArray[2] = new Array('documents/serviceplan.pdf', 'imageHere', 'Finance Service Plan');
	secondaryNavArray[3] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll?f=templates&amp;fn=default.htm&amp;vid=nxtpub:app1', 'imageHere', 'Accounting Policies and Procedures');
	secondaryNavArray[4] = new Array('newsletters/index.html', 'imageHere', 'Newsletters');
	secondaryNavArray[5] = new Array('transparency/index.html', 'imageHere', 'Transparency');
	secondaryNavArray[6] = new Array('refund/index.html', 'imageHere', 'Where\'s My Refund');
	secondaryNavArray[7] = new Array('http://email.state.ut.us/', 'imageHere', 'Groupwise');
	secondaryNavArray[8] = new Array('contact/index.php', 'imageHere', 'Send Us a Comment');
	secondaryNavArray[9] = new Array('', 'imageHere', '');
	secondaryNavArray[10] = new Array('', 'imageHere', '');
	
	secondaryNavArray[11] = new Array('emp/index.html', 'imageHere', 'Employee Portal');

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.php', 'imageHere', 'Contact Us');
	footerNavArray[2] =  new Array('parking.htm', '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');


var payrollNavArray = new Array();
	payrollNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	payrollNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	payrollNavArray[2] = new Array('payroll/index.html', 'imageHere', 'Payroll Home');
	payrollNavArray[3] = new Array('payroll/whotocall.html', 'imageHere', 'Who to Call');
	payrollNavArray[4] = new Array('training/payrolltrain.html', 'imageHere', 'Training');
	payrollNavArray[5] = new Array('payroll/payrollforms.html', 'imageHere', 'Payroll Forms');
	payrollNavArray[6] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll?f=templates&fn=default.htm&vid=nxtpub:apppay', 'imageHere', 'Payroll Policies and Procedures');
	payrollNavArray[7] = new Array('payroll/payrollemail.html', 'imageHere', 'Payroll Email List');
	payrollNavArray[8] = new Array('', '', '');
	payrollNavArray[9] = new Array('http://apps.finance.utah.gov/quest/payrollmanual.htm', 'imageHere', 'Payroll User Manual');
	payrollNavArray[10] = new Array('http://apps.finance.utah.gov/quest/payrollcodes.htm', 'imageHere', 'Payroll Codes');
	payrollNavArray[11] = new Array('http://apps.finance.utah.gov/quest/payrolldocs.htm', 'imageHere', 'Payroll Documents');
	/*payrollNavArray[12] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll/Payfiscalye/12008fye.pdf?f=templates$fn=default.htm$q=pfy$x=advanced', 'imageHere', 'Payroll Fiscal Year End');*/
	

	
var finetNavArray = new Array();
	finetNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	finetNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	finetNavArray[2] = new Array('http://apps.finance.utah.gov:8090/Quest/FINET_TR/training.htm', 'imageHere', 'FINET Training');
	finetNavArray[3] = new Array('http://apps.finance.utah.gov:8090/Quest/FINET/finance.htm', 'imageHere', 'FINET Help');
	finetNavArray[4] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll?f=templates&fn=default.htm&vid=nxtpub:app1', 'imageHere', 'Accounting Policies and Procedures');
	
	
var travelNavArray = new Array();
	travelNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	travelNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	travelNavArray[2] = new Array('travel/index.html', 'imageHere', 'Travel Home');
	travelNavArray[3]  = new Array('travel/contact.html', 'imageHere', 'Who to call');
	travelNavArray[4]  = new Array('newsletters/index.html', 'imageHere', 'Travel Newsletters');
	travelNavArray[5]  = new Array('travel/travelforms.html', 'imageHere', 'Travel Forms');
	travelNavArray[6]  = new Array('travel/findit.html', 'imageHere', 'FindIT Guide');
	travelNavArray[7] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll?f=templates&fn=default.htm&vid=nxtpub:apptravel', 'imageHere', 'State Policy & Procedure');
	travelNavArray[8]  = new Array('travel/traveltraining.html', 'imageHere', 'Travel Training');
	travelNavArray[9]  = new Array('travel/contact/index.php', 'imageHere', 'Send Your Comments');
	
var warehouseNavArray = new Array();
	warehouseNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	warehouseNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	warehouseNavArray[2] = new Array('http://datawarehouse.utah.gov/new_finet/index.htm', 'imageHere', 'New Data Warehouse (Fiscal Year 2007 to Current)');
	warehouseNavArray[3] = new Array('http://datawarehouse.utah.gov/index2.htm', 'imageHere', 'Old Data Warehouse (Fiscal Years 1995-2006)');
	
	
var reportingNavArray = new Array();
	reportingNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	reportingNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	reportingNavArray[2] = new Array('reporting/index.html', 'imageHere', 'Financial Reporting Home');
	reportingNavArray[3] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll?f=templates&amp;fn=default.htm&amp;vid=nxtpub:app1', 'imageHere', 'Accounting Policies and Procedures');
	reportingNavArray[4] = new Array('reporting/cafr.html', 'imageHere', 'CAFR');
	reportingNavArray[5] = new Array('reporting/highlights.html', 'imageHere', 'FY 2009 Financial Highlights');
	reportingNavArray[6] = new Array('http://smw1.finance.utah.gov/quest/coa.htm', 'imageHere', 'Chart of Accounts');
	reportingNavArray[7] = new Array('http://apps.finance.utah.gov/quest/ba.htm', 'imageHere', 'Budget and Accounting Officer Meeting Handouts');
	reportingNavArray[8] = new Array('http://apps.finance.utah.gov/quest/act.htm', 'imageHere', 'ACT Meeting Handouts');
	reportingNavArray[9] = new Array('reporting/bonds.html', 'imageHere', 'State Bonds');
	reportingNavArray[10] = new Array('training/finetclassroom.html#recorded', 'imageHere', 'Year End Training');
	
var trainingNavArray = new Array();
	trainingNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	trainingNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	trainingNavArray[2] = new Array('training/index.html', 'imageHere', 'Training Home');
	trainingNavArray[3] = new Array('', 'imageHere', 'About the Trainers');
	trainingNavArray[4] = new Array('training/payrolltrain.html', 'imageHere', 'Payroll Courses');
	trainingNavArray[5] = new Array('http://apps.finance.utah.gov:8090/Quest/FINET_TR/training.htm', 'imageHere', 'FINET Training');
	trainingNavArray[6] = new Array('training/finethelp.htm', 'imageHere', 'FINET Help');
	trainingNavArray[7] = new Array('http://apps.finance.utah.gov:8090/Quest/FINET_TR/finet_practice/main_page.htm', 'imageHere', 'FINET Practice');
	trainingNavArray[8] = new Array('training/datawarehousetraining.html', 'imageHere', 'Data Warehouse Courses');
	trainingNavArray[9]  = new Array('../travel/traveltraining.html', 'imageHere', 'Travel Training');
	/*trainingNavArray[10] = new Array('', 'imageHere', 'FineLine Training Articles');*/

	
	var newslettersNavArray = new Array();
	newslettersNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	newslettersNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	newslettersNavArray[2] = new Array('newsletters/archive.html#fineLine', 'imageHere', 'Past Issues of FineLine');
	newslettersNavArray[3] = new Array('newsletters/archive.html#travel', 'imageHere', 'Past Issues of Traveler Update');
	newslettersNavArray[4] = new Array('newsletters/finelineemail.html', 'imageHere', 'Sign Up for FineLine');
	newslettersNavArray[5] = new Array('newsletters/travelemail.html', 'imageHere', 'Sign Up for Traveler Update');
	
	
	var transparencyNavArray = new Array();
	transparencyNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	transparencyNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	transparencyNavArray[2] = new Array('http://www.utah.gov/transparency/index.html', 'imageHere', 'Utah Transparency website');
	transparencyNavArray[3] = new Array('transparency/mandate.html', 'imageHere', 'Mandate');
	transparencyNavArray[4] = new Array('http://www.le.state.ut.us/search.jsp?Sess=2009GS&String=sb18', 'imageHere', 'Current Legislation');
	transparencyNavArray[5] = new Array('transparency/otherstates.html', 'imageHere', 'Other Transparency Sites');
	transparencyNavArray[6] = new Array('transparency/minutes.html', 'imageHere', 'Transparency Board Meeting Minutes');
	transparencyNavArray[7] = new Array('transparency/documents/policylinks.pdf', 'imageHere', 'Policy');
	//transparencyNavArray[2] = new Array('transparency/timeline.html', 'imageHere', 'Timeline');


/* ---------------  employee section  --------------- */
var empNavArray = new Array();
	
	empNavArray[0] = new Array('http://employeegateway.utah.gov', 'imageHere', 'Employee Gateway');
	empNavArray[1] = new Array('http://das.utah.gov/policies.html', 'imageHere', 'DAS Employee Policies');
	empNavArray[2] = new Array('http://stateemployees.utah.gov', 'imageHere', 'ESS');
	empNavArray[3] = new Array('helpdesk', 'imageHere', 'Enter a Help Desk Request');
	empNavArray[4] = new Array('emp/newsletters.html', 'imageHere', 'Employee Newsletters');
	//empNavArray[5] = new Array('', 'imageHere', 'sampleEmpLink05');

var secondaryempNavArray = new Array();
	
	secondaryempNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	secondaryempNavArray[1] = new Array('index.html', 'imageHere', 'Finance Home');
	secondaryempNavArray[2] = new Array('http://www.rideuta.com/ridingUTA/schedules/routeSchedules.aspx', 'imageHere', 'UTA Bus Schedule');
	secondaryempNavArray[3] = new Array('http://www.rideuta.com/files/FrontRunnerApr08schedule.pdf', 'imageHere', 'Front Runner Schedule');
	secondaryempNavArray[4] = new Array('emp/documents/flexTimeAgreement.pdf', 'imageHere', 'Flexible Work Schedule Agreement');
	secondaryempNavArray[5] = new Array('emp/documents/exerciseAgreement.pdf', 'imageHere', 'Exercise Agreement');
	//secondaryempNavArray[4] = new Array('', 'imageHere', 'Employee Newsletters');
	//empNavArray[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", "Finance 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-8"); 
	pageTracker._trackPageview(); 
}


function buildAddress() {
	var htmlCode = '';
	htmlCode += '<address>' + currentYear + ' &copy; Division of Finance<br />';
	htmlCode += '2110 State Office Building/Capitol Hill Complex/450 North State Street/Salt Lake City, UT 84114<br />';
	htmlCode += 'Phone: 801-538-3082 / Fax: 801-538-3244</address>';
	document.write(htmlCode);
}


function buildFooter() {
	var htmlCode = '';
	buildTextMenu(footerNavArray, 'no', 'no', 'divider364600');
	document.write('<br />');
	buildTextMenu(divisionNavArray, 'no', 'no', 'divider364600');
	document.write('<br />');
	buildTextMenu(uiiFooterNavArray, 'no', 'no', 'divider364600');
	
	//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="../../common/script/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;'", 500);
	}
}
/*<script language="javascript" src="http://www.utah.gov/nav/fluidheader.js" type="text/javascript"></script>*/


































