<?php


		// don't put in the common library because different sites have different color schemes
		
	function form_start( $handler, $param1="", $value1="", $param2="", $value2="", $param3="", $value3="" )
	{
			//lightskyblue  #cceeff azure
			// lighter color first #c0f5ff
			// azure, lightblue

		$color_scheme = val( $_SESSION, "color_scheme" );
		                                                                    // box-shadow: 10px 10px 5px #888888;
		if ($color_scheme != 2)		/* black screen background */
			echo "<form id='form' name='form' action='".url_encode( $handler, $param1, $value1, $param2, $value2, $param3, $value3 )."' method='POST'><table style='border: 1px solid #bbbbbb; border-radius: 10px; background: ".table_background.";); '>\n";
		else
			echo "<form id='form' name='form' action='".url_encode( $handler, $param1, $value1, $param2, $value2, $param3, $value3 )."' method='POST'><table style='border: 1px solid #bbbbbb; border-radius: 10px;'>\n";
		
	}


	function additional_validations( $id, $form_name, $newrecord, &$validation_errors, &$screen_data, &$screen_data_error, $cxn )
	{
	    if ($form_name == "jobseeker_profile" || $form_name == "advertiser_profile")
		{
			$email_address = $screen_data['email_address'];		
			
			if ($email_address != "")
			{
				if (email_address_is_valid( $email_address ) == "false")
				{
					$validation_errors = $validation_errors."The email address that you have entered is not a valid email address<br>";
					$screen_data_error['email_address'] = "true";
				}
			}
		}

	    if ($form_name == "jobseeker_profile")
		{
			$username = $screen_data['username'];		
			
			if ($username != "")
			{
				if (! check_jobseeker_username( $newrecord, $username, $id, $cxn ))
				{
					$validation_errors = $validation_errors."This username name has already been used by an existing jobseeker<br>";
					$screen_data_error['username'] = "true";
				}
			}
		}
		
	    if ($form_name == "advertiser_profile")
		{
			$username = $screen_data['username'];		
			
			if ($username != "")
			{
				if (! check_advertiser_username( $newrecord, $username, $id, $cxn ))
				{
					$validation_errors = $validation_errors."This username name has already been used by an existing advertiser<br>";
					$screen_data_error['username'] = "true";
				}
			}
		}

	    if ($form_name == "jobseeker_profile" )
    	{		
			$date_format = "dd/mm/yyyy";
	
			if ($screen_data['date_of_birth'] != "" && $date_format != "")
			{
				$age = check_date( convert_date_of_birth(prep_for_sql( $screen_data['date_of_birth'] ), str_replace( "'", "''", $date_format), $cxn ), $cxn);
		
				if ($age == -1)
				{
					$validation_errors = $validation_errors."The date of birth is not in a valid format. Please enter it in the format dd/mm/yyyy, mm/dd/yyyy or yyyy/mm/dd and select the format that you have used from the 'date format' list<br>";
	
					$screen_data_error['date_of_birth'] = "true";				
					$screen_data_error['date_format'] = "true";				
				}
				else
				if ($age < 18)
				{
					$validation_errors = $validation_errors."You must be at least 18 years of age to join this site<br>";
					
					$screen_data_error['date_of_birth'] = "true";				
					$screen_data_error['date_format'] = "true";				
				}
				else
				if ($age > 120)
				{
					$validation_errors = $validation_errors."Your date of birth may be incorrect, it is indicating you as over 110 years old<br>";
					
					$screen_data_error['date_of_birth'] = "true";				
					$screen_data_error['date_format'] = "true";				
				}
			}
		}
		
	}

			/* check to see whether a new user has selected an existing handle */

	function check_advertiser_username( $newprofile, $username, $advertiser_id, $cxn )
	{
		$handle = str_replace( "'", "''", $username );

		if ($newprofile == "true")
			$query = "SELECT username FROM advertiser_username_history WHERE username = '".$username."'";
		else
			$query = "SELECT username FROM advertiser_username_history WHERE username = '".$username."' AND advertiser_id <> ".$advertiser_id;

		$result = run_query( $query, $cxn );

		if (query_num_rows($result) == 0)
			return true;
		else
			return false;
	}


	function check_jobseeker_username( $newprofile, $username, $jobseeker_id, $cxn )
	{
		$handle = str_replace( "'", "''", $username );

		if ($newprofile == "true")
			$query = "SELECT username FROM jobseeker_username_history WHERE username = '".$username."'";
		else
			$query = "SELECT username FROM jobseeker_username_history WHERE username = '".$username."' AND jobseeker_id <> ".$jobseeker_id;

		$result = run_query( $query, $cxn );

		if (query_num_rows($result) == 0)
			return true;
		else
			return false;
	}
	

	function additional_screen_initialisations( $id, $newrecord, $form_name, $table_name, &$screen_data, $cxn )
	{
			// the following code is needed if those fields are put back on the form.

		if ($form_name == "jobseeker_profile" || $form_name == "advertiser_profile" || $form_name == "job")
		{
			$screen_data['confirm_email'] = $screen_data['email_address'];
			
//			$screen_data['confirm_password'] = $screen_data['password'];
		}
    }
	

		// don't delete this function it is called by the general save function
		
	function additional_changes_before_database_save( $id, $newrecord, $form_name, $table_name, &$screen_data, $cxn )
	{
//		if ($form_name == "alert_details" && $newrecord == "true")
//		{
//			$id = val( $_SESSION, "id" );
//			
//			$screen_data['member_id'] = $id;
//		}
	}


        // prevent long lines that don't word wrap, insert spaces if they're not there after commas and full stops
        //
        // inserts a space after each comma and full stop if there isn't one already, except for full stops in email addresses.
        //
        // also inserts a hypen and space after 40 characters without a space
        
        
    function str_insert_spaces( $text )
    {
        $text2 = "";
        $chars_without_space = 0;
        $in_email_address = false;
        
        if (strlen( $text ) > 0)
        {
            for ($i=0; $i < strlen( $text )-1; $i++)
            {
                $ch = substr( $text, $i, 1 );
                
                if ($ch == ",")
                {
                    if (substr( $text, $i+1, 1) != " ")
                    {
                        $text2 .= ", ";
                        $chars_without_space = 0;
                    }
                    else
                        $text2 .= ",";
                        
                    $in_email_address = false;
                }
                else
                if ($ch == ".")
                {
                    if (strpos( substr( $text, $i, 20 ), "@" ) === false && substr( $text, $i+1, 1) != "." && substr( $text, $i+1, 1) != " " && (! $in_email_address))
                    {
                        $text2 .= ". ";
                        $chars_without_space = 0;
                    }
                    else
                        $text2 .= ".";
                }
                else
                    $text2 .= $ch;
                
                if ($ch == "@")    
                    $in_email_address = true;

                if ($ch == " ")
                    $in_email_address = false;
                    
                if ($ch == " ")
                    $chars_without_space = 0;
                else
                    $chars_without_space++;
                    
                if ($chars_without_space >= 40)
                {
                    $text2 .= "- ";
                    $chars_without_space = 0;
                }
            }
    
            $text2 .= substr( $text, strlen($text)-1, 1 );
        }
        
        return ($text2);
    }
    


    function generate_custom_fields( $newrecord, $form_name, $field_name, $right_side_pane, $screen_data, $screen_data_error, $cxn )
    {
        if (($form_name == "jobseeker_profile" || $form_name == "advertiser_profile") && $field_name == "country")
        {
            write_city_list_update_function();
            
        	$countries = build_dropdown_list( common_data_database_name.".country", $cxn );
            
            $country = $screen_data['country'];
            $city = $screen_data['city'];
            
            $cities = "<option></option>";
            
          	if ($country != "")
        	{
                $query2 = "SELECT * FROM ".common_data_database_name.".full_list_cities_regions WHERE country = '".$country."' AND city_region_etc <> '' ORDER BY city_region_etc";
        
            	$result2 = run_query( $query2, $cxn );
            	
            	for ($i=0; $i < query_num_rows( $result2 ); $i++)
            	{
            	    $data = get_row( $result2 );
            
                    $cities .= "<option>";
                    $cities .= $data['city_region_etc'];
                    $cities .="</option>";
            	}
            
    			$pos = strpos( $countries, "<option>".$country."</option>" );
    
    			if ($pos !== false)
    			{
    				$pos = $pos + 8;
    				$countries = substr( $countries, 0, $pos - 1 )." selected".substr( $countries, $pos - 1, strlen( $countries ) - $pos + 1 );
    			}
    		}
    
    
            if (! low_res_screen())
            {
                if ($screen_data_error['country'] == "true")
                {
            		echo "<tr><td><span class='fprompt_error'>Country</span></td><td>".watermark( "*" )."</td>";
            		echo "<td><select id='country' name='country' class='finput_error' onchange='UpdateCityList();'>".$countries."</select></td></tr>";
                }
                else
                {
            		echo "<tr><td><span class='fprompt'>Country</span></td><td>".watermark( "*" )."</td>";
            		echo "<td><select id='country' name='country' class='finput' onchange='UpdateCityList();'>".$countries."</select></td></tr>";
                }
            }
            else
            {
                if ($screen_data_error['country'] == "true")
                {
            		echo "<tr><td><br><span class='fprompt_error'>Country</span> ".watermark( "*" );
            		echo "<br><select id='country' name='country' class='finput_error' onchange='UpdateCityList();'>".$countries."</select></td></tr>";
                }
                else
                {
            		echo "<tr><td><br><span class='fprompt'>Country</span> ".watermark( "*" );
            		echo "<br><select id='country' name='country' class='finput' onchange='UpdateCityList();'>".$countries."</select></td></tr>";
                }
            }
        
    		if ($city != "")
    		{
    			$pos = strpos( $cities, "<option>".$city."</option>" );
    
    			if ($pos !== false)
    			{
    				$pos = $pos + 8;
    				$cities = substr( $cities, 0, $pos - 1 )." selected".substr( $cities, $pos - 1, strlen( $cities ) - $pos + 1 );
    			}
    		}
    
            if (! low_res_screen())
            {
        		echo "<tr><td><span class='fprompt'>City</span></td><td></td>";
        		echo "<td><select id='city' name='city' class='finput'>".$cities."</select></td></tr>";				
            }
            else
            {
    	    	echo "<tr><td><br><span class='fprompt'>City</span>";
    		    echo "<br><select id='city' name='city' class='finput'>".$cities."</select></td></tr>";	
            }
        }
    }


    function write_city_list_update_function()
    {
        echo "<script>";
        
        echo "function UpdateCityList()";
        
        echo "{";

        echo "  var xmlHttp = new XMLHttpRequest();";
    
        echo "  var country = document.getElementById( 'country' ).value;";

        echo "  var CityList = document.getElementById( 'city' );";

        echo "  xmlHttp.open( 'GET', '/retrieve_city_list.php?country='+country, true );";      // `false` makes the request synchronous

        echo "  xmlHttp.onreadystatechange = update_list;";

        echo "  function update_list()";
        echo "  {";

        echo "      if (xmlHttp.readyState == 4 && xmlHttp.status == 200)";
        echo "      {";
        echo "          var return_values = xmlHttp.responseText;";
        echo "          var return_values_array = return_values.split( \";\" );";

        echo "          while (CityList.options.length) { CityList.remove(0); }";
        
        echo "          var i;";

        echo "          for (i=0; i < return_values_array.length; i++) { var option = document.createElement(\"option\"); option.text = return_values_array[i]; CityList.add( option, i ); }";

        echo "          var option = document.createElement(\"option\"); option.text = \"\"; CityList.add( option, 0 );";

        echo "          CityList.selectedIndex = 0;";

        echo "          var all_countries_checkbox = document.getElementById( 'all_countries' );";
        
        echo "          all_countries_checkbox.checked = false;";
        echo "      }";        
        
        echo "  }";        

        echo "  xmlHttp.send( null );";

        echo "}";
        
        echo "</script>";
    }        


    
    function show_search_screen( $full_fields, $amp, $cxn )
    {
    
        write_city_list_update_function();
        
    
        if (! low_res_screen())
            echo "<br><br>";
    
    
    
    	$countries = build_dropdown_list( common_data_database_name.".country", $cxn );
    
    	$regions = build_dropdown_list( common_data_database_name.".region", $cxn );
    	
    	$keywords = build_dropdown_list( "keywords", $cxn );
    	
    
    
    	$_SESSION['search_attempt'] = "1";
    
    
    		// NOTE: use different field names to the profile edit screen otherwise going to edit profile will bring values into the search screen
    		
    	$min_age = val( $_SESSION, "smin_age" );
    	$max_age = val( $_SESSION, "smax_age" );
    	$city = val( $_SESSION, "scity" );
    	$state = val( $_SESSION, "sstate" );
    	$all_countries = val( $_SESSION, "sallcountries" );
    	$country = val( $_SESSION, "scountry" );
    	$region = val( $_SESSION, "sregion" );	
    	$keyword = val( $_SESSION, "skeyword" );
    	$search_for_word = val( $_SESSION, "ssearch_for_word" );
    	$compatability = val( $_SESSION, "scompatability" );
    	$logged_on = val( $_SESSION, "slogged_on" );
        $sex_and_seeking = val( $_SESSION, "ssex_and_seeking" );
        $verified_member_status = val( $_SESSION, "sverified_member_status" );
    
    
        $cities = "<option></option>";
        
      	if ($country != "")
    	{
            $query2 = "SELECT * FROM ".common_data_database_name.".full_list_cities_regions WHERE country = '".$country."' AND city_region_etc <> '' ORDER BY city_region_etc";
    
        	$result2 = run_query( $query2, $cxn );
        	
        	for ($i=0; $i < query_num_rows( $result2 ); $i++)
        	{
        	    $data = get_row( $result2 );
        
                $cities .= "<option>";
                $cities .= $data['city_region_etc'];
                $cities .="</option>";
        	}
    	}
    
    
    	$options = "<option></option><option>I am a Man seeking a Woman for a relationship</option>";
    	$options .= "<option>I am a Woman seeking a Man for a relationship</option>";	
    	$options .= "<option>I am a Man seeking a Man for a relationship</option>";	
    	$options .= "<option>I am a Woman seeking a Woman for a relationship</option>";
    	$options .= "<option>I am seeking Men for friendship or relationship</option>";
    	$options .= "<option>I am seeking Women for friendship or relationship</option>";	
    	$options .= "<option>I am seeking Men for friendship</option>";
    	$options .= "<option>I am seeking Women for friendship</option>";
    	$options .= "<option>I am seeking Either for friendship</option>";
    
    
    	if (! low_res_screen())
            search_desktop_display( $full_fields, $options, $cities, $countries, $regions, $keywords, $min_age, $max_age, $city, $state, $all_countries, $country, $region, $keyword, $search_for_word, $compatability, $logged_on, $sex_and_seeking, $verified_member_status, $cxn );
        else
            search_mobile_display( $amp, $full_fields, $options, $cities, $countries, $regions, $keywords, $min_age, $max_age, $city, $state, $all_countries, $country, $region, $keyword, $search_for_word, $compatability, $logged_on, $sex_and_seeking, $verified_member_status, $cxn );
        
    }
    
        
    function search_desktop_display( $full_fields, $options, $cities, $countries, $regions, $keywords, $min_age, $max_age, $city, $state, $all_countries, $country, $region, $keyword, $search_for_word, $compatability, $logged_on, $sex_and_seeking, $verified_member_status, $cxn )
    {
		$color_scheme = val( $_SESSION, "color_scheme" );
		                                                                    // box-shadow: 10px 10px 5px #888888;
		if ($color_scheme != 2)		/* black screen background */
        	echo "<form name='form' action='".url_encode( "search_init.php" )."' method='POST'><table ><tr><td width='5%'>&nbsp;</td><td valign='top'><table style='border: 1px solid #bbbbbb; border-radius: 10px; background: ".table_background.";'>\n";
//        	echo "<form name='form' action='".url_encode( "search_init.php" )."' method='POST'><table width='100%'><tr><td width='5%'>&nbsp;</td><td width='75%' valign='top'><table width='60%' style='border: 1px solid #bbbbbb; border-radius: 10px; background: ".table_background.";'>\n";
        else
            echo "<form name='form' action='".url_encode( "search_init.php" )."' method='POST'><table ><tr><td width='5%'>&nbsp;</td><td valign='top'><table style='border: 1px solid #bbbbbb; border-radius: 10px;'>\n";        
//            echo "<form name='form' action='".url_encode( "search_init.php" )."' method='POST'><table width='100%'><tr><td width='5%'>&nbsp;</td><td width='75%' valign='top'><table width='60%' style='border: 1px solid #bbbbbb; border-radius: 10px;'>\n";        
            
    	echo "<tr>".form_dropdowny( "Search for", "sex_and_seeking", $options, $sex_and_seeking );
    

    	form_text( "Minimum Age", "min_age", "3", $min_age );
    	form_text( "Maximum Age", "max_age", "3", $max_age );

//    	form_checkbox( "All Countries", "all_countries", $all_countries );

        search_show_all_countries_checkbox( $all_countries );


  		if ($country != "")
		{
			$pos = strpos( $countries, "<option>".$country."</option>" );

			if ($pos !== false)
			{
				$pos = $pos + 8;
				$countries = substr( $countries, 0, $pos - 1 )." selected".substr( $countries, $pos - 1, strlen( $countries ) - $pos + 1 );
			}
		}


		echo "<tr><td><span class='fprompt'>Country</span></td>";
		echo "<td><select id='country' name='country' class='finput' onchange='UpdateCityList();'>".$countries."</select></td></tr>";

        if ($full_fields)
        {
    		if ($city != "")
    		{
    			$pos = strpos( $cities, "<option>".$city."</option>" );
    
    			if ($pos !== false)
    			{
    				$pos = $pos + 8;
    				$cities = substr( $cities, 0, $pos - 1 )." selected".substr( $cities, $pos - 1, strlen( $cities ) - $pos + 1 );
    			}
    		}
    
    		echo "<tr><td><span class='fprompt'>City</span></td>";
    		echo "<td><select id='city' name='city' class='finput'>".$cities."</select></td></tr>";				
    
    
            if (is_academic_dating)
            	form_dropdown( "Region", "region", $regions, $region );	
      
        	form_dropdown( "Search&nbsp;for&nbsp;Keyword", "keyword", $keywords, $keyword );
    
        	form_text( "Search for Word", "search_for_word", "15", $search_for_word );
        
        
        	if ($compatability == "on")
        		$checked = "checked";
        	else
        	    $checked = "";
        
        
        // include the line below to activate compatability searches
        
        //	echo "<tr><td><span class='fprompt'>Order by highest compatability matches</span></td><td><input type='checkbox' name='compatability' ".$checked."> ".watermark( "Must be a member to search by compatability" )."</td></tr>";
        
        
            echo "<tr><td>&nbsp;</td></tr>";
    
    
            if ($verified_member_status == "")
                $verified_member_status = "all_members";
                
                
    //    	form_radio( "Search for", "verified_member_status", "all_members", "All members", $verified_member_status );
    //    	form_radio( "", "verified_member_status", "all_messages_only", "Only member's who accept all messages", $verified_member_status );
    //    	form_radio( "", "verified_member_status", "verified_members_only", "Only Member's who want contact from verified members only", $verified_member_status );
    
    		echo "<tr><td>&nbsp;</td></tr>";
        
    		echo "<tr><td width=18%></td><td colspan=2>".watermark( "Leave fields blank if they are not important to your search criteria&nbsp;&nbsp;&nbsp;" )."</td></tr>";		
    //		echo "<tr><td width=18%></td><td>".watermark( "Leave fields blank if they are not important to your search criteria" )."</td><td></td><td></td><td></td></tr>";		
        }
        
		echo "<tr><td></td><td width='20%'><br>";

    	show_green_button_submit( "Search", 90 );
    	
    	echo "</td></tr>";
    
        echo "<tr><td></td><td></td><td></td></tr>";
    
        echo "</table></td><td></td><td align='right' rowspan=8 valign='top'>";
      
		$color_scheme = val( $_SESSION, 'color_scheme' );
      
//        if ($color_scheme == 2)
//    		echo "<br><br><div style='background: #000000; border: 8px solid #000000; display: inline-block;'>";
//    	else
//	    	echo "<br><br><div style='background: #ffffff; border: 8px solid #ffffff; display: inline-block;'>";
		
//		show_image( select_website_image( $cxn ), 380 );

//		echo "</div></td>";
      

//    	show_ads_medium_skyscraper();
    
    
        echo "</td><td width='5%'>&nbsp;</td></tr>";
    
        echo "<tr><td colspan=3>";
        
        echo "<br><br>";
        
        
//        if (val( $_SESSION, "id" ) == "")

//    		show_ads( $cxn );		

//    	else
//   		show_double_ads( $cxn );
    
        echo "</td></tr>";
    
//        echo "</table>";
  
        echo "<tr><td colspan='3' align='center'>";
    
    //        if (val( $_SESSION, "id" ) == "")
    
    //    	else
    //    		show_double_ads( $cxn );
    		
        echo "</td></tr>";

    	echo "</table></form>";
    
    	echo "<br>";
    }

    
    function search_show_all_countries_checkbox( $all_countries )
    {
        $checked = "";
        
		if ($all_countries == "on")
			$checked = "checked";

		echo "<tr><td><span class='fprompt'>All Countries</span></td><td><input type='checkbox' id = 'all_countries' name='all_countries' onclick='
		                                    document.getElementById( \"country\" ).value = \"\"; 
		                                    document.getElementById( \"city\" ).value = \"\"; 
		                                    while (document.getElementById( \"city\" ).options.length) 
		                                    document.getElementById( \"city\" ).remove(0);' ".$checked."></td></tr>\n";
    }

    
    function search_mobile_display( $amp, $full_fields, $options, $cities, $countries, $regions, $keywords, $min_age, $max_age, $city, $state, $all_countries, $country, $region, $keyword, $search_for_word, $compatability, $logged_on, $sex_and_seeking, $verified_member_status, $cxn )
    {
        if ($amp)
        	echo "<form name='form' action-xhr='".url_encode( "search_init.php" )."' method='post' target='_top'><table width='100%'>\n";
        else
            echo "<form name='form' action='".url_encode( "search_init.php" )."' method='POST'><table width='100%'>\n";
            
		echo "<tr><td width='30%'></td><td width='35%'></td><td width='30%'></td><td width='5%'></td></tr>";
    		
		if ($sex_and_seeking != "")
		{
			$pos = strpos( $options, "<option>".$sex_and_seeking."</option>" );

			if ($pos !== false)
			{
				$pos = $pos + 8;
				$options = substr( $options, 0, $pos - 1 )." selected".substr( $options, $pos - 1, strlen( $options ) - $pos + 1 );
			}
		}

		echo "<tr><td colspan='2'><span class='fprompt'>Search for</span></td></tr>";
		echo "<tr><td colspan='2'><select name='sex_and_seeking' class='finput'>".$options."</select></td></tr>";				
		
		echo "<tr><td>&nbsp;</td></tr>";

    
    	form_textz( "Minimum Age", "min_age", "3", $min_age );
    	form_textz( "Maximum Age", "max_age", "3", $max_age );

        if ($full_fields)
        {
            if (is_academic_dating)
            	form_dropdown( "Region", "region", $regions, $region );	
        
        	form_dropdown( "Search for Keyword", "keyword", $keywords, $keyword );
    
        	form_textz( "Search for Word", "search_for_word", "14", $search_for_word );
    
            search_show_all_countries_checkbox( $all_countries );
        }
        
    //    	form_checkbox( "All Countries", "all_countries", $all_countries );
    
    
        	if ($compatability == "on")
        		$checked = "checked";
        	else
        	    $checked = "";
        
        
        // include the line below to activate compatability searches
        
        //	echo "<tr><td><span class='fprompt'>Order by highest compatability matches</span></td><td><input type='checkbox' name='compatability' ".$checked."> ".watermark( "Must be a member to search by compatability" )."</td></tr>";
        
        
    //		echo "<tr><td>&nbsp;</td></tr>";
    
    	    
    
		if ($country != "")
		{
			$pos = strpos( $countries, "<option>".$country."</option>" );

			if ($pos !== false)
			{
				$pos = $pos + 8;
				$countries = substr( $countries, 0, $pos - 1 )." selected".substr( $countries, $pos - 1, strlen( $countries ) - $pos + 1 );
			}
		}


		echo "<tr><td colspan='2'><span class='fprompt'>Country</span></td></tr>";
		echo "<tr><td colspan='2'><select id='country' name='country' onchange='UpdateCityList();' class='finput'>".$countries."</select></td></tr>";				

        if ($full_fields)
        {
    		if ($city != "")
    		{
    			$pos = strpos( $cities, "<option>".$city."</option>" );
    
    			if ($pos !== false)
    			{
    				$pos = $pos + 8;
    				$cities = substr( $cities, 0, $pos - 1 )." selected".substr( $cities, $pos - 1, strlen( $cities ) - $pos + 1 );
    			}
    		}
    
    		echo "<tr><td colspan='2'><span class='fprompt'>City</span></td></tr>";
    		echo "<tr><td colspan='2'><select id='city' name='city' class='finput'>".$cities."</select></td></tr>";				
    
    		echo "<tr><td>&nbsp;</td></tr>";
    
    		echo "<tr><td colspan='2'>".watermark( "Leave fields blank if they are not important to your search criteria" )."</td><td></td></tr>";		
    		echo "<tr><td>&nbsp;</td></tr>";
        }
        
	    echo "<tr><td colspan='2' align='center'>";			

//        echo "<br><br>";
        
        if ($amp)    		
            echo "<input type='submit' value='Search'>";
        else
        	show_green_button_submit( "Search", 90 );
    	
    	echo "</td></tr>";
    
        echo "<tr><td></td><td></td><td></td><td></td><td></td><td></td></tr>";
    
//        echo "</table></td><td align='right' rowspan=8>";
//      
//    	show_ads_medium_skyscraper();
//    
//        echo "</td><td width='10%'>&nbsp;</td></tr>";
//    
//        echo "<tr><td colspan=2>";
//        
//        if (val( $_SESSION, "id" ) == "")
//    		show_ads( $cxn );		
//    	else
//    		show_double_ads( $cxn );
    
        echo "</td></tr>";
    

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

    	echo "</table></form>";

        echo "<br>";
    }
  
?>