<?php

	include "library.php";

	$cxn = start_code();
	
	$cxn_common = db_common_login();
	

	page_header( "Search Listings", $cxn, $cxn_common );

//	if (val( $_GET, 'country' ) != "")
//		$curr_country = rawurldecode( val( $_GET, 'country' ) );
//	else

	$curr_country = "";


	$cities = build_dropdown_list( "city", $cxn_common );
	
	$industries = build_dropdown_list( "industry", $cxn );

	$countries = build_dropdown_list( "country", $cxn_common );

	$regions = build_dropdown_list( "region", $cxn_common );

	$_SESSION['search_attempt'] = "1";

	$min_price = val( $_SESSION, "min_price" );
	$max_price = val( $_SESSION, "max_price" );
	$industry = val( $_SESSION, "industry" );
	$suburb = val( $_SESSION, "suburb" );
	$city = val( $_SESSION, "city" );
	$region = val( $_SESSION, "region" );
	$country = val( $_SESSION, "country" );
	$search_for_word = val( $_SESSION, "search_for_word" );


	echo "<form name='form' action='".url_encode( "search_init.php", "country", rawurlencode( $curr_country ) )."' method='POST'><table>\n";

	echo "<tr>";


	form_text( "Minimum Price", "min_price", "10", $min_price );
	form_text( "Maximum Price", "max_price", "10", $max_price );
	form_dropdown( "Industry", "industry", $industries, $industry );
	
	form_text( "Suburb", "suburb", "20", $suburb );
	form_dropdown( "City", "city", $cities, $city );	
	form_dropdown( "Country", "country", $countries, $country );
	form_dropdown( "Region", "region", $regions, $region );	
	form_text( "Search for Word", "search_for_word", "20", $search_for_word );


	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";

	echo "<tr><td>&nbsp</td></tr>";

	form_hidden( "screen_width" );
	form_hidden( "screen_height" );
	form_hidden( "has_javascript" );
	form_hidden( "came_from_search", "yes" );

	echo "<tr></td><td colspan=2>".black( "Leave fields blank if they are not important to your search criteria" )."</td></tr>";

	echo "<tr><td></td><td><br>";
	
	show_green_button_submit( "Search", 90 );
	
	echo "</td></tr>";


		/* don't delete these of there won't be space for the ads */

	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";
	echo "<tr><td>&nbsp</td></tr>";

//	echo "<tr><td>".sp(1)."</td></tr>";

	form_end();

		// leave out until there is more traffic to keep the Adsense rating high
//	show_ads( $cxn );


?>