function printList()
{
printListURL = document.forms[0].printListURL.value;
URL = "widgets/Printlist.php" + printListURL;
window.open(URL,'List'); 

}

var szFindWhat = '';
function search()
{
     document.getElementById("introtext").style.display="None";
     document.getElementById("queryres").style.display="Block";
     window["queryres"].document.body.innerHTML='<img src="images/ajaxLoading.gif" border="0">';
    // get the selected FindWhat radio button
    var radFindWhatGrp = document.forms[0].radFindWhat;

    for( var i=0; i< radFindWhatGrp.length; i++ )
    {
        if ( radFindWhatGrp[i].checked )
        {
            szFindWhat = radFindWhatGrp[i].value;
        }
    }

    // get selected FindBy radio button
    var radFindByGrp = document.forms[0].radFindBy;
    var szFindBy = '';
    for( var i=0; i< radFindByGrp.length; i++ )
    {
        if ( radFindByGrp[i].checked )
        {
            szFindBy = radFindByGrp[i].value;
            break;
        }
    }

    // determine which field and values to use
    var szField = '';
    var szValue = '';
   
    switch ( szFindBy )
    {
        case 'zip_code_query':  
            szField = 'zip';
            szValue = document.forms[0].txtZipCode.value;
            break;
        case 'city_query':
            szField = 'name';
            szValue = document.forms[0].selCity.value;
            break;
        case 'park_query':
            szField = 'unit_name';
            szValue = document.forms[0].txtparksquery.value;
            break;
        case 'address_query':
            szValue = document.forms[0].geoDist.value;
            break;
        case 'agency_query': 
                  if (szFindWhat == "campgrounds")
                     {    
                            szField = 'ORG';
			       var selectBox = document.forms[0].agencyName;
                            szValue = selectBox.options[selectBox.selectedIndex].value
			                            
                     }	
                  if (szFindWhat == "statewide_osdb")
                     {
				    if (document.forms[0].agencyName.value == "--- Show All ---")
                            {           
                  			szValue = document.forms[0].agencyType.value;
					if (szValue == "City") 
					{
						szValue = "4"
					} 
					else if (szValue == "County")
					{
						szValue = "3"
					} 
					else if (szValue == "Federal")
					{
						szValue = "1"
					}
					else if (szValue == "Non Profit")
					{
						szValue = "6"
					} 
					else if (szValue == "State")
					{
						szValue = "2"
					} 
					else if (szValue == "Special District")
					{
						szValue = "5"
					} 
                  			szField = 'type_of_ow';
					
                            }
            		    if (document.forms[0].agencyName.value != "--- Show All ---")
                            {
                  			szValue = document.forms[0].agencyName.value;
                 				szField = 'agency_nam';
            		    }
                     }	

            break;

    }

    // check for a blank value
    if ( szValue == '' )
    {
        alert( 'Please supply a search value.'  );
        return true;
    }
    


    if (szFindBy != 'address_query') {   

    // set the IFRAME page source
    frames['queryres'].location.href = 'widgets/Search/SearchResults_ge.phtml?result_geom=' + szFindWhat + '&bound_geom=' + szFindBy + '&bound_field=' + szField + '&bound_value=' + szValue;
    
    // set the printlist URL to capture the current query parameters
    document.forms[0].printListURL.value = "?result_geom=" + szFindWhat + "&bound_geom=" + szFindBy + "&bound_field=" + szField + "&bound_value=" + szValue;
    return true;
    } else {
    var txtResultsPage = '';
    txtResultsPage = 'widgets/Search/SearchResults_ge.phtml';
    showAddress(szFindWhat, szFindBy, szField, szValue, txtResultsPage);
    }
}

function clearValue () 
{
document.forms[0].txtZipCode.value ="";
document.forms[0].txtZipCode.style.fontStyle = "normal";
if (document.forms[0].selCity.value == "Type in city or place here") {
document.forms[0].selCity.value ="";
}
document.forms[0].selCity.style.fontStyle = "normal";
document.forms[0].geoquery.style.fontStyle = "normal";
document.forms[0].geoquery.value ="";
document.forms[0].txtparksquery.value ="";
document.forms[0].txtparksquery.style.fontStyle = "normal";
}
   
function ZipForm()
{
document.forms[0].txtZipCode.value ="Type in zip code here";
document.forms[0].txtZipCode.style.fontStyle = "italic";
document.forms[0].txtZipCode.style.display="block";
document.forms[0].selCity.style.display="none";
document.forms[0].geoquery.style.display="none";
document.forms[0].geoDist.style.display="none"; 
document.forms[0].agencyType.style.display="none";
document.forms[0].agencyName.style.display="none";
document.forms[0].txtparksquery.style.display="none";
}

function CityForm()
{
document.forms[0].selCity.style.display="block";
document.forms[0].selCity.value ="Type in city or place here";
document.forms[0].selCity.style.fontStyle = "italic";
document.forms[0].txtZipCode.style.display="none";
document.forms[0].geoquery.style.display="none";
document.forms[0].geoDist.style.display="none"; 
document.forms[0].agencyType.style.display="none";
document.forms[0].agencyName.style.display="none";
document.forms[0].txtparksquery.style.display="none";
}

function AddressForm()
{
document.forms[0].geoquery.style.display="block";
document.forms[0].geoDist.style.display="block";  
document.forms[0].geoquery.value ="Type your address, then select a distance";
document.forms[0].geoquery.style.fontStyle = "italic";
document.forms[0].selCity.style.display="none";
document.forms[0].txtZipCode.style.display="none";
document.forms[0].agencyType.style.display="none";
document.forms[0].agencyName.style.display="none";
document.forms[0].txtparksquery.style.display="none";
}
function AgencyForm()
{
document.forms[0].agencyType.options[0].selected = true;
document.forms[0].agencyName.options[0].selected = true;
document.forms[0].agencyType.style.display="block";
document.forms[0].agencyName.style.display="block";
document.forms[0].geoquery.style.display="none";
document.forms[0].geoDist.style.display="none"; 
document.forms[0].selCity.style.display="none";
document.forms[0].txtZipCode.style.display="none";
document.forms[0].txtparksquery.style.display="none";
}

function ParkNameForm()
{
document.forms[0].selCity.style.display="none";
document.forms[0].txtparksquery.style.display="block";
document.forms[0].txtparksquery.value ="Type park name here";
document.forms[0].txtparksquery.style.fontStyle = "italic";
document.forms[0].txtZipCode.style.display="none";
document.forms[0].geoquery.style.display="none";
document.forms[0].geoDist.style.display="none"; 
document.forms[0].agencyType.style.display="none";
document.forms[0].agencyName.style.display="none";
}

function CampForm()
{
var parksDiv = document.getElementById("parks");
parksDiv.style.display='none'; 
var parksLab = document.getElementById("parks_label");
parksLab.style.display='none';
}

function TrailsForm()
{
var parksDiv = document.getElementById("parks");
parksDiv.style.display='none'; 
var parksLab = document.getElementById("parks_label");
parksLab.style.display='none';
}

function ParksForm()
{
var parksDiv = document.getElementById("parks");
parksDiv.style.display='block'; 
var parksLab = document.getElementById("parks_label");
parksLab.style.display='block';

}



function submitenter(myfield,e)
{
var keycode;
var safari = navigator.userAgent.indexOf('Safari')>0;
if (window.event) keycode = window.event.keyCode;
else if (safari && keyCode==3) keycode = 13;
else if (e) keycode = e.which;
else return true;

if (keycode == 13)
   {
   search();
   return false;
   }
else
   return true;
}

function SelectCity(city_name){
document.forms[0].radFindBy[2].checked="true";
document.forms[0].selCity.style.display="block";
document.forms[0].selCity.value = city_name;
document.forms[0].txtZipCode.style.display="none";
document.forms[0].geoquery.style.display="none";
document.forms[0].geoDist.style.display="none"; 
document.forms[0].agencyType.style.display="none";
document.forms[0].agencyName.style.display="none";
search();
}