<?php
if (isset($data['searchnow'])) {
if (isset($data['superregion'])) {
foreach ($data['superregion'] as $key => $value_superregion) {
  if ($value_superregion == "") $data['superregion'] = ""; }
}
if (isset($data['country'])) {
foreach ($data['country'] as $key => $value_country) {
  if ($value_country == "") $data['country'] = ""; }
}
if (isset($data['region'])) {
foreach ($data['region'] as $key => $value_region) {
  if ($value_region == "") $data['region'] = ""; }
}
}	
?>

<form name="search" method="post" action="<?echo $PHP_SELF?>">
<table cellpadding=0 cellspacing=0 class=form width=100%>
<!-- browse tr -->
<tr><td colspan=2>
          <p> <a href = "index.php?searchnow=1&letter=A">A</a>&nbsp; <a href = "index.php?searchnow=1&letter=B">B</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=C">C</a>&nbsp; <a href = "index.php?searchnow=1&letter=D">D</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=E">E</a>&nbsp; <a href = "index.php?searchnow=1&letter=F">F</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=G">G</a>&nbsp; <a href = "index.php?searchnow=1&letter=H">H</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=I">I</a>&nbsp; <a href = "index.php?searchnow=1&letter=J">J</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=K">K</a>&nbsp; <a href = "index.php?searchnow=1&letter=L">L</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=M">M</a>&nbsp; <a href = "index.php?searchnow=1&letter=N">N</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=O">O</a>&nbsp; <a href = "index.php?searchnow=1&letter=P">P</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=Q">Q</a>&nbsp; <a href = "index.php?searchnow=1&letter=R">R</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=S">S</a>&nbsp; <a href = "index.php?searchnow=1&letter=T">T</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=U">U</a>&nbsp; <a href = "index.php?searchnow=1&letter=V">V</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=W">W</a>&nbsp; <a href = "index.php?searchnow=1&letter=X">X</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=Y">Y</a>&nbsp; <a href = "index.php?searchnow=1&letter=Z">Z</a>&nbsp; 
            <a href = "index.php?searchnow=1&letter=.">[non-letters]</a> </p>
          <p><b>Note:</b> Leave fields blank for "don't care" conditions or to 
            select all.</p>
</td></tr>

<tr><td>(Click <a href="Javascript:resetForm()">here</a> to clear the form.)</td></tr>
<tr>

<!-- search boxes two columns  -->
<td valign=top width=66%>
<table cellpadding=0 cellspacing=0>

<!-- row 1: name and city -->
<tr>
<td width=220>
<P>Name contains:<BR>
<input type=text class=text name="namecontains"<?php
if (isset($data['namecontains'])) print(" value = \"{$data['namecontains']}\"");?>size="43"></p>
</td>

<td>
<P>City:<BR>
<input name="city"<?php
if (isset($data['city'])) print(" value = \"{$data['city']}\"");?>size="43" type="text" class="text"></p>
</td>
</tr>

<!-- row 2: description / geographic area -->
<tr>
<!-- description -->
<td valign=top>
<P>Description contains:<BR>
<input name="descriptioncontains"<?php
if (isset($data['descriptioncontains'])) print(" value = \"{$data['descriptioncontains']}\"");?>size="43" type="text" class="text"></p>
</td>

 <!-- continent --> 
<td valign=top>
   <p>Geographic area:<br>
    <SELECT NAME="superregion[]" ID="superregion" onChange="showCountries(this);">
    <option value="">All continents</option>
<?php 
foreach ($countries as $key => $value)
  $result1[] = $key;
 sort($result1);
 while (list($key,$val) = each($result1))
  if ((!empty ($data['superregion'])) && (in_array("$val", $data['superregion'])))
   printf("<option selected value=\"%s\">%s</option>\n",$val,$val);
  else printf("<option value=\"%s\">%s</option>\n",$val,$val);
?>
</SELECT></p>
</td>

<!-- group is / countries-->
<tr>
<td>
           <!-- type of group --> 
<p>Group is:<BR>
<select ID="groupis" name="groupis[]">
 <option value="blank">&lt;Type of group&gt;</option>
 <option value="N"<?php if (!empty ($data['groupis']) && (in_array("N",$data['groupis']))) print(" selected"); ?>>Non-profit</option>
 <option value="G"<?php if (!empty ($data['groupis']) && (in_array("G",$data['groupis']))) print(" selected");?>
>Governmental</option>
 <option value="C"<?php if (!empty ($data['groupis']) && (in_array("C",$data['groupis']))) print(" selected");?>>Commercial</option>
 <option value="A"<?php if (!empty ($data['groupis']) && (in_array("A",$data['groupis']))) print(" selected");?>>Academic</option>
 <option value="W"<?php if (!empty ($data['groupis']) && (in_array("W",$data['groupis']))) print(" selected");?>>Website (blog, etc.)</option>
 <option value="O"<?php if (!empty ($data['groupis']) && (in_array("O",$data['groupis']))) print(" selected");?>>Other</option>
</select>
	</td>
<!-- country -->
<?php if ($data['superregion'] != "") { ?>
<td valign=top id="country_table" style="display: block;">
<?php } else { ?>
<td valign=top id="country_table" style="display: none;">
<?php } ?>
<P>&nbsp;<BR>
<SELECT NAME="country[]" id="country_select" onChange="showRegions(this);">
<option value="">All countries</option>
<?php if ($data['superregion'] != "") {
foreach ($countries as $key => $value) {
  if (in_array("$key", $data['superregion'])) {
   for($foo=0;$foo<count($value);$foo+=1) 
    {
    if ($data['country'] != "" && in_array("$value[$foo]", $data['country'])) printf("<option selected value=\"%s\">%s</option>\n",$value[$foo],$value[$foo]);
	else printf("<option value=\"%s\">%s</option>\n",$value[$foo],$value[$foo]);
	}
  }
}
}?>
</SELECT></p> 
</td></tr>

<!-- activity / state-province-->
<tr>
<!-- area of activity --> 
<td>
<p>Active in:<BR>
<select ID="foci" name="fociare[]">
<option value="blank">&lt;Area of focus&gt;</option>
 <option value="TECH"<?php if (!empty ($data['fociare']) && (in_array("TECH",$data['fociare']))) print(" selected");
?>>Alternative Technologies</option>
 <option value="CORP"<?php if (!empty ($data['fociare']) && (in_array("CORP",$data['fociare']))) print(" selected");
?>>Anti-Corporate/Globalisation</option>
 <option value="CARF"<?php if (!empty ($data['fociare']) && (in_array("CARF",$data['fociare']))) print(" selected");
?>>Anti-Car/Car-Free Living</option>
 <option value="CITI"<?php if (!empty ($data['fociare']) && (in_array("CITI",$data['fociare']))) print(" selected");
?>>Cities & Public Space</option>
 <option value="CLIM"<?php if (!empty ($data['fociare']) && (in_array("CLIM",$data['fociare']))) print(" selected");
?>>Climate Change</option>
 <option value="CYCL"<?php if (!empty ($data['fociare']) && (in_array("CYCL",$data['fociare']))) print(" selected");
?>>Cycling</option>
 <option value="PEDE"<?php if (!empty ($data['fociare']) && (in_array("PEDE",$data['fociare']))) print(" selected");
?>>Pedestrians/Walking</option>
 <option value="PUBT"<?php if (!empty ($data['fociare']) && (in_array("PUBT",$data['fociare']))) print(" selected");
?>>Public Transport</option>
 <option value="RDBL"<?php if (!empty ($data['fociare']) && (in_array("RDBL",$data['fociare']))) print(" selected");
?>>Anti-Highway/Habitat Protection</option>
 <option value="RDSF"<?php if (!empty ($data['fociare']) && (in_array("RDSF",$data['fociare']))) print(" selected");
?>>Road Safety/Road Deaths</option>
 <option value="TRAF"<?php if (!empty ($data['fociare']) && (in_array("TRAF",$data['fociare']))) print(" selected");
?>>Traffic Reduction/Calming</option>
<!--
<option value="AIRT">Air Transport</option>
<option value="INDU">Oil/Auto Industries</option>
<option value="POLL">Pollution/Health</option>
<option value="RESD">Resource Depletion</option>
-->
</select>
</td>
<!-- state/province -->
<?php if ($data['country'] != "" && ($value_country == "Canada" || $value_country == "United States")) { ?>
<td valign=top id="state_table" style="display: block;">
<?php } else { ?>
<td valign=top id="state_table" style="display: none;">
<?php } ?>
<P>&nbsp;<BR>
<SELECT NAME="region[]" id="state_select">
<?php 
if ($data['country'] != "" && ($value_country == "Canada" || $value_country == "United States")) {
if ($value_country == "Canada") printf("<option value=\"\">Province</option>\n");
  else printf("<option value=\"\">State</option>\n");
foreach ($regions as $key => $value) {
 if (in_array("$key", $data['country'])) {
    for($foo=0;$foo<count($value);$foo+=1) 
    {
     if ($data['region'] != "" && in_array("$value[$foo]", $data['region'])) printf("<option selected value=\"%s\">%s</option>\n",$value[$foo],$value[$foo]);
	else printf("<option value=\"%s\">%s</option>\n",$value[$foo],$value[$foo]);
    }
 }
}
}?>
</SELECT>
</td></tr>

<tr>
<!-- methods --> 
<td>
<p>Involved with:<BR>
<select id="methods" name="methodsare[]">
 <option value="blank">&lt;Methods&gt;</option>
 <option value="PLAN"<?php if (!empty ($data['methodsare']) && (in_array("PLAN",$data['methodsare']))) print(" selected");
?>>Consultancy/Urban Planning</option>
 <option value="DIRA"<?php if (!empty ($data['methodsare']) && (in_array("DIRA",$data['methodsare']))) print(" selected");
?>>Direct Action (Protests)</option>
 <option value="EDUC"<?php if (!empty ($data['methodsare']) && (in_array("EDUC",$data['methodsare']))) print(" selected");
?>>Education/Training</option>
 <option value="MONI"<?php if (!empty ($data['methodsare']) && (in_array("MONI",$data['methodsare']))) print(" selected");
?>>Industry Monitoring</option>
 <option value="LOBB"<?php if (!empty ($data['methodsare']) && (in_array("LOBB",$data['methodsare']))) print(" selected");
?>>Lobbying/Political Advocacy</option>
 <option value="MEDI"<?php if (!empty ($data['methodsare']) && (in_array("MEDI",$data['methodsare']))) print(" selected");
?>>Information (Publications, websites)</option>
 <option value="INFO"<?php if (!empty ($data['methodsare']) && (in_array("INFO",$data['methodsare']))) print(" selected");
?>>Public Media Campaigns</option>
 <option value="RESE"<?php if (!empty ($data['methodsare']) && (in_array("RESE",$data['methodsare']))) print(" selected");
?>>Research/Scientific Studies</option>
            </select>
        </td>
<td></td>		
</tr>
<tr><td>
<input class="go" name="searchnow" value="Search" type="submit" style="margin-top:20px">
</td>
<td>
<div class="button" style="margin-top:20px" onclick="resetForm()">Clear</div></td>
</tr>
</table>
</td>

<td valign=center width=33%><table><tr>
<td><img src="img/greenpageslogo.jpg" border=1> 
</td>
      </tr>
    </table>
</td></tr></table>
</form>