window.onload = initPage;

var pageDivIds = new Array(3);
pageDivIds[0] = new Array("howToPage","TSPage", "CAPage", "CalendarPage", "contactPage");
//The second element of this array will indicate whether the associated pages have been initialized.
pageDivIds[1] = new Array(true, false, false, false, true);
//The third element of this array will indicate whether the associated data structures have been initialized.
pageDivIds[2] = new Array(true, false, false, true, true);

var entityTypeOptions = new Array();
entityTypeOptions[0] = new Array("Branch","Executive Office of the President","Department","Independent Agency","Current Commission","Currently Unfunded Entity (as of 2009)","Miscellaneous");
entityTypeOptions[1] = new Array(1,2,3,4,5,6,7);
entityTypeOptions[2] = new Array(true,true,true,true,true,true,true);

var menuTree;
var currentDate = new Date();
var baseYear = 2005;

var sessionID;
var contextData;
var partyControlData;
var economicData;
var presAdminData;
var presidentialAdmins;

//initPage method is invoked when the page is first loaded and sets up all the elements of the page
//and also loads agency/bureau, function/subfunction, and source category/subcategory data.
function initPage() {
	var i;

	for (i=0;i<pageDivIds[0].length;i++) {
		if (pageDivIds[0][i] != "howToPage") {
			$(pageDivIds[0][i]).hide();
		}
	}
	
	$('QSTSSelect').onclick=topMenuClickHandler;
	$('QSCASelect').onclick=topMenuClickHandler;
	
	//Set up the top menu.
	var topMenuItems = $('topMenu').getElementsByTagName('span');
	for (i=0;i<topMenuItems.length;i++) {
		topMenuItems[i].onclick = topMenuClickHandler;
		if (topMenuItems[i].getAttribute('id') == 'howToTab') {
			topMenuItems[i].setAttribute('style', 'background:#707E92;color:#FFFFFF');
		} else if (topMenuItems[i].getAttribute('style')) {
			topMenuItems[i].removeAttribute('style');
		}
	}

	//Launch AJAX data load routines.
	new Ajax.Request ("./PresAdmins.xml", {
					  method: 'get',
					  onSuccess: loadPresidentialAdmins,
					  onFailure: function(){ alert('Something went wrong...PresAdmins') }
					  });
	
	new Ajax.Request ("./phpscripts/geteconomicdata.php", {
					  onSuccess: loadContextData,
					  onFailure: function(){ alert('Something went wrong...geteconomicdata') }
					  });
}

function FC_Rendered(DOMId) {
}

function selectTSPage() {
	var i;
	var menuItems = document.getElementById('topMenu').getElementsByTagName('span');
	
	for (i=0;i<pageDivIds[0].length;i++) {
		if(pageDivIds[0][i] == 'TSPage' && (!pageDivIds[1][i] || !pageDivIds[2][i])) {
			return null;
		}
	}
	
	for (i=0;i<menuItems.length;i++) {
		if (menuItems[i].getAttribute('value') == 'TSPage') {
			menuItems[i].setAttribute('style', 'background:#707E92;color:#FFFFFF');
		} else if (menuItems[i].getAttribute('style')) {
			menuItems[i].removeAttribute('style');
		}
	}
	
	for (i=0;i<pageDivIds[0].length;i++) {
		if (pageDivIds[0][i] != 'TSPage') {
			$(pageDivIds[0][i]).hide();
		} else {
			$(pageDivIds[0][i]).show();
		}
	}
	
	refreshTSChart(true);
}

//Manage selections in the top menu bar.
function topMenuClickHandler() {
	var i;
	var menuItems = document.getElementById('topMenu').getElementsByTagName('span');
	
	for (i=0;i<pageDivIds[0].length;i++) {
		if(pageDivIds[0][i] == this.getAttribute('value') && (!pageDivIds[1][i] || !pageDivIds[2][i])) {
			return null;
		}
	}
	
	for (i=0;i<menuItems.length;i++) {
		if (menuItems[i].getAttribute('value') == this.getAttribute('value')) {
			menuItems[i].setAttribute('style', 'background:#707E92;color:#FFFFFF');
		} else if (menuItems[i].getAttribute('style')) {
			menuItems[i].removeAttribute('style');
		}
	}
	
	for (i=0;i<pageDivIds[0].length;i++) {
		if (pageDivIds[0][i] != this.getAttribute('value')) {
			$(pageDivIds[0][i]).hide();
		} else {
			$(pageDivIds[0][i]).show();
		}
	}

	switch (this.getAttribute('value')) {
		case 'TSPage':
			refreshTSChart(true);
			break;
		case 'CAPage':
			refreshCAChart(true);
			break;
	}
}

//loadContextData loads GDP, CPI, and political control information.
function loadPresidentialAdmins (transport) {
	presAdminData = convertStringToXMLDOMObject(transport.responseText);
	presidentialAdmins = presAdminData.getElementsByTagName('president');
	
	new Ajax.Request ("./phpscripts/getmenudata.php", {
					  onSuccess: updateMenuData,
					  onFailure: function(){ alert('Something went wrong...getmenudata') }
					  });
}	

//loadContextData loads GDP, CPI, and political control information.
function loadContextData (transport) {
	contextData = convertStringToXMLDOMObject(transport.responseText);
	
	sessionID = contextData.getElementsByTagName('sessionInfo')[0].getAttribute('sessionID');
	partyControlData = contextData.getElementsByTagName('partyControlData')[0];
	economicData = contextData.getElementsByTagName('economicData')[0];
	
	//Populate the time series chart.
	new Ajax.Request ("./phpscripts/getTSdata.php", {
					  parameters: {sessionID: sessionID, seriesID: "outlays", startYear: 1962, endYear: 2015, category: 'outlays', drillDown: 'all'},
					  onSuccess: initializeTSChart,
					  onFailure: function(){ alert('Something went wrong...getTSdata') }
					  });

	//Populate the change analysis chart.
	new Ajax.Request ("./phpscripts/getCAdata.php", {
					  parameters: {sessionID: sessionID, analysisID: "CAChartData", startYear: 2010, endYear: 2011, itemType: 'agencies' , category: 'outlays', analysisOption: 'largest'},
					  onSuccess: initializeCAChart,
					  onFailure: function(){ alert('Something went wrong...getCAdata') }
					  });
}
	
//updateAgencies is called as a result of an AJAX request when the data is returned.
//updateAgencies loads the agency list into a global masterAgencyList array.
//masterAgencyList[0] contains the agency codes, masterAgencyList[1] contains the names, and masterAgencyList[2]
//contains the entity type codes (Branch, EOP, Department, Independent Agency, Current commission,
//Currently unfunded (in 2009), or Miscellaneous.
function updateMenuData (transport) {
	var i;
	var j;
	var currentIndex;
	var agencyCode;

	var myData = transport.responseXML.getElementsByTagName("item");
	var agencies = myData[0].getElementsByTagName("column");
	var agencyCodes = agencies[0].getElementsByTagName("row");
	var agencyNames = agencies[1].getElementsByTagName("row");
	var agencyEntityCodes = agencies[2].getElementsByTagName("row");
	
	menuTree = convertStringToXMLDOMObject("<menuTree></menuTree>");

	agencyTree = menuTree.createElement("agencyTree");
	menuTree.firstChild.appendChild(agencyTree);
	
	agencyTree.setAttribute('nextLevelTitle',"Select branch:");
	
	var executiveBranch = menuTree.createElement('branch');
	executiveBranch.setAttribute('name',"Executive Branch");
	executiveBranch.setAttribute('value','EB');
	executiveBranch.setAttribute('drillDown','branch');
	executiveBranch.setAttribute('branchCode','EB');
	executiveBranch.setAttribute('nextLevelTitle','Select type of entity:');

	//Add first item under the Executive Branch: all EB funds.
	executiveBranch.appendChild(menuTree.createElement('entityType'));
	executiveBranch.childNodes[0].setAttribute('name','Total Executive Branch ');
	executiveBranch.childNodes[0].setAttribute('value','all');
	executiveBranch.childNodes[0].setAttribute('drillDown','branch');
	executiveBranch.childNodes[0].setAttribute('branchCode','EB');
	executiveBranch.childNodes[0].setAttribute('nextLevelTitle','');
	
	for (i=1; i<entityTypeOptions[0].length;i++) {
		executiveBranch.appendChild(menuTree.createElement('entityType'));
		executiveBranch.childNodes[i].setAttribute('name',entityTypeOptions[0][i]);
		executiveBranch.childNodes[i].setAttribute('value',entityTypeOptions[1][i]);
	}
	
	agencyTree.appendChild(executiveBranch);

	var entityTypes = executiveBranch.getElementsByTagName('entityType');
	for (i=0; i<agencyCodes.length; i++) {
		if (agencyEntityCodes[i].firstChild.nodeValue == 1) {
			agencyTree.appendChild(menuTree.createElement('branch'));
			agencyTree.childNodes[agencyTree.childNodes.length-1].setAttribute('name',agencyNames[i].firstChild.nodeValue);
			agencyTree.childNodes[agencyTree.childNodes.length-1].setAttribute('value',agencyCodes[i].firstChild.nodeValue);
			agencyTree.childNodes[agencyTree.childNodes.length-1].setAttribute('drillDown','branch');
			agencyTree.childNodes[agencyTree.childNodes.length-1].setAttribute('branchCode',agencyCodes[i].firstChild.nodeValue);
			agencyTree.childNodes[agencyTree.childNodes.length-1].setAttribute('nextLevelTitle','Select office:');

			//Add first item under the branch: all branch funds.
			agencyTree.childNodes[agencyTree.childNodes.length-1].appendChild(menuTree.createElement('office'));
			agencyTree.childNodes[agencyTree.childNodes.length-1].childNodes[0].setAttribute('name','Total ' + agencyNames[i].firstChild.nodeValue + ' ');
			agencyTree.childNodes[agencyTree.childNodes.length-1].childNodes[0].setAttribute('value','all');
			agencyTree.childNodes[agencyTree.childNodes.length-1].childNodes[0].setAttribute('drillDown','branch');
			agencyTree.childNodes[agencyTree.childNodes.length-1].childNodes[0].setAttribute('branchCode',agencyCodes[i].firstChild.nodeValue);
			agencyTree.childNodes[agencyTree.childNodes.length-1].childNodes[0].setAttribute('nextLevelTitle','');
		} else {
			for (j=0; j<entityTypes.length; j++) {
				if (agencyEntityCodes[i].firstChild.nodeValue == entityTypes[j].getAttribute('value')) {
					if (entityTypes[j].getAttribute('value') != 2) {
						entityTypes[j].appendChild(menuTree.createElement('agency'));
						currentIndex = entityTypes[j].childNodes.length-1;
						entityTypes[j].childNodes[currentIndex].setAttribute('name',agencyNames[i].firstChild.nodeValue);
						entityTypes[j].childNodes[currentIndex].setAttribute('value',agencyCodes[i].firstChild.nodeValue);
						entityTypes[j].childNodes[currentIndex].setAttribute('drillDown','agency');
						entityTypes[j].childNodes[currentIndex].setAttribute('agencyCode',agencyCodes[i].firstChild.nodeValue);
						entityTypes[j].childNodes[currentIndex].setAttribute('nextLevelTitle','Select bureau/office:');
						
						//Add first item under the agency: all agency funds.
/*						entityTypes[j].childNodes[currentIndex].appendChild(menuTree.createElement('bureau'));
						entityTypes[j].childNodes[currentIndex].childNodes[0].setAttribute('name','Total ' + agencyNames[i].firstChild.nodeValue);
						entityTypes[j].childNodes[currentIndex].childNodes[0].setAttribute('value','all');
						entityTypes[j].childNodes[currentIndex].childNodes[0].setAttribute('drillDown','agency');
						entityTypes[j].childNodes[currentIndex].childNodes[0].setAttribute('agencyCode',agencyCodes[i].firstChild.nodeValue);
						entityTypes[j].childNodes[currentIndex].childNodes[0].setAttribute('nextLevelTitle','');*/
					} else {
						//Add first item under the EOP: all EOP funds.
						entityTypes[j].appendChild(menuTree.createElement('bureau'));
						entityTypes[j].childNodes[0].setAttribute('name','Total ' + agencyNames[i].firstChild.nodeValue + ' ');
						entityTypes[j].childNodes[0].setAttribute('value',agencyCodes[i].firstChild.nodeValue);
						entityTypes[j].childNodes[0].setAttribute('drillDown','agency');
						entityTypes[j].childNodes[0].setAttribute('agencyCode',agencyCodes[i].firstChild.nodeValue);
						entityTypes[j].childNodes[0].setAttribute('nextLevelTitle','');
					}
				}
			}
		}
	}

	for (i=1; i<entityTypeOptions[0].length;i++) {
		executiveBranch.childNodes[i].setAttribute('drillDown','agency');
		agencyCode = executiveBranch.childNodes[i].childNodes[0].getAttribute('value');
		executiveBranch.childNodes[i].setAttribute('agencyCode',agencyCode);
		if (agencyCode == 100) {
			var EOPItem = executiveBranch.childNodes[i];
			EOPItem.setAttribute('nextLevelTitle','Select office');
		} else {
			executiveBranch.childNodes[i].setAttribute('nextLevelTitle','Select ' + entityTypeOptions[0][i].toLowerCase());
		}
	}

//	alert(convertXMLDOMObjectToString(menuTree.firstChild));
	
/*	var bureaus = myData[1].getElementsByTagName("column");
	var bureauCodes = bureaus[0].getElementsByTagName("row");
	var bureauNames = bureaus[1].getElementsByTagName("row");
	var bureauAgencyCodes = bureaus[2].getElementsByTagName("row");
*/	
/*	var branchList = agencyTree.getElementsByTagName("branch");
	var agencyList = agencyTree.getElementsByTagName("agency");
	var newBureau;
	
	for (i=0;i<bureauCodes.length;i++) {
		for (j=1;j<branchList.length;j++) {
			if (bureauAgencyCodes[i].firstChild.nodeValue == branchList[j].getAttribute('value')) {
				newBureau = menuTree.createElement('office');
				newBureau.setAttribute('name',bureauNames[i].firstChild.nodeValue);
				newBureau.setAttribute('value',bureauCodes[i].firstChild.nodeValue);
				newBureau.setAttribute('drillDown','bureau');
				newBureau.setAttribute('agencyCode',bureauAgencyCodes[i].firstChild.nodeValue);
				newBureau.setAttribute('bureauCode',bureauCodes[i].firstChild.nodeValue);
				newBureau.setAttribute('nextLevelTitle','');
				if(branchList[j].childNodes.length>0 && bureauCodes[i].firstChild.nodeValue == '00') {
					if(branchList[j].firstChild.getAttribute('value') != 'all') {
						branchList[j].insertBefore(newBureau,branchList[j].firstChild);
					} else if (branchList[j].childNodes.length>1) {
						branchList[j].insertBefore(newBureau,branchList[j].firstChild.nextSibling);
					} else {
						branchList[j].appendChild(newBureau);
					}						
				} else {
					branchList[j].appendChild(newBureau);
				}
			}
		}
		for (j=0;j<agencyList.length;j++) {
			if (bureauAgencyCodes[i].firstChild.nodeValue == agencyList[j].getAttribute('value')) {
				newBureau = menuTree.createElement('bureau');
				newBureau.setAttribute('name',bureauNames[i].firstChild.nodeValue);
				newBureau.setAttribute('value',bureauCodes[i].firstChild.nodeValue);
				newBureau.setAttribute('drillDown','bureau');
				newBureau.setAttribute('agencyCode',bureauAgencyCodes[i].firstChild.nodeValue);
				newBureau.setAttribute('bureauCode',bureauCodes[i].firstChild.nodeValue);
				newBureau.setAttribute('nextLevelTitle','');
				if(agencyList[j].childNodes.length>0 && bureauCodes[i].firstChild.nodeValue == '00') {
					if(agencyList[j].firstChild.getAttribute('value') != 'all') {
						agencyList[j].insertBefore(newBureau,agencyList[j].firstChild);
					} else if (agencyList[j].childNodes.length>1) {
						agencyList[j].insertBefore(newBureau,agencyList[j].firstChild.nextSibling);
					} else {
						agencyList[j].appendChild(newBureau);
					}
				} else {
					agencyList[j].appendChild(newBureau);
				}
			}
		}
		if (bureauAgencyCodes[i].firstChild.nodeValue == 100) {
			newBureau = menuTree.createElement('bureau');
			newBureau.setAttribute('name',bureauNames[i].firstChild.nodeValue);
			newBureau.setAttribute('value',bureauCodes[i].firstChild.nodeValue);
			newBureau.setAttribute('drillDown','bureau');
			newBureau.setAttribute('agencyCode',bureauAgencyCodes[i].firstChild.nodeValue);
			newBureau.setAttribute('bureauCode',bureauCodes[i].firstChild.nodeValue);
			newBureau.setAttribute('nextLevelTitle','');
			if(EOPItem.childNodes.length>1 && bureauCodes[i].firstChild.nodeValue == '00') {
				EOPItem.insertBefore(newBureau,EOPItem.firstChild.nextSibling);
			} else {
				EOPItem.appendChild(newBureau);
			}
		}
	}
*/
	//Now we're going to process the functions.
	var functions = myData[2].getElementsByTagName("column");
	var functionCodes = functions[0].getElementsByTagName("row");
	var functionNames = functions[1].getElementsByTagName("row");
	
	functionTree = menuTree.createElement("functionTree");
	menuTree.firstChild.appendChild(functionTree);
	
	functionTree.setAttribute('nextLevelTitle',"Select function:");
	
	for (i=0; i<functionCodes.length; i++) {
		functionTree.appendChild(menuTree.createElement('function'));
		functionTree.childNodes[i].setAttribute('name',functionNames[i].firstChild.nodeValue);
		functionTree.childNodes[i].setAttribute('value',functionCodes[i].firstChild.nodeValue);
		functionTree.childNodes[i].setAttribute('drillDown','function');
		functionTree.childNodes[i].setAttribute('functionCode',functionCodes[i].firstChild.nodeValue);
		functionTree.childNodes[i].setAttribute('nextLevelTitle','Select subfunction:');
		
		//Add first item under the function: all function funds.
		functionTree.childNodes[i].appendChild(menuTree.createElement('subfunction'));
		functionTree.childNodes[i].childNodes[0].setAttribute('name','Total ' + functionNames[i].firstChild.nodeValue);
		functionTree.childNodes[i].childNodes[0].setAttribute('value','all');
		functionTree.childNodes[i].childNodes[0].setAttribute('drillDown','function');
		functionTree.childNodes[i].childNodes[0].setAttribute('functionCode',functionCodes[i].firstChild.nodeValue);
		functionTree.childNodes[i].childNodes[0].setAttribute('nextLevelTitle','');
	}
/*
	var subfunctions = myData[3].getElementsByTagName("column");
	var subfunctionCodes = subfunctions[0].getElementsByTagName("row");
	var subfunctionNames = subfunctions[1].getElementsByTagName("row");
	var subfunctionFnCodes = subfunctions[2].getElementsByTagName("row");
	
	var functionList = functionTree.getElementsByTagName('function');
	
	for (i=0;i<subfunctionCodes.length;i++) {
		for (j=0;j<functionList.length;j++) {
			if (subfunctionFnCodes[i].firstChild.nodeValue == functionList[j].getAttribute('value')) {
				newSubfunction = menuTree.createElement('subfunction');
				newSubfunction.setAttribute('name',subfunctionNames[i].firstChild.nodeValue);
				newSubfunction.setAttribute('value',subfunctionCodes[i].firstChild.nodeValue);
				newSubfunction.setAttribute('drillDown','subfunction');
				newSubfunction.setAttribute('subfunctionCode',subfunctionCodes[i].firstChild.nodeValue);
				newSubfunction.setAttribute('functionCode',subfunctionFnCodes[i].firstChild.nodeValue);
				newSubfunction.setAttribute('nextLevelTitle','');
				if(functionList[j].childNodes.length>1 && subfunctionCodes[i].firstChild.nodeValue == '00') {
					functionList[j].insertBefore(newSubfunction,functionList[j].childNodes[1]);
				} else {
					functionList[j].appendChild(newSubfunction);
				}
			}
		}
	}
*/
	//Now we're going to process the source categories.
	var sourceCategories = myData[4].getElementsByTagName("column");
	var sourceCategoryCodes = sourceCategories[0].getElementsByTagName("row");
	var sourceCategoryNames = sourceCategories[1].getElementsByTagName("row");

	sourceCategoryTree = menuTree.createElement("sourceCategoryTree");
	menuTree.firstChild.appendChild(sourceCategoryTree);
	
	sourceCategoryTree.setAttribute('nextLevelTitle',"Select source category:");
	
	for (i=0; i<sourceCategoryCodes.length; i++) {
		sourceCategoryTree.appendChild(menuTree.createElement('sourceCategory'));
		sourceCategoryTree.childNodes[i].setAttribute('name',sourceCategoryNames[i].firstChild.nodeValue);
		sourceCategoryTree.childNodes[i].setAttribute('value',sourceCategoryCodes[i].firstChild.nodeValue);
		sourceCategoryTree.childNodes[i].setAttribute('drillDown','source_category');
		sourceCategoryTree.childNodes[i].setAttribute('sourceCategoryCode',sourceCategoryCodes[i].firstChild.nodeValue);
		sourceCategoryTree.childNodes[i].setAttribute('nextLevelTitle','Select source subcategory:');

		//Add first item under the source category: all source category funds.
		sourceCategoryTree.childNodes[i].appendChild(menuTree.createElement('subcategory'));
		sourceCategoryTree.childNodes[i].childNodes[0].setAttribute('name','Total ' + sourceCategoryNames[i].firstChild.nodeValue);
		sourceCategoryTree.childNodes[i].childNodes[0].setAttribute('value','all');
		sourceCategoryTree.childNodes[i].childNodes[0].setAttribute('drillDown','source_category');
		sourceCategoryTree.childNodes[i].childNodes[0].setAttribute('sourceCategoryCode',sourceCategoryCodes[i].firstChild.nodeValue);
		sourceCategoryTree.childNodes[i].childNodes[0].setAttribute('nextLevelTitle','');
	}
	
/*	var sourceSubCategories = myData[5].getElementsByTagName("column");
	var subcategoryCodes = sourceSubCategories[0].getElementsByTagName("row");
	var subcategoryNames = sourceSubCategories[1].getElementsByTagName("row");
	var subcategoryCatCodes = sourceSubCategories[2].getElementsByTagName("row");

	var sourceCategoryList = sourceCategoryTree.getElementsByTagName('sourceCategory');

	for (i=0;i<subcategoryCatCodes.length;i++) {
		for (j=0;j<sourceCategoryList.length;j++) {
			if (subcategoryCatCodes[i].firstChild.nodeValue == sourceCategoryList[j].getAttribute('value')) {
				newSubcategory = menuTree.createElement('subcategory');
				newSubcategory.setAttribute('name',subcategoryNames[i].firstChild.nodeValue);
				newSubcategory.setAttribute('value',subcategoryCodes[i].firstChild.nodeValue);
				newSubcategory.setAttribute('drillDown','source_subcategory');
				newSubcategory.setAttribute('sourceSubCategoryCode',subcategoryCodes[i].firstChild.nodeValue);
				newSubcategory.setAttribute('sourceCategoryCode',subcategoryCatCodes[i].firstChild.nodeValue);
				newSubcategory.setAttribute('nextLevelTitle','');
				if(sourceCategoryList[j].childNodes.length>1 && subcategoryCodes[i].firstChild.nodeValue == '00') {
					sourceCategoryList[j].insertBefore(newSubcategory,sourceCategoryList[j].childNodes[1]);
				} else {
					sourceCategoryList[j].appendChild(newSubcategory);
				}
			}
		}
	}

	trimExtraNodes(menuTree.firstChild);
*/

	new Ajax.Request ("./TSPageLayout.xml", {
					  method: 'get',
					  onSuccess: initTSPage,
					  contentType: 'text/xml',
					  onFailure: function(){ alert('Something went wrong...TSPageLayout') }
					  });
	
	new Ajax.Request ("./CAPageLayout.xml", {
					  method: 'get',
					  onSuccess: initCAPage,
					  contentType: 'text/xml',
					  onFailure: function(){ alert('Something went wrong...CAPageLayout') }
					  });

	new Ajax.Request ("./calendarTab.xml", {
					  method: 'get',
					  onSuccess: initCalendarPage,
					  contentType: 'text/xml',
					  onFailure: function(){ alert('Something went wrong...CalendarPageLayout') }
					  });
}

//Updtate party control information to make it consistent with other series visible in the charts.
function updatePartyControlData () {
	var i;
	
	var chartInfo = TSChartXMLObject.getElementsByTagName('TSChartInfo')[0];
	var partyControlLines = TSChartXMLObject.getElementsByTagName('vLine');
	var partyControlItems = partyControlData.childNodes;
	var controlId = chartInfo.getAttribute('partyControl');
	
	var numAxes = 1.0*chartInfo.getAttribute('numAxes');
	
	for (i=0; i< partyControlLines.length; i++) {
		if (partyControlLines[i].getAttribute('partyControlLine') == '1') {
			partyControlLines[i].setAttribute('thickness',13-numAxes);
			if (partyControlItems[partyControlLines[i].getAttribute('partyControlIndex')].getAttribute(controlId) == 'Republican') {
				partyControlLines[i].setAttribute('color','FF0000');
			} else if (partyControlItems[partyControlLines[i].getAttribute('partyControlIndex')].getAttribute(controlId) == 'Democrat') {
				partyControlLines[i].setAttribute('color','0070B0');
			} else {
				partyControlLines[i].setAttribute('color','FFFFFF');
			}
		}
	}
}