function OpenPrintVer(parcel, twp){
	window.open("PropDetailReport_print.cfm?parcelnum="+parcel+"","","toolbar=no, scrollbars=yes, menubar=yes, status=yes, resizable, width=700, height=550");
}
function OpenContact(parcel){
	window.open("ContactInfo.cfm?parcelnum="+parcel+"","","toolbar=no, scrollbars=yes, menubar=no, status=no, resizable, width=300, height=200");
}
function selectOption(){
	var thisOption;
	var result = "";
	for (i=0; i<document.form.optSearch.length; i++){
		 thisOption = window.document.form.optSearch[i];  
 		//check to see if the current element is selected
    	if (thisOption.checked == true){
      		result = thisOption.value;
			break;
		}
	}
	window.document.form.searchBy.value = result;
}
function FocusOnEnter (field, evt) {
  	var keyCode = document.layers ? evt.which : document.all ? 
	evt.keyCode : evt.keyCode;
  	if (keyCode != 13)
    	return true;
  	else {
   		document.form.btnSubmit.focus();
   		return true;
  	}
}

function selectOption(){
	var thisOption;
	var result = "";
	for (i=0; i<4; i++){
		 thisOption = window.document.form.optSearch[i];  
 		//check to see if the current element is selected
    	if (thisOption.checked == true){
      		result = thisOption.value;
		}
	}
	window.document.form.searchBy.value = result;
}
function prefill(){
	var searchoption = document.form.searchBy.value;
	if (searchoption == "Parcel Number")window.document.form.optSearch[0].checked = true;
	else if (searchoption == "Alt Parcel Number")window.document.form.optSearch[1].checked = true;
	else if (searchoption == "Owner Name")window.document.form.optSearch[2].checked = true;
	else if (searchoption == "Property Address")window.document.form.optSearch[3].checked = true;	
}
function FocusOnEnter (field, evt) {
  	var keyCode = document.layers ? evt.which : document.all ? 
	evt.keyCode : evt.keyCode;
  	if (keyCode != 13)
    	return true;
  	else {
   		document.form.btnSubmit.focus();
   		return true;
  	}
}
function GetDetailReport(parcelnum, reporttodisplay, pagenum, spagenum, startrow){
	document.form.parcelnum.value = parcelnum;
	document.form.report.value = reporttodisplay;
	document.form.pagenav.value = pagenum;
	document.form.sPageNum.value = spagenum;
	document.form.sStartRow.value = startrow;
	document.form.action = "PropDetailReport.cfm";
	document.form.submit();
}
function GetMainReport(page){
	document.form.pagenav.value = page;
	
	if (document.form.reporttype.value == "sales"){
		//alert("reporttype=" + document.form2.reporttype.value);
		document.form.action = "SalesSearch2.cfm";
		document.form.submit();
	}else{
		if (document.form.reporttype.value == "property"){
			document.form.action = "propsearch2.cfm";
			document.form.submit();
		}
	}
	
}
function LoadPropSearchForm(){
	document.form.action = "propsearch.cfm";
	document.form.submit();
}
function LoadSaleSearchForm(){
	document.form.action = "SalesSearch.cfm";
	document.form.submit();
}
function clearPropFormFields(){
	var doc = document.form;
	doc.parcelnumber.value = "";
	doc.altparcelnumber.value = "";
	doc.ownername.value = "";
	doc.propaddress.value = "";
	for(var x = 0; x< doc.propclass.length; x++){
			doc.propclass.options[x].selected = false;
	}
	doc.citytown.options[0].selected = true;
	doc.township.options[0].selected = true;
	doc.district.options[0].selected = true;
	doc.neighborhood.options[0].selected = true;
	doc.corporation.options[0].selected = true;
	//document.form.searchtype[0].checked = true;
	doc.parcelnumber.focus();
	
}
function clearSaleFormFields(){
	var doc = document.form;
	doc.parcelnumber.value = "";
	doc.altparcelnumber.value = "";
	doc.altparcelnumber2.value = "";
	doc.buyername.value = "";
	doc.sellername.value = "";
	doc.propaddress.value = "";
	doc.SalePriceRangeMin.value = "";
	doc.SalePriceRangeMax.value = "";
	doc.SaleDateRangeMin.value = "";
	doc.SaleDateRangeMax.value = "";
	doc.vacant.value = doc.vacant.options[0];
	for(var x = 0; x< doc.propclass.length; x++){
			doc.propclass.options[x].selected = false;
	}
	doc.citytown.options[0].selected = true;
	doc.township.options[0].selected = true;
	doc.district.options[0].selected = true;
	doc.neighborhood.options[0].selected = true;
	doc.corporation.options[0].selected = true;
	//document.form.searchtype[0].checked = true;
	doc.parcelnumber.focus();
	
}
function ValidateInput(){
	var ischecked = false;
	if (document.form){
	/*for (i=0; i < document.form.searchtype.length; i++){
		if (document.form.searchtype[i].checked){
			ischecked = true;
			break;
		}
	}
	if (ischecked == false){
		document.form.searchtype[0].checked = true;
	}*/
	document.form.parcelnumber.focus();
	document.form.parcelnumber.select();
	}
	return true;
}

function inputMask(fieldobj, evt){
	var dash = "-";
	var period = ".";
	var keyCode = document.layers ? evt.which : document.all ? 
	evt.keyCode : evt.keyCode;
	//check for backspace or delete keys
	if ((keyCode != 8) || (keyCode != 46)){
		if (fieldobj.name == "parcelnumber"){
			var doc = document.form.parcelnumber.value;
			if ((doc.length == 3) && (doc.substring(2,3) != dash))document.form.parcelnumber.value = doc.substring(0,2) + dash + doc.substring(2,3);
			else if ((doc.length == 9) && (doc.substring(8,9) != dash))document.form.parcelnumber.value = doc.substring(0,8) + dash + doc.substring(8,9);
			else if ((doc.length == 13) && (doc.substring(12,13) != dash))document.form.parcelnumber.value = doc.substring(0,12) + dash + doc.substring(12,13);
			//else if ((doc.length == 17) && (doc.substring(16,17) != dash))document.form.parcelnumber.value = doc.substring(0,16) + dash + doc.substring(16,17);
		}
		if (fieldobj.name == "altparcelnumber"){
			var doc = document.form.altparcelnumber.value;
			if ((doc.length == 3) && (doc.substring(2,3) != dash))document.form.altparcelnumber.value = doc.substring(0,2) + dash + doc.substring(2,3);
			else if ((doc.length == 6) && (doc.substring(5,6) != dash))document.form.altparcelnumber.value = doc.substring(0,5) + dash + doc.substring(5,6);
			else if ((doc.length == 9) && (doc.substring(8,9) != dash))document.form.altparcelnumber.value = doc.substring(0,8) + dash + doc.substring(8,9);
			else if ((doc.length == 13) && (doc.substring(12,13) != dash))document.form.altparcelnumber.value = doc.substring(0,12) + dash + doc.substring(12,13);
			else if ((doc.length == 17) && (doc.substring(16,17) != period))document.form.altparcelnumber.value = doc.substring(0,16) + period + doc.substring(16,17);
			else if ((doc.length == 21) && (doc.substring(20,21) != dash))document.form.altparcelnumber.value = doc.substring(0,20) + dash + doc.substring(20,21);
		}
		if (fieldobj.name == "altparcelnumber2"){
			var doc = document.form.altparcelnumber2.value;
			if ((doc.length == 3) && (doc.substring(2,3) != dash))document.form.altparcelnumber2.value = doc.substring(0,2) + dash + doc.substring(2,3);
			else if ((doc.length == 6) && (doc.substring(5,6) != dash))document.form.altparcelnumber2.value = doc.substring(0,5) + dash + doc.substring(5,6);
			else if ((doc.length == 10) && (doc.substring(9,10) != dash))document.form.altparcelnumber2.value = doc.substring(0,9) + dash + doc.substring(9,10);
			else if ((doc.length == 14) && (doc.substring(13,14) != period))document.form.altparcelnumber2.value = doc.substring(0,13) + period + doc.substring(13,14);
			else if ((doc.length == 18) && (doc.substring(17,18) != dash))document.form.altparcelnumber2.value = doc.substring(0,17) + dash + doc.substring(17,18);
		}
	}
}

function RepopulateDropdowns(fieldname){
	var doc = document.form;
	var selectedCtytn = "";
	var selectedCorp = "";
	var selectedTwp = "";
	var selectedDist = "";
	var selectedNhood = "";
	selectedCtytn = doc.citytown.options[doc.citytown.selectedIndex].value;
	selectedCorp = doc.corporation.options[doc.corporation.selectedIndex].value;
	selectedTwp = doc.township.options[doc.township.selectedIndex].value;
	selectedDist = doc.district.options[doc.district.selectedIndex].value;
	selectedNhood = doc.neighborhood.options[doc.neighborhood.selectedIndex].text;
	//==============================================================================================================
	//if district, township, corporation, neighborhood, and citytown are not selected, show all items by default
	if ((selectedDist == "") && (selectedTwp == "") && (selectedCorp == "") && (selectedCtytn == "") && (selectedNhood == "")){
			//************** township **************
			var twpText = "";
			var twpValue = "";
			doc.township.length = 0;
			doc.township.options[doc.township.length] = new Option(twpText, twpValue, true, false);//text, value, default selected, selected
			for (i = 0; i < twpName.length; i++){
				twpText = twpName[i];
				twpValue = twpName[i];
				doc.township.options[doc.township.length] = new Option(twpText, twpValue, false, false);
			}
			//************* corporation **************
			var corpText = "";
			var corpValue = "";
			doc.corporation.length = 0;
			doc.corporation.options[doc.corporation.length] = new Option(corpText, corpValue, true, false);//text, value, default selected, selected
			for (i = 0; i < corpName.length; i++){
				corpText = corpName[i];
				corpValue = corpName[i];
				doc.corporation.options[doc.corporation.length] = new Option(corpText, corpValue, false, false);
			}
			//************* citytown **************
			var citytownText = "";
			var citytownValue = "";
			doc.citytown.length = 0;
			doc.citytown.options[doc.citytown.length] = new Option(citytownText, citytownValue, true, false);//text, value, default selected, selected
			for (i = 0; i < citytownName.length; i++){
				citytownText = citytownName[i];
				citytownValue = citytownName[i];
				doc.citytown.options[doc.citytown.length] = new Option(citytownText, citytownValue, false, false);
			}
			//************* district **************
			var districtText = "";
			var districtValue = "";
			doc.district.length = 0;
			doc.district.options[doc.district.length] = new Option(districtText, districtValue, true, false);//text, value, default selected, selected
			for (i = 0; i < districtName.length; i++){
				districtText = districtName[i];
				districtValue = districtName[i];
				doc.district.options[doc.district.length] = new Option(districtText, districtValue, false, false);
			}
			//************* neighborhood **************
			var nhoodText = "";
			var nhoodValue = "";
			doc.neighborhood.length = 0;
			doc.neighborhood.options[doc.neighborhood.length] = new Option(nhoodText, nhoodValue, true, false);
			for (j = 0; j < nhoodCode.length; j++){
				var ncode = nhoodCode[j];
				var ncodename = nhoodName[j];
				nhoodText = ncode + " - " + ncodename;
				nhoodValue = nhoodCode[j];
				doc.neighborhood.options[doc.neighborhood.length] = new Option(nhoodText, nhoodValue, false, false);
			}
	}else{
			//add an empty string to the first item in the lists and is selected by default
			//****** school corporation ******
			if (fieldname != "corporation"){
			var corpText = "";
			var corpValue = "";
			doc.corporation.length = 0;
			doc.corporation.options[doc.corporation.length] = new Option(corpText, corpValue, true, false);//text, value, default selected, selected
			}
			//******* city/town ******
			if (fieldname != "citytown"){
			var citytownText = "";
			var citytownValue = "";
			doc.citytown.length = 0;
			doc.citytown.options[doc.citytown.length] = new Option(citytownText, citytownValue, true, false);//text, value, default selected, selected
			}
			//******* district *******
			if (fieldname != "district"){
			var districtText = "";
			var districtValue = "";
			doc.district.length = 0;
			doc.district.options[doc.district.length] = new Option(districtText, districtValue, true, false);//text, value, default selected, selected
		 	}
			//******* township *******
			if (fieldname != "township"){
			var twpText = "";
			var twpValue = "";
			doc.township.length = 0;
			doc.township.options[doc.township.length] = new Option(twpText, twpValue, true, false);//text, value, default selected, selected
			}
			//****** neighborhood ******
			if (fieldname != "neighborhood"){
			var nhoodText = "";
			var nhoodValue = "";
			doc.neighborhood.length = 0;
			doc.neighborhood.options[doc.neighborhood.length] = new Option(nhoodText, nhoodValue, true, false);//text, value, default selected, selected
			}
			//add match items to the lists
			var arraylength = districtNames.length;
			for (i = 0; i < arraylength; i++){
				var nomatch = 0;
				var NhoodDistrict = "";
				//retrieve district Name from neighborhood array.
				for (j = 0; j < nhoodCode.length; j++){
					var nhood = nhoodCode[j] + " - " + nhoodName[j];
					if (nhood == selectedNhood){
						NhoodDistrict = nhoodDist[j];
						break;
					}
				}
				//set nomatch flag for adding items to each dropdown list.
				//increment nomatch flag when user selected any item in any list and that item was found in LU_TAXDT exported table.
				if ((selectedTwp != "") && (selectedTwp != twpNames[i])){
					 nomatch += 1;
				}
				if ((selectedCtytn != "") && (selectedCtytn != citytownNames[i])){
					nomatch += 1;
				}
				if ((selectedCorp != "") && (selectedCorp != corpNames[i])){
					nomatch += 1;
				}
				if ((selectedDist != "") && (selectedDist != districtNames[i])){
					nomatch += 1;
				}
				if ((selectedNhood != "") && (NhoodDistrict != districtNames[i])){
					nomatch += 1;
				}
				if (nomatch == 0){
					var isTwpSelected = false;
					var isCorpSelected = false;
					var isDistSelected = false;
					var isCtyTnSelected = false;
					if (selectedTwp == twpNames[i]){isTwpSelected = true;}
					if (selectedCorp == corpNames[i]){isCorpSelected = true;}
					if (selectedDist == districtNames[i]){isDistSelected = true;}
					if (selectedCtytn == citytownNames[i]){isCtyTnSelected = true;}
					//********** township ***************
						twpText = twpNames[i];
						twpValue = twpNames[i];
						var existflag = false;
						for (j = 0; j < doc.township.length; j++){
							if (doc.township.options[j].value == twpValue){
								existflag = true;
								break;
							}
						}
						if (existflag == false){
							doc.township.options[doc.township.length] = new Option(twpText, twpValue, false, isTwpSelected);
						}
					//************* corporation **************
						corpText = corpNames[i];
						corpValue = corpNames[i];
						var existflag = false;
						for (j = 0; j < doc.corporation.length; j++){
							if (doc.corporation.options[j].value == corpValue){
								existflag = true;
								break;
							}
						}
						if (existflag == false){
							doc.corporation.options[doc.corporation.length] = new Option(corpText, corpValue, false, isCorpSelected);
						}
					//************* citytown **************
						citytownText = citytownNames[i];
						citytownValue = citytownNames[i];
						var existflag = false;
						for (j = 0; j < doc.citytown.length; j++){
							if (doc.citytown.options[j].value == citytownValue){
								existflag = true;
								break;
							}
						}
						if (existflag == false){
							doc.citytown.options[doc.citytown.length] = new Option(citytownText, citytownValue, false, isCtyTnSelected);
						}
					//************* district **************
						districtText = districtNames[i];
						districtValue = districtNames[i];
						var existflag = false;
						for (j = 0; j < doc.district.length; j++){
							if (doc.district.options[j].value == districtValue){
								existflag = true;
								break;
							}
						}
						if (existflag == false){
							doc.district.options[doc.district.length] = new Option(districtText, districtValue, false, isDistSelected);
						}
					//************* neighborhood **************
						var tempdist = districtNames[i];
						for (j = 0; j < nhoodDist.length; j++){
							if (nhoodDist[j] == tempdist){
								nhoodText = nhoodCode[j] + " - " + nhoodName[j];
								nhoodValue = nhoodCode[j];
								var isNhoodSelected = false;
								if (selectedNhood == nhoodText){isNhoodSelected = true;}
								doc.neighborhood.options[doc.neighborhood.length] = new Option(nhoodText, nhoodValue, false, isNhoodSelected);
							}
						}//end for neighborhood	
				}//end if nomatch = 0
			}//end for districtNames
	}//end if
	
}
		
		
		
		
		
		
		
		
		
		
		
		
		
	
	