//alert('includes.js loaded');

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://www.rules.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(globalPath + 'abtdivision.htm', 'imageHere', 'About Us');
	mainNavArray[1] = new Array(globalPath + 'publicat/bulletin.htm', 'imageHere', 'Proposed Rules');
	mainNavArray[2] = new Array(globalPath + 'publicat/code.htm', 'imageHere', 'Effective Rules');
	mainNavArray[3] = new Array(globalPath + 'publicat/emergencyrules.htm', 'imageHere', 'Emergency Rules');
	mainNavArray[4] = new Array(globalPath + 'calendar/hearings.htm', 'imageHere', 'Rule Hearings');
	mainNavArray[5] = new Array(globalPath + 'research.htm', 'imageHere', 'Research');
	mainNavArray[6] =  new Array(globalPath + 'executivedocuments.htm', 'imageHere', 'Governors Executive Documents');

var sampleNavArray = new Array();
	sampleNavArray[0] = new Array('', 'imageHere', 'sampleLink00');

var secondaryHomeNavArray = new Array();
	secondaryHomeNavArray[0] =  new Array('http://das.utah.gov/index.html', 'imageHere', 'DAS Home');
	secondaryHomeNavArray[1] =  new Array(globalPath + 'index.htm', 'imageHere', 'Rules Home');
	secondaryHomeNavArray[2] =  new Array(globalPath + 'agencyresources/FY2010RulesServicePlan.pdf', 'imageHere', 'Service Plan');
	secondaryHomeNavArray[3] =  new Array(globalPath + 'abtrules.htm', 'imageHere', 'About Rules');
	secondaryHomeNavArray[4] =  new Array(globalPath + 'abtprocess.htm', 'imageHere', 'About Rulemaking');
	secondaryHomeNavArray[5] =  new Array(globalPath + 'publications.htm', 'imageHere', 'Rules Publications');
	secondaryHomeNavArray[6] =  new Array(globalPath + 'publicat/bulletin.htm', 'imageHere', 'Utah State Bulletin');
	secondaryHomeNavArray[7] =  new Array(globalPath + 'publicat/code.htm', 'imageHere', 'Utah Administrative Code');
	secondaryHomeNavArray[8] =  new Array(globalPath + 'law.htm', 'imageHere', 'Rulemaking Law');
	secondaryHomeNavArray[9] =  new Array(globalPath + 'publicFAQ.htm', 'imageHere', 'Rulemaking FAQ');
	secondaryHomeNavArray[10] =  new Array(globalPath + 'agencyresources.htm', 'imageHere', 'Rule Filing Agency Resources (eRules)');
	secondaryHomeNavArray[11] =  new Array(globalPath + 'emp/index.htm', 'imageHere', 'Employee Portal (Division employees only)');

var secondaryNavArray = new Array();
	secondaryNavArray[0] =  new Array('http://das.utah.gov/index.html', 'imageHere', 'DAS Home');
	secondaryNavArray[1] =  new Array(globalPath + 'index.htm', 'imageHere', 'Rules Home');
	secondaryNavArray[2] =  new Array(globalPath + 'agencyresources/FY2010RulesServicePlan.pdf', 'imageHere', 'Service Plan');
	secondaryNavArray[3] =  new Array(globalPath + 'abtrules.htm', 'imageHere', 'About Rules');
	secondaryNavArray[4] =  new Array(globalPath + 'abtprocess.htm', 'imageHere', 'About Rulemaking');
	secondaryNavArray[5] =  new Array(globalPath + 'publications.htm', 'imageHere', 'Rules Publications');
	secondaryNavArray[6] =  new Array(globalPath + 'publicat/bulletin.htm', 'imageHere', 'Utah State Bulletin');
	secondaryNavArray[7] =  new Array(globalPath + 'publicat/code.htm', 'imageHere', 'Utah Administrative Code');
	secondaryNavArray[8] =  new Array(globalPath + 'law.htm', 'imageHere', 'Rulemaking Law');
	secondaryNavArray[9] =  new Array(globalPath + 'publicFAQ.htm', 'imageHere', 'Rulemaking FAQ');
	secondaryNavArray[10] =  new Array(globalPath + 'agencyresources.htm', 'imageHere', 'Rule Filing Agency Resources (eRules)');

var bulletinNavArray = new Array();
	bulletinNavArray[0] =  new Array('http://das.utah.gov/index.html', 'imageHere', 'DAS Home');
	bulletinNavArray[1] =  new Array(globalPath + 'index.htm', 'imageHere', 'Rules Home');
	bulletinNavArray[2] =  new Array(globalPath + 'publications.htm', 'imageHere', 'Rules Publications');
	bulletinNavArray[3] =  new Array(globalPath + 'publicat/bulletin.htm', 'imageHere', 'Utah State Bulletin');
	bulletinNavArray[4] =  new Array(globalPath + 'publicat/code.htm', 'imageHere', 'Utah Administrative Code');
	bulletinNavArray[5] =  new Array(globalPath + 'law.htm', 'imageHere', 'Rulemaking Law');
	bulletinNavArray[6] =  new Array(globalPath + 'publicFAQ.htm', 'imageHere', 'Rulemaking FAQ');

var codeNavArray = new Array();
	codeNavArray[0] =  new Array('http://das.utah.gov/index.html', 'imageHere', 'DAS Home');
	codeNavArray[1] =  new Array(globalPath + 'index.htm', 'imageHere', 'Rules Home');
	codeNavArray[2] =  new Array(globalPath + 'publications.htm', 'imageHere', 'Rules Publications');
	codeNavArray[3] =  new Array(globalPath + 'publicat/bulletin.htm', 'imageHere', 'Utah State Bulletin');
	codeNavArray[4] =  new Array(globalPath + 'publicat/code.htm', 'imageHere', 'Utah Administrative Code');
	codeNavArray[5] =  new Array(globalPath + 'law.htm', 'imageHere', 'Rulemaking Law');
	codeNavArray[6] =  new Array(globalPath + 'publicFAQ.htm', 'imageHere', 'Rulemaking FAQ');

var execdocNavArray = new Array();
	execdocNavArray[0] =  new Array('http://das.utah.gov/index.html', 'imageHere', 'DAS Home');
	execdocNavArray[1] =  new Array(globalPath + 'index.htm', 'imageHere', 'Rules Home');
	execdocNavArray[2] =  new Array(globalPath + 'publications.htm', 'imageHere', 'Rules Publications');
	execdocNavArray[3] =  new Array(globalPath + 'publicat/bulletin.htm', 'imageHere', 'Utah State Bulletin');
	execdocNavArray[4] =  new Array('http://www.utah.gov/governor/index.html', 'imageHere', 'Governor&rsquo;s Home Page');

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://www.rules.utah.gov/', 'imageHere', 'Rules');
	divisionNavArray[10] = new Array('http://unrhf.utah.gov/', 'imageHere', 'Navajo Royalities Holding Fund');


var footerNavArray = new Array();
	footerNavArray[0] =  new Array('sitemap.htm', 'imageHere', 'Site Map');
	footerNavArray[1] =  new Array('contact/', 'imageHere', 'Contact Us');
	footerNavArray[2] =  new Array('parking.htm', 'imageHere', 'Public Parking');

var uiiFooterNavArray = new Array();
	uiiFooterNavArray[0] =  new Array('http://www.utah.gov/index.html', '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('http://rulesintra.rules.utah.gov/blog/', 'imageHere', 'Rules Rules!');
	sampleEmpNavArray[1] = new Array('http://rulesintra.rules.utah.gov/cgi-bin/wiki.pl', 'imageHere', 'Rules DocWiki');
	sampleEmpNavArray[2] = new Array('http://rulesintra.rules.utah.gov/erulesdev/', 'imageHere', 'eRules Blog');
	sampleEmpNavArray[3] = new Array('http://rulesintra.rules.utah.gov/mantis/login_page.php', 'imageHere', 'eRules Bug Tracking');
	sampleEmpNavArray[4] = new Array('http://erules.at.utah.gov/', 'imageHere', 'eRules AT');



/* ------------------------------------------------   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 += '<a href="' + globalPath + '"index.htm"><img src="' + globalPath + 'common/images/banners/bannerDefault.jpg" alt="Division of Administrative Rules" title="Division of Administrative Rules" /></a>';
	//htmlCode += '</div>';
	document.write(htmlCode);

	//var so = new SWFObject(globalPath + "common/randomBanner/banner.swf", "Rules 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-6"); 
	pageTracker._trackPageview(); 
}


function buildAddress() {
	var htmlCode = '';
	htmlCode += '<address>' + currentYear + ' &copy; Division of Administrative Rules<br />';
	htmlCode += '4120 State Office Building / Capitol Hill Complex / 450 North State Street / Salt Lake City, UT 84114<br />';
	htmlCode += 'Phone: 801-538-3764 / Fax: 801-538-1773</address>';
	document.write(htmlCode);
}

function buildFooter() {
	var htmlCode = '';
	
	buildTextMenu(footerNavArray, 'no', 'no', 'dividerRed');
	document.write('<br />');
	buildTextMenu(divisionNavArray, 'no', 'no', 'dividerRed');
	document.write('<br />');
	buildTextMenu(uiiFooterNavArray, 'no', 'no', 'dividerRed');
	
	//htmlCode += '<br />Copyright © 2009 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>*/


































