<?php

	include "library.php";

	include forms_library;

	include ad_forms_library;


	$cxn = start_code( true, true );


    if (val( $_SESSION, "session_active" ) == "")
        $new_entry = true;
    else
        $new_entry = false;


    process_external_entry_point( $cxn );
    
    
//    echo $_SERVER['HTTP_USER_AGENT']."<br>";
    

        // academicdating.net/country/Australia/Australia.php               (splash_country.php)


		// 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

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

	if (val( $_SESSION, "screen_width" ) == "")
	{
		$source = val( $_GET, "source" );

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

		$_SESSION['source'] = $source;

		log_hits( $source, $cxn );
	}


	log_page_view( $cxn );


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

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


//    if (! low_res_screen())
        $amp = false;
//    else
//        $amp = true;


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


        
    $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 );


//    if ($new_entry)
//        $_SESSION['scountry'] = $country;
        

    $the = "";
    
    $wikipedia_link = "";
    $immigration_link = "";


	$query = "SELECT prefix, wikipedia_link, immigration_link 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 );	

        if ($data['prefix'] != "")
            $the = "the ";

        $wikipedia_link = $data['wikipedia_link'];
        $immigration_link = $data['immigration_link'];
	}    


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


	$site_num_active_members = get_site_num_active_members( $cxn );



//        $ip = get_ip_address();
//        
//        if ($ip != "49.176.227.110")
//        {
//            echo "Academic Dating will be down for 60 minutes for maintenance. We apologise for the inconvenience.<br>";
//            exit();
//        }


	if (! low_res_screen())	
	    desktop_display( $id, $site_num_active_members, $the, $country, $wikipedia_link, $immigration_link, $amp, $cxn );
	else
	    mobile_display( $id, $site_num_active_members, $the, $country, $wikipedia_link, $immigration_link, $amp, $cxn );
	    

    echo "<br><br><br>";
    
    
    echo "</body>";
	
    echo "</html>";

    


        // full format of the home page for a desktop
        
    function desktop_display( $id, $site_num_active_members, $the, $country, $wikipedia_link, $immigration_link, $amp, $cxn )
    {
		$color_scheme = val( $_SESSION, 'color_scheme' );


        // column widths    5 15 10 40 10 5 15
        
        
            // #004499 #007500 #007f00 darkblue darkgreen 007600 73b8bb 00b000 8B4513

//		echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td style='line-height: 6px; background-color: #008500;'>&nbsp;</td></tr></table>";


        $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" );		
	    
	    
	    $num_members_in_country = 0;
	    
	    
		echo "<table width='100%' cellpadding='3' cellspacing='3'><tr><td width='5%'></td><td align='left' width='15%' valign='top' colspan=2>";

		echo "<br>";

		echo "<td width='10%'></td><td width='40%' align='left' valign='top'>";

		echo "<br><br>";

        $splash_country = "";

		echo "<br><br>";
		echo "<br><br>";
		echo "<br><br>";
		echo "<br><br>";
        
        
        show_inner_table_1( $the, $country, $site_num_active_members, $splash_country, $num_members_in_country, $cxn );


//        echo home_page_text( "To get started, click on " );
        	
//        echo home_page_search_link();


        echo "<br><br><br><br><br>";
        
        show_ads_large_banner_arj( $cxn );

		echo "</td>";

		echo "<td width='15%' align='center' valign='top'></td>";

		echo "<td width='10%' rowspan='20' valign='top'>";

        if ($color_scheme == 2)
    		echo "<br><br><div style='background: #000000; border: 8px solid #000000; display: inline-block;'>";
    	else
	    	echo "<br><br><div style='background: #ffffff; border: 8px solid #ffffff; display: inline-block;'>";
		
//        echo "<img alt='Photo' src='/images/pixabay_melbourne-panorama-614036_1920_4.jpg' height='250'></td>";            

//		show_image( select_website_image( $cxn ), 250, $amp );

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

	
		echo "<td width='5%' rowspan='20' valign='top'>";


//		show_ads_medium_skyscraper();

//		show_ads_large_square();

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

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

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

//        show_ads_large_banner( $cxn );

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

        echo "</table>";        

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


        if ($color_scheme == 2)
            echo "<table width='100%'><tr><td width='5%'>&nbsp;</td><td style='background: #000000;'>";
        else
            echo "<table width='100%'><tr><td width='5%'>&nbsp;</td><td style='background: #ffffff;'>";

//        show_recent_members( $cxn, "main", 0, $amp, "", $the, $country );

        echo "</td><td width='5%'>&nbsp;</td><tr></table>";
        

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

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

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

//        echo "<table width='100%'>";
//        
//        echo "<tr><td>&nbsp;</td></tr>";
//        echo "<tr><td>&nbsp;</td></tr>";
//
//        echo "</table>";


        show_recent_listings( $cxn );

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

        echo "&nbsp;&nbsp;<a href='https://www.humanservices.gov.au/individuals/centrelink'>Centrelink</a><br><br>";

        echo "&nbsp;&nbsp;<a href='https://www.homeaffairs.gov.au/'>Department of Immigration</a><br><br>";


		echo "<br>";

		echo "<br>";
        
        
        
//        show_country_list( $cxn );
	}


    function show_inner_table_1( $the, $country, $site_num_active_members, $splash_country,  $num_members_in_country, $cxn )
    {
	    echo home_page_text( sitename." is a site for listing part-time jobs in Australia.<br><br>" );

		echo "<br>";

//        echo "<span style='font-family: verdana; font-size: 11pt; color: #e00000;'>This is a new site. We welcome new listings (free).</span>";
//
//		echo "<br>";
//
//		echo "<br>";
//
//		echo "<br>";

	    echo home_page_text( "List jobs on this site (free) or register yourself as a jobseeker.<br><br>" );

		echo "<br><br>";
    }
    


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

    function mobile_display( $id, $site_num_active_members, $the, $country, $wikipedia_link, $immigration_link, $amp, $cxn )
    {
		echo "<table cellspacing='0' width='100%'><tr><td class='home_heading_mobile' valign='middle' align='center'>".sitename."<td></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%'>";
		
	    echo "<br>";

//        show_image( select_website_image( $cxn ), 130, $amp );

        echo "<img alt='Photo' src='/images/pixabay_melbourne-panorama-614036_1920_4.jpg' 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='32%' align='center' valign='center'>";

        show_google_translate();

        echo "<br>";

        echo home_page_text( "<br>".sitename." is site for listing part-time jobs in Australia</span><br><br>" );
		    

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

        echo "<br>";

//        echo black( "&nbsp;&nbsp;&nbsp;See below for members recently logged in" );

        echo "<br><br>";
        
	    echo "<table width='100%'><tr><td align='center'>";


	    show_ads_large_square();
		   
		
		echo "</td></td></table>";

    	echo "<br><br><br><br><br>";
    	
//        show_recent_members( $cxn, "main", 0, $amp, "", $the, $country );

        echo "<table><tr><td width='2%'></td><td width='96%'>";
        
//        echo home_page_text( "Enquiries about the site can be directed to Site Administration at " );
//        
//        echo "<a href='mailto:admin@academicdating.net' class='gemail'>Contact Us</a><br><br>";
  
	    echo home_page_text( sitename." is a site for listing part-time jobs in Australia<br><br>" );

	    echo home_page_text( "List jobs on this site (free) or register yourself as a jobseeker, where prospective employers can search for jobseekers through the site.<br><br>" );


//    	echo "<br>";
//    	echo "<br>";
    	echo "<br>";

//		show_ads_narrow_banner();

    	echo "<br>";

        echo "</td><td width='2%'></td></tr></table>";
    
//        echo "<span class='pgheading' style='color: #a00000'>&nbsp;&nbsp;We have members in the following countries</span><br><br><br>";
//	
//        show_country_links( $cxn, false );

    	echo "<br>";

        echo "<table width='100%'><tr><td width='2%'>&nbsp;</td><td>";

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

        echo "</table>";


		echo "<br>";
		echo "<br>";
		
        show_recent_listings( $cxn );

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



    function show_mobile_home_page_buttons( $id, $amp )
    {
        echo "<table width='100%' cellpadding='0' cellspacing='0' class='border_collapse'>";

        echo "<tr>";
    
        echo "<td width='5%'>&nbsp;</td>";
        
    	echo "<td width='30%' align='center'>";

    	show_green_button3( "Jobs", 112, $amp, "/show_mobile_menus.php",  "menu", "jobs" );

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

    	show_green_button3( "Jobs Seekers", 112, $amp, "/show_mobile_menus.php",  "menu", "jobseekers" );
    	
    	echo "</td><td width='30%' align='center'>";

    	show_green_button3( "Advertisers", 112, $amp, "/show_mobile_menus.php",  "menu", "advertisers" );

    	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_bottom( "Information", 112, $amp, "/show_mobile_menus.php",  "menu", "information" );

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

    	show_green_button3_bottom( "", 112, $amp, "",  "", "" );

    	echo "</td><td width='30%' align='center'>";
    	
    	show_green_button3_bottom( "Other", 112, $amp, "/show_mobile_menus.php",  "menu", "other" );

    	echo "</td>";

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



        // tab style buttons for mobile screen buttons
        
	function show_green_button3( $text, $size, $amp, $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' >".$text."</div>";			
                
	    }
	    else
    		echo "<div class='greenbuttonmobile3'>&nbsp;</div> ";				    
	}


	function show_red_button3( $text, $size, $amp, $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' style='line-height: 45px; width:100%; color: #ff0000;' >".$text."</div> ";			
	    }
	    else
    		echo "<div class='greenbuttonmobile3' >&nbsp;</div> ";
	}


        // different style to sub-menu tabs
        
    function show_green_button3_bottom( $text, $size, $amp, $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' >&nbsp;</div> ";				    
	}


    function home_page_search_link()
    {
        if (! low_res_screen())
            return ("<a href='/search_profiles.php' class='homepagelink'>Search Profiles</a>");
        else
            return ("<a href='/search_profiles.php' class='homepagelink_mobile'>Search Profiles</a>");
    }


    function show_recent_listings( $cxn )
    {
        echo "<span class='pgheading'>&nbsp;&nbsp;Recent listings</span><br><br>";
        
    	$query = "SELECT * FROM job WHERE status = 'active' order by date_created DESC limit 20";
    
    	$result = run_query( $query, $cxn );
    
        echo "<table width='100%'>";
        
    	for ($i=0; $i < query_num_rows($result); $i++)
    	{
    		$data = get_row( $result );
    	    
//    		$found_one = "true";
    
//    		echo "<a name='id".$data[$i]['id']."'>";		/* bookmark to go back to search screen */
    
            $amp = false;
    
            echo "<tr><td></td>";
    
    //        echo "<td>".name_case( $data[$i]['type'] )."</td>";
    
            echo "<td>".show_link( $data['short_description'], "display_job.php", "showid", $data['id'], "returnpoint", "search_jobs", "startpos", $start_pos )."</td>";
    
            echo "<td>City: ".$data['city']."</td>";
    
            echo "<td>Postcode: ".$data['postcode']."</td>";
    
            echo "</tr>";
            
            echo "<tr><td></td><td colspan='4'><hr></td></tr>";
    
    		if (($i % 8 == 7) && ($i != $num_this_page-1))
    //		if ($start_pos == 0 && ($i % 8 == 7) && ($i != $num_this_page-1))
    		{
                echo "<br><br><br><br>";
    
                if (! low_res_screen())
                {
                    echo "<table width='100%'><tr><td width='10%'>&nbsp;</td><td width='80%' align='left'>";
                
                    echo show_ads_large_banner_arj();
    
                    echo "</td></tr></table>";
                }
                else
                {
                    echo "<table width='100%'><tr><td width='100%' align='center'>";
    
                    echo show_ads_narrow_banner();
            
                    echo "</td></tr></table>";
                }
                
                echo "<br><br><br><br><hr>";
    		}
    
    	}

        echo "</table>";
    }

?>