



/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://health.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 ie7 = false; //this is set with a ie conditional statement in ieStye() (below). it's a great way to find out if the user is browsing with ie7. i'm using it a2z.js to set coordinates. 

var theDate = new Date();
var currentYear = theDate.getYear();
if (currentYear < 2000) {
	currentYear += 1900;
}
//alert('currentYear = ' + currentYear);

function addDate() {
	var theDay = theDate.getDate();
	//alert(theDay);
	
	var  month = new Array(12);
		month[0]="January";
		month[1]="February";
		month[2]="March";
		month[3]="April";
		month[4]="May";
		month[5]="June";
		month[6]="July";
		month[7]="August";
		month[8]="September";
		month[9]="October";
		month[10]="November";
		month[11]="December";
		
	var theMonth =  month[theDate.getMonth()];
	
	document.getElementById("month").innerHTML = theMonth;
	document.getElementById("day").innerHTML = theDay;
	//alert(theMonth);

	//alert("The current month is " + month[theDate.getMonth()]);
}



//google analytics stuff
//var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
//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.

// .push({theLink:'', theImage:'imageHere', theName:''});


var  mainNavArray = new Array();
	mainNavArray.push({theLink:'index.html', theImage:'imageHere', theName:'Home'});
	mainNavArray.push({theLink:'services/index.html', theImage:'imageHere', theName:'Health Services'});
	mainNavArray.push({theLink:'a-z/index.html', theImage:'imageHere', theName:'A-Z List'});
	mainNavArray.push({theLink:'faq/index.html', theImage:'imageHere', theName:'FAQ'});
	mainNavArray.push({theLink:'data/index.html', theImage:'imageHere', theName:'Data'});
	mainNavArray.push({theLink:'about/index.html', theImage:'imageHere', theName:'About Us'});
	//mainNavArray.push({theLink:'', theImage:'imageHere', theName:''});
	

var  footerNavArray = new Array();
	footerNavArray.push({theLink:'index.html', theImage:'imageHere', theName:'Home'});
	footerNavArray.push({theLink:'contact/index.html', theImage:'imageHere', theName:'Contact Us'});
	footerNavArray.push({theLink:'a-z/index.html', theImage:'imageHere', theName:'A-Z List'});
	footerNavArray.push({theLink:'about/index.html', theImage:'imageHere', theName:'About Us'});
	footerNavArray.push({theLink:'about/disclaimer.html', theImage:'imageHere', theName:'Use Disclaimer'});	
	footerNavArray.push({theLink:'about/privacy.html', theImage:'imageHere', theName:'Privacy Policy'});


var  secondaryNavArray = new Array();
	secondaryNavArray.push({theLink:'index.html', theImage:'imageHere', theName:'Home'});
	secondaryNavArray.push({theLink:'online/index.html', theImage:'imageHere', theName:'Online Services'});
	secondaryNavArray.push({theLink:'a-z/index.html', theImage:'imageHere', theName:'Find a Program'});
	secondaryNavArray.push({theLink:'news/index.html', theImage:'imageHere', theName:'Health News'});
	secondaryNavArray.push({theLink:'calendar/month.php', theImage:'imageHere', theName:'Calendar'});
	//secondaryNavArray.push({theLink:'http://www.immunize-utah.org/apps/flu/index.php', theImage:'imageHere', theName:'Flu Vaccination'});

	
var  smsNavArray = new Array();
	smsNavArray.push({theLink:'index.html', theImage:'imageHere', theName:'Home', theStyle:'home'});
	smsNavArray.push({theLink:'http://twitter.com/#!/utahdepofhealth', theImage:'imageHere', theName:'Twitter', theStyle:'twitter'});
	//smsNavArray.push({theLink:'index.html', theImage:'imageHere', theName:'Facebook', theStyle:'facebook'});
	smsNavArray.push({theLink:'news/index.html', theImage:'imageHere', theName:'News', theStyle:'news'});
	//smsNavArray.push({theLink:'index.html', theImage:'imageHere', theName:'Get Help', theStyle:'help'});
	smsNavArray.push({theLink:'http://www.youtube.com/user/UtahDepOfHealth', theImage:'imageHere', theName:'YouTube', theStyle:'youtube'});
	smsNavArray.push({theLink:'a-z/index.html', theImage:'imageHere', theName:'Find Agency', theStyle:'find'});
	smsNavArray.push({theLink:'contact/index.html', theImage:'imageHere', theName:'Contact Us', theStyle:'contact'});
	
	



/* ------------------------------------------------   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, divisionMenu) { 
	var htmlCode = '';
	
	var linkPath = '';
	var listOpen = '';
	var listClose = '';
	var listItemBegin = '';
	var listItemEnd = '';
	var hardReturnBegin = '';
	var hardReturnEnd = '';
	var linkClass = '';
	
	if (divisionMenu == 'yes') {
		linkPath = divisionGlobalPath;
	} else {
		linkPath = globalPath;	
	}
	
	if (hardReturn == 'yes') {
		hardReturnBegin = '<p>';
		hardReturnEnd = '</p>';
	}
	
	if (listItem == 'yes') {
		listOpen = '<ul class="menuList">';
		listClose = '</ul>';
		listItemBegin = '<li>';
		listItemEnd = '</li>';
	}
	
	htmlCode += listOpen;
	
	for(i=0; i<theArray.length; i++) {
		if(i == theArray.length-1) {
			linkClass = ' class="lastItem"';
		}
		
		if( theArray[i].theLink.indexOf('http://') != -1 || theArray[i].theLink.indexOf('https://') != -1){ //check for absolute url
			htmlCode += '\n' + hardReturnBegin + listItemBegin + '<a href="' + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '"' + linkClass +  '/>' + theArray[i].theName + '</a>' + listItemEnd + hardReturnEnd;
		} else { //if url is not absolute, then add the global path
			htmlCode += '\n' + hardReturnBegin + listItemBegin + '<a href="' + linkPath + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '"' + linkClass +  '/>' + theArray[i].theName + '</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 = '';
	
	var linkPath = '';
	
	if (divisionMenu == 'yes') {
		linkPath = divisionGlobalPath;
	} else {
		linkPath = globalPath;	
	}

	for(i=0; i<theArray.length; i++) {
		if( theArray[i].theLink.indexOf('http://') != -1 || theArray[i].theLink.indexOf('https://') != -1){ //check for absolute url
			htmlCode += '\n' + '<a href="' + theArray[i].theLink + '"><img src="' + linkPath + theArray[i].theImage + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '" /></a>';
		} else { //if url is not absolute, then add the global path
			htmlCode += '\n' + '<a href="' + linkPath + theArray[i].theLink + '"><img src="' + linkPath + theArray[i].theImage + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '" /></a>';
		}
	}
	
	document.write(htmlCode);
}


function removeSpaces(theString) {
	return theString.split(' ').join('');
}


// note: sectionHighlight will be a string that needs to exactly match theArray[i].theName. This will make reordering the menus very easy because they don't rely on a numerical placeholder. 
function buildTabMenu(theArray, hardReturn, listItem, sectionHighlight, divisionMenu) { 
	var htmlCode = '';

	var linkPath = '';
	var listOpen = '';
	var listClose = '';
	var listItemBegin = '';
	var listItemEnd = '';
	var hardReturnBegin = '';
	var hardReturnEnd = '';
	var linkClass = '';
	var itemID = '';
	var finalTab = theArray.length-1;
	//alert(finalTab);
	
	if (divisionMenu == 'yes') {
		linkPath = divisionGlobalPath;
	} else {
		linkPath = globalPath;	
	}
	
	
	if (hardReturn == 'yes') {
		hardReturnBegin = '<p>';
		hardReturnEnd = '</p>';
	}
	
	if (listItem == 'yes') {
		listOpen = '<ul>';
		listClose = '</ul>';
		listItemBegin = '<li>';
		listItemEnd = '</li>';
	}
	
	htmlCode += '\n' + listOpen;
	
	for(var i=0; i<theArray.length; i++) {
		itemID = removeSpaces( theArray[i].theName.toLowerCase() );
		
		if (i==0) {
			listItemBegin = '<li id="' + itemID + '" class="firstTab">';	
		
		} else if (i==finalTab) {
			listItemBegin = '<li id="' + itemID + '" class="lastTab">';
					
		} else {
			listItemBegin = '<li id="' + itemID + '" >';
		}
		
		if (sectionHighlight == i) {
			linkClass = 'class="tabSelected"';
		} else {
			linkClass = '';
		}
		
		
		if( theArray[i].theLink.indexOf('http://') != -1 ){ //check for absolute url
			htmlCode += '\n' + hardReturnBegin + listItemBegin + '<a href="' + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '" ' + linkClass + '>' + theArray[i].theName + '</a>' + listItemEnd + hardReturnEnd;
		} else { //if url is not absolute, then add the global path
			htmlCode += '\n' + hardReturnBegin + listItemBegin + '<a href="' + linkPath + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '" ' + linkClass + '>' + theArray[i].theName + '</a>' + listItemEnd + hardReturnEnd;
		}
		//alert('linkClass is: ' + linkClass);
	}
	
	htmlCode +=  '\n' + listClose;
	//alert(htmlCode);
	
	document.write(htmlCode);
	//alert(htmlCode);
}


//buildPipeMenu builds a text menu that uses a text separator between links that will look like the uii footer menu. in 2011, uii was using a "pipe" character between text links. if uii changes to another character, simply replace pipeVar (below) with that character
function buildPipeMenu(theArray, divisionMenu) { 
	var htmlCode = '';
	var linkPath = '';
	var pipeVar = '';
	
	if (divisionMenu == 'yes') {
		linkPath = divisionGlobalPath;
	} else {
		linkPath = globalPath;	
	}

	for(var i=0; i<theArray.length; i++) {
		if(i==0) {
			pipeVar='';
		} else {
			pipeVar=' | ';
		}
		
		if( theArray[i].theLink.indexOf('http://') != -1 ){ //check for absolute url
			htmlCode += '\n' + pipeVar + '<a href="' + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '">' + theArray[i].theName + '</a>';
		} else { //if url is not absolute, then add the global path
			htmlCode += '\n' + pipeVar + '<a href="' + globalPath + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '">' + theArray[i].theName + '</a>';
		}
	}
	
	document.write(htmlCode);
	//alert(htmlCode);
}

function smsNav(theArray, hardReturn, listItem) { 
	var htmlCode = '';
	
	var listOpen = '';
	var listClose = '';
	var listItemBegin = '';
	var listItemEnd = '';
	var hardReturnBegin = '';
	var hardReturnEnd = '';
	
	if (hardReturn == 'yes') {
		hardReturnBegin = '<p>';
		hardReturnEnd = '</p>';
	}
	
	if (listItem == 'yes') {
		listOpen = '<ul class="menuList">';
		listClose = '</ul>';
		listItemEnd = '</li>';
	}
	
	htmlCode += listOpen;
	
	for(i=0; i<theArray.length; i++) {
		
		if(listItem == 'yes') {
			listItemBegin = '<li class="' + theArray[i].theStyle + '">';
		}
		
		if( theArray[i].theLink.indexOf('http://') != -1 || theArray[i].theLink.indexOf('https://') != -1){ //check for absolute url
			htmlCode += hardReturnBegin + listItemBegin + '<a href="' + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '" /><span>' + theArray[i].theName + '</span></a>' + listItemEnd + hardReturnEnd;
		} else { //if url is not absolute, then add the global path
			htmlCode += hardReturnBegin + listItemBegin + '<a href="' + globalPath + theArray[i].theLink + '" alt="' + theArray[i].theName + '" title="' + theArray[i].theName + '"><span>' + theArray[i].theName + '</span></a>' + listItemEnd + hardReturnEnd;
		}
	}
	
	htmlCode += listClose;
	//alert(htmlCode);
	
	document.write(htmlCode);
}






/* ------------------------------------------------   Search   ------------------------------------------------ */
function buildSearchBox() {
	var htmlCode = '';
	
	//htmlCode+= 'search area';

	htmlCode += '\n' + '<form action="' + globalPath + 'search/index.html" id="searchbox_015797132617248936942:fl9rxjqr2j4">';
	//htmlCode += '<div>';
	
	
	htmlCode += '\n' + '<input type="hidden" name="cx" value="015797132617248936942:fl9rxjqr2j4" />';
	htmlCode += '\n' + '<input type="hidden" name="cof" value="FORID:10" />';
	htmlCode += '\n' + '<input type="hidden" name="ie" value="UTF-8" />';
	
	htmlCode += '\n' + '<table>';
	htmlCode += '\n' + '<tr>';
	
	htmlCode += '\n' + '<td align="right">';
	htmlCode += '\n' + '<input type="text" name="q" />';
	htmlCode += '\n' + '</td>';
	
	htmlCode += '\n' + '<td align="left">';
	//htmlCode += '\n' + '<button id="sa" name="sa" type="submit" class="searchButton">Site Search</button>';
	htmlCode += '\n' + '<button id="sa" name="sa" type="submit">';
	htmlCode += '\n' + '<img src="' + globalPath + 'common/images/backgrounds/button.png" alt="Site Search" />';
	htmlCode += '\n' + '</button>';
	htmlCode += '\n' + '</td>';
	htmlCode += '\n' + '</tr>';
	htmlCode += '\n' + '</table>';
	
	htmlCode += '\n' + '</form>';
	
	document.write(htmlCode);

	document.write(unescape("%3Cscript type='text/javascript' src='http://www.google.com/coop/cse/brand?form=cse-search-box&lang=en'%3E%3C/script%3E"));
}







/* ------------------------------------------------   A-Z Directory   ------------------------------------------------ */
function buildDirectory() {
//document.write('\n' + unescape('%3Clink href="../common/css/directory.css" rel="stylesheet" type="text/css" /%3E'));
document.write('\n' + unescape('%3Clink href="' + globalPath + 'common/css/directory.css" rel="stylesheet" type="text/css" /%3E'));
document.write('\n' + unescape('%3Cscript type="text/javascript" src="' + globalPath + 'a-z/include/js/a2z.js"%3E%3C/script%3E'));

	if (document.getElementById('a-zlist')) {
		var listTarget = document.getElementById('a-zlist');
		
		listTarget.onmouseover = function() {
			mopen('a-zlist','UDOH_AZlist-container');
		}
		
		listTarget.onmouseout = function() {
			mclosetime();
		}
	}
}



/* ------------------------------------------------   Content   ------------------------------------------------ */
function brandingContent() {
	var htmlCode = '';
	document.write(htmlCode);
}


function printBanner() {
	var htmlCode = '';
	htmlCode += '<img src="' + globalPath + 'common/images/branding/printBanner.jpg" title="" alt=" />'; 
	document.write(htmlCode);
}


function addAnalytics() { //adds google anayltics

	try {
		var pageTracker = _gat._getTracker("UA-5213743-1");
		pageTracker._trackPageview();
		} 
		catch(err) {}
}


function buildFooter() {
	document.write('\n' +  '<p class="healthMenu">');	
	buildPipeMenu(footerNavArray);
	document.write('\n' + '</p>' +  '\n');
	document.write(unescape('%3Cscript src="http://www.utah.gov/nav/footer.js"type="text/javascript"%3E%3C/script%3E'));
	//addAnalytics();
}

/*<script language="JavaScript" src="http://www.utah.gov/nav/footer.js" type="text/javascript"></script>*/


//document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));









/* ------------------------------------------------   IE Style   ------------------------------------------------ */
function ieStyle() {
	//alert('ieStyle() fired');
	var htmlCode = '';
	
	htmlCode += '\n' + '<!--[if IE 6]><link href="' + globalPath + 'common/css/ieStyle.css" rel="stylesheet" type="text/css"><![endif]-->';
	htmlCode += '\n' + '<!--[if IE 7]><link href="' + globalPath + 'common/css/ieStyle7.css" rel="stylesheet" type="text/css"><script type="text/javascript">ie7 = true;</script><![endif]-->';
	htmlCode += '\n' + '<!--[if gt IE 7]><link href="' + globalPath + 'common/css/ieStyle.css" rel="stylesheet" type="text/css"><![endif]-->';
	document.write(htmlCode);
}



/* ------------------------------------------------   UII Loader   ------------------------------------------------ */
function loadUII() {
	var htmlCode =  '';
	
	if(uiiOverride == true ) {
		document.getElementById('uiiBanner').innerHTML = '<a href="http://utah.gov"><img src="' + globalPath + 'common/images/uii/uiiError.jpg" /></a>';
	}
}
















