//alert('includes.js loaded');

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://purchasing.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.html', 'imageHere', 'About Us');
	mainNavArray[1] = new Array('http://generalservices.utah.gov/statewidecontracts/contractsearch.aspx', 'imageHere', 'State Contracts');
	mainNavArray[2] = new Array('vendor/currentbids.html', 'imageHere', 'Current Bids');
	mainNavArray[3] = new Array('vendor/index.html', 'imageHere', 'Vendor Information');
	mainNavArray[4] = new Array('buyer/index.html', 'imageHere', 'Buyer Information');
	mainNavArray[5] = new Array('training/index.html', 'imageHere', 'Agency Training');
	mainNavArray[6] = new Array('directories/index.html', 'imageHere', 'Directories');
	mainNavArray[7] = new Array('general/index.html', 'imageHere', 'General Services');

var sampleNavArray = new Array();
	sampleNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	sampleNavArray[1] = new Array('index.html', 'imageHere', 'Purchasing Home');
	sampleNavArray[2] = new Array('mail/index.html', 'imageHere', 'State Mail');
	sampleNavArray[3] = new Array('print/index.html', 'imageHere', 'Print Services');
	sampleNavArray[4] = new Array('http://generalservices.utah.gov/pdfreports2', 'imageHere', 'General Services Invoice Search');
	sampleNavArray[5] = new Array('emp/index.html', 'imageHere', 'Employee Intranet');

var secondaryNavArray = new Array();
	secondaryNavArray[0] =   new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	secondaryNavArray[1] =   new Array('index.html', 'imageHere', 'Purchasing Home');
	secondaryNavArray[2] =   new Array('documents/fy2011serviceplan.pdf', 'imageHere', 'Service Plan');
	secondaryNavArray[3] =   new Array('epurchasing/index.html', 'imageHere', 'ePurchasing');
	secondaryNavArray[4] =   new Array('mail/index.html', 'imageHere', 'State Mail');
	secondaryNavArray[5] =   new Array('print/index.html', 'imageHere', 'Print Services');
	secondaryNavArray[6] =   new Array('buyer/bid.html', 'imageHere', 'Bid Notification System');
	secondaryNavArray[7] =   new Array('vendor/documents/Vendorgd.pdf', 'imageHere', 'Guide to Doing Business with Utah');
	secondaryNavArray[8] =   new Array('http://generalservices.utah.gov/pdfreports2', 'imageHere', 'General Services Invoice Search');
	secondaryNavArray[9] =   new Array('vendor/bidtab.html', 'imageHere', 'Bid Tabulations and Awards');
	secondaryNavArray[10] =  new Array('http://finance.utah.gov/procurementcard/index.html', 'imageHere', 'State Purchasing P-Card Info');
	secondaryNavArray[11] =  new Array('orgchart/PurchasingOrgChart2.pdf', 'imageHere', 'Organizational Chart');
	secondaryNavArray[12] =  new Array('emp/index.html', 'imageHere', 'Employee Intranet');
	secondaryNavArray[13] =  new Array('documents/wscapcstandards.pdf', 'imageHere', 'WSCA Standard PC Configurations');
	secondaryNavArray[14] =  new Array('media/index.html', 'imageHere', 'Media Center');
	secondaryNavArray[15] =  new Array('general/surplus/index.html', 'imageHere', 'Surplus Program');
    /*secondaryNavArray[14] =  new Array('contact/index.php', 'imageHere', 'Send Us a Comment');*/

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://untf.utah.gov', 'imageHere', 'Navajo Royalties Holding Fund');

var footerNavArray = new Array();
	footerNavArray[0] =  new Array('', 'imageHere', 'Site Map');
	footerNavArray[1] =  new Array('directories/documents/purchasing.pdf', 'imageHere', 'Contact Us');
	footerNavArray[2] =  new Array('', '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 surplusNavArray = new Array();
	surplusNavArray[0] = new Array('aboutus.html', 'imageHere', 'About Us');
	surplusNavArray[1] = new Array('../general/index.html', 'imageHere', 'General Services');
	surplusNavArray[2] = new Array('../mail/index.html', 'imageHere', 'State Mail');
	surplusNavArray[3] = new Array('../print/index.html', 'imageHere', 'Print Services');
	surplusNavArray[4] = new Array('http://fleet.utah.gov', 'imageHere', 'Fleet');
	
var generalNavArray = new Array();
	generalNavArray[0] = new Array('http://das.utah.gov', 'imageHere', 'DAS Home');
	generalNavArray[1] = new Array('../../index.html', 'imageHere', 'Purchasing Home');
	generalNavArray[2] = new Array('../../documents/fy2011serviceplan.pdf', 'imageHere', 'Service Plan');
	generalNavArray[3] = new Array('../../general/surplus/index.html', 'imageHere', 'Surplus Program');
	generalNavArray[4] = new Array('../../epurchasing/index.html', 'imageHere', 'ePurchasing');
	generalNavArray[5] = new Array('../../orgchart/PurchasingOrgChart2.pdf', 'imageHere', 'Organizational Chart');
	generalNavArray[6] = new Array('../../emp/index.html', 'imageHere', 'Employee Intranet');
	generalNavArray[7] = new Array('../../general/surplus/surpluspropertyep.html', 'imageHere', 'Employee Portal');
	/*generalNavArray[8] = new Array('http://apps.finance.utah.gov/nxt/gateway.dll?f=templates&fn=default.htm&vid=nxtpub:apptravel', 'imageHere', 'State Policy & Procedure');
	generalNavArray[9] = new Array('travel/traveltraining.html', 'imageHere', 'Travel Training');
	generalNavArray[10] = new Array('travel/contact/index.php', 'imageHere', 'Send Your Comments');/*
	
/* ---------------  employee section  --------------- */
var sampleEmpNavArray = new Array();
	sampleEmpNavArray[0] = new Array('http://stateemployees.utah.gov/irj/index.html', 'imageHere', 'ESS');
	sampleEmpNavArray[1] = new Array('http://email.utah.gov/', 'imageHere', 'Groupwise Web');
	sampleEmpNavArray[2] = new Array('http://finance.utah.gov/finet/index.html', 'imageHere', 'FINET Info');
	sampleEmpNavArray[3] = new Array('http://remedy.dts.utah.gov/', 'imageHere', 'DTS Help Desk');
	sampleEmpNavArray[4] = new Array('http://www.employeegateway.utah.gov/', 'imageHere', 'Employee Gateway');
	sampleEmpNavArray[5] = new Array('http://www.accessvalues.com', 'imageHere', 'Access Benefits');



/* ------------------------------------------------   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 = '';
	//alert('loadBanner');
	
	//htmlCode += '<div id="flashBanner">';
	htmlCode += '<img src="' + globalPath + 'common/images/banners/bannerDefault.jpg" alt="Utah Department of Administrative Services" title="Division of Purchasing and General Services" />';
	//htmlCode += '</div>';
	document.write(htmlCode);

	//var so = new SWFObject(globalPath + "common/randomBanner/banner.swf", "Purchasing 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-5"); 
	pageTracker._trackPageview(); 
}


function buildAddress() {
	var htmlCode = '';
	htmlCode += '<address>' + currentYear + ' &copy; Division of Purchasing and General Services<br />';
	htmlCode += '3150 State Office Building/Capitol Hill Complex/450 North State Street/Salt Lake City, UT 84114<br />';
	htmlCode += 'Phone: 801-538-3026 / Fax: 801-538-3882</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]-->';
	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>*/



































