 // This is not really necessary
	var energy = 'mass x speed of light, squared';


function init() {

	if (document.getElementById('partner_nav')) {
	
		var imageList = document.getElementById('partner_nav').getElementsByTagName('IMG');
	
		for (var x = 0; x < imageList.length; x++) {
		
			addListener(imageList[x], "mouseover", swapImageLogic, false);
			addListener(imageList[x], "mouseout", swapImageLogic, false);
		};
	};
	
	if (document.getElementById('ad_content_footer')) {

		var imageList = document.getElementById('ad_content_footer').getElementsByTagName('IMG');
	
		for (var x = 0; x < imageList.length; x++) {
		
			addListener(imageList[x], "mouseover", swapImageLogic, false);
			addListener(imageList[x], "mouseout", swapImageLogic, false);
		};
	};
	
	if (document.getElementById('alphaTableInner')) {
		var tdList = document.getElementById('alphaTableInner').getElementsByTagName('TD');
	
		for (var x = 0; x < tdList.length; x++) {
		
			if (!tdList[x].className) {
		
				addListener(tdList[x], "mouseover", alphaTDaction, false);
				addListener(tdList[x], "mouseout", alphaTDaction, false);
				addListener(tdList[x], "mousedown", alphaTDaction, false);
		
			};
		};
	};
	
};


function alphaTDaction(event) {

	setEventTargets(event);
	
	if (event.type.toString().match('mouseover')) {
		
		eTarget.hasAttribute ? eTarget.setAttribute('class','alphaHover') : eTarget.className = 'alphaHover';
	
	} else if (event.type.toString().match('mouseout')) {
	
		eTarget.hasAttribute ? eTarget.removeAttribute('class') : eTarget.removeAttribute('className');
		
	} else if (event.type.toString().match('mousedown')) {
	
		var theURL = window.location.toString().split('?')[0];
		window.location = theURL + '?alpha=' + eTarget.firstChild.nodeValue;

	};


};


function swapImageLogic(event) {

	setEventTargets(event);
	
	if (eTarget.nodeName == 'IMG') {
	
		if (!eTarget.className) {
			swapImage(eTarget, 'mouseover', event.type, true, '_normal.', '_hover.');
		};
	};
};


function addFilter() {
	
	var targetDiv = document.getElementById('inner_recipient_wrapper');
	
	//var newDiv = document.createElement('div');
	//newDiv.setAttribute('style','padding: 12px 12px 0 12px; clear: both;');
	var form = document.createElement('form');
	form.setAttribute('id','form1');
	form.setAttribute('method','post');
	form.setAttribute('action','grant-recipients-list.php');
	
		var p = document.createElement('p');
		p.hasAttribute ? p.setAttribute('class','form1Paragraph') : p.className = 'form1Paragraph';
			var text = document.createTextNode('View Recipient By: ');
			p.appendChild(text);
		
			var select = document.createElement('select');
			select.setAttribute('id','filter1');
			select.setAttribute('name','filter1');
			select.setAttribute('style','margin-left: 8px;');
				var option = document.createElement('option');
				option.setAttribute('value','year');
					
					if (filter1 == 'year') {
						option.setAttribute('selected','selected');
					};
					
					var text = document.createTextNode('Year');
					option.appendChild(text);
				select.appendChild(option);
				

				var option = document.createElement('option');
				option.setAttribute('value','state');
					
					if (filter1 == 'state') {
						option.setAttribute('selected','selected');
					};
					
					var text = document.createTextNode('State');
					option.appendChild(text);
				select.appendChild(option);
				
				var option = document.createElement('option');
				option.setAttribute('value','alpha');
					
					if (filter1 == 'alpha') {
						option.setAttribute('selected','selected');
					};
					
					var text = document.createTextNode('Alphabetical Listing');
					option.appendChild(text);
				select.appendChild(option);
			
			addListener(select, "change", submitFilter, false);
			p.appendChild(select);
		form.appendChild(p);

			if (filter1 != 'alpha') {
				var select = document.createElement('select');
				select.setAttribute('id','filter2');
				select.setAttribute('name','filter2');
				select.setAttribute('style','margin-left: 8px;');
			
					if (filter1 == 'year') {
						for (var x = 0; x < arrayOfYears.length; x++) {
					
							var option = document.createElement('option');
							option.setAttribute('value','year_'+arrayOfYears[x]);
							
								var theYear = filter2.replace("year_", "");
								if (theYear == arrayOfYears[x]) {
									option.setAttribute('selected','selected');
								};
		
								var text = document.createTextNode(arrayOfYears[x]);
								option.appendChild(text);
							select.appendChild(option);	
						};
					
					} else if (filter1 == 'state') {
				
						for (var x = 0; x < arrayOfStates.length; x++) {
					
							var option = document.createElement('option');
							option.setAttribute('value','state_'+arrayOfStates[x]);
							
								var theState = filter2.replace("state_", "");
								if (theState == arrayOfStates[x]) {
									option.setAttribute('selected','selected');
								};
		
								var text = document.createTextNode(arrayOfStates[x]);
								option.appendChild(text);
							select.appendChild(option);	
						};
					};

				
				addListener(select, "change", submitFilter, false);
				p.appendChild(select);
			form.appendChild(p);
			
			};
	//newDiv.appendChild(form);
	//targetDiv.insertBefore(newDiv, targetDiv.firstChild);
	targetDiv.insertBefore(form, targetDiv.firstChild);
	
};


function submitFilter() {

	document.forms["form1"].submit();

};
