<?php

    if (! isset( $argv ))
    	include "defines.php";


	include "/home/academi1/public_html/common_code/common_library.php";



    			/* startup code to be called at the top of each file */

	function start_code( $first=false, $index_page=false )
	{

        $GLOBALS['free_site'] = true;


            // by default this variable is set to on
//		ini_set( "session.use_only_cookies", "0" );
//		ini_set( "session.cookie_httponly", "0" );

		
        if (session_status() != PHP_SESSION_ACTIVE)
    		session_start();


			/* remember user across pages */

			/* set config options */

		ini_set( "error_log", error_log_filename );

//		ini_set( "display_errors", "on" );
//		ini_set( "display_startup_errors", "on" );

        error_reporting( E_ALL & ~E_DEPRECATED & ~E_WARNING );
        

//		ini_set( "gc_maxlifetime", 3*60*60 );		/* set session timeout to 3 hours */


								// set limits to allow uploading large photos
								
		ini_set( "upload_max_filesize", "20M" );
		ini_set( "post_max_size", "20M" );		
//		ini_set( "max_input_time", 120 );		
//		ini_set( "max_execution_time'", 120 );		

//		ini_set( "date.timezone", "Australia/Melbourne" );		


//		$user_agent = val( $_SERVER, "HTTP_USER_AGENT" );

//		if (! $first )
//			check_url();


		$cxn = db_login( database_name );


		log_page_load( $cxn );

        
		return ($cxn);
	}



		/* generate the heading line for a page */

		/* NOTE: don't call this before any jump_to_page's or the jumps wont work */

	function page_header( $heading, $cxn, $dont_jump=false, $index_page=false, $home_page=false, $amp=false, $no_ads=false )
	{
        $ip_country = get_ip_country( $cxn );

        if ($adcountry != "")
            $country = $adcountry;
        else
            $country = get_country_from_ip_country( $ip_country, $cxn );

        $the = get_heading_the( $country, $cxn );
	    
	    
//        echo "<br><span style='font-size: 16pt; font-family: verdana'>Academic Dating will be down for 30 minutes for maintenance. Please try again later.</span>";
//        exit();

        $bg = write_head_section_of_page( $heading, $cxn, $index_page, $home_page, $amp );


        if ((! $amp) && val( $_SESSION, "screen_width" ) == "")
    		echo "<body onload='js_set_screen_parameters();'>";
    	else
    		echo "<body>";

        if (! low_res_screen())
        {
    		echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td width='5%' class='home_heading_desktop'>&nbsp;</td><td width='75%' class='home_heading_desktop' align='left'>".sitename."</td>";
//    		echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td width='20%' class='home_heading_desktop'>&nbsp;</td><td width='60%' class='home_heading_desktop' align='center'>".sitename."&nbsp;&nbsp;(".$the.$country.")</td>";

	        echo "<td width='20%' valign='center' align='left' class='home_heading_desktop'>";
    
            show_google_translate( "#007500" );
    
            echo "</td></tr></table>";
            
            echo "<table width='98%'><tr><td width='12%' align='center' valign='top'><br><br>";
            
            main_menu( val( $_SESSION, "id" ) );
            
            echo "</td><td width='3%'>&nbsp;</td><td valign='top'>";
            
            echo "<br>";
            
//            echo "<table width='100%'><tr><td width='100%' align='center'>";
//            
//            if (! $no_ads)
//            {
//                echo "<br><br>";
//            
//                show_ads( $cxn );
//
//                echo "<br><br><br>";
//            }                
//            
//            echo "</td></tr></table><br><hr>";
            
            
    		if ($heading != "")
    		{
                echo "<span class='spacer_line_1pt'>&nbsp;</span><br>";
    		
                echo "<span class='pgheading' valign='center'>".$heading."</span><br><br>";
    		}
        }
        else
        {
//    		echo "<table cellspacing='0' width='100%'><tr><td class='home_heading_mobile' valign='middle' align='center'>".sitename."<td></tr></table>";
//    		echo "<table cellspacing='0' width='100%'><tr><td class='home_heading_mobile' valign='middle' align='center'>".sitename."&nbsp;&nbsp;(".$the.$country.")<td></tr></table>";
            
            if (! $home_page)
        		echo "<table width='100%'><tr><td class='spacer_line_1pt'>&nbsp;<td></tr></table>";
            

    		if ($heading != "")
    		{
    			echo "<table width='100%'><tr><td width='45%'><span class='pgheading' valign='center' >".$heading."</span></td>";

    		    echo "<td width='30%' valign='left'>";
    
                show_google_translate();
    
                echo "</td>";
    
    			echo "<td width='25%' align='center'>";
    			
    			show_green_button( "Home", 80, "/" );
    			
    			echo "</td></tr></table>";
    
    			echo "<br>";
    		}
    		else
    		{
    			if (! $home_page)
    			{
        			echo "<table width='100%'><tr><td width='80%'>&nbsp;</td><td width='20%' align='center'>";
    
    		        show_google_translate();
    		        
                    echo "</td></tr></table>";
    			}
    		}
        }
        
    	
//		log_page_load( $cxn );

	}


    function write_head_section_of_page( $heading, $cxn, $index_page, $home_page=false, $amp=false )
    {
		echo "<!doctype html>";

		echo "<head>";
		
        echo "<meta charset='utf-8'>";
        echo "<meta name='viewport' content='width=device-width, minimum-scale=1, initial-scale=1.0'>";
		
        if (val( $_SESSION, "screen_width" ) == "")
            write_screen_parameters_function();


        echo "<meta name='keywords' content='".sitename.",Part time,Job,Jobs,Retirement'>";

        echo "<meta name='description' content='".sitename." is a site for listing part-time jobs in Australia.'>";
        

            // Google overall products
            
            // <!-- Global site tag (gtag.js) -->
        
        echo "<script async src='https://www.googletagmanager.com/gtag/js?id=UA-97849346-1'></script>\n";
        echo "<script>\n";
        echo "  window.dataLayer = window.dataLayer || [];\n";
        echo "  function gtag(){dataLayer.push(arguments);}\n";
        echo "  gtag('js', new Date());\n";
        echo "  gtag('config', 'UA-97849346-1', {'groups': 'MLMGoogleAnalytics' });\n";
        echo "  gtag('config', 'AW-851976106');\n";
        echo "</script>\n";

                // <!-- Google Tag Manager -->
                
//            echo "<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':";
//            echo "new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],";
//            echo "j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=";
//            echo "'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);";
//            echo "})(window,document,'script','dataLayer','GTM-TC7P6ST');</script>";

//		echo "<meta http-equiv='Content-Type' content='text/html; charset=UTF-8'>";

            // page-level mobile ads
            
//        echo "<script async src='//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>";
//        echo "<script>";
//        echo "  (adsbygoogle = window.adsbygoogle || []).push({";
//        echo "    google_ad_client: 'ca-pub-7728790744816510',";
//        echo "    enable_page_level_ads: true";
//        echo "  });";
//        echo "</script>";

//		echo "<meta http-equiv='cache-control' content='no-cache' >";
		
//        echo "<meta http-equiv='expires' content='0' >";
//        echo "<meta http-equiv='expires' content='Tue, 01 Jan 1980 1:00:00 GMT' >";
//        echo "<meta http-equiv='pragma' content='no-cache' >";		
		
		
			// ********** Notes
			
			// at present only the old version (legacy) of the Google Analytics libary generates Google Translate information
			
    
//		include "google_analytics_legacy_version.php";

//		include "google_analytics_tracking.php";


        echo "<link rel='shortcut icon' href='/ad_favicon.ico' type='image/x-icon'>";
        echo "<link rel='icon' href='/ad_favicon.ico' type='image/x-icon'>";
        echo "<link rel='icon' type='image/png' sizes='96x96' href='/ad_favicon-96x96.png'>";


			/* javascript functions for chat and online refresh */

		write_js_functions();

			/* define styles */


    	echo "<style>";



		write_common_styles();
		
		
		$data = define_styles( $home_page );
		
		$bg = $data['bg'];


        if ($home_page || (! low_res_screen()))
        {
    		echo "html, body {";
    		echo "margin:0;";
    		echo "padding:0;";
    		echo "background-color: ".$bg.";";
    		echo "}";
        }
        else
        {
    		echo "html, body {";
    		echo "margin-top:0;";
    		echo "padding:0;";
    		echo "background-color: ".$bg.";";
    		echo "}";
        }

		echo "</style>";


		if ($heading != "")
		{
			echo "<title>".sitename.": ".$heading."</title></head>";
		}
		else
		{
      		echo "<title>".sitename." - a site for listing part-time jobs in Australia</title>";
		}
		
		
//        if ($home_page)		
//        {
//            echo '<script type="application/ld+json">';
//            echo '{';
//            echo '  "@context": "http://schema.org",';
//            echo '  "@type": "Organization",';
//            echo '  "url": "'.full_site_url.'",';
//            echo '  "name": "Academic Dating",';
//            echo '  "contactPoint": {';
//            echo '    "@type": "ContactPoint",';
//            echo '    "url": "'.full_site_url.'/contact_us.php",';
//            echo '    "email": "'.admin_email_address.'",';
//            echo '    "contactType": "Customer service"';
//            echo '  }';
//            echo '}';            
//            echo "</script>";
//        }
        
        echo "</head>";
        
		return ($bg);
    }


		/* define the CSS styles */

	function define_styles( $home_page=false )
	{
		$color_scheme = val( $_SESSION, 'color_scheme' );


        if (! low_res_screen())
            $standard_font_size = 12;
        else
            $standard_font_size = 12;

		$blue_color = "#0000bb";


        if (! low_res_screen())
        	$home_page_font_size = "11";
        else
        	$home_page_font_size = "12";

        
        $_SESSION['home_page_font_size'] = $home_page_font_size;
        
//007500
        echo ".home_heading_desktop {line-height: 52px; font-family: Calibri; font-size: 24pt; color: #ffffff; background-color: #007500}";

//1144b8
        echo ".home_heading_mobile {padding-top: 3; padding-bottom: 5; font-family: Calibri; font-size: 14pt; color: #ffffff; opacity: 0.9; background-color: #007500}";

        echo ".spacer_line {font-size: 4pt}";

        echo ".spacer_line_1pt {font-size: 1pt}";
        


            //-----------------------------------------------------
            // country list
            

        echo ".country_list_link {";
        
	    if ($color_scheme == 2)
            echo "color: #ffffff;";
        else
            echo "color: #000000;";
            
        echo "font-family: verdana;";
        echo "font-size: 8pt;";
        echo "text-decoration: none;";
        echo "}";
        
        echo ".country_list_link:hover {";
        echo "color: #008500;";
        echo "font-family: verdana;";
        echo "font-size: 8pt;";
        echo "text-decoration: underline;";
        echo "}";


        echo ".border_collapse {";
        echo "  border-collapse: collapse;";
        echo "}";
        


            //-----------------------------------------------------
            // main menu styles
            
            
		if ($color_scheme == 2)
            $main_menu_highlight_color = '#555555';
        else
            $main_menu_highlight_color = '#eeeeee';
        

        $main_menu_heading_color = '#000000';
        $main_menu_text_color = "#007500";
        $main_menu_hover_color = "#00af00";
        $main_menu_highlight_color = "#ffffff";


        $menu_font_size = "10";


        echo ".mainmenuitem {";
        echo "  padding: 1.5px;";
        echo "  padding-left: 8px;";
        echo "  color: ".$main_menu_text_color.";";
        echo "  cursor: pointer;";
//        echo "  background: #ffffff;";
//        echo "  border: 1px solid #ffffff;";
        echo "  font-family: verdana;";
        echo "  font-size: ".$menu_font_size."pt;";
        echo "}";

        echo ".mainmenuitem:hover {";
        echo "  padding: 1.5px;";
        echo "  padding-left: 8px;";
        echo "  color: ".$main_menu_hover_color.";";
//        echo "  background: ".$main_menu_highlight_color.";";
        echo "  cursor: pointer;";
        echo "  font-family: verdana;";
        echo "  font-size: ".$menu_font_size."pt;";
        echo "}";

        echo ".mainmenuitem_disabled {";
        echo "  padding: 1.5px;";
        echo "  padding-left: 8px;";
        echo "  color: #aaaaaa;";
        echo "  cursor: pointer;";
        echo "  font-family: verdana;";
        echo "  font-size: ".$menu_font_size."pt;";
        echo "}";

        echo ".mainmenuitem_disabled:hover {";
        echo "  padding: 1.5px;";
        echo "  padding-left: 8px;";
        echo "  color: #aaaaaa;";
        echo "  background: ".$main_menu_highlight_color.";";
        echo "  cursor: pointer;";
        echo "  font-family: verdana;";
        echo "  font-size: ".$menu_font_size."pt;";
        echo "}";

        echo ".mainmenuitem_heading {";
        echo "  padding: 1.5px;";
        echo "  color: ".$main_menu_heading_color.";";
        echo "  font-style: italic;";
        echo "  font-family: verdana;";
        echo "  font-size: ".$menu_font_size."pt;";
        echo "}";
        
        
				/* standard */

        $bg = '#ffffff';
            
            
		echo "body   		{ color: #000000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";


		echo ".ghome_page_text  { color: #007500; font-family: verdana; font-size: ".$home_page_font_size."pt;}";

		echo ".ghome_page_text_mobile  { color: #8B4513; font-family: verdana; font-size: ".$home_page_font_size."pt;}";


		echo ".gblack         { color: #000000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".gblue          { color: ".$blue_color."; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".gred           { color: #bb0000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".ggreen         { color: #00bb00; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".gwatermark     { color: #999999; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".gdarkgreen     { color: #007500; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".gbrown         { color: #8B4513; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".gemail         { color: #ff0000; font-family: courier; font-size: ".fs( $standard_font_size )."pt}";
		
		
			// NOTE: if changing the color of the input box border, must also change it in 'write_yellow_input_boxes' as this function
			// sets it back when a field loses the focus

		if (! low_res_screen())
        {				
			echo ".fprompt        { padding-left: 2px; margin-right: 3px; color: ".$blue_color."; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".finput         { padding-left: 2px; margin-right: 3px; color: #000000; padding-left: 2px; border-style: solid; border-width: 1px; border-color: #cccccc; border-radius: 5px; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";			
			echo ".fradio         { padding-left: 2px; margin-right: 3px; color: #000000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

			echo ".fprompt_error  { padding-left: 2px; color: #ff0000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".finput_error   { padding-left: 2px; color: #000000; padding-left: 2px; border-style: solid; border-width: 1px; border-color: #cccccc; border-radius: 5px; background-color: #ff9999; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".fradio_error   { padding-left: 2px; color: #000000; background-color: #ff9999; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
        }
        else
        {
			echo ".fprompt        { color: ".$blue_color."; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".finput         { color: #000000; padding-left: 2px; border-style: solid; border-width: 1px; border-color: #cccccc; border-radius: 5px; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".fradio         { color: #000000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

			echo ".fprompt_error  { color: #ff0000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".finput_error   { color: #000000; padding-left: 2px; border-style: solid; border-width: 1px; border-color: #cccccc; border-radius: 5px; background-color: #ff9999; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
			echo ".fradio_error   { color: #000000; background-color: #ff9999; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
        }
        
		echo ".dprompt        { color: ".$blue_color."; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";          // display prompt
		echo ".dtext          { color: #000000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";          // display text

		echo ".paraheading    { color: ".$blue_color."; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".pgheading      { color: ".$blue_color."; font-family: verdana; font-size: ".fs( 16 )."pt}";

		echo ".redpgheading      { color: #a00000; font-family: verdana; font-size: ".fs( 16 )."pt}";

		echo ".glink		  { color: ".$blue_color."; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".glink:hover    { color: #00a000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".blacklink		  { color: #000000; text-decoration: none; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".blacklink:hover    { color: #00a000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".gdarkgreenlink		   { color: #007500; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".gdarkgreenlink:hover    { color: #00bb00; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".redlink { text-decoration: none; color: #8B4513; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".redlink:hover { text-decoration: underline; color: #8B4513; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".redlink2 { color: #cc0000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".redlink2:hover { text-decoration: underline; color: green; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".brownlink { color: #8B4513; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".brownlink:hover { text-decoration: underline; color: green; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";

		echo ".homepagelink { color: #8B4513; font-family: verdana; font-size: ".$home_page_font_size."pt}";
		echo ".homepagelink:hover { text-decoration: underline; color: green; font-family: verdana; font-size: ".$home_page_font_size."pt}";

		echo ".homepagelink_mobile { color: #8B4513; font-family: verdana; font-size: ".$home_page_font_size."pt}";
		echo ".homepagelink_mobile:hover { text-decoration: underline; color: green; font-family: verdana; font-size: ".$home_page_font_size."pt}";

		echo ".chat		      { color: #000000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";
		echo ".chat2		      { color: #ff0000; font-family: verdana; font-size: ".fs( $standard_font_size )."pt}";			



		$data['bg'] = $bg;

		return ($data);
	}



        // log a count of the number of page views. Make sure that this isn't called from online_refresh.php or background email sending program
        
    function log_page_view( $cxn )
    {
        $ip_country = get_ip_country( $cxn );
        
        $today_date = date( "Y-m-d" );
        
	    $device = device_type();
        
        
        $query = "SELECT id FROM page_views WHERE page_view_date = '".$today_date."' AND ip_country = '".$ip_country."' AND device = '".$device."'";
        
        
            // on rare occasions there may be two records created for one date if two users are checking and adding at the same time.
            
        if (query_has_rows( $query, $cxn ))
        {
            $query = "UPDATE page_views SET count = count + 1 WHERE page_view_date = '".$today_date."' AND ip_country = '".$ip_country."' AND device = '".$device."'";
            
            $result = run_query( $query, $cxn );
        }
        else
        {
            $query = "INSERT INTO page_views (page_view_date, ip_country, count, device) VALUES ('".$today_date."', '".$ip_country."', 1, '".$device."' )";
            
            $result = run_query( $query, $cxn );            
        }
    }
    



		// write a record to the 'page_loads' table for each page loaded, if called
		
	function log_page_load( $cxn )
	{
		$ip_address = get_ip_address();	
		
		$ip_country = get_ip_country( $cxn );
		
		$loaded_datetime = date("Y-m-d H:i:s");
		
		$page = val( $_SERVER, "PHP_SELF" );
		
		$page2 = prep_for_sql( $page );
		
		$query = "INSERT INTO page_loads (ip_address, ip_country, loaded, page) VALUES ('".$ip_address."', '".$ip_country."', '".$loaded_datetime."', '".$page2."')";
		
		$result = run_query( $query, $cxn );		
	}



    function member_display_one_line( $this_id, $show_sex_seeking, $age, $handle, $short_intro, $sex, $sex_wanted, $city, $country, $photo_number, $file_extension, $aspect_ratio_large, $aspect_ratio_small, $version, $return_point, $start_pos, $site_url, $amp )
    {

		echo "<table width='100%'><tr>";

		$url = url_encode( $site_url."/display_profile_init.php", "showid", $this_id, "returnpoint", $return_point, "startpos", $start_pos );

        
        if (! low_res_screen())
        {
    		echo "<td width='8%'>";
    
        	echo "&nbsp;<a href='".$url."' class='glink'>".$handle."</a>";
    
    		echo "</td><td width='16%' align='center' valign='center'>";
        }
        else
            echo "<td>&nbsp;</td><td valign='center'>";
            

    	show_photo_info( $this_id, true, false, $photo_number, $file_extension, $aspect_ratio_large, $aspect_ratio_small, $version, $site_url, $amp );


		echo "</td>";

        if (! low_res_screen())
        {
            if ($show_sex_seeking)		
        		echo "<td width='30%'>";
        	else
                echo "<td width='52%'>";
        }
        else
        {
//            if ($show_sex_seeking)		
//        		echo "<td width='30%' valign='top'>";
//        	else
//                echo "<td width='52%' valign='top'>";

            echo "<td>&nbsp;</td><td width='52%' valign='top'>";
        }   

        if (low_res_screen())
    	    echo "<br><a href='".$url."' class='glink'>".$handle."</a><br><br>";

		echo show_introduction( $this_id, convert_to_html( $short_intro ), $return_point, $start_pos, $site_url );
		

        if (! low_res_screen() && $show_sex_seeking)		
        {
			echo "</td><td width='1%'></td>";
		
			echo "<td width='5%'>".black( "Age ".$age )."</td>";		
		
			echo "<td width='1%'></td>";		
		
			echo "<td width='5%'>".black( $sex )."</td>";				

			echo "<td width='1%'></td>";		
		
			echo "<td width='8%'>".black( "Looking for ".$sex_wanted )."</td>";				

			echo "<td width='1%'></td>";		
        }
    
    
//		if ($data[$i]['verified_members_only'] == "on")
//		    echo "<br><br><br>".darkgreen( "<i>Verified members only</i>" );
		    
		
		    // prevent the column being one word wide on mobiles
		    
        if (low_res_screen())
    		echo "<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;";


		if (! low_res_screen())
		{
    		echo "</td>";

	    	echo "<td width='2%'></td>";
		    
			echo "<td width='10%'>".black( name_case( $city ) )."</td>";
	
			echo "<td width='8%'>".black( $country )."</td>";

	    	echo "<td width='8%'>&nbsp;</td>";
		}
		else
		{
    		echo "</td>";

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

            if ($show_sex_seeking)
            {
    			echo "<td rowspan='10'>";

    			echo black( "Age ".$age )."<br><br>";
    
    			echo black( $sex )."<br><br>";
    
    			echo black( "Looking for ".$sex_wanted )."<br><br>";
            }	
            else
                echo "<td>";
                
            if ($city == "")
    			echo black( name_case( $country ) )."</td>";
    		else
	    		echo black( name_case( $city )."<br><br>".name_case( $country ) )."</td>";


			echo "</td></tr>";		
		}	
		
//		echo "</tr></table><hr>";
		echo "</tr></table>";
    }


	function show_introduction( $member_id, $text, $returnpoint, $startpos, $site_url )
	{
		if ($startpos == "")
			$startpos = "0";		// if missing default to start of list

		$url = url_encode( $site_url."/display_profile_init.php", "showid", $member_id, "returnpoint", $returnpoint, "startpos", $startpos );

		return ("<a href='".$url."' class='blacklink'>".$text."</a>");
	}
    
    
    function member_is_online( $member_id, $cxn )
    {
        $query = "SELECT id FROM online_status WHERE member_id = ".$member_id;
        
		$result = run_query( $query, $cxn );		
        
    	if (query_num_rows( $result ) > 0)
    	    return (true);
    	else
    	    return (false);   
    }



	function show_photo( $member_id, $photo_number, $allow_zoom, $large, $cxn, $amp=false, $height_override="" )
	{
	    
        if ($height_override != "")
            $height = $height_override;
        else
        if ($large)
            $height = large_photo_height;
        else
            $height = small_photo_height;


		if ($photo_number == -1)
			$query = "SELECT * FROM photos WHERE member_id = ".$member_id." AND primary_photo = 'yes'";
		else
			$query = "SELECT * FROM photos WHERE member_id = ".$member_id." AND photo_number = ".$photo_number;


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


		if (query_num_rows($result) == 0)
		{
            show_no_photo( $height );
		}
		else
		{
			$data = get_row( $result );
		    
            show_photo_info( $member_id, $allow_zoom, $large, $data['photo_number'], $data['file_extension'], $data['aspect_ratio_large'], $data['aspect_ratio_small'], $data['version'], "", $amp, $height_override );
		}
	}



	function show_photo_info( $member_id, $allow_zoom, $large, $photo_number, $file_extension, $aspect_ratio_large, $aspect_ratio_small, $version, $site_url="", $amp=false, $height_override="" )
	{
        if ($large)
        {
            if ($height_override != "")
            {
                $height = $height_override;
                
            	$width = $height * $aspect_ratio_large;
            }
            else
            if (! low_res_screen())            
            {
                $height = large_photo_height;
                
            	$width = $height * $aspect_ratio_large;
            }
            else
            {
                $width = val( $_SESSION, "screen_width" ) * 0.9;
                
                $height = $width / $aspect_ratio_large;
            }
        }
        else
        {
            if ($height_override != "")
            	$height = $height_override;
            else
                $height = small_photo_height;

			$width = $height * $aspect_ratio_small;
        }


        if ($photo_number == "")
		{
            show_no_photo( $height );
		}
		else
		{
			    // allow for revised versions of photos due to rotating them etc.
			    
			if ($version == "")
			    $version_str = "";
			else
			    $version_str = "_v".$version;

			if ($large)
				$filename = get_photos_url_pathroot( $member_id )."/photo_".$member_id."_".$photo_number."_l".$version_str.".".$file_extension;
			else
				$filename = get_photos_url_pathroot( $member_id )."/photo_".$member_id."_".$photo_number."_sm".$version_str.".".$file_extension;
				

                // in most cases $site_url should be ""

			if ($allow_zoom)
			{
				echo "<a href='".url_encode( $site_url."/show_large_photo.php", "showid", $member_id, "photonumber", $photo_number )."'>";
				
				if ($amp)
    				echo "<amp-img alt='Member Photo ".$member_id."' src='".url_encode_file( $site_url.$filename )."' width='".$width."' height='".$height."'></amp-img>";
    			else
    				echo "<img alt='Member Photo ".$member_id."' src='".url_encode_file( $site_url.$filename )."' width='".$width."' height='".$height."' border='0'>";
				
				echo "</a>";
			}
			else
			{
				if ($amp)
    				echo "<amp-img alt='Member Photo ".$member_id."' src='".url_encode_file( $site_url.$filename )."' width='".$width."' height='".$height."'></amp-img>";
    			else
	    			echo "<img alt='Member Photo ".$member_id."' src='".url_encode_file( $site_url.$filename )."' width='".$width."' height='".$height."'>";
			}
		}
	}



	function show_return_point( $returnpoint, $startpos, $show_id )
	{
		if ($returnpoint == "")
		{
		    log_error_and_continue( "return point missing in 'show_return_point'" );
		
		    $returnpoint = "main";
		}
		
	    
//		if ($show_id == "")
//		{
//			echo "<span class='gblack'>Internal Error: missing id in show_return_point</span>";
//			exit();
//		}

		if ($returnpoint == "inbox")
			echo show_link( "Inbox", "mailboxes.php", "box", "inbox" );
		else
		if ($returnpoint == "received")
			echo show_link( "Received messages", "mailboxes.php", "box", "received" );
		else
		if ($returnpoint == "sent")
			echo show_link( "Sent messages", "mailboxes.php", "box", "sent" );
		else
		if ($returnpoint == "blocked")
			echo show_link( "Blocked members", "mailboxes.php", "box", "blocked" );
		else
		if ($returnpoint == "remembered")
			echo show_link( "Remebered members", "mailboxes.php", "box", "remembered" );
		else
		if ($returnpoint == "contacts")
			echo show_link( "Contacts", "mailboxes.php", "box", "contacts" );
		else
		if ($returnpoint == "main")
			echo show_home_link();
		else
		if ($returnpoint == "search_jobs")
			echo show_link_encoded( "Back to Search", url_encode( "view_jobs.php", "startpos", $startpos )."#id".$show_id );
		else
		if ($returnpoint == "search_jobseekers")
			echo show_link_encoded( "Back to Search", url_encode( "view_jobseekers.php", "startpos", $startpos )."#id".$show_id );
		else
		{
			echo "<span class='gblack'>Internal Error: return point not recognised ".$returnpoint."</span>";
			exit();
		}
	}


		// don't put in the common library because there is a different tracking ID for each site
		
	function show_google_translate( $background="" )
    {
//        if (val( $_SESSION, "translate_showing" ) != "on")
//            show_gray_button( "Translate", 80, "/translate_on.php" );
//        else
//        {
//    		echo ' <div id="google_translate_element"></div><script type="text/javascript"> ';
//    		echo ' function googleTranslateElementInit() { ';
//    //		echo " new google.translate.TranslateElement({pageLanguage: 'en', layout: google.translate.TranslateElement.InlineLayout.SIMPLE, gaTrack: true, gaId: 'UA-97849346-1'}, 'google_translate_element'); ";		
//   		echo " new google.translate.TranslateElement({pageLanguage: 'en', gaTrack: true, gaId: 'UA-97849346-1'}, 'google_translate_element'); ";				
//    		echo ' } ';
//   		echo ' </script><script type="text/javascript" src="//translate.google.com/translate_a/element.js?cb=googleTranslateElementInit"></script> ';
//        }
    }



		/* send the email to the user allowing them to verify their email address */
		
		// NOTE: can't use SESSION variables here as this is called from a background process

	function send_advertiser_verification_email( $id, $email_verification_code, $queue_name, $cxn )
	{
		$first_name = "";
	
		$query = "SELECT username, contact_first_name FROM advertiser_profile WHERE id = ".$id;

		if (query_has_rows( $query, $cxn ))
		{
			$result = run_query( $query, $cxn );
			$data = get_row( $result );
			$first_name = $data['contact_first_name'];
		}

		$subject = "Verification email from ".sitename;

		$url = url_encode( full_site_url."/verify_advertiser_email.php", "verifyid", $id, "code", $email_verification_code );
		
		$text_body = "Hi ".$first_name.",\n\nThanks for joining ".sitename.".\n\nTo activate your account please copy and paste the following text into your browser address bar and press enter\n\n";
		$text_body .= $url;

		$text_body .= "If the link does not work when you click on it please copy and paste the following text into your browser address bar and press enter:<br><br>";
		
		$text_body .= $url;

		$text_body .= "\n\n\n\n";
		
		$text_body .= "If you have received this message in error please contact Site Administration at ".admin_email_address."\n\n\n";


		$html_body = "Hi ".$first_name.",<br><br>Thanks for joining ".sitename.".<br><br>";
		
		$html_body .= "To activate your account please click on the link below<br><br>";

		$html_body .= "<a href='".$url."'>activate account</a><br><br><br><br>";		
		
		$html_body .= "If the link does not work when you click on it please copy and paste the following text into your browser address bar and press enter<br><br>";
		
		$html_body .= $url;
		
		$html_body .= "<br><br><br><br>";
		
		$html_body .= "If you have received this message in error please contact Site Administration at ".admin_email_address."<br><br><br>";

		return (send_external_advertiser( $id, $subject, $text_body, $html_body, $cxn, $queue_name ));
	}



	function send_jobseeker_verification_email( $id, $email_verification_code, $queue_name, $cxn )
	{
		$first_name = "";
	
		$query = "SELECT username, first_name FROM jobseeker_profile WHERE id = ".$id;

		if (query_has_rows( $query, $cxn ))
		{
			$result = run_query( $query, $cxn );
			$data = get_row( $result );
			$first_name = $data['first_name'];
		}

		$subject = "Verification email from ".sitename;

		$url = url_encode( full_site_url."/verify_jobseeker_email.php", "verifyid", $id, "code", $email_verification_code );
		
		$text_body = "Hi ".$first_name.",\n\nThanks for joining ".sitename.".\n\nTo activate your account please copy and paste the following text into your browser address bar and press enter\n\n";
		$text_body .= $url;

		$text_body .= "If the link does not work when you click on it please copy and paste the following text into your browser address bar and press enter:<br><br>";
		
		$text_body .= $url;

		$text_body .= "\n\n\n\n";
		
		$text_body .= "If you have received this message in error please contact Site Administration at ".admin_email_address."\n\n\n";


		$html_body = "Hi ".$first_name.",<br><br>Thanks for joining ".sitename.".<br><br>";
		
		$html_body .= "To activate your account please click on the link below<br><br>";

		$html_body .= "<a href='".$url."'>activate account</a><br><br><br><br>";		
		
		$html_body .= "If the link does not work when you click on it please copy and paste the following text into your browser address bar and press enter<br><br>";
		
		$html_body .= $url;
		
		$html_body .= "<br><br><br><br>";
		
		$html_body .= "If you have received this message in error please contact Site Administration at ".admin_email_address."<br><br><br>";

		return (send_external_jobseeker( $id, $subject, $text_body, $html_body, $cxn, $queue_name ));
	}




	
		// select an image to show on the home page depedant on region
		
	function select_website_image( $cxn )
	{	
	    if (is_nordic_singles)
	    {
//            $image = "images/scandinavian_couple_expires_2023_(2).jpg";
			$image = "images/couple_freestock_24256453_compact.jpg";
			
    		return ($image);
	    }

        if (is_academic_dating)
        {
    		$ip_country = get_ip_country( $cxn );
    		$ip_country = str_replace( "'", "", $ip_country );
    
    		$query = "SELECT photo_type FROM ".common_data_database_name.".country WHERE ip_address_name = '".$ip_country."'";
    
    		$result = run_query( $query, $cxn );
    
    		if (query_num_rows( $result ) == 0)
    			$photo_type = "white";
    		else
    		{
    			$data = get_row( $result );
    			
    			$photo_type = $data['photo_type'];		
    		}
    
    		if ($photo_type == "arab")		// don't show arabic photos for security
    			$photo_type = "white";
    
    
//    		$photo_type = "african";
//    		$photo_type = "asian";

//			$photo_type = "white";
			
    
    		$random_photo_number = rand(0,100);
    
    
        	if ($photo_type == "african")		
    		{
    //			if ($random_photo_number <= 20)
    //				$image = "images/african_couple_1.jpg";
    //			else
    //			if ($random_photo_number <= 40)
    //				$image = "images/african_couple_2.jpg";
    //			else
    //			if ($random_photo_number <= 60)
    //				$image = "images/african_couple_3.jpg";
    //			else
    //			if ($random_photo_number <= 80)
    //				$image = "images/african_couple_4.jpg";
    //			else
    //				$image = "images/african_couple_5.jpg";
    //
    
    				$image = "images/african_couple_1b_compact.jpg";
    		}
    		else
    		if ($photo_type == "asian")
    		{
    //			if ($random_photo_number <= 20)
    //				$image = "images/asian_couple_1.jpg";
    //			else
    //			if ($random_photo_number <= 40)
    //				$image = "images/asian_couple_2.jpg";
    //			else
    //			if ($random_photo_number <= 60)
    //				$image = "images/asian_couple_3.jpg";
    //			else
    //			if ($random_photo_number <= 80)
    //				$image = "images/asian_couple_4.jpg";
    //			else
    //				$image = "images/asian_couple_5.jpg";
    
//    			$image = "images/asian_couple_2_compact.jpg";

    			$image = "images/freestock_10728631_asian_couple_compact.jpg";
    		}
    		else
    		if ($photo_type == "arab")
    		{
    			if ($random_photo_number <= 20)
    				$image = "images/arab_couple_dreamstime_xs_36959586.jpg";
    			else
    			if ($random_photo_number <= 40)
    				$image = "images/arab_couple_dreamstime_xs_63085331.jpg";
    			else
    			if ($random_photo_number <= 60)
    				$image = "images/arab_couple_dreamstime_xs_66060264.jpg";
    			else
    			if ($random_photo_number <= 80)
    				$image = "images/arab_couple_dreamstime_xs_71867492.jpg";
    			else
    				$image = "images/arab_couple_dreamstime_xs_80580750.jpg";
    		
    		}
    		else
    
    //		if ($photo_type == "white")
    
    		{
    		
    //			if ($random_photo_number <= 20)
    //				$image = "images/couple_freestock_36325414.jpg";
    //			else
    //			if ($random_photo_number <= 40)
    
    				$image = "images/couple_freestock_24256453_compact.jpg";
    				
    //			else
    //			if ($random_photo_number <= 60)
    //				$image = "images/couple_freestock_113104756.jpg";
    //			else
    //			if ($random_photo_number <= 80)
    
    //				$image = "images/couple_freestock_135667358.jpg";
    				
    //			else
    //				$image = "images/couple_freestock_75384427.jpg";
    
    //				$image = "images/couple_freestock_36325414.jpg";	
    				
    //				$image = "images/couple_freestock_113104756_sm.jpg";
    
    		}

    		return ($image);
	    }
	}



		// second image, for search screen
		
	function select_website_image2( $cxn )
	{	
		$ip_country = get_ip_country( $cxn );
		$ip_country = str_replace( "'", "", $ip_country );

		$query = "SELECT photo_type FROM ".common_data_database_name.".country WHERE ip_address_name = '".$ip_country."'";

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

		if (query_num_rows( $result ) == 0)
			$photo_type = "white";
		else
		{
			$data = get_row( $result );
			
			$photo_type = $data['photo_type'];		
		}

		if ($photo_type == "arab")		// don't show arabic photos for security
			$photo_type = "white";


//		$photo_type = "african";
		
						
		$random_photo_number = rand(0,100);
		

		if ($photo_type == "african")		
		{
//			if ($random_photo_number <= 20)
//				$image = "images/african_couple_1.jpg";
//			else
//			if ($random_photo_number <= 40)
//				$image = "images/african_couple_2.jpg";
//			else
//			if ($random_photo_number <= 60)
//				$image = "images/african_couple_3.jpg";
//			else
//			if ($random_photo_number <= 80)
//				$image = "images/african_couple_4.jpg";
//			else
//				$image = "images/african_couple_5.jpg";
//
				
			$image = "images/african_couple_2_sm.jpg";

//			$image = "images/african_couple_5_sm.jpg";
						
		}
		else
		if ($photo_type == "asian")
		{
//			if ($random_photo_number <= 20)
//				$image = "images/asian_couple_1.jpg";
//			else
//			if ($random_photo_number <= 40)
//				$image = "images/asian_couple_2.jpg";
//			else
//			if ($random_photo_number <= 60)
//				$image = "images/asian_couple_3.jpg";
//			else
//			if ($random_photo_number <= 80)
//				$image = "images/asian_couple_4.jpg";
//			else
//				$image = "images/asian_couple_5.jpg";

			$image = "images/asian_couple_3_sm.jpg";
		}
		else
		if ($photo_type == "arab")
		{
			if ($random_photo_number <= 20)
				$image = "images/arab_couple_dreamstime_xs_36959586.jpg";
			else
			if ($random_photo_number <= 40)
				$image = "images/arab_couple_dreamstime_xs_63085331.jpg";
			else
			if ($random_photo_number <= 60)
				$image = "images/arab_couple_dreamstime_xs_66060264.jpg";
			else
			if ($random_photo_number <= 80)
				$image = "images/arab_couple_dreamstime_xs_71867492.jpg";
			else
				$image = "images/arab_couple_dreamstime_xs_80580750.jpg";
		
		}
		else

//		if ($photo_type == "white")

		{
		
//			if ($random_photo_number <= 20)
//				$image = "images/couple_freestock_36325414.jpg";
//			else
//			if ($random_photo_number <= 40)
//				$image = "images/couple_freestock_24256453.jpg";
//			else
//			if ($random_photo_number <= 60)
//				$image = "images/couple_freestock_113104756.jpg";
//			else
//			if ($random_photo_number <= 80)
//				$image = "images/couple_freestock_135667358.jpg";
//			else
//				$image = "images/couple_freestock_75384427.jpg";


			$image = "images/couple_freestock_75384427_sm.jpg";

		}
		
		return ($image);
	}

	
		// Don't put this function in the common library because it's different for SSL and non SSL connections
		
		/* log into the database and return the connection */
		

	function db_login( $database )
	{
		$host = "localhost";
		$user = "academi1_mlm1";
		$password = "plastic1";


        $cxn = new mysqli( $host, $user, $password, $database );

		if ($cxn->connect_errno)
		{
			echo "<br><span style='font-size: 14pt; font-family: verdana'>".sitename." is currently unavailable.<br><br>Please try again in half an hour.<br><br></span>";
			
			echo "Error text: ".$cxn->connect_error."<br>";

			exit();
		}

		return $cxn;
	}


        // return the path to a photo file  
  
    function get_photos_pathroot( $member_id )
    {
        $tag = floor( $member_id / 2000 ) * 2000;
        
        if ($tag != 0 && $tag < 10000)
            $tag = "0".$tag;
            
        $photo_pathroot = pathroot.photos_pathroot."/photos_".$tag;
        
        if (! file_exists( $photo_pathroot ))
            mkdir( $photo_pathroot );
            
        return ($photo_pathroot);
    }



      // return the path to a photo file  
  
    function get_photos_url_pathroot( $member_id )
    {
        $tag = floor( $member_id / 2000 ) * 2000;

        if ($tag != 0 && $tag < 10000)
            $tag = "0".$tag;
        
        $photo_pathroot = photos_pathroot."/photos_".$tag;

        return ($photo_pathroot);
    }


        /* send an email to a member */

	function send_external_advertiser( $to_id, $subject, $text_body, $html_body, $cxn, $queue )
	{
		$from_name = sitename;
		$from_addr = email_sender_address;
		$reply_name = sitename;
		$reply_addr = email_sender_address;

		$query = "SELECT email_address FROM advertiser_profile WHERE id = ".$to_id;

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

		$data = get_row( $result );

		$to_addr = $data['email_address'];


		send_email( $from_name, $from_addr, $to_addr, $reply_name, $reply_addr, $subject, $text_body, $html_body, $cxn, $queue );

		return ($to_addr);
	}



        /* send an email to a member */

	function send_external_jobseeker( $to_id, $subject, $text_body, $html_body, $cxn, $queue )
	{
		$from_name = sitename;
		$from_addr = email_sender_address;
		$reply_name = sitename;
		$reply_addr = email_sender_address;

		$query = "SELECT email_address FROM jobseeker_profile WHERE id = ".$to_id;

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

		$data = get_row( $result );

		$to_addr = $data['email_address'];


		send_email( $from_name, $from_addr, $to_addr, $reply_name, $reply_addr, $subject, $text_body, $html_body, $cxn, $queue );

		return ($to_addr);
	}



        /* send an email to a member */

	function send_external_job( $to_id, $subject, $text_body, $html_body, $cxn, $queue )
	{
		$from_name = sitename;
		$from_addr = email_sender_address;
		$reply_name = sitename;
		$reply_addr = email_sender_address;

		$query = "SELECT email_address FROM job WHERE id = ".$to_id;

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

		$data = get_row( $result );

		$to_addr = $data['email_address'];


		send_email( $from_name, $from_addr, $to_addr, $reply_name, $reply_addr, $subject, $text_body, $html_body, $cxn, $queue );

		return ($to_addr);
	}



	function show_ads( $cxn )
	{
		show_ads_1_line();
	}


		// show 2 banner ads per page
		
	function show_double_ads( $cxn )
	{
		show_ads_1_line();
		
		echo "<br><br><br>";
		
		show_ads_1_line();
	}
	
	

	function show_ads_1_line()
	{
	    show_ads_large_banner();

//	    responsive_ad();
	}
	


	function first_name_or_handle( $data )
	{
		if (val( $data, 'first_name' ) != "")
			return ($data['first_name']);
		else
			return ($data['handle']);
	}


	function get_site_num_active_members( $cxn )
	{

		if (val( $_SESSION, "site_number_of_active_members" ) != "")
			$site_number_of_active_members = val( $_SESSION, "site_number_of_active_members" );
		else
		{

		    $today_date = date_create( date("Y-m-d") );

        	$today_minus_365_days = clone $today_date;

        	date_sub( $today_minus_365_days, date_interval_create_from_date_string( '365 days' ));
        	
	        $today_minus_365_days_str = $today_minus_365_days->format( "Y-m-d" );		

//			$data = get_first_row( "SELECT count(*) as num FROM profile WHERE deleted = 'no' and system_user = 'no' AND returned_mail = 'no' and last_login >= '".$today_minus_365_days_str."'", $cxn );


			$site_number_of_active_members = number_format( round($data['num'] /100)*100);
			

    		$_SESSION['site_number_of_active_members'] = $site_number_of_active_members;
		}
		
		return ($site_number_of_active_members);
	}



	function get_site_num_active_countries( $cxn )
	{
	    
		if (val( $_SESSION, "site_num_active_countries" ) != "")
			$site_num_active_countries = val( $_SESSION, "site_num_active_countries" );
		else
		{
	        $today_date = date_create( date("Y-m-d") );

        	$today_minus_365_days = clone $today_date;

        	date_sub( $today_minus_365_days, date_interval_create_from_date_string( '365 days' ));
        	
	        $today_minus_365_days_str = $today_minus_365_days->format( "Y-m-d" );		
		    
		    
//			$query = "SELECT count(*) as num FROM (SELECT DISTINCT country FROM profile WHERE deleted = 'no' and system_user = 'no' AND email_address_valid = 'yes' and returned_mail = 'no' and last_login >= '".$today_minus_365_days_str."') x";
//			$result = run_query( $query, $cxn );
//			$data = get_row( $result );
		
			$site_num_active_countries = $data['num'];
			

			$_SESSION['site_num_active_countries'] = $site_num_active_countries;
		}
	
		return ($site_num_active_countries);
	}




    function show_cyan_button( $text, $width, $url )
    {
            // large font sizes
            
        if (val( $_SESSION, "color_scheme" ) == 3)
        {
            $font_size = "16pt";
            $this_width = 1.2 * $width;
        }
        else
        {
            $font_size = "12pt";
            $this_width = $width;
        }
        
        echo "<td width='5%'>&nbsp;</td><td width=".$this_width."px align=center style='cursor: pointer; font-family: verdana; font-size: ".$font_size."; background: #008500; line-height: 45px; color: #ffffff' onclick=\"window.location.href='".$url."'\" >";
    
        echo $text;

        echo "</td><td></td>";
    }



    function show_cyan_space_line()
    {
        echo "<td width=160px align=center style='font-family: verdana; line-height: 22px;'>&nbsp;</td>";
    }




        // show the menu bar for the FAQ, Policies etc pages
        
	function show_info_menu( $cxn )
	{
		$bg = "#73b8bb";

        echo "<style>";
        echo "table.infomenubartable td {";
        echo "    color: #000000;";
//        echo "    line-height: 25pt;";
        echo "    font-size: ".fs( 13 ) ."pt;";
        echo "    font-family:verdana;";
        echo "    background-color: #73b8bb;";
        echo "}";
        
        echo "table.infomenubartable td:hover {";
//        echo "      color: #00a000;";
        echo "      background-color: #eeeeee;";
        echo "      cursor: pointer;";
        echo "}";        
        echo "</style>";

		echo "<table class='infomenubartable' width='100%' border='0' cellspacing='0'>";

		echo "<tr bgcolor='".$bg."' >";

		echo show_one_info_menu_item( "FAQ", "faq.php" );

		echo show_one_info_menu_item( "Policies", "policies.php" );		
		
//		echo show_one_info_menu_item( "Site News", "news.php" );		

		echo show_one_info_menu_item( "About Us", "about_us.php" );		

		echo show_one_info_menu_item( "Contact Us", "contact_us.php" );		

		echo "</tr>";

		echo "</table>";
	}


        // show one item on the information menu bar
        
	function show_one_info_menu_item( $prompt, $page )
	{
		return "<td height='40' style='background-color: #73b8bb' width='2%'></td><td width='10%' align='center' onclick='location.href=\"".url_encode( $page )."\"'>".$prompt."</td><td style='background-color: #73b8bb' width='2%'></td>";
	}


    function get_ip_country_from_country( $country, $cxn )
    {
		$query = "SELECT ip_address_name FROM ".common_data_database_name.".country WHERE display_name = '".$country."'";

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

		if (query_num_rows( $result ) > 0)
		{
			$data = get_row( $result );
			
			return ($data['ip_address_name']);
		}
			
        return ("");
    }



    function get_country_from_ip_country( $ip_country, $cxn )
    {
		$query = "SELECT display_name FROM ".common_data_database_name.".country WHERE ip_address_name = '".$ip_country."'";

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

		if (query_num_rows( $result ) > 0)
		{
			$data = get_row( $result );
			
			return ($data['display_name']);
		}

        return ("");
    }


		/* return true if the logged-in user is a system profile */

	function is_system_user( $member_id, $cxn )
	{
		if ($member_id == "")		// displaying profile from external page
			$is_system = false;
		else
		{
			$query = "SELECT id FROM jobseeker_profile WHERE id = ".$member_id." AND system_user = 'yes'";

			if (query_has_rows( $query, $cxn ))
				$is_system = true;
			else
				$is_system = false;
		}

		return ($is_system);
	}



    function show_members( $result, $return_point, $start_pos, $site_url, $amp )
    {
    	for ($i=0; $i < query_num_rows( $result ); $i++)
    	{
    	        
//    		if (($i % 8) == 7)
//    		{
//                echo "<br><br><br><br><table width='100%'><tr><td width='100%' align='center'>";
//                
//                if (! low_res_screen())
//                    echo show_ads( $cxn );
//                else
//                    echo show_ads_narrow_banner();
//                    
//                echo "</td></tr></table><br><br><br><br><hr>";
//    		}
  
    	    
    		$data = get_row( $result );
    			
    		$age = calc_person_age( $data['dob_dayofyear'], $data['dob_year'] );			
    			
    			
    		echo "<a name='id".$data['id']."'>";		/* bookmark to go back to search screen */

            member_display_one_line( $data['id'], true, $age, $data['handle'], $data['short_intro'], $data['sex'], $data['sex_wanted'], $data['city'], $data['country'], $data['photo_number'], $data['file_extension'], $data['aspect_ratio_large'], $data['aspect_ratio_small'], $data['version'], $return_point, $start_pos, $site_url, $amp );

            echo "<hr>";
    	}
    }




    function show_recent_members( $cxn, $return_point, $start_pos, $amp, $site_url, $the, $country )
    {
        if (is_subdomain())
        {
            $this_country = get_country_from_subdomain( $cxn );

            $the = get_heading_the( "", $cxn );

        	$query = "SELECT profile.*, photos.photo_number, photos.file_extension, photos.aspect_ratio_large, photos.aspect_ratio_small, photos.version, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile LEFT JOIN photos ON photos.member_id = profile.id WHERE (photos.primary_photo is NULL or photos.primary_photo = 'yes') and visibility = 'all_members' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' AND country = '".$this_country."' AND has_unchecked_photos = 'no' ORDER BY last_login DESC LIMIT 4";

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


            if (query_num_rows( $result ) > 0)
            {
                echo "<span class='redpgheading'>&nbsp;Members recently logged on in ".$the.$this_country."<br><br>";

                show_members( $result, $return_point, $start_pos, $site_url, $amp );
            }

            $num_remaining = 12 - query_num_rows( $result );

            $num_remaining = 12;

        	$query2 = "SELECT profile.*, photos.photo_number, photos.file_extension, photos.aspect_ratio_large, photos.aspect_ratio_small, photos.version, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile LEFT JOIN photos ON photos.member_id = profile.id WHERE (photos.primary_photo is NULL or photos.primary_photo = 'yes') and visibility = 'all_members' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' AND has_unchecked_photos = 'no' ORDER BY last_login DESC LIMIT ".$num_remaining;

        	$result2 = run_query( $query2, $cxn );


            if (query_num_rows( $result ) == 0)
                echo "<br><br><span class='redpgheading'>&nbsp;Members recently logged on<br><br>";
            else
                echo "<br><br><span class='redpgheading'>&nbsp;Members recently logged on, all countries<br><br>";


            show_members( $result2, $return_point, $start_pos, $site_url, $amp );
        }
        else
        {
            $process_country = false;

            if ($country != "")
            {
            	$today_date = date_create( date( "Y-m-d" ) );
            	
            	$today_minus_365_days = clone $today_date;
            
            	date_sub( $today_minus_365_days, date_interval_create_from_date_string( '365 days' ));
            	
            	$today_minus_365_days_str = $today_minus_365_days->format( "Y-m-d" );		
                
                
                $query2 = "SELECT count(*) as num from profile where country = '".$country."' and deleted = 'no' and system_user = 'no' and last_login > '".$today_minus_365_days_str."'";

            	$result2 = run_query( $query2, $cxn );

                if (query_num_rows( $result2 ) > 0)
                {
                    $data = get_row( $result2 );
                    
                    if ($data['num'] > 200)
                        $process_country = true;
                }

                if ($process_country)
                {
                    echo "<span class='redpgheading'>&nbsp;Members recently logged on in ".$the.$country."<br><br>";
        
        
                	$query_male = "SELECT profile.*, photos.photo_number, photos.file_extension, photos.aspect_ratio_large, photos.aspect_ratio_small, photos.version, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile LEFT JOIN photos ON photos.member_id = profile.id WHERE photos.primary_photo = 'yes' and visibility = 'all_members' AND sex = 'Male' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' AND returned_mail = 'no' and email_address_valid = 'yes' and has_unchecked_photos = 'no' and country = '".$country."' ORDER BY last_login DESC LIMIT 10";
        
                	$result_male = run_query( $query_male, $cxn );
                	
            
                	$query_female = "SELECT profile.*, photos.photo_number, photos.file_extension, photos.aspect_ratio_large, photos.aspect_ratio_small, photos.version, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile LEFT JOIN photos ON photos.member_id = profile.id WHERE photos.primary_photo = 'yes' and visibility = 'all_members' AND sex = 'Female' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' AND returned_mail = 'no' and email_address_valid = 'yes' AND has_unchecked_photos = 'no' and country = '".$country."' ORDER BY last_login DESC LIMIT 10";
        
                	$result_female = run_query( $query_female, $cxn );
        
                    
                    for ($i=0; $i < 6; $i++)
                    {
                        if ($i % 2 == 0)
                    		$data = get_row( $result_female );
                    	else
                            $data = get_row( $result_male );
                            
                        if ($data != NULL)
                        {
                            show_one_member_data( $data, $return_point, $start_pos, $site_url, $amp, $cxn );
    
                            echo "<hr>";

                            if (($i % 6 == 5) && (! low_res_screen()))
                            {
                            	echo "<br><br><br><br>";
                            	
                            	echo "<table width='100%'><tr><td width='20%'>&nbsp;</td><td width='80%' align='left'>";
                            	
                                show_ads( $cxn );
                                    
                                echo "</td></tr></table>";
                                
                        	    echo "<br><br><br><br><hr>";
                            }
                        }
                    }
    
                    echo "<br><br>";
                }
            }


            if ($process_country)
                echo "<span class='redpgheading'>&nbsp;Members recently logged on, all countries<br><br>";
            else
                echo "<span class='redpgheading'>&nbsp;Members recently logged in<br><br>";
                
            if ($process_country)
                $number_to_retrieve = 6;
            else
                $number_to_retrieve = 12;
                
        	$query_male = "SELECT profile.*, photos.photo_number, photos.file_extension, photos.aspect_ratio_large, photos.aspect_ratio_small, photos.version, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile LEFT JOIN photos ON photos.member_id = profile.id WHERE photos.primary_photo = 'yes' and visibility = 'all_members' AND sex = 'Male' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' AND returned_mail = 'no' and email_address_valid = 'yes' AND has_unchecked_photos = 'no' ORDER BY last_login DESC LIMIT ".$number_to_retrieve;

        	$result_male = run_query( $query_male, $cxn );
        	
    
        	$query_female = "SELECT profile.*, photos.photo_number, photos.file_extension, photos.aspect_ratio_large, photos.aspect_ratio_small, photos.version, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile LEFT JOIN photos ON photos.member_id = profile.id WHERE photos.primary_photo = 'yes' and visibility = 'all_members' AND sex = 'Female' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' AND returned_mail = 'no' and email_address_valid = 'yes' AND has_unchecked_photos = 'no' ORDER BY last_login DESC LIMIT ".$number_to_retrieve;

        	$result_female = run_query( $query_female, $cxn );

            
            for ($i=0; $i < $number_to_retrieve; $i++)
            {
                if ($i % 2 == 0)
            		$data = get_row( $result_female );
            	else
                    $data = get_row( $result_male );
                    
                if ($data != NULL)
                {
                    show_one_member_data( $data, $return_point, $start_pos, $site_url, $amp, $cxn );
                    
                    if ($i < $number_to_retrieve-1)        
                        echo "<hr>";
                        
                    if (($i % 6 == 5) && (! low_res_screen()) && $i != $number_to_retrieve-1)
                    {
                    	echo "<br><br><br><br>";
                    	
                    	echo "<table width='100%'><tr><td width='20%'>&nbsp;</td><td width='80%' align='left'>";

                        show_ads( $cxn );

                        echo "</td></tr></table>";
                        
                	    echo "<br><br><br><br><hr>";
                    }
                }                
            }
            
        }


    	echo "<hr><br><br>";
    	

//        if (! low_res_screen())
//        {
//        	echo "<br><br><br><br>";
//        	
//            echo show_ads( $cxn );
//
//    	    echo "<br><br><br><br>";
//        }

    }
  


    function show_one_member_data( $data, $return_point, $start_pos, $site_url, $amp, $cxn )
    {
		$age = calc_person_age( $data['dob_dayofyear'], $data['dob_year'] );			

        $url = "";
        
		echo "<a name='id".$data['id']."'>";		/* bookmark to go back to search screen */

        member_display_one_line( $data['id'], true, $age, $data['handle'], $data['short_intro'], $data['sex'], $data['sex_wanted'], $data['city'], $data['country'], $data['photo_number'], $data['file_extension'], $data['aspect_ratio_large'], $data['aspect_ratio_small'], $data['version'], $return_point, $start_pos, $site_url, $amp );
        
//        echo "<hr>";
    }

  
		/* show a handle on the screen */

	function show_handle( $member_id, $handle, $returnpoint, $startpos )
	{
		if ($startpos == "")
			$startpos = "0";		// if missing default to the start of the list

		$url = url_encode( "display_profile_init.php", "showid", $member_id, "returnpoint", $returnpoint, "startpos", $startpos );

		return ("<a class='glink' href='".$url."'>".$handle."</a>");		
	}
	

    function show_ads_large_banner_arj()
	{
	    show_ads_large_banner();
	    
//		echo black( "Advertisement" )."<br>";
//
//		echo "<script async src='//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>\n";
//
//		// <!-- New Ads 2 Wide Banner (ARJ) -->
//		
//		echo "<ins class='adsbygoogle'\n";
//     	echo "style='display:inline-block;width:728px;height:90px'\n";
//		echo "data-ad-client='ca-pub-7728790744816510'\n";
//		echo "data-ad-slot='7462963411'></ins>\n";
//		echo "<script>\n";
//		echo "(adsbygoogle = window.adsbygoogle || []).push({});\n";
//		echo "</script>\n";
	}
	


	function show_ads_medium_skyscraper_arj()
	{
	    show_ads_medium_skyscraper();
	    
//        echo black( "&nbsp;&nbsp;Advertisement<br>" );
//
//		echo "<script async src='//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js'></script>\n";
//		
//		// <!-- New Ads 2 Medium Skyscraper (ARJ) -->
//		
//		echo "<ins class='adsbygoogle'\n";
//		echo "     style='display:inline-block;width:160px;height:600px'\n";
//		echo "     data-ad-client='ca-pub-7728790744816510'\n";
//	    echo "     data-ad-slot='3666779518'></ins>\n";
//		echo "<script>\n";
//		echo "(adsbygoogle = window.adsbygoogle || []).push({});\n";
//		echo "</script>\n";
	}



    function main_menu( $id )
    {
        echo "<table>";

        echo "<tr><td class='mainmenuitem_heading'>Main</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/" )."\";'>";

        echo "Home</td></tr>";
        

    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/search_jobs.php" )."\";'>";

        echo "Search Jobs</td></tr>";


    	echo "<td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/search_jobseekers.php" )."\";'>";

        echo "Search Jobseekers</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/view_one_job.php" )."\";'>";

        echo "View a Job</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/view_one_jobseeker.php" )."\";'>";

        echo "View a Jobseeker</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/view_one_advertiser.php" )."\";'>";

        echo "View an Advertiser</td></tr>";



        echo "<tr><td style='font-size: 4pt'>&nbsp;</td></tr>";

        echo "<tr><td class='mainmenuitem_heading'>Jobseekers</td></tr>";

        
    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/edit_jobseeker_profile.php", "newprofile", "true" )."\";'>";

        echo "Create&nbsp;a&nbsp;Jobseeker&nbsp;Profile</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/display_jobseeker_profile.php", "showid", "-1", "returnpoint", "main" )."\";'>";

        echo "View&nbsp;My&nbsp;Jobseeker&nbsp;Profile</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/edit_jobseeker_profile.php", "newprofile", "false" )."\";'>";

        echo "Edit My Jobseeker Profile</td></tr>";


        echo "<tr><td style='font-size: 4pt'>&nbsp;</td></tr>";

        echo "<tr><td class='mainmenuitem_heading'>Advertisers</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/edit_job.php", "newjob", "true" )."\";'>";
    	
        echo "Post a Job</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/list_jobs.php" )."\";'>";
    	
        echo "List Jobs</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/edit_advertiser.php", "newadvertiserprofile", "true" )."\";'>";

        echo "Create&nbsp;an&nbsp;Advertiser&nbsp;Profile</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/edit_advertiser.php", "newadvertiserprofile", "false" )."\";'>";

        echo "Edit My Advertiser Profile</td></tr>";




        echo "<tr><td style='font-size: 4pt'>&nbsp;</td></tr>";

        echo "<tr><td class='mainmenuitem_heading'>Login</td></tr>";
        

            // login

    	echo "<td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/jobseeker_main_menu_login.php" )."\";'>";
        	
        echo "Jobseeker Login</td></tr>";

            
    	echo "<td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/advertiser_main_menu_login.php" )."\";'>";
        	
        echo "Advertiser Login</td></tr>";


            // logout

    	echo "<td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/session_kill.php" )."\";'>";
    	
        echo "Logout</td></tr>";



        echo "<tr><td style='font-size: 4pt'>&nbsp;</td></tr>";

        echo "<tr><td class='mainmenuitem_heading'>Information</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/faq.php" )."\";'>";
        	
    	echo "FAQ</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/policies.php" )."\";'>";
    	
    	echo "Policies</td></tr>";


//    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/news.php" )."\";'>";
//    	
//        echo "Site News</td></tr>";


    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/about_us.php" )."\";'>";
    	
    	echo "About Us</td></tr>";

    	
    	echo "<tr><td class='mainmenuitem' align='left' onclick='location.href=\"".url_encode( "/contact_us.php" )."\";'>";
    	
    	echo "Contact Us</td></tr>";


        echo "</table>";
    }


	function show_handle_black( $member_id, $handle, $returnpoint, $startpos )
	{
		if ($startpos == "")
			$startpos = "0";		// if missing default to the start of the list

		$url = url_encode( "display_profile_init.php", "showid", $member_id, "returnpoint", $returnpoint, "startpos", $startpos );

		return ("<a class='gblacklink' href='".$url."'>".$handle."</a>");		
	}
	

?>