// Written by Jayson Ward
// Created 3/28/2007
// Last Updated 4/10/2008

function $(id) { return document.getElementById(id); } //based on prototype library

window.onload = init;
window.onresize = resizeInit;

function init()
{
	mainDiv1 = $('mainDiv'); // variables used in page sizing functions below	
	logoDiv1 = $('logoDiv');
	navDiv = $('pageNavigation');	
	deptNav = $('deptNavigation');
	deptContent1 = $('deptContent');
	pageFooter1 = $('pageFooter');
	
	deptNavGlobalHeight = 0;
	deptContentGlobalHeight = 0;
	deptNavChildrenHeight = 0;
	ieDropDownResize = false;
	pathDepth = getPageLocation();
	
  	setMainDivTrueHeight();
	setMainDivHeight();
 	setupRollOvers();
	setupPopups();
	setupDropDowns();
	setupDeptNavigation();
	setupFormValidation();
	if($('SlideShow'))
	{
		runSlideShow();
	}
}

function resizeInit()
{
	if(ieDropDownResize == false)
	{
		setMainDivHeight();
	}
	else
	{
		ieDropDownResize = false;
	}
}
function setMainDivTrueHeight()
{	
	if (window.innerHeight) //Firefox
	{
		mainDivTrueHeight = $('mainDiv').offsetHeight;
	}
	else //IE
	{
		mainDivTrueHeight = $('mainDiv').offsetHeight;
	}
}
function setMainDivHeight()
{	
		/*  
				This function sets the mainDiv height, the deptNavigation height and the deptContent height.
				If the mainDiv content is shorter than the actual window height, it forces the mainDiv to be
				the full height of the window, then it forces the deptartment navigation div and the department
				content div to fill the screen.  To establish the height for both of these divs you take the 
				window height and subtract the offsetHeights of the logoDiv, the pageNavigation div and the pageFooter div.
				
				THE ADDITION OF MARGINS AND PADDING TO THE DIVS THEMSELVES (NOT CHILDREN OF THE DIVS)
				WILL IMPACT THIS SCRIPT AND IT SHOULD BE ADJUSTED ACCORDINGLY.
		
		*/	
	if (window.innerHeight) // Firefox, Netscape, Mozilla
	{
		var windowHeight = window.innerHeight;		
		
		if(mainDivTrueHeight < windowHeight)
		{
			mainDiv1.style.height = windowHeight + 'px';
			deptNav.style.height = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight - 10) + 'px';
			deptContent1.style.height = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight - 11) + 'px';
			
			deptNavGlobalHeight = parseInt(deptNav.style.height);
			deptContentGlobalHeight = parseInt(deptContent1.style.height);
		}
		else
		{	
			//mainDiv.style.height = mainDivTrueHeight + 'px'
			deptNav.style.height = deptContent1.offsetHeight + 'px';
			deptNavGlobalHeight = deptContent1.offsetHeight;
			deptContentGlobalHeight = deptContent1.offsetHeight;
		}		
	}

	else if (document.documentElement.clientHeight) //IE6 and 7
	{
		var windowHeight = document.documentElement.clientHeight;		
		
		if(mainDivTrueHeight < windowHeight)
		{
			mainDiv1.style.height = windowHeight + 'px';
			deptNav.style.height = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight - 10) + 'px';
			deptContent1.style.height = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight -11) + 'px';
			
			deptNavGlobalHeight = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight - 10);
			deptContentGlobalHeight = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight -10);
		}
		else
		{
			deptNav.style.height = deptContent1.offsetHeight + 'px';
			deptNavGlobalHeight = deptContent1.offsetHeight;
			deptContentGlobalHeight = deptContent1.offsetHeight;
			
		}		
	}
	
	else if (document.body.clientHeight) //IE past
	{
		var windowHeight = document.body.clientHeight;	
		
		if(mainDivTrueHeight > windowHeight)
		{
			mainDiv1.style.height = windowHeight + 'px';
			deptNav.style.height = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight) + 'px';
			deptContent1.style.height = (windowHeight - logoDiv1.offsetHeight - navDiv.offsetHeight - pageFooter1.offsetHeight) + 'px';

			deptNavGlobalHeight = parseInt(deptNav.style.height);
			deptContentGlobalHeight = parseInt(deptContent1.style.height);
		}
		else
		{
			deptNav.style.height = deptContent1.offsetHeight + 'px';
			deptNavGlobalHeight = deptContent1.offsetHeight;
			deptContentGlobalHeight = deptContent1.offsetHeight;
		}
	}
	
	else // None of the above
	{
		return;
	}	
}

function setupRollOvers()
{	
	var navButtons = $('pageNavigation').getElementsByTagName('img');

	for(i=0; i<navButtons.length; i++)
	{
		if(navButtons[i].getAttribute('id') != "") //The id for the image is null when it belongs to the page department
		{
			if(window.innerHeight) //Firefox
			{
				navButtons[i].addEventListener('mouseover', highLiteMe, false);
				navButtons[i].addEventListener('mouseout', unhighLiteMe, false);
			}
			else //IE
			{
				navButtons[i].attachEvent('onmouseover', highLiteMe);
				navButtons[i].attachEvent('onmouseleave', unhighLiteMe);
			}
		}
	}	
}
function setupDeptNavigation()
{
	var deptNav = $('deptNavigation').getElementsByTagName('h3');
	var deptNavH2 = $('deptNavigation').getElementsByTagName('h2'); //Used to calculate the total height of the deptNav Elements
	var deptNavH2Height = 0; //Used to calculate the total height of the deptNav Elements
	
	for(i=0;i<deptNavH2.length; i++)
	{
		deptNavChildrenHeight += deptNavH2[i].offsetHeight; //Adds the height of all H2 elements in the deptNavigation <div> area
	}
	
	for(i=0; i<deptNav.length; i++)
	{		
		if(window.innerHeight) //Fox
		{
			if( (deptNav[i].getAttribute('class') != 'noDropDown') && (deptNav[i].getAttribute('class') != 'sectionHeader') )
			{
				if(deptNav[i].getAttribute('class') != 'sectionNavHeader' && deptNav[i].getAttribute('class') != 'nestedSectionNavHeader')
				{
					deptNav[i].style.cursor = 'pointer';
					deptNav[i].addEventListener('mousedown', showDeptMenu, false);
				
					deptNavChildrenHeight += deptNav[i].offsetHeight + 1; //Adds the height of the h3 tags to the overall height of the deptNav children
					
					for(x=0; x<deptNav.length-1; x++) //Sets border bottom properties for deptNav H1 tags, except for the bottom H1 tag
					{
						if(deptNav[x].getAttribute('class') != 'nestedMenuHeader' && deptNav[x].getAttribute('class') != 'nestedSectionNavHeader')
						{
							deptNav[x].style.borderBottom = '1px solid #ffffff';
						}
					}
				}
				else
				{
					var menuToShow = deptNav[i].getAttribute('id') + 'menu';
					$(menuToShow).style.height = 'auto';
					$(menuToShow).style.display = 'block';
					deptNav[i].style.cursor = 'default';
					deptNav[i].style.borderBottom = '1px solid #ffffff';	
				}
			}// End of if != 'noDropDown' or != 'sectionHeader' 
			else //For the other h3 tags
			{
				deptNav[i].style.borderBottom = '1px solid #ffffff';	
			}
		}//end of if(window.innerHeight)
		
		else if(window.event) //IE
		{
			if( (deptNav[i].getAttribute('className') != 'noDropDown') && (deptNav[i].getAttribute('className') != 'sectionHeader') )
			{						
				if(deptNav[i].getAttribute('className') != 'sectionNavHeader' && deptNav[i].getAttribute('className') != 'nestedSectionNavHeader')
				{
					deptNav[i].style.cursor = 'pointer';
					deptNav[i].attachEvent('onmousedown', showDeptMenu);
				
					deptNavChildrenHeight += deptNav[i].offsetHeight + 1; //Adds the height of the h3 tags to the overall height of the deptNav children
					
					for(x=0; x<deptNav.length-1; x++) //Sets border bottom properties for deptNav H1 tags, except for the bottom H1 tag
					{
						if(deptNav[x].getAttribute('className') != 'nestedMenuHeader' && deptNav[x].getAttribute('className') != 'nestedSectionNavHeader')
						{
							deptNav[x].style.borderBottom = '1px solid #ffffff';
						}
					}
				}
				else
				{
					var menuToShow = deptNav[i].getAttribute('id') + 'menu';
					$(menuToShow).style.height = 'auto';
					$(menuToShow).style.display = 'block';
					deptNav[i].style.cursor = 'default';
					deptNav[i].style.borderBottom = '1px solid #ffffff';

				}
			} // End of IE if != 'noDropDown' or != 'sectionHeader'
			else //For the other h3 tags
			{
				deptNav[i].style.borderBottom = '1px solid #ffffff';	
			}
		} //End of else if(window.event)
	} //End of for(i=0; i<deptNav.length; i++) Loop
	
	deptNavChildrenHeight -= 1; //Subtract one from the overall height to compensate for the lack of a 1pixel border-bottom on the last h3 tag
}

function showDeptMenu(e)
{
	var e = e || mouse.event;
	
	if(window.event) //IE
	{
		var menuTrigger = e.srcElement.getAttribute('id');
		var menuTriggerParent = e.srcElement.parentNode.tagName;
		var menuToShow = menuTrigger + 'menu';

		if ($(menuToShow).offsetHeight <= 0)
		{			
			$(menuToShow).style.height = 'auto';
			$(menuToShow).style.display = 'block';
			if($(menuTrigger).getAttribute('className') != 'nestedMenuHeader')
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/minus.gif)';			
			}
			else
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/minus.gif)';			
			}
			
			deptNavChildrenHeight += $(menuToShow).offsetHeight;
		
			if(deptNavChildrenHeight > deptNavGlobalHeight)
			{
				//IE triggers the window.resize function when the drop down menus become greater in size than the originaly set deptNavGlobalHeight variable.
				//Firefox doesn't do this. In order to keep IE from triggering the resize function the following variable is set to true and tested for in
				//the window.resize function at the beginning of this code page.
				
				ieDropDownResize = true; 
				navigationDifference = deptNavChildrenHeight - deptNavGlobalHeight;
				deptNav.style.height = deptNavGlobalHeight + navigationDifference + 10 + 'px';
				deptContent1.style.height = deptNavGlobalHeight + navigationDifference + 10 + 'px';
				mainDiv1.style.height = logoDiv1.offsetHeight + navDiv.offsetHeight + deptNavGlobalHeight + navigationDifference + 20 + pageFooter1.offsetHeight + 'px';
			}
		}
		
		else
		{
			deptNavChildrenHeight -= $(menuToShow).offsetHeight;
			
			$(menuToShow).style.height = '0px';
			$(menuToShow).style.display = 'none';
			
			if($(menuTrigger).getAttribute('className') != 'nestedMenuHeader')
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/plus.gif)';			
			}
			else
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/plus.gif)';			
			}
	
			if(deptNavChildrenHeight < deptNavGlobalHeight)
			{
				if(deptNavChildrenHeight < deptContentGlobalHeight)
				{
					if(deptContent1.offsetHeight > deptContentGlobalHeight)
					{
						
						deptContent1.style.height = deptContentGlobalHeight + 'px';
						deptNav.style.height = deptNavGlobalHeight + 'px';	
						mainDiv1.style.height = mainDivTrueHeight + 'px';
					}					
					else
					{
						setMainDivHeight();
					}
				}
				
				else
				{
					//document.getElementById('infoBox').innerHTML += 'overthere';
					navigationDifference = deptNavGlobalHeight - deptNavChildrenHeight;			
					deptNav.style.height = deptNavGlobalHeight - navigationDifference + 10 + 'px';
					deptContent1.style.height = deptNavGlobalHeight - navigationDifference + 10 + 'px';
				}
			}			
		}
	}//End IE portion of this function
	
	else //Firefox
	{
		var menuTrigger = this.getAttribute('id');
		var menuToShow = menuTrigger + 'menu';
		
		if ($(menuToShow).offsetHeight <= 0)
		{			
			$(menuToShow).style.height = 'auto';
			$(menuToShow).style.display = 'block';
			
			if($(menuTrigger).getAttribute('class') != 'nestedMenuHeader')
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/minus.gif)';			
			}
			else
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/minus.gif)';			
			}

			deptNavChildrenHeight += $(menuToShow).offsetHeight;
		
			if(deptNavChildrenHeight > deptNavGlobalHeight)
			{
				navigationDifference = deptNavChildrenHeight - deptNavGlobalHeight;
				deptNav.style.height = deptNavGlobalHeight + navigationDifference + 10 + 'px';
				deptContent1.style.height = deptNavGlobalHeight + navigationDifference + 10 + 'px';
				mainDiv1.style.height = logoDiv1.offsetHeight + navDiv.offsetHeight + deptNavGlobalHeight + navigationDifference + 20 + pageFooter1.offsetHeight + 'px';
			}
		}
		else
		{
			deptNavChildrenHeight -= $(menuToShow).offsetHeight;
			
			$(menuToShow).style.height = '0px';
			$(menuToShow).style.display = 'none';
			if($(menuTrigger).getAttribute('class') != 'nestedMenuHeader')
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/plus.gif)';			
			}
			else
			{
				$(menuTrigger).style.backgroundImage = 'url(' + pathDepth + 'images/plus.gif)';			
			}
			
			if(deptNavChildrenHeight < deptNavGlobalHeight)
			{
				if(deptNavChildrenHeight < deptContentGlobalHeight)
				{
					if(deptContent1.offsetHeight > deptContentGlobalHeight)
					{
						deptContent1.style.height = deptContentGlobalHeight + 'px';
						deptNav.style.height = deptNavGlobalHeight + 'px';	
						//mainDiv.style.height = mainDiv.offsetHeight - 11 + 'px';
					}
					
					else
					{
						setMainDivHeight();
					}
				}				
				else
				{
					navigationDifference = deptNavGlobalHeight - deptNavChildrenHeight;			
					deptNav.style.height = deptNavGlobalHeight - navigationDifference + 10 + 'px';
					deptContent1.style.height = deptNavGlobalHeight - navigationDifference + 10 + 'px';
				}
			}			
		}
	}	
}

function highLiteMe(e)
{
	var e = e || mouse.event;
	
	if(window.event) //IE
	{
		var imageToShow = pathDepth + 'images/' + e.srcElement.getAttribute('id') + '2.gif';
		e.srcElement.setAttribute('src', imageToShow);
		
	}
	else //Firefox
	{
		var imageToShow = pathDepth + 'images/' + this.getAttribute('id') + '2.gif';
		this.setAttribute('src', imageToShow);
		
	}	
}
function unhighLiteMe(e)
{
	var e = e || mouse.event;
	
	if(window.event) //IE
	{
		var imageToShow = pathDepth + 'images/' + e.srcElement.getAttribute('id') + '.gif';
		e.srcElement.setAttribute('src', imageToShow);
		
	}
	else //Firefox
	{
		var imageToShow = pathDepth + 'images/' + this.getAttribute('id') + '.gif';
		this.setAttribute('src', imageToShow);
	}	
}
function setupPopups()
{
	if($('popupWindows'))
	{
		if(window.innerHeight)//Fox
		{
			if($('cacMap')){ $('cacMap').addEventListener('mousedown', showMap, false);	}
			if($('desertMap')){ $('desertMap').addEventListener('mousedown', showMap, false); }
			if($('socoMap')){ $('socoMap').addEventListener('mousedown', showMap, false); }
			if($('ord810fees')){ $('ord810fees').addEventListener('mousedown', showPopup, false); }
		}
		else //IE
		{
			if($('cacMap')){ $('cacMap').attachEvent('onmousedown', showMap); }
			if($('desertMap')){ $('desertMap').attachEvent('onmousedown', showMap); }
			if($('socoMap')){ $('socoMap').attachEvent('onmousedown', showMap); }
			if($('ord810fees')){ $('ord810fees').attachEvent('onmousedown', showPopup);	}
		}
	}
	else
	{
		return;
	}
}
function setupDropDowns()
{
	if($('dropDownsContainer'))
	{
		var dropDownTriggers = $('dropDownsContainer').getElementsByTagName('h3');
		
		for(i=0; i<dropDownTriggers.length; i++)
		{
			if(window.innerHeight) //Firefox
			{
				dropDownTriggers[i].addEventListener('mousedown', displayDropDownData, false);
				dropDownTriggers[i].style.cursor = 'pointer';
			}
			else //IE
			{
				dropDownTriggers[i].attachEvent('onmousedown', displayDropDownData);
				dropDownTriggers[i].style.cursor = 'pointer';
			}
		}
	}
	else
	{
		return;
	}
}
function showPopup(e) //THIS FUNCTION IS DEVELOPMENT CODE AND NEEDS TO BE OPTIMIZED PRIOR TO THE WEBSITE GOING INTO PRODUCTION.
{
	var e = e || mouse.event;
	var popupWidth = 730; //This is a size that will work in an 800 x 600 screen
	var popupHeight = 450;
	
	if(window.event) //IE
	{
		var popupToShow = e.srcElement.getAttribute('id');
		
		var popupWindow = document.createElement('div');
		popupWindow.style.left = ((document.documentElement.clientWidth - popupWidth) / 2) + 'px';
		popupWindow.style.top = ((document.documentElement.clientHeight - popupHeight) / 2) + 'px';		
		popupWindow.setAttribute('id', 'popupWindow');
		popupWindow.className = 'popupWindowDiv';
		
		var popupWindowShadow = document.createElement('div');
		popupWindowShadow.style.left = ((document.documentElement.clientWidth - popupWidth) / 2 + 10) + 'px';
		popupWindowShadow.style.top = ((document.documentElement.clientHeight - popupHeight) / 2 + 10) + 'px';		
		popupWindowShadow.style.filter = 'alpha(opacity=50)';
		popupWindowShadow.setAttribute('id', 'popupWindowShadow');
		popupWindowShadow.className = 'popupWindowDivShadow';		
	}
	else //Fox, etc.
	{
		var popupToShow = this.getAttribute('id');
		
		var popupWindow = document.createElement('div');
		popupWindow.style.left = ((window.innerWidth - popupWidth) / 2) + 'px';
		popupWindow.style.top = ((window.innerHeight - popupHeight) / 2) + 'px';		
		popupWindow.setAttribute('id', 'popupWindow');
		popupWindow.setAttribute('class', 'popupWindowDiv');
		
		var popupWindowShadow = document.createElement('div');
		popupWindowShadow.style.left = ((window.innerWidth - popupWidth) / 2 + 10) + 'px';
		popupWindowShadow.style.top = ((window.innerHeight - popupHeight) / 2 + 10) + 'px';		
		popupWindowShadow.style.opacity = '.5';
		popupWindowShadow.setAttribute('id', 'popupWindowShadow');
		popupWindowShadow.setAttribute('class', 'popupWindowDivShadow');
	}
		
	var xhr = createXMLHttpRequest();
	xhr.onreadystatechange = function()
	{	
		if(xhr.readyState==4)
		{
			if(xhr.status==200)
			{
				popupWindow.innerHTML = xhr.responseText;
			}
			else
			{
				popupWindow.innerHTML = "Error Loading. We apologize for any inconvenience.<br />" +
				"<p style=\"clear:both;margin-right:11px;\"><a href=\"#\" onmousedown=\"javascript: document.body.removeChild(document.getElementById('mapWindowShadow'))\" onclick=\"javascript: document.body.removeChild(document.getElementById('mapWindows'))\">Close Window</a></p>";
			}			
		}	
		else //While the external text is loading display a loading image
		{
			popupWindow.innerHTML = '<img src="' + pathDepth + 'images/loading.gif">';
		}
	}
	var fileToGet = pathDepth + 'common/' + popupToShow + '.html';
	xhr.open("GET", fileToGet, true);
	xhr.send(null);
		
	document.body.appendChild(popupWindow);
	document.body.appendChild(popupWindowShadow);
}
function showMap(e) //THIS FUNCTION IS DEVELOPMENT CODE AND NEEDS TO BE OPTIMIZED PRIOR TO THE WEBSITE GOING INTO PRODUCTION.
{
	var e = e || mouse.event;
	
	if(window.event) //IE
	{
		var mapToShow = e.srcElement.getAttribute('id');
		
		var mapWindow = document.createElement('div');
		mapWindow.style.left = ( e.clientX < 158 ? (e.clientX + e.srcElement.offsetWidth - 30 + 'px') : ($('mainDiv').offsetLeft + 20 + 'px') );
		mapWindow.style.top = (e.clientY - 250) + 'px';
		mapWindow.setAttribute('id', 'mapWindows');
		mapWindow.className = 'popupWindowDiv';
		
		var mapWindowShadow = document.createElement('div');
		mapWindowShadow.style.left = ( e.clientX < 158 ? (e.clientX + e.srcElement.offsetWidth - 20 + 'px') : ($('mainDiv').offsetLeft + 30 + 'px') );
		mapWindowShadow.style.top = (e.clientY - 240) + 'px';
		mapWindowShadow.style.filter = 'alpha(opacity=50)';
		mapWindowShadow.setAttribute('id', 'mapWindowShadow');
		mapWindowShadow.className = 'popupWindowDivShadow';		
	}
	else //Fox, etc.
	{
		var mapToShow = this.getAttribute('id');
		
		var mapWindow = document.createElement('div');
		mapWindow.style.left = ( this.offsetLeft < 158 ? (this.offsetLeft + this.offsetWidth - 20 + 'px') : ($('mainDiv').offsetLeft + 20 + 'px') );
		mapWindow.style.top = this.offsetTop - 250 + 'px';
		mapWindow.setAttribute('id', 'mapWindows');
		mapWindow.setAttribute('class', 'popupWindowDiv');
		
		var mapWindowShadow = document.createElement('div');
		mapWindowShadow.style.left = ( this.offsetLeft < 158 ? (this.offsetLeft + this.offsetWidth - 10 + 'px') : ($('mainDiv').offsetLeft + 30 + 'px') );
		mapWindowShadow.style.top = this.offsetTop - 240 + 'px';
		mapWindowShadow.style.opacity = '.5';
		mapWindowShadow.setAttribute('id', 'mapWindowShadow');
		mapWindowShadow.setAttribute('class', 'popupWindowDivShadow');
	}
		
	var xhr = createXMLHttpRequest();
	xhr.onreadystatechange = function()
	{	
		if(xhr.readyState==4)
		{
			if(xhr.status==200)
			{
				mapWindow.innerHTML = '<img src="' + pathDepth + 'images/' + mapToShow + '.gif" alt="' + mapToShow + '" width="552" height="388" style="float:left;margin:0px;padding:0px;"/>' + xhr.responseText;
			}
			else
			{
				mapWindow.innerHTML = "Error Loading Map. We apologize for any inconvenience.<br />" +
				"<p style=\"clear:both;margin-right:11px;\"><a href=\"#\" onmousedown=\"javascript: document.body.removeChild(document.getElementById('mapWindowShadow'))\" onclick=\"javascript: document.body.removeChild(document.getElementById('mapWindows'))\">Close Window</a></p>";
			}			
		}	
		else //While the external text is loading display a loading image
		{
			mapWindow.innerHTML = '<img src="' + pathDepth + 'images/loading.gif">';
		}
	}
	var fileToGet = pathDepth + 'common/' + mapToShow + '.html';
	xhr.open("GET", fileToGet, true);
	xhr.send(null);
		
	document.body.appendChild(mapWindow);
	document.body.appendChild(mapWindowShadow);
}
function displayDropDownData(e)
{
	var e = e || mouse.event;
	
	if(window.event) //IE
	{
		var dropDownTrigger = e.srcElement.getAttribute('id');
		
		if(dropDownTrigger.substring(dropDownTrigger.length-1, dropDownTrigger.length) != 'x')
		{
			var dataToShow = e.srcElement.getAttribute('id') + 'data';
			e.srcElement.setAttribute('id', e.srcElement.getAttribute('id') + 'x');
			$(dataToShow).style.display = 'block';
			$(e.srcElement.getAttribute('id')).style.backgroundImage = 'url(' + pathDepth + 'images/quick_minus.gif)';
			$(e.srcElement.getAttribute('id')).style.backgroundColor = '#eeeeee';
			document.body.style.height = document.body.offsetHeight + $(dataToShow).offsetHeight + 'px';
			$('deptContent').style.height = $('deptContent').offsetHeight + $(dataToShow).offsetHeight + 'px';
			$('deptNavigation').style.height = $('deptNavigation').offsetHeight + $(dataToShow).offsetHeight + 'px';
		}
		else
		{
			var resetDropDownTrigger = e.srcElement.getAttribute('id');
			resetDropDownTrigger = resetDropDownTrigger.substr(0, resetDropDownTrigger.length-1);
			e.srcElement.setAttribute('id', resetDropDownTrigger);
			var dataToShow = e.srcElement.getAttribute('id') + 'data';
			var dataHeight = $(dataToShow).offsetHeight;
			$(dataToShow).style.display = 'none';
			$(e.srcElement.getAttribute('id')).style.backgroundImage = 'url(' + pathDepth + 'images/quick_plus.gif)';
			$(e.srcElement.getAttribute('id')).style.backgroundColor = '';
			document.body.style.height = '100%';
			setMainDivHeight();
		}		
	}
	else //Firefox
	{
		var dropDownTrigger = this.getAttribute('id');
		
		if(dropDownTrigger.substring(dropDownTrigger.length-1, dropDownTrigger.length) != 'x')
		{
			var dataToShow = this.getAttribute('id') + 'data';
			this.setAttribute('id', this.getAttribute('id') + 'x');
			$(dataToShow).style.display = 'block';
			$(this.getAttribute('id')).style.backgroundImage = 'url(' + pathDepth + 'images/quick_minus.gif)';
			$(this.getAttribute('id')).style.backgroundColor = '#eeeeee';
			document.body.style.height = document.body.offsetHeight + $(dataToShow).offsetHeight + 'px';
			$('deptContent').style.height = $('deptContent').offsetHeight + $(dataToShow).offsetHeight + 'px';
			$('deptNavigation').style.height = $('deptNavigation').offsetHeight + $(dataToShow).offsetHeight + 'px';
		}
		else
		{
			var resetDropDownTrigger = this.getAttribute('id');
			resetDropDownTrigger = resetDropDownTrigger.substr(0, resetDropDownTrigger.length-1);
			this.setAttribute('id', resetDropDownTrigger);
			var queryToShow = this.getAttribute('id') + 'data';
			$(queryToShow).style.display = 'none';
			$(this.getAttribute('id')).style.backgroundImage = 'url(' + pathDepth + 'images/quick_plus.gif)';
			$(this.getAttribute('id')).style.backgroundColor = '';
			document.body.style.height = '100%';
			setMainDivHeight();
		}
	}	
}
function createXMLHttpRequest()
{
	try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch(e) {}
	try { return new ActiveXObject("Microsoft.XMLHTTP"); } catch(e) {}
	try { return new XMLHttpRequest(); } catch(e) {}
	alert("XMLHttpRequest not supported");
	return null;	
}
function setupFormValidation()
{
	var formElements = document.getElementsByTagName('form');
	
	for(i=0; i<formElements.length; i++)
	{
		if(formElements[i].getAttribute('id').search(/^apn/i) != -1) // for apn based queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkAPN);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkAPN, false);
			}	
		}
		else if(formElements[i].getAttribute('id').search(/address/i) != -1) // for address based queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkAddress);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkAddress, false);
			}				
		}
		else if(formElements[i].getAttribute('id').search(/case/i) != -1) // for queries that involve cases from multiple departments such as planning and b and s
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkCaseNumber);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkCaseNumber, false);
			}				
		}
		else if(formElements[i].getAttribute('id').search(/planning/i) != -1) // for planning related queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkCaseNumber);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkCaseNumber, false);
			}				
		}
		else if(formElements[i].getAttribute('id').search(/trans/i) != -1) // for transporation related queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkCaseNumber);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkCaseNumber, false);
			}				
		}
		if(formElements[i].getAttribute('id').search(/bands/i) != -1) // for building and safety queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkCaseNumber);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkCaseNumber, false);
			}				
		}
		if(formElements[i].getAttribute('id').search(/survey/i) != -1) // for survey related queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkCaseNumber);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkCaseNumber, false);
			}				
		}
		if(formElements[i].getAttribute('id').search(/^date/i) != -1) // for date related queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkDate);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkDate, false);
			}	
		}
		if(formElements[i].getAttribute('id').search(/^name/i) != -1) // for name, text-only based queries
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkName);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkName, false);
			}	
		}
		if(formElements[i].getAttribute('id').search(/ceViolationReport/i) != -1) // for the code enforcement violation report
		{
			if(window.event) //IE
			{
				formElements[i].attachEvent('onsubmit', checkCEViolationReport);
			}
			else //Fox
			{
				formElements[i].addEventListener('submit', checkCEViolationReport, false);
			}	
		}
		else if(formElements[i].getAttribute('id') == "")
		{
			//do nothing	
		}
	} // end for loop
}	// end setupFormValidation function
function checkCaseNumber(e) // Function validates case numbers for b and s, planning, trans, and survey queries
{
	
	var planningCasePattern = /^TR\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGM\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGN\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AG\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^COC\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^CUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^CZ\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^DA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^EA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^EIR\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^HOG\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^OAD\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PM\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGE\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^GPA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^SP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^LLA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PAR\d{3,6}$|^SBA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^WCS\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^SMP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^RCL\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^RP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^TUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^SUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^UPH\d{5,7}$|^FSM\d{5,7}$|^FPM\d{5,7}$/i;
	
	//var planningCasePattern = /^TR\d{5,6}$|^AGM\d{5,6}$|^COC\d{5,6}$|^CUP\d{5,6}$|^CZ\d{5,6}$|^DA\d{5,6}$|^EA\d{5,6}$|^EIR\d{5,6}$|^HOG\d{5,6}$|^OAD\d{5,6}$|^PM\d{5,6}$|^PP\d{5,6}$|^AGE\d{5,6}$|^GPA\d{5,6}$|^SP\d{5,6}$|^LLA\d{5,6}$|^PAR\d{5,6}$|^SBA\d{5,6}$/i; // RegEx for Planning case types only
	
	var bandsCasePattern = /^BNR\d{5,7}$|^BTI\d{5,7}$|^BME\d{5,7}$|^BPL\d{5,7}$|^BSP\d{5,7}$|^BDE\d{5,7}$|^BEL\d{5,7}$|^BRR\d{5,7}$|^BHR\d{5,7}$|^BAS\d{5,7}$|^BCT\d{5,7}$|^BSD\d{5,7}$|^BMK\d{5,7}$|^BRS\d{5,7}$|^BRE\d{5,7}$|^BMN\d{5,7}$|^BPT\d{5,7}$|^BSN\d{5,7}$|^BMR\d{5,7}$|^BAR\d{5,7}$|^BWE\d{5,7}$|^BWL\d{5,7}$|^BTW\d{5,7}$|^BXX\d{5,7}$|^BGR\d{5,7}$|^BFE\d{5,7}$|^BTW\d{5,7}$|MT\d{5,7}$|^BZ\d{5,7}$/i; // RegExp for Building and Safety case types only
	
	var transCasePattern = /^IP\d{5,7}$|^TRAN\d{5,7}$|^MITF\d\d{5,7}$/i; // RegExp for Transportation case types only
	
	var surveyCasePattern = /^SUR\d{5,7}$|^AB\d{5,7}$|^ROS\d{5,7}$|^SNC\d{5,7}$|^FSM\d{5,7}$|^FPM\d{5,7}$|^MAP\d{5,7}$/i; // RegExp for Survey case types only
	
	var anyCaseTypePattern = /^TR\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGM\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGN\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AG\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^COC\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^CUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^CZ\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^DA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^EA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^EIR\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^HOG\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^OAD\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PM\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^AGE\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^GPA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^SP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^LLA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PAR\d{3,6}$|^SBA\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^WCS\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^SMP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^RCL\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^PUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^RP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^TUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^SUP\d{3,6}(([A,M,R,S][1-9A-Z])?)$|^UPH\d{5,7}$|^BNR\d{5,7}$|^BTI\d{5,7}$|^BME\d{5,7}$|^BPL\d{5,7}$|^BSP\d{5,7}$|^BDE\d{5,7}$|^BEL\d{5,7}$|^BRR\d{5,7}$|^BHR\d{5,7}$|^BAS\d{5,7}$|^BCT\d{5,7}$|^BSD\d{5,7}$|^BMK\d{5,7}$|^BRS\d{5,7}$|^BRE\d{5,7}$|^BMN\d{5,7}$|^BPT\d{5,7}$|^BSN\d{5,7}$|^BMR\d{5,7}$|^BAR\d{5,7}$|^BWE\d{5,7}$|^BWL\d{5,7}$|^BTW\d{5,7}$|^BXX\d{5,7}$|^BZ\d{5,7}$|^BFE\d{5,7}$|^BTW\d{5,7}$|^BGR\d{5,7}$/i; // RegExp for all case types that information can be retrieved for the type of query - this is for more generic queries such as apns attached to a case number
	
	if(window.event) //IE start
	{
		var formUsed = event.srcElement.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if(formUsed.search(/planning/i) != -1)
		{		
			if( planningCasePattern.test(formValue) != true )
				{
					event.returnValue = false;
					$(formUsed).elements[0].style.backgroundColor = "yellow";
					$(formUsed).elements[0].value = "";
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
					$(validationInfo).style.display = 'block';
			}
			else
			{
					$(validationInfo).style.display = 'none';
					$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/case/i) != -1)
		{		
			if( anyCaseTypePattern.test(formValue) != true )
				{
					event.returnValue = false;
					$(formUsed).elements[0].style.backgroundColor = "yellow";
					$(formUsed).elements[0].value = "";
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
					$(validationInfo).style.display = 'block';
			}
			else
			{
					$(validationInfo).style.display = 'none';
					$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/bands/i) != -1)
		{		
			if( bandsCasePattern.test(formValue) != true )
				{
					event.returnValue = false;
					$(formUsed).elements[0].style.backgroundColor = "yellow";
					$(formUsed).elements[0].value = "";
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
					$(validationInfo).style.display = 'block';
			}
			else
			{
					$(validationInfo).style.display = 'none';
					$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/trans/i) != -1)
		{		
			if( transCasePattern.test(formValue) != true )
				{
					event.returnValue = false;
					$(formUsed).elements[0].style.backgroundColor = "yellow";
					$(formUsed).elements[0].value = "";
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
					$(validationInfo).style.display = 'block';
			}
			else
			{
					$(validationInfo).style.display = 'none';
					$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/survey/i) != -1)
		{		
			if( surveyCasePattern.test(formValue) != true )
				{
					event.returnValue = false;
					$(formUsed).elements[0].style.backgroundColor = "yellow";
					$(formUsed).elements[0].value = "";
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
					$(validationInfo).style.display = 'block';
			}
			else
			{
					$(validationInfo).style.display = 'none';
					$(submitButton).disabled = true;
			}
		}
	} // IE end
	else // Fox start
	{
		var formUsed = this.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if(formUsed.search(/planning/i) != -1)
		{		
			if( planningCasePattern.test(formValue) != true )
			{
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
				$(validationInfo).style.display = 'block';
				e.preventDefault();
				$(formUsed).elements[0].value = "";
				$(formUsed).elements[0].style.backgroundColor = 'yellow';
			}
			else
			{
				$(validationInfo).style.display = 'none';
				$(formUsed).elements[0].style.backgroundColor = '';
				$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/case/i) != -1)
		{		
			if( anyCaseTypePattern.test(formValue) != true )
			{
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
				$(validationInfo).style.display = 'block';
				e.preventDefault();
				$(formUsed).elements[0].value = "";
				$(formUsed).elements[0].style.backgroundColor = 'yellow';
			}
			else
			{
				$(validationInfo).style.display = 'none';
				$(formUsed).elements[0].style.backgroundColor = '';
				$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/bands/i) != -1)
		{		
			if( bandsCasePattern.test(formValue) != true )
			{
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
				$(validationInfo).style.display = 'block';
				e.preventDefault();
				$(formUsed).elements[0].value = "";
				$(formUsed).elements[0].style.backgroundColor = 'yellow';
			}
			else
			{
				$(validationInfo).style.display = 'none';
				$(formUsed).elements[0].style.backgroundColor = '';
				$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/trans/i) != -1)
		{		
			if( transCasePattern.test(formValue) != true )
			{
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
				$(validationInfo).style.display = 'block';
				e.preventDefault();
				$(formUsed).elements[0].value = "";
				$(formUsed).elements[0].style.backgroundColor = 'yellow';
			}
			else
			{
				$(validationInfo).style.display = 'none';
				$(formUsed).elements[0].style.backgroundColor = '';
				$(submitButton).disabled = true;
			}
		}
		else if(formUsed.search(/survey/i) != -1)
		{		
			if( surveyCasePattern.test(formValue) != true )
			{
					$(validationInfo).innerHTML = 'INVALID CASE NUMBER. <a href="' + pathDepth +'online/content/project_number_scheme.aspx">CLICK HERE TO VIEW INFORMATION ON PROJECT NUMBERING SCHEMES.</a>';
				$(validationInfo).style.display = 'block';
				e.preventDefault();
				$(formUsed).elements[0].value = "";
				$(formUsed).elements[0].style.backgroundColor = 'yellow';
			}
			else
			{
				$(validationInfo).style.display = 'none';
				$(formUsed).elements[0].style.backgroundColor = '';
				$(submitButton).disabled = true;
			}
		}
	} // Fox end
} // end checkCaseNumber function

function checkAPN(e) // Function validates APN numbers from query forms
{
	var apnPattern = /^\d\d\d\d\d\d\d\d\d$/; //RegEx for APN
	
	if(window.event) //IE start
	{
		var formUsed = event.srcElement.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if(apnPattern.test(formValue) != true)
		{
			$(validationInfo).innerHTML = 'INVALID APN. PLEASE ENTER 9 DIGITS WITH NO HYPHENS';
			$(validationInfo).style.display = 'block';
			event.returnValue = false;
			$(formUsed).elements[0].value = "";
			$(formUsed).elements[0].style.backgroundColor = 'yellow';
		}
		else
		{
			$(validationInfo).style.display = 'none';
			$(submitButton).disabled = true;
		}
	} // IE end
	else // Fox start
	{
		var formUsed = this.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if(apnPattern.test(formValue) != true)
		{
			
			$(validationInfo).innerHTML = 'INVALID APN. PLEASE ENTER 9 DIGITS WITH NO HYPHENS';
			$(validationInfo).style.display = 'block';
			e.preventDefault();
			$(formUsed).elements[0].value = "";
			$(formUsed).elements[0].style.backgroundColor = 'yellow';
		}
		else
		{
			$(validationInfo).style.display = 'none';
			$(formUsed).elements[0].style.backgroundColor = '';
			$(submitButton).disabled = true;
		}
	} // Fox end
} // end checkAPN function
function checkAddress(e) // form validates address input
{
	if(window.event) //IE start
	{
		var formUsed = event.srcElement.getAttribute('id');
		var arrayLength = $(formUsed).length;
		var validationInfo = formUsed + 'ValidationInfo';
		
		for(i=0; i<arrayLength; i++)
		{
			if($(formUsed).elements[i].value == '')
			{
				event.returnValue = false;
				$(formUsed).elements[i].style.backgroundColor = "yellow";
				$(validationInfo).style.fontWeight = 'bold';
				$(validationInfo).innerHTML = "ALL FIELDS REQUIRED. <br />Please enter both a Street Number and Street Name and choose the appropriate Street Type. Otherwise, you will not get accurate results.";
			}
		}	
	} // IE end
	else //Fox start
	{
		var arrayLength = this.length;
		var formUsed = this.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		
		for (i=0; i < arrayLength; i++)
		{
			if(this.elements[i].value == '')
			{
				e.preventDefault();
				this.elements[i].style.backgroundColor = "yellow";
				$(validationInfo).style.fontWeight = 'bold';
				$(validationInfo).innerHTML = "ALL FIELDS REQUIRED. <br />Please enter both a Street Number and Street Name and choose the appropriate Street Type. Otherwise, you will not get accurate results.";
			}
		}
	} // Fox end
} // end checkAddress function

function checkDate(e) // validates date
{
	var dateCheck = /(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d/; // regExp for date
	
	if(window.event) //IE start
	{
		var formUsed = event.srcElement.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if(dateCheck.test(formValue) != true)
		{
			$(validationInfo).innerHTML = 'INVALID DATE. Please enter like: 03/04/2005, with a zero preceding single digit months and years.';
			$(validationInfo).style.display = 'block';
			event.returnValue = false;
			$(formUsed).elements[0].value = "";
			$(formUsed).elements[0].style.backgroundColor = 'yellow';
		}
		else
		{
			$(validationInfo).style.display = 'none';
			$(formUsed).elements[0].style.backgroundColor = '';
			$(submitButton).disabled = true;
		}
	} // IE end
	else // Fox start
	{
		var formUsed = this.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if(dateCheck.test(formValue) != true)
		{
			
			$(validationInfo).innerHTML = 'INVALID DATE. Please enter like: 03/04/2005, with a zero preceding single digit months and years.';
			$(validationInfo).style.display = 'block';
			e.preventDefault();
			$(formUsed).elements[0].value = "";
			$(formUsed).elements[0].style.backgroundColor = 'yellow';
		}
		else
		{
			$(validationInfo).style.display = 'none';
			$(formUsed).elements[0].style.backgroundColor = '';
			$(submitButton).disabled = true;
		}
	} // Fox end

} // end checkDate function

function checkName(e) // makes sure only text is entered and no numbers, etc.
{
	var nameCheck = /^\D/; // regExp for date
	
	if(window.event) //IE start
	{
		var formUsed = event.srcElement.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if( nameCheck.test(formValue) != true)
		{
			$(validationInfo).innerHTML = 'Names can only contain letters, not numbers.';
			$(validationInfo).style.display = 'block';
			event.returnValue = false;
			$(formUsed).elements[0].value = "";
			$(formUsed).elements[0].style.backgroundColor = 'yellow';
		}
		else
		{
			$(validationInfo).style.display = 'none';
			$(formUsed).elements[0].style.backgroundColor = '';
			$(submitButton).disabled = true;
		}
	} // IE end
	else // Fox start
	{
		var formUsed = this.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var formValue = $(formUsed).elements[0].value;
		
		if( nameCheck.test(formValue) != true )
		{
			
			$(validationInfo).innerHTML = 'Names can only contain letters, not numbers.';
			$(validationInfo).style.display = 'block';
			e.preventDefault();
			$(formUsed).elements[0].value = "";
			$(formUsed).elements[0].style.backgroundColor = 'yellow';
		}
		else
		{
			$(validationInfo).style.display = 'none';
			$(formUsed).elements[0].style.backgroundColor = '';
			$(submitButton).disabled = true;
		}
	} // Fox end
	// Code
	
} //end checkName function

function checkCEViolationReport(e) // validates that all required information is submitted on the ce violation report
{
	if(window.event) // IE start
	{
		var formUsed = event.srcElement.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var arrayLength = $(formUsed).length;
		var emailRegEx = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
		
		if( ( $(formUsed).sPhone.value == '' || $(formUsed).sName.value == '' || $(formUsed).vAddress.value == '' || $(formUsed).vDetails.value == '' ||  $(formUsed).vComm.value == '' || $(formUsed).vType.value == '' ) && ( $(formUsed).sEmail.value == '' ) )
		{
			for(i=0; i < arrayLength; i++)
			{
				if($(formUsed).elements[i].value == '')
				{
					event.returnValue = false;
					$(formUsed).elements[i].style.backgroundColor = "yellow";
				}
			}
			$(validationInfo).innerHTML = 'PLEASE ENTER THE REQUIRED INFORMATION. An * denotes a required field.';
			$(validationInfo).style.display = 'block';
			$(formUsed).sEmail.style.backgroundColor = "";
			$(formUsed).sPhone2.style.backgroundColor = "";
			$(formUsed).sAddr.style.backgroundColor = "";
		}
		else if( ( $(formUsed).sPhone.value == '' || $(formUsed).sName.value == '' || $(formUsed).vAddress.value == '' || $(formUsed).vDetails.value == '' ||  $(formUsed).vComm.value == '' || $(formUsed).vType.value == '' ) && ( $(formUsed).sEmail.value != '' ) )
		{
			for(i=0; i < arrayLength; i++)
			{
				if($(formUsed).elements[i].value == '')
				{
					event.returnValue = false;
					$(formUsed).elements[i].style.backgroundColor = "yellow";
				}
			}
			
			if(emailRegEx.test($(formUsed).sEmail.value) != true)
			{
				$(validationInfo).innerHTML = "PLEASE ENTER THE REQUIRED INFORMATION. AN * denotes a required field.<br /><br />The e-mail address entered is invalid. Please enter a valid e-mail address (e.g. somebody@domain.com)";	
				$(validationInfo).style.display = 'block';
				$(formUsed).sEmail.style.backgroundColor = "yellow";
				$(formUsed).sPhone2.style.backgroundColor = "";
				$(formUsed).sAddr.style.backgroundColor = "";
			}
			else
			{
				$(validationInfo).innerHTML = 'PLEASE ENTER THE REQUIRED INFORMATION. An * denotes a required field.';
				$(validationInfo).style.display = 'block';
				$(formUsed).sEmail.style.backgroundColor = "";
				$(formUsed).sPhone2.style.backgroundColor = "";
				$(formUsed).sAddr.style.backgroundColor = "";
			}
		}
		else if( ( $(formUsed).sPhone.value != '' || $(formUsed).sName.value != '' || $(formUsed).vAddress.value != '' || $(formUsed).vDetails.value != '' ||  $(formUsed).vComm.value != '' || $(formUsed).vType.value != '' ) && ( $(formUsed).sEmail.value != '' ) )
		{
			if(emailRegEx.test($(formUsed).sEmail.value) != true)
			{
			event.returnValue = false;
			$(validationInfo).innerHTML = "The e-mail address entered is invalid. Please enter a valid e-mail address (e.g. somebody@domain.com)";	
			$(validationInfo).style.display = 'block';
			$(formUsed).sEmail.style.backgroundColor = "yellow";
			}
		}
		else
		{
			$(submitButton).disabled = true;
			event.returnValue = true;
		}
	} // IE end
	else // Fox start
	{
		var formUsed = this.getAttribute('id');
		var validationInfo = formUsed + 'ValidationInfo';
		var submitButton = formUsed + 'SearchSubmit';
		var emailRegEx = /^[_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*\.(([0-9]{1,3})|([a-zA-Z]{2,3})|(aero|coop|info|museum|name))$/;
		
		if( ( $(formUsed).sPhone.value == '' || $(formUsed).sName.value == '' || $(formUsed).vAddress.value == '' || $(formUsed).vDetails.value == '' ||  $(formUsed).vComm.value == '' || $(formUsed).vType.value == '' ) && ( $(formUsed).sEmail.value == '' ) )
		{
			for(i=0; i < this.length; i++)
			{
				if(this.elements[i].value == '')
				{
					e.preventDefault();
					this.elements[i].style.backgroundColor = "yellow";
				}
			}
			$(validationInfo).innerHTML = 'PLEASE ENTER THE REQUIRED INFORMATION. An * denotes a required field.';
			$(validationInfo).style.display = 'block';
			$(formUsed).sEmail.style.backgroundColor = "";
			$(formUsed).sPhone2.style.backgroundColor = "";
			$(formUsed).sAddr.style.backgroundColor = "";
		}		
		else if( ( $(formUsed).sPhone.value == '' || $(formUsed).sName.value == '' || $(formUsed).vAddress.value == '' || $(formUsed).vDetails.value == '' ||  $(formUsed).vComm.value == '' || $(formUsed).vType.value == '' ) && ( $(formUsed).sEmail.value != '' ) )
		{
			for(i=0; i < this.length; i++)
			{
				if(this.elements[i].value == '')
				{
					e.preventDefault();
					this.elements[i].style.backgroundColor = "yellow";
				}
			}
			
			if(emailRegEx.test($(formUsed).sEmail.value) != true)
			{
				$(validationInfo).innerHTML = "PLEASE ENTER THE REQUIRED INFORMATION. AN * denotes a required field.<br /><br />The e-mail address entered is invalid. Please enter a valid e-mail address (e.g. somebody@domain.com)";	
				$(validationInfo).style.display = 'block';
				$(formUsed).sEmail.style.backgroundColor = "yellow";
				$(formUsed).sPhone2.style.backgroundColor = "";
				$(formUsed).sAddr.style.backgroundColor = "";
			}
			else
			{
				$(validationInfo).innerHTML = 'PLEASE ENTER THE REQUIRED INFORMATION. An * denotes a required field.';
				$(validationInfo).style.display = 'block';
				$(formUsed).sEmail.style.backgroundColor = "";
				$(formUsed).sPhone2.style.backgroundColor = "";
				$(formUsed).sAddr.style.backgroundColor = "";
			}
		}
		else if( ( $(formUsed).sPhone.value != '' || $(formUsed).sName.value != '' || $(formUsed).vAddress.value != '' || $(formUsed).vDetails.value != '' ||  $(formUsed).vComm.value != '' || $(formUsed).vType.value != '' ) && ( $(formUsed).sEmail.value != '' ) )
		{
			if(emailRegEx.test($(formUsed).sEmail.value) != true)
			{
				e.preventDefault();
				$(validationInfo).innerHTML = "The e-mail address entered is invalid. Please enter a valid e-mail address (e.g. somebody@domain.com)";	
				$(validationInfo).style.display = 'block';
				$(formUsed).sEmail.style.backgroundColor = "yellow";
			}
		}
		else
		{
			$(submitButton).disabled = true;
			return;
		}
	} // Fox end
} // end checkCEValidation function
function getPageLocation()
{
	var pageLocation = window.location.pathname.toString();
	var pathName = pageLocation.split("/");

 	var fileDepth = pathName.length - 3; // FOR DEVELOPMENT VERSION
	//var fileDepth = pathName.length - 2; // FOR LIVE VERSION
	var pathDepthToAdd = '';
	
	for(i = 0; i<fileDepth; i++)
	{
		pathDepthToAdd += "../";		
	}
	return pathDepthToAdd;
}

