/* 
 *	index.js
 *	Purpose: used for js functions on the index page
 *
 *	Written by:  Don Deskins
 *	Last Modified:  01/16/06
 *
 */

function getSearchBoxes(recent)
{
	if (recent == 'recent')
		{
			document.getElementById('propertySearchType').selectedIndex = 1;
			//document.getElementById('propertySearchType').selected = "selected";
			//document.getElementById('propertySearchType').style.background.color = "CCCCCC";
			
		}
		
	getPropertySearchBox();
	getGisSearchBox();
	/*if(document.getElementById('archiveRecordType').value=='marriageRecords')
		document.getElementById('archiveRecordType').value='marriageRecords';
	else if (document.getElementById('archiveRecordType').value=='1865Census')
		document.getElementById('archiveRecordType').value='1865Census';
	else if(document.getElementById('archiveRecordType').value=='naturalizationRecords')
		document.getElementById('archiveRecordType').value='naturalizationRecords';
	else if (document.getElementById('archiveRecordType').value=='courtRecords')
		document.getElementById('archiveRecordType').value='courtRecords';
	else if (document.getElementById('archiveRecordType').value=='chancerydivorceRecords')
		document.getElementById('archiveRecordType').value='chancerydivorceRecords';
	else if (document.getElementById('archiveRecordType').value=='birthRecords')
		document.getElementById('archiveRecordType').value='birthRecords';
	else if (document.getElementById('archiveRecordType').value=='deathRecords')
			document.getElementById('archiveRecordType').value='deathRecords';*/

	//getArchiveDeathSearchBox();
	/*var visibleArchiveSearchBox = document.getElementById('archiveRecordType').value;
		document.getElementById(visibleArchiveSearchBox).style.display = "block";*/
		
	
			//shift focus to name
			if (recent != 'recent')
				{
					document.getElementById('proplastname').focus();
				}
			else
				{
					document.getElementById('cityaddr').focus();
				}
		
	
}

function clearSearchBoxes()  
{
	
	if(document.getElementById('propertySearchType').value=='Name')
		document.getElementById('propertySearchType').value='Name';
	else if(document.getElementById('propertySearchType').value=='Document')
		document.getElementById('propertySearchType').value='Document';
	else if(document.getElementById('propertySearchType').value=='PID')
		document.getElementById('propertySearchType').value='PID';
	else if(document.getElementById('propertySearchType').value=='Address')
		document.getElementById('propertySearchType').value='Address';
	else if(document.getElementById('propertySearchType').value=='Recent')
		document.getElementById('propertySearchType').value='Recent';
	else if(document.getElementById('propertySearchType').value=='InstType')
		document.getElementById('propertySearchType').value='InstType';
		
	if(document.getElementById('gisSearchType').value=='gisAddressSearchBox')
		document.getElementById('gisSearchType').value='gisAddressSearchBox';
	else if(document.getElementById('gisSearchType').value=='gisNameSearchBox')
		document.getElementById('gisSearchType').value='gisNameSearchBox';
	else if(document.getElementById('gisSearchType').value=='gisParcelidSearchBox')
		document.getElementById('gisSearchType').value='gisParcelidSearchBox';
	else if(document.getElementById('gisSearchType').value=='gisTaxMapSearchBox')
		document.getElementById('gisSearchType').value='gisTaxMapSearchBox';
		
	if(document.getElementById('archiveRecordType').value=='mlkssss' || document.getElementById('archiveRecordType').value=='milk' || document.getElementById('archiveRecordType').value=='school')
		document.getElementById('archiveRecordType').value = 'deathRecords';
	else if(document.getElementById('archiveRecordType').value=='marriageRecords')
		document.getElementById('archiveRecordType').value = 'marriageRecords';
}

/* 
 *	getPropertySearchBox()
 *	Purpose: used to make the proper property search box visible -
 * 		onLoad (body) and onChange (searchType select box)
 *
 *	Written by:  Don Deskins
 *	Last Modified:  01/16/06
 *
 */
function getPropertySearchBox()
{
	//document.getElementById('InstNumber').style.display = "none";
	document.getElementById('InstTypeHDR').style.display = "none";
	//document.getElementById('BookPage').style.display = "none";
	document.getElementById('DocumentHDR').style.display = "none";
	document.getElementById('PIDHDR').style.display = "none";
	document.getElementById('AddressHDR').style.display = "none";
	document.getElementById('NameHDR').style.display = "none";
	document.getElementById('RecentHDR').style.display = "none";
	document.getElementById('InstTypeTBL').style.display = "none";
	//document.getElementById('BookPage').style.display = "none";
	document.getElementById('DocumentTBL').style.display = "none";
	document.getElementById('PIDTBL').style.display = "none";
	document.getElementById('AddressTBL').style.display = "none";
	document.getElementById('RecentTBL').style.display = "none";
	document.getElementById('NameTBL').style.display = "none";
	// BUG #3879 - Paul Cleaveland
	// New InstrumentType - All option
	document.getElementById('InstTypeAllHDR').style.display = "none";
	document.getElementById('InstTypeAllTBL').style.display = "none";
	
	var visiblePropertySearchBox = document.getElementById('propertySearchType').value;
	var visiblePropertySearchBoxHDR = visiblePropertySearchBox+'HDR';
	var visiblePropertySearchBoxTBL = visiblePropertySearchBox+'TBL';
	document.getElementById(visiblePropertySearchBoxHDR).style.display = "block";
	document.getElementById(visiblePropertySearchBoxTBL).style.display = "block";
	
	if (visiblePropertySearchBox =='Recent')
		{
			document.getElementById('certinfo').style.display = "none";	
		}
	else
		{
			document.getElementById('certinfo').style.display = "block";	
		}
	//made these to put the cursors in the right place - JH
	//alert(visiblePropertySearchBox);
	if (visiblePropertySearchBox =='Address')
		{
			//shift focus to gisaddr
			document.getElementById('propaddr').focus();
		}
	else if (visiblePropertySearchBox =='Name')
		{
			//shift focus to name
			document.getElementById('proplastname').focus();	
		}
	else if (visiblePropertySearchBox =='Document')
		{
			//shift focus to name
			document.getElementById('propinst').focus();	
		}
	else if (visiblePropertySearchBox =='PID')
		{
			//shift focus to name
			document.getElementById('subprop').focus();	
		}
	else if (visiblePropertySearchBox =='InstType')
		{
			//shift focus to name
			document.getElementById('bdateinst').focus();	
		}
}

function getGisSearchBox()
{
	document.getElementById('gisNameSearchBoxHDR').style.display = "none";
	document.getElementById('gisAddressSearchBoxHDR').style.display = "none";
	document.getElementById('gisParcelidSearchBoxHDR').style.display = "none";
	document.getElementById('gisTaxMapSearchBoxHDR').style.display = "none";
	document.getElementById('gisNameSearchBoxTBL').style.display = "none";
	document.getElementById('gisAddressSearchBoxTBL').style.display = "none";
	document.getElementById('gisParcelidSearchBoxTBL').style.display = "none";
	document.getElementById('gisTaxMapSearchBoxTBL').style.display = "none";

	var visibleGisSearchBox = document.getElementById('gisSearchType').value;
	//alert(visibleGisSearchBox);
	var visibleGisSearchBoxHDR = visibleGisSearchBox+'HDR';
	var visibleGisSearchBoxTBL = visibleGisSearchBox+'TBL';			
	document.getElementById(visibleGisSearchBoxHDR).style.display = "block";
	document.getElementById(visibleGisSearchBoxTBL).style.display = "block";
	
	//made these to put the cursors in the right place - JH
	if (visibleGisSearchBox =='gisAddressSearchBox')
		{
			//shift focus to gisaddr
			document.getElementById('gisaddr').focus();
		}
	else if (visibleGisSearchBox =='gisNameSearchBox')
		{
			//shift focus to name
			document.getElementById('name').focus();	
		}
	else if (visibleGisSearchBox =='gisTaxMapSearchBox')
		{
			//shift focus to taxmap
			document.getElementById('taxmap').focus();	
		}
	else 
		{
			//shift focus to parcelSearch, had to do it this way for IE
			document.getElementById('parcelid_gis').focus();	
		}
}

function getArchiveDeathSearchBox()
{
	/*document.getElementById('archiveDeathNameSearchBox').style.display = "none";
	document.getElementById('archiveDeathFileNumSearchBox').style.display = "none";

	var visibleArchiveDeathSearchBox = document.getElementById('deathRecordSearchType').value;
	document.getElementById(visibleArchiveDeathSearchBox).style.display = "";*/
	document.getElementById('birthRecords').style.display = "none";
	document.getElementById('TNdeathRecords').style.display = "none";
	document.getElementById('TNmarriageRecords').style.display = "none";
	document.getElementById('TNdivorceRecords').style.display = "none";
	document.getElementById('deathRecords').style.display = "none";
	document.getElementById('marriageRecords').style.display = "none"; 
	document.getElementById('naturalizationRecords').style.display = "none"; 
	document.getElementById('1865Census').style.display = "none"; 
	document.getElementById('courtRecords').style.display = "none"; 
	document.getElementById('cityDirectories').style.display = "none"; 
	document.getElementById('chancerydivorceRecords').style.display = "none"; 
	
	
	
	//{
	//	window.location.replace("./mlk/index.php");
		//alert(window.location.pathname);
	//}
		
	//else if(document.getElementById('archiveRecordType').value=='milk')
	//	window.location="./milk/";
	//else if(document.getElementById('archiveRecordType').value=='school')
		//window.location="./school/";
		//alert(document.getElementById('archiveRecordType').value);
	    var visibleArchiveSearchBox = document.getElementById('archiveRecordType').value;
		document.getElementById(visibleArchiveSearchBox).style.display = "block";
		
	
	
}

function go(linkvalue, title) 
{
	document.getElementById('deathRecords').style.display = "none";
	document.getElementById('TNdeathRecords').style.display = "none";
	document.getElementById('TNmarriageRecords').style.display = "none";
	document.getElementById('TNdivorceRecords').style.display = "none";
	document.getElementById('marriageRecords').style.display = "none"; 
	document.getElementById('naturalizationRecords').style.display = "none"; 
	document.getElementById('1865Census').style.display = "none"; 
	document.getElementById('birthRecords').style.display = "none"; 
	document.getElementById('courtRecords').style.display = "none"; 
	document.getElementById('marriageIndex').style.display = "none"; 
	document.getElementById('cityDirectories').style.display = "none"; 
	document.getElementById('chancerydivorceRecords').style.display = "none";
	document.getElementById('probateRecords').style.display = "none";
	
	if(linkvalue == 'RESET')
	{
		document.getElementById('archiveLinkMenu').style.display = "block";
		document.getElementById('linkHeading').style.display = "none";
		document.getElementById('archiveLabel').style.display = "inline";
	}
	else
	{
		document.getElementById('archiveLinkMenu').style.display = "none";
		document.getElementById('linkHeading').style.display = "inline";
		document.getElementById('archiveLabel').style.display = "none";
		document.getElementById('linkHeading').innerHTML = title;
	}
	
	//comment out mlk if going live
	//document.getElementById('mlk').style.display = "none";

	
	if(linkvalue=='aerialviewer.php'||
							   linkvalue=='mlk/' || 
							   linkvalue=='milk/' || 
							   linkvalue=='buck_boshwit_collection/' ||    
							   linkvalue=='school/' || 
							   linkvalue=='Landmarks/' ||
							   linkvalue=='news_articles/' ||
							   linkvalue=='wths/' ||
							   linkvalue=='doc/documentary.php' ||
							   linkvalue=='elmwood/documentary.php' ||
							   linkvalue=='overton/documentary.php')
	{
	box = document.getElementById('archiveRecordType');
	
	destination = box.options[box.selectedIndex].value;
	if (destination) {location.href = destination;}
	}
	
	var visibleArchiveSearchBox = linkvalue;
		document.getElementById(visibleArchiveSearchBox).style.display = "block";
	
	if (visibleArchiveSearchBox =='deathRecords')
		{
			//shift focus to deathname
			document.getElementById('deathname').focus();
		}
	else if (visibleArchiveSearchBox =='birthRecords')
		{
			//shift focus to name
			document.getElementById('birthlast').focus();	
		}
	else if (visibleArchiveSearchBox =='marriageRecords')
		{
			//shift focus to name
			document.getElementById('marrname').focus();	
		}
	else if (visibleArchiveSearchBox =='1865Census')
		{
			//shift focus to name
			document.getElementById('censusname').focus();	
		}
	else if (visibleArchiveSearchBox =='naturalizationRecords')
		{
			//shift focus to name
			document.getElementById('natname').focus();	
		}
	else if (visibleArchiveSearchBox =='TNdeathRecords')
		{
			//shift focus to name
			document.getElementById('TNdeathname').focus();	
		}
	else if (visibleArchiveSearchBox =='TNmarriageRecords')
		{
			//shift focus to name
			document.getElementById('TNmarrname').focus();	
		}
	else if (visibleArchiveSearchBox =='TNdivorceRecords')
		{
			//shift focus to name
			document.getElementById('TNdivname').focus();	
		}
	else if (visibleArchiveSearchBox =='probateRecords')
		{
			//shift focus to name
			document.getElementById('probateRecordsName');
		}
	
		

	//natname

}


/*
 *	function chgAct
 *	Purpose: to change to form action based upon the selection it the select box.
 *	Written by: Don Deskins
 *			from http://www.webmasterworld.com/forum47/2488.htm
 *	Last Modified: 01/16/06
 *
 *
 */ 
function chgAct(val)
{
	var myVar = val.options[val.selectedIndex].value;
	if(myVar == "ST")
	{
		document.myForm.action = "p4.php";	
	}
	else
	{
		document.myForm.action = "p3.php";	
	}
}


function getCourtRecords()
{
	document.getElementById('birthRecords').style.display = "none";
	document.getElementById('deathRecords').style.display = "none";
	document.getElementById('marriageRecords').style.display = "none"; 
	document.getElementById('1865Census').style.display = "none"; 
	document.getElementById('courtRecords').style.display = "block";
	document.getElementById('archiveRecordType').value=='courtRecords'
}