<?php

    define( "online_status_filename", "/home/academi1/m-m-ventures.com/academicdating/online_status/online_status.txt" );

	include "library.php";

	$cxn = start_code( true );

	$cxn_common = db_common_login();



	$_SESSION['sitename'] = 'Chat City';

    $id = val( $_SESSION, 'id' );
    
    


		// NOTES: for country entry points to the site go to 'splash_country.php' and 'country' subfolder
		
		// Don't change the URL of the home page such as by adding new parameters to it, as Adsense and Adwords will have indexed the current URL only
		
		
		// do this before the screen size redirect because internal-jump will be set to true
		
	if (val( $_GET, "internaljump" ) != "true")
	{
//		$source = val( $_GET, "source" ).".".val( $_GET, "ad" );

		$source = val( $_GET, "source" );

		if ($source == "")
			$source = "organic";

		$_SESSION['source'] = $source;

		log_hits( $source, $cxn, $cxn_common );
	}
	else
	{
		$source = val( $_SESSION, 'source' );
			
		if ($source == "")
			$source = "organic";

		$_SESSION['source'] = $source;
	}


		// relaod this page after setting the 'screen_width' and 'screen_height' values using javascript
		// only execute this reload once per entire session
		
	if (val( $_GET, "screen_width" ) == "" && val( $_SESSION, "screen_width" ) == "")
	{
		echo "<script language='JavaScript'> document.location=\"index.php?internaljump=true&screen_width=\"+screen.width+\"&screen_height=\"+screen.height; </script>";
		
			// exit immediately to avoid the browser delay of loading the entire page.
		exit();
	}


//    if (val( $_SERVER, "HTTPS" ) == "on")
//	{
//	    jump_to_page( url_encode( "http://chatcity1.net/index.php", "internaljump", "true" ) );		/* must happen before print output */
//
//		exit();
//	}


	if (val( $_GET, "screen_width" ) != "" && val( $_SESSION, "screen_width" ) == "")
	{
		log_screen_size( $_GET['screen_width'], $_GET['screen_height'], $cxn );

		$_SESSION['screen_width'] = $_GET['screen_width'];
		$_SESSION['screen_height'] = $_GET['screen_height'];		
	}


	if (val( $_GET, "noncharging" ) == "true")
		$_SESSION['non_charging_override'] = true;

	$_SESSION['availableoverride'] = val( $_GET, 'availableoverride' );

	$_SESSION['validation_error'] = "false";
	$_SESSION['validation_errors'] = "";

	$_SESSION['session_active'] = "yes";


	page_header( "", $cxn, $cxn_common, "", true, true );


//    echo black( "<br>This website is not yet active.<br>" );
//    exit();


	$domain = $_SESSION['domain'];

	$ip_country = get_ip_country( $cxn_common );
	$ip_country = str_replace( "'", "", $ip_country );
	$country = rawurlencode( $ip_country );

	$site_num_active_members = get_site_num_active_members( $cxn );


	if (! low_res_screen())	
	    desktop_display( $site_num_active_members, $ip_country, $country, $cxn, $cxn_common );
	else
	    mobile_display( $site_num_active_members, $ip_country, $country, $cxn, $cxn_common );
	
	    
	    
    show_members_online( $id, $cxn );
	    

    
        // full format of the home page for a desktop
        
    function desktop_display( $site_num_active_members, $ip_country, $country, $cxn, $cxn_common )
    {
        
		echo "<style> html, body {";
		echo "margin:0;";
		echo "padding:0;";
		echo "}";
		echo "</style>";

    	$site_num_active_countries = get_site_num_active_countries( $cxn );


        $menu_text_color = "#0000bb";
        $menu_background_color = "#eeeeee";
        $menu_highlight_color = "#cccccc";
        
		show_dropdown_styles( $menu_text_color, $menu_background_color, $menu_highlight_color );

            // #004499
            
		echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td style='line-height: 45px; font-family: Calibri; font-size: 20pt; color: #ffffff; opacity: 1; background-color: darkgreen' align='center'>Chat City</td></tr></table>";

		
        echo "<table width='100%' style='border-collapse: collapse;'><tr>";

        show_main_menu_bar( $country, $menu_background_color );

		echo "</tr></table>";
		
		
			// don't show translate button for all members because it slows down the page load and causes a page re-format
			
		if (val( $_SESSION, 'show_language_translation' ) == "on" && (! low_res_screen()))	
		{
			echo "<table width='100%'><tr><td width='80%'>&nbsp;</td>";
			
			show_google_translate();
			
			echo "</tr></table>";
		}

		echo "<table width='100%' cellpadding='3' cellspacing='3'><td width='10%'></td><td align='left' width='20%'>";

		echo "<br><br>";

		show_image( select_website_image( $cxn, $cxn_common ), 125 );

		echo "</td>";

		echo "<td width='35%' align='center' valign='middle'>";

		echo "<br>";


		echo blue( "Chat City is an international chatting site." );

//		echo blue( "Chat City is an international chatting site.<br><br>The site is suitable for all ages." );

//		echo blue( "Chat City is an international frienship and chatting site with ".$site_num_active_members." members from ".$site_num_active_countries." countries" );

		echo "</td>";
	
		echo "<td width='20%' align='center' valign='top'>";
	
		echo "</td><td width='10%' rowspan='20' valign='top'>";
		
		echo "<br>";
		
//		show_ads_medium_skyscraper();

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


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

//    	echo "<tr><td></td><td colspan='3'>".blue( "Welcome to Chat City. The site host members from all around the world." )."</td><td></td><td></td></tr>";

    	echo "<tr><td></td><td colspan='3'>".blue( "Welcome to Chat City." )."</td><td></td><td></td></tr>";

    	echo "<tr><td></td><td colspan='3'>".blue( "Join the site and search for members who are online and available for chat, or send email alerts to members who you would like to contact." )."</td><td></td><td></td></tr>";
    	


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

        echo "<tr><td></td><td colspan='3'>";
        
        show_ads( $cxn );
        
        echo "</td><td></td><td></td></tr>";

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

        echo "</table>";        

    	echo "<br><br><br><br>";
	}




        // full format of the home page for a mobile phone

    function mobile_display( $site_num_active_members, $ip_country, $country, $cxn, $cxn_common )
    {
		echo "<style> html, body {";
		echo "margin:0;";
		echo "padding:0;";
		echo "}";
		echo "</style>";

		echo "<table cellspacing='0' width='100%'><tr><td style='padding-top: 3; padding-bottom: 3; font-family: Calibri; font-size: 13pt; color: #ffffff; background-color: #004499' valign='middle' align='center'>Chat City</td></tr></table>";


		if (val( $_SESSION, 'show_language_translation' ) == "on")	
		{
			echo "<table width='100%'><tr><td width='80%'>&nbsp;</td>";
			
			show_google_translate();
			
			echo "</tr></table>";
		}
		
		
			// 30% each side and 40% in the middle, centered
			
		echo "<table width='100%'><td width='5%' align='center' valign='top'></td><td align='left' width='17%'>";
		
		if (val( $_SESSION, 'show_language_translation' ) != "on")	            
		    echo "<br>";
		    
        echo "<img alt='Couple Photo' src='".select_website_image( $cxn, $cxn_common )."' height='130'></td>";            
        
		echo "<td width='20%' align='center' valign='top'></span>";		
		
		echo "<br><br><br><br><br>";

		echo "</td>";
	
		echo "<td width='3%'></td><td width='18%' align='center' valign='center'>";

//		echo "<span class='gblue'><br>Chat City is an international friendship and chatting site ".$site_num_active_members." members</span><br><br>";
	
		echo "<span class='gblue'><br>Chat City is an international chatting site.</span><br><br>";

		echo "</td><td width='5%'></tr></table>";
    		
    	echo "<br>";
    	
        show_mobile_home_page_buttons();

        echo "<br><br>";

	    echo "<table width='100%'><tr><td align='center'>";
	    
		show_ads_large_square();
		
		echo "</td></td></table>";

    	echo "<br><br><br><br>";
    }
    
    

        // write the CSS styles for the drop-down menus
        
    function show_dropdown_styles( $menu_text_color, $menu_background_color, $menu_highlight_color)
    {
        echo "<style>";
        
		$color_scheme = val( $_SESSION, 'color_scheme' );

                                    // black background, pink italics
                                    
		if ($color_scheme == 2 || $color_scheme == 1) 
		{
		    $fs = fs( 11 );
		    $fs2 = fs( 11 );		    
		}
		else
		{
		    $fs = fs( 14 );
		    $fs2 = fs( 13 );		    
		}

                                    //pink italics
		if ($color_scheme == 1)
            $menu_text_color = "#FF69B4";		


        echo ".mainmenuitem {";
        echo "    background-color: ".$menu_background_color.";";
        echo "    padding: 13px;";
		echo "    font-size: ".$fs."pt; ";
        echo "    border: none;";
        echo "    cursor: pointer;";
        echo "  color: ".$menu_text_color.";";        
		echo "  font-family:verdana; ";
        echo "  text-decoration:none;";
//		echo "  border-bottom: solid ".$menu_background_color." 2px;";        
        echo "}";

        echo ".mainmenuitem_red {";
        echo "    background-color: ".$menu_background_color.";";
        echo "    padding: 13px;";
		echo "    font-size: ".$fs."pt; ";
        echo "    border: none;";
        echo "    cursor: pointer;";
        echo "  color: #dd0000;";        
		echo "  font-family:verdana; ";
        echo "  text-decoration:none;";
//		echo "  border-bottom: solid ".$menu_background_color." 2px;";        
        echo "}";
        
		echo ".mainmenuitem:hover {";
        echo "  color: ".$menu_text_color.";";
		echo "  background-color: ".$menu_highlight_color."; ";
		echo "  font-size: ".$fs."pt; ";
		echo "  font-family:verdana; ";
		echo "  text-decoration:none;";
//		echo "  border-bottom: solid #0000bb 2px;";
        echo " }";

		echo ".mainmenuitem_red:hover {";
        echo "  color: #dd0000;";
		echo "  background-color: ".$menu_highlight_color."; ";
		echo "  font-size: ".$fs."pt; ";
		echo "  font-family:verdana; ";
		echo "  text-decoration:none;";
//		echo "  border-bottom: solid #dd0000 2px;";
        echo " }";
				
        echo ".dropdown {";
        echo "    position: relative;";
        echo "    display: inline-block;";
        echo "}";
        
        echo ".dropdown-content {";
        echo "    display: none;";
        echo "    position: absolute;";
        echo "    font-size: ".$fs2."pt;";
		echo "    font-family:verdana; ";
        echo "    color: ".$menu_text_color.";";

        echo "    background-color: ".$menu_background_color.";";
        echo "    min-width: 180px;";
        echo "    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);";
        echo "    z-index: 1;";
        echo "}";
        
        echo ".dropdown-content a {";
        echo "    color: ".$menu_text_color.";";
        echo "    padding: 12px 16px;";
        echo "    text-decoration: none;";
        echo "    display: block;";
        echo "}";
        
        echo ".dropdown-content a:hover {background-color: ".$menu_highlight_color.";";
        echo " }";
        
        echo ".dropdown:hover .dropdown-content {";
        echo "    display: block;";
        echo "}";
        
        echo ".dropdown:hover .mainmenuitem {";
        echo "    background-color: ".$menu_highlight_color.";";
        echo "}";
    
        echo "</style>";
    }



		// show the main menu bar
		
	function show_main_menu_bar( $country, $menu_background_color )
	{

		$color_scheme = val( $_SESSION, 'color_scheme' );
		
		$fs = fs( 15 );

		if ($color_scheme == "" || $color_scheme == 0 || $color_scheme == 3)
		    $height = "44";
		else
		    $height = "56";
		    
		    
            // join the site
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID3' style='background-color: ".$menu_background_color."' onclick='location.href=\"".url_encode( "edit_profile.php", "newprofile", "true" )."\";'>";
    	
        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Join the Site</button>";
        echo "</div>";
    
        echo "</td>";



            // Profiles
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID2' style='background-color: ".$menu_background_color."'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Profiles</button>";
        echo "<div class='dropdown-content'>";
        
        echo "<a href='".url_encode( "edit_profile.php", "newprofile", "false" )."'>Edit My Profile</a>";
        echo "<a href='".url_encode( "view_one_profile.php" )."'>View a Profile</a>";
        echo "<a href='".url_encode( "display_profile.php", "showid", "-1", "returnpoint", "main" )."'>View My Profile</a>";
        
        echo "</div>";
        echo "</div>";
    
        echo "</td>";


            // Search
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID3' style='background-color: ".$menu_background_color."' onclick='location.href=\"".url_encode( "search_profiles.php" )."\";'>";
    	
        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Search</button>";
        echo "</div>";
    
        echo "</td>";


            // Messages
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID4' style='background-color: ".$menu_background_color."'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Messages</button>";
        echo "<div class='dropdown-content'>";
        
        echo "<a href='".url_encode( "mailboxes.php", "box", "inbox" )."'>Inbox</a>";        
        echo "<a href='".url_encode( "mailboxes.php", "box", "sent" )."'>Sent</a>";        
        echo "<a href='".url_encode( "mailboxes.php", "box", "received" )."'>Received</a>";        
        echo "<a href='".url_encode( "mailboxes.php", "box", "contacts" )."'>Contacts</a>";        
        echo "<a href='".url_encode( "mailboxes.php", "box", "remembered" )."'>Remembered</a>";        
        echo "<a href='".url_encode( "mailboxes.php", "box", "blocked" )."'>Blocked</a>";        
        echo "<a href='".url_encode( "mailboxes.php", "box", "chat_history" )."'>Chat History</a>";        

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


            // Photos
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID5' style='background-color: ".$menu_background_color."' onclick='location.href=\"".url_encode( "manage_photos.php" )."\";'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Photos</button>";
        echo "</div>";
    
        echo "</td>";


            // Other
            
//    	echo "<td width='10%' height='".$height."pt' align='center' id='ID6' style='background-color: ".$menu_background_color."'>";
//
//        echo "<div class='dropdown'>";
//        echo "<button class='mainmenuitem'>Other</button>";
//        echo "<div class='dropdown-content'>";
//        
//        echo "<a href='".url_encode( "latest_100.php" )."'>Latest 100 Members</a>";        
//        echo "<a href='".url_encode( "members_online_now.php" )."'>Members Online Now</a>";        
//        echo "<a href='".url_encode( "main_menu_login.php" )."'>Login</a>";        
//        echo "<a href='".url_encode( "session_kill.php" )."'>Logout</a>";        
//
//        echo "</div>";
//        echo "</div>";
//    
//        echo "</td>";
        

            // Information
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID7' style='background-color: ".$menu_background_color."'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Information</button>";
        echo "<div class='dropdown-content'>";

        echo "<a href='".url_encode( "faq.php" )."'>FAQ</a>";        
        echo "<a href='".url_encode( "policies.php" )."'>Policies</a>";
//        echo "<a href='".url_encode( "charges.php" )."'>Membership costs</a>";
        echo "<a href='".url_encode( "about_us.php" )."'>About Us</a>";        
        echo "<a href='".url_encode( "contact_us.php" )."'>Contact Us</a>";        

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



    	echo "<td width='10%' height='".$height."pt' align='center' id='ID5' style='background-color: ".$menu_background_color."'>&nbsp;";
        echo "</td>";
        

            // Login
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID5' style='background-color: ".$menu_background_color."' onclick='location.href=\"".url_encode( "main_menu_login.php" )."\";'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Login</button>";
        echo "</div>";
    
        echo "</td>";


            // Logout
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID5' style='background-color: ".$menu_background_color."' onclick='location.href=\"".url_encode( "session_kill.php" )."\";'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Logout</button>";
        echo "</div>";
    
        echo "</td>";
        
	}



    function show_mobile_home_page_buttons()
    {
        echo "<table width='100%' cellpadding='0' cellspacing='0' style='border-collapse: collapse'>";
    
        echo "<tr>";
    
        echo "<td width='3%'></td>";
        
    	echo "<td width='30%' align='center'>";


    	show_green_button3( "Join the site", 112, "edit_profile.php", "newprofile", "true" );

    	echo "</td><td width='30%' align='center'>";

    	show_green_button3( "Search", 112, "search_profiles.php" );
    	
    	echo "</td><td width='30%' align='center'>";

    	show_green_button3( "Profiles", 112, "show_mobile_menus.php",  "menu", "profiles" );
    	
    	echo "</td>";
    	
        echo "<td width='5%'></td>";
    	
    	echo "</tr>";

    	echo "<tr>";

        echo "<td width='3%'></td>";
    	
    	echo "<td width='30%' align='center'>";
    	
    	show_green_button3( "Messages", 112, "show_mobile_menus.php",  "menu", "messages" );
    	
    	echo "</td><td width='30%' align='center'>";
    	
    	show_green_button3( "Photos", 112, "manage_photos.php" );
    	
    	echo "</td><td width='30%' align='center'>";
    	
    	show_green_button3( "Other", 112, "show_mobile_menus.php",  "menu", "other" );
    	
    	echo "</td>";

        echo "<td width='3%'></td>";
    	
    	echo "</tr>";
    	
    	echo "<tr>";
    	
        echo "<td width='2%'></td>";
    	
    	echo "<td width='31%' align='center'>";

    	show_green_button3_bottom( "", 112, "",  "", "" );
    	
    	echo "</td><td width='30%' align='center'>";

    	show_green_button3_bottom( "Information", 112, "show_mobile_menus.php",  "menu", "information" );

    	echo "</td>";

    	echo "</td><td width='30%' align='center'>";
    	
    	show_green_button3_bottom( "", 112, "",  "", "" );

    	echo "</td>";

        echo "<td width='3%'></td>";
    	
    	echo "</tr>";
    	
    	echo "</table>";
    }


    function show_members_online_ad( $id, $cxn )
    {
        
        $found_one = false;
        
        $in_clause = "";

        if (file_exists( online_status_filename ))
        {
            $fp = fopen( online_status_filename, "r" );   
            
            $i = 0;
                
            while (! feof( $fp ) && $i < 1000)
            {
                 $data1 = fscanf( $fp, "%s %s %s %s %s %s\n" );
            
                 if ($data1[0] != "-1" && $data1[0] != "")
                 {
                    $found_one = true;
    
                    if ($id == "" || $id != $data1[0])
                    {
                        if ($in_clause == "")
                            $in_clause = $data1[0];
                        else
                            $in_clause .= ", ".$data1[0];
                    }
                }
            }
        }
        
    	echo blue( "&nbsp;&nbsp;Members Online on our Sister Site, Academic Dating<br><br>" );		

    
        if ($in_clause == "")
        {
    		if ($id != "")
    			echo "<br>&nbsp;&nbsp;There are no other members online at the moment.<br>";
    		else
    			echo "<br>&nbsp;&nbsp;There are no members online at the moment.<br>";
    			
    		exit();
        }
        else
        {
    		$query = "SELECT id, handle, short_intro, sex, sex_wanted, city, country, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM academi1_academicdating.profile WHERE visibility = 'all_members' AND deleted = 'no' AND locked  = 'no' AND system_user = 'no' and profile.id in ( ".$in_clause." ) ORDER BY last_login DESC";

        	$heading = "Members Online Now";		
        
        	$result = run_query( $query, $cxn );
        
        	
        	if (query_num_rows( $result ) == 0)
        	{
        		if ($id != "")
        			echo "<br>&nbsp;&nbsp;There are no other members online at the moment.<br>";
        		else
        			echo "<br>&nbsp;&nbsp;There are no members online at the moment.<br>";
        			
        		exit();
        	}
        //	else
        //		echo "<hr>";
        
        		
        	for ($i=0; $i < query_num_rows( $result ); $i++)
        	{
        		$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 */
        
        
        		echo "<table width='100%'><tr>";
        
        		echo "<td width='7%'>";
        
        		echo show_handle_ad( $data['id'], $data['handle'], "search", 0 );

        		echo "</td><td width='16%' align='center'>";
        
        		show_photo_ad( $data['id'], 100, -1, true, false, $cxn );
        
        		echo "</td>";
        
        		if (! low_res_screen())
        		{
            		echo "<td width='33%'>".show_introduction( $data['id'], convert_to_html( $data['short_intro'] ), "main", "0" )."</td>";
        
        			echo "<td width='1%'></td>";
        		
        			echo "<td width='5%'>".black( "Age ".$age )."</td>";		
        		
        			echo "<td width='1%'></td>";		
        		
        			echo "<td width='5%'>".black( $data['sex'] )."</td>";				
        
        			echo "<td width='1%'></td>";		
        		
//        			echo "<td width='12%'>".black( "Looking for ".$data['sex_wanted'] )."</td>";				
//        
//        			echo "<td width='1%'></td>";		
        				
        			echo "<td width='8%'>".black( name_case( $data['city'] ) )."</td>";
        
        			echo "<td width='16%'>".black( $data['country'] )."</td>";
        
        			echo "<td width='2%'></td>";	
        		}
        		else
        		{
        			echo "<td width='10%'>".black( name_case( $data['city'] )."<br><br>".name_case( $data['country'] ) )."</td>";		
        		}
        		
        		echo "</tr></table>";
        		
        		if (low_res_screen())
        		{
            		echo "<table width='100%'><tr><td width='50%'>".show_introduction( $data['id'], convert_to_html( $data['short_intro'] ), "main", "0" )."</td>";
        
        			echo "<td width='1%'></td>";
        		
        			echo "<td width='5%'>".black( "Age ".$age )."</td>";		
        		
        			echo "<td width='1%'></td>";		
        		
        			echo "<td width='5%'>".black( $data['sex'] )."</td>";				
        
        			echo "<td width='1%'></td>";		
        		
//        			echo "<td width='12%'>".black( "Looking for ".$data['sex_wanted'] )."</td>";				
//        
//        			echo "<td width='1%'></td>";		
        		
        			
        			echo "</tr></table>";
        		}
        		
        				
        		echo "<hr>";
        	}
    
        
        	if (! low_res_screen())
        	{
        		echo "<br><br><br><br><br><br>";
        		
        		show_double_ads( $cxn );
        		
        		    // space to prevent the ads being squashed against the bottom of the page
        		echo "<br><br><br><br><br><br>";		
        	}
        	else
        	{
        		echo "<br><br><br><br>";
        		
        		show_ads_large_square();	
        
        		    // space to prevent the ads being squashed against the bottom of the page
        //		show_ads_narrow_banner();
        		
        		echo "<br><br><br><br><br><br>";		
        	}
        }
    }
    
    
    
    function show_members_online( $id, $cxn )
    {
    	if ($id != "")
    		$query = "SELECT id, handle, short_intro, sex, sex_wanted, city, country, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile WHERE deleted = 'no' AND locked  = 'no' AND system_user = 'no' and profile.id in (SELECT member_id FROM online_status WHERE member_id <> ".$id.") ORDER BY last_login DESC";
    	else
    		$query = "SELECT id, handle, short_intro, sex, sex_wanted, city, country, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile WHERE deleted = 'no' AND locked  = 'no' AND system_user = 'no' and profile.id in (SELECT member_id FROM online_status) ORDER BY last_login DESC";

    		$query = "SELECT id, handle, short_intro, sex, sex_wanted, city, country, dayofyear(profile.date_of_birth) as dob_dayofyear, year(profile.date_of_birth) as dob_year FROM profile WHERE deleted = 'no' AND locked  = 'no' AND profile.id in (SELECT member_id FROM online_status) ORDER BY last_login DESC";
    	
    	
    	$result = run_query( $query, $cxn );


    	if (query_num_rows( $result ) == 0)
    	{
    		if ($id != "")
    			echo "<br>There are no other members online at the moment.<br>";
    		else
    			echo "<br>There are no members online at the moment.<br>";
    			
    		exit();
    	}
    	else
			echo green( "<br>&nbspMembers online now<br>" );
        	
    		
    	for ($i=0; $i < query_num_rows( $result ); $i++)
    	{
    		$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 */
    
    
    		echo "<table width='100%'><tr>";
    
    		echo "<td width='7%'>";
    
            $start_pos = 0;
    
    		echo show_handle( $data['id'], $data['handle'], "search", $start_pos );
    
    //		if ($data[$i]['logged_in'] != "")
    //			echo "<br><br>".watermark( "online now" );
    
    		echo "</td><td width='16%' align='center'>";
    
    		show_photo( $data['id'], 100, -1, true, false, $cxn );
    
    		echo "</td>";
    
    		if (! low_res_screen())
    		{
        		echo "<td width='33%'>".show_introduction( $data['id'], convert_to_html( $data['short_intro'] ), "main", "0" )."</td>";
    
    			echo "<td width='1%'></td>";
    		
    			echo "<td width='5%'>".black( "Age ".$age )."</td>";		
    		
    			echo "<td width='1%'></td>";		
    		
    			echo "<td width='5%'>".black( $data['sex'] )."</td>";				
    
    			echo "<td width='1%'></td>";		
    		
    			echo "<td width='12%'>".black( "Looking for ".$data['sex_wanted'] )."</td>";				
    
    			echo "<td width='1%'></td>";		
    				
    			echo "<td width='8%'>".black( name_case( $data['city'] ) )."</td>";
    
    			echo "<td width='16%'>".black( $data['country'] )."</td>";
    
    			echo "<td width='2%'></td>";	
    		}
    		else
    		{
    			echo "<td width='10%'>".black( name_case( $data['city'] )."<br><br>".name_case( $data['country'] ) )."</td>";		
    		}
    		
    		echo "</tr></table>";
    		
    		if (low_res_screen())
    		{
        		echo "<table width='100%'><tr><td width='50%'>".show_introduction( $data['id'], convert_to_html( $data['short_intro'] ), "main", "0" )."</td>";
    
    			echo "<td width='1%'></td>";
    		
    			echo "<td width='5%'>".black( "Age ".$age )."</td>";		
    		
    			echo "<td width='1%'></td>";		
    		
    			echo "<td width='5%'>".black( $data['sex'] )."</td>";				
    
    			echo "<td width='1%'></td>";		
    		
    			echo "<td width='12%'>".black( "Looking for ".$data['sex_wanted'] )."</td>";				
    
    			echo "<td width='1%'></td>";		
    		
    			
    			echo "</tr></table>";
    		}
    		
    				
    		echo "<hr>";
    	}
    
    
    	
    	if (! low_res_screen())
    	{
    		echo "<br><br><br><br><br><br>";
    		
    		show_double_ads( $cxn );
    		
    		    // space to prevent the ads being squashed against the bottom of the page
    		echo "<br><br><br><br><br><br>";		
    	}
    	else
    	{
    		echo "<br><br><br><br>";
    		
    		show_ads_large_square();	
    
    		    // space to prevent the ads being squashed against the bottom of the page
    //		show_ads_narrow_banner();
    		
    		echo "<br><br><br><br><br><br>";		
    	}
    }

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

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

		return ("<a href='".$url."' style='text-decoration: none;'><span class='gblack'>".$text."</span></a>");
	}
	


		/* show a handle on the screen */

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

		$url = url_encode( "https://academicdating.net/display_profile.php", "showid", $member_id, "returnpoint", $returnpoint, "startpos", $startpos );

		return ("<a class='glink' href='".$url."'>".$handle."</a>");		
	}
    
    
	function show_introduction_ad( $member_id, $text, $returnpoint, $startpos )
	{
		if ($startpos == "")
			$startpos = "0";		// if missing default to start of list

		$url = url_encode( "https://academicdating.net/display_profile.php", "showid", $member_id, "returnpoint", $returnpoint, "startpos", $startpos );

		return ("<a href='".$url."' style='text-decoration: none;'><span class='gblack'>".$text."</span></a>");
	}


        // tab style buttons for mobile screen buttons
        
	function show_green_button3( $text, $size, $page="", $param1="", $value1="", $param2="", $value2="", $param3="", $value3="", $param4="", $value4="", $param5="", $value5=""  )
	{
		$url = url_encode( $page, $param1, $value1, $param2, $value2, $param3, $value3, $param4, $value4, $param5, $value5 );

		echo "<div onclick=\"window.location.href='".$url."'\" class='greenbuttonmobile3' style='line-height: 45px; width:100%;' >".$text."</div> ";			
	}


	function show_red_button3( $text, $size, $page="", $param1="", $value1="", $param2="", $value2="", $param3="", $value3="", $param4="", $value4="", $param5="", $value5=""  )
	{
		$url = url_encode( $page, $param1, $value1, $param2, $value2, $param3, $value3, $param4, $value4, $param5, $value5 );

		echo "<div onclick=\"window.location.href='".$url."'\" class='redbuttonmobile3' style='line-height: 45px; width:100%;' >".$text."</div> ";			
	}


        // different style to sub-menu tabs
        
    function show_green_button3_bottom( $text, $size, $page="", $param1="", $value1="", $param2="", $value2="", $param3="", $value3="", $param4="", $value4="", $param5="", $value5=""  )
	{
	    if ($page != "")
	    {
    		$url = url_encode( $page, $param1, $value1, $param2, $value2, $param3, $value3, $param4, $value4, $param5, $value5 );

    		echo "<div onclick=\"window.location.href='".$url."'\" class='greenbuttonmobile3_bottom' style='line-height: 45px; width:100%;'>".$text."</div> ";			
	    }
	    else
    		echo "<div class='greenbuttonmobile3_bottom' style='line-height: 45px; width:100%;'>&nbsp;</div> ";				    
	}

	
//	function show_black_link( $prompt, $page, $param1="", $value1="", $param2="", $value2="", $param3="", $value3="", $param4="", $value4="" )
//	{
//		return "<a class='blacklink' href='".url_encode( $page, $param1, $value1, $param2, $value2, $param3, $value3, $param4, $value4 )."'>".$prompt."</a>";		
//	}

?>