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

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://veterans.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('index.html', 'imageHere', 'Home');
	mainNavArray[1] = new Array('outreach/index.html', 'imageHere', 'Outreach');
	mainNavArray[2] = new Array('cemetery/index.html', 'imageHere', 'Cemetery');
	mainNavArray[3] = new Array('nursingHome/index.html', 'imageHere', 'Nursing Home');
	mainNavArray[4] = new Array('education/index.html', 'imageHere', 'Education');
	mainNavArray[5] = new Array('https://veterans.utah.gov/forms/registration.php', 'imageHere', 'Register With Us ');
	mainNavArray[6] = new Array('whoweare/index.html', 'imageHere', 'Who We Are');
	mainNavArray[7] = new Array('communityevents/index.html', 'imageHere', 'Community Events');

var homeNavArray = new Array();
	homeNavArray[0] = new Array('homepage/stateBenefits/index.html', 'imageHere', 'State Benefits');
	homeNavArray[1] =  new Array('homepage/federalBenefits/index.html', 'imageHere', 'Federal Benefits');
	homeNavArray[2] =  new Array('homepage/medicalBenefits/index.html', 'imageHere', 'Medical Benefits');
	homeNavArray[3] =  new Array('homepage/servicesRights/index.html', 'imageHere', 'Employment Services & Rights');
	homeNavArray[4] =  new Array('homepage/faq/index.html', 'imageHere', 'FAQ');
	homeNavArray[5] =  new Array('homepage/iraqAfghVets/index.html', 'imageHere', 'Iraq & Afghanistan Veterans');
	homeNavArray[6] =  new Array('homepage/womenVets/index.html', 'imageHere', 'Women Veterans');
	homeNavArray[7] =  new Array('outreach/councilMeetings/index.html', 'imageHere', 'Advisory Board Meetings and Minutes');
	homeNavArray[8] =  new Array('homepage/misc/index.html', 'imageHere', 'Miscellaneous Information');
	homeNavArray[9] =  new Array('outreach/upcomingEvents/index.html', 'imageHere', 'New Upcoming Events');
	homeNavArray[10] =  new Array('outreach/recentEvents/index.html', 'imageHere', 'Recent Events');
	homeNavArray[11] =  new Array('nursingHome/ogden/documents/BrickOrderForm.pdf', 'imageHere', 'Order a Personalized Memorial Brick');
	homeNavArray[12] =  new Array('homepage/links/index.html', 'imageHere', 'Links');

var outreachNavArray = new Array();
	outreachNavArray[0] =  new Array('outreach/schedules/index.html', 'imageHere', 'Schedules, Locations & Contact Information');
	outreachNavArray[1] =  new Array('outreach/upcomingEvents/index.html', 'imageHere', 'Upcoming Events');
	outreachNavArray[2] =  new Array('outreach/recentEvents/index.html', 'imageHere', 'Recent Events');
	outreachNavArray[3] =  new Array('outreach/councilMeetings/index.html', 'imageHere', 'Advisory Board Meetings and Minutes');

var cemeteryNavArray = new Array();
	cemeteryNavArray[0] =  new Array('cemetery/burialBenefits/index.html', 'imageHere', 'Burial Benefits & Information');
	cemeteryNavArray[1] =  new Array('cemetery/militaryHonors/index.html', 'imageHere', 'Military Funeral Honors');

var nursinghomeNavArray = new Array();
	nursinghomeNavArray[0] =  new Array('nursingHome/saltLakeCity/index.html', 'imageHere', 'Salt Lake City');
	nursinghomeNavArray[1] =  new Array('nursingHome/ogden/index.html', 'imageHere', 'Ogden');

var ogdenNavArray = new Array();
	ogdenNavArray[0] =  new Array('nursingHome/ogden/donations.html', 'imageHere', 'Donations & Pledges');

var educationNavArray = new Array();
	educationNavArray[0] =  new Array('education/educationBenefits/index.html', 'imageHere', 'Education Benefit Information');
	educationNavArray[1] =  new Array('education/scholarships/index.html', 'imageHere', 'Scholarships & Grants');
	educationNavArray[2] =  new Array('education/schoolInfo/index.html', 'imageHere', 'Information for Schools');

var commEventsNavArray = new Array();
	commEventsNavArray[0] =  new Array('index.html', 'imageHere', 'Home');

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');


/* ------------------------------------------------   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", "DAS Banner", "960", "73", "8", "#FFFFFF");
	so.addVariable("whatBannerSection", sectionNumber);
	so.addVariable("xmlSource", bannerSourceXML);
	so.addVariable("showSourcePath", false);
	so.write("flashBanner");
}


function addAnalytics() { //adds google anayltics
	var pageTracker = _gat._getTracker("UA-5219135-1"); 
	pageTracker._trackPageview(); 
}


function buildAddress() {
	var htmlCode = '';
	htmlCode += '550 Foothill Blvd. #202, Salt Lake City, UT 84113&nbsp;&nbsp;&nbsp;Toll Free (800) 894-9497&nbsp;&nbsp;&nbsp;(801) 326-2372&nbsp;&nbsp;&nbsp;Fax (801) 326-2369&nbsp;&nbsp;&nbsp;<a href="mailto:veterans@utah.gov">veterans@utah.gov</a>&nbsp;&nbsp;&nbsp;<address>' + currentYear + ' &copy; Utah Department of Veteran Affairs<br />';
	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 © 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/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;
		document.getElementById('uiiStage').innerHTML = ' ';
	}
}
/*<script language="javascript" src="http://www.utah.gov/nav/fluidheader.js" type="text/javascript"></script>*/



































