

/* ------------------------------------------------   Magic Vars   ------------------------------------------------ */
var globalPath = 'http://jcc.utah.gov/'; //this is the path to root that we can use for building common elements
//var globalPath = '';
var uiiOverride = false; //false allows the uii banner to load. true turns it off. used with the loadUII() function below

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


/* ------------------------------------------------   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', 'common/images/nav/01home.gif', 'Home', 'homeBtn');
	mainNavArray[1] = new Array('about/index.html', 'common/images/nav/02aboutus.gif', 'About the JCC', 'aboutBtn');
	mainNavArray[2] = new Array('documents/jcc_complaint_form2.rtf', 'common/images/nav/03complaintform.gif', 'Complaint Form', 'complaintFormBtn');
	mainNavArray[3] = new Array('reports/index.html', 'common/images/nav/04annualreports.gif', 'Annual Reports', 'reportsBtn');
	mainNavArray[4] = new Array('code/index.html', 'common/images/nav/05code.gif', 'Code of Judicial Conduct', 'codeBtn');
	mainNavArray[5] = new Array('documents/flowchartFull.pdf', 'common/images/nav/06complaintresolution.gif', 'Complaint Resolution Process', 'complaintResolutionBtn');
	mainNavArray[6] = new Array('http://www.rules.utah.gov/publicat/code/r595/r595.htm', 'common/images/nav/07rulesofprocedure.gif', 'Rules of Procedure', 'rulesBtn');
	mainNavArray[7] = new Array('http://le.utah.gov/~code/TITLE78A/78A11.htm', 'common/images/nav/08statutes.gif', 'Statutes', 'statuesBtn');
	mainNavArray[8] = new Array('http://www.utcourts.gov/resources/ethadv/', 'common/images/nav/09ethics.gif', 'Ethics Advisory Options', 'ethicsBtn');
	mainNavArray[9] = new Array('discipline/index.html', 'common/images/nav/10publicdiscipline.gif', 'Public Discipline', 'disciplineBtn');



var footerArray = new Array();
	footerArray[0] = new Array('http://www.utah.gov/privacypolicy.html', 'imageHere', 'Privacy Policy');
	footerArray[1] = new Array('http://www.utah.gov/disclaimer.html', 'imageHere', 'Terms of Use');


	
	
/* ------------------------------------------------   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) { 
	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>';
		listClose = '</ul>';
		listItemBegin = '<li>';
		listItemEnd = '</li>';
	}
	
	htmlCode += listOpen;
	
	for(i=0; i<theArray.length; i++) {
		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] + '" />' + 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] + '">' + theArray[i][2] + '</a>' + listItemEnd + hardReturnEnd;
		}
	}
	
	htmlCode += listClose;
	//alert(htmlCode);
	
	document.write(htmlCode);
}





function buildRolloverMenu(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>';
		listClose = '</ul>';
		listItemBegin = '<li>';
		listItemEnd = '</li>';
	}
	
	htmlCode += listOpen;
	
	for(i=0; i<theArray.length; i++) {
		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="' + theArray[i][3] + '">' + 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="' + theArray[i][3] + '">' + 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);
}



function buildMainNav() {
	var htmlCode = '';
	
	buildRolloverMenu(mainNavArray, 'no', 'yes');
	
	htmlCode += '<img src="' + globalPath + 'common/images/nav/leftnavbottom.gif" />';
	document.write(htmlCode);
}





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




function footer() {
	var htmlCode = '';
	htmlCode += currentYear + ' &copy; Utah Judicial Conduct Commission<br />';
	document.write(htmlCode);
	buildTextMenu(mainNavArray, 'no', 'no');
	document.write('<br />');
	buildTextMenu(footerArray, 'no', 'no');
}



// daParams means include parameters or don't; parameter passed here should be 'y' for yes or 'n' for no
// You can use defaults for the parameters by leaving them between empty quote marks. Example: ('http:// url', '', '', '', '', 'y')
// You can specify the parameters you want to by adding numeric values. DO NOT, however, put the numeric values in quotes.

function popup(daURL, daWidth, daHeight, daTop, daLeft, daParams) {

	var h = ''; // New window height. Defined by daHeight, but has a default if daHeight is empty.
	var w = ''; // New window width. Defined by daWidth, but has a default if daWidth is empty.
	var t = ''; // New window location from screen top. Defined by daTop, but has a default if daTop is empty.
	var l = ''; // New window location from screen left. Defined by daLeft, but has a default if daLeft is empty.

		if(daWidth == 'null' || daWidth == '') {
		  w = screen.availWidth / 2; //width default
		} else {
		  w = daWidth;
		}
		
		if(daHeight == 'null' || daHeight == '') {
		  h = screen.availHeight / 2; //height default
		} else {
		  h = daHeight;
		}

		if(daTop == 'null' || daTop == '') {
		  t = 75; //top default
		} else {
		  t = daTop
		}

		if(daLeft == 'null' || daLeft == '') {
		  l = screen.availWidth / 2.5; //left default
		} else {
		  l = daLeft
		}

	var params = 'toolbar=yes,location=yes,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width='+ w +',height='+ h +',top='+ t +',left='+ l +'';
	var params2 = 'toolbar=no,location=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width='+ w +',height='+ h +',top='+ t +',left='+ l +'';
	var newWindow = '';

		if (daParams == 'y') {
		  newWindow = window.open(daURL, 'daWindow', params);
		} else {
		  newWindow = window.open(daURL, 'daWindow', params2);
		}
		
	newWindow.focus();
}







/* ------------------------------------------------   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/ieStyle.css" rel="stylesheet" type="text/css"><![endif]-->';
	
	document.write(htmlCode);
}



/* ------------------------------------------------   UII Loader   ------------------------------------------------ */
function loadUII(pleaseLoad) {
	var htmlCode =  '';
	
	if(uiiOverride == true ) {
		document.getElementById('uiiBanner').innerHTML = '<img src="' + globalPath + 'common/images/uii/uiiLeft.gif">';
	}
}





























