<?php

	include "library.php";

	$cxn = start_code( true );
	

	$screen_graphics = true;

//	$_SESSION['sitename'] = 'Australian Businesses for Sale Platform';


		// NOTE: for country entry points to the site go to 'splash_country.php' and 'country' subfolder


		/* log the hits. remember the original source for conversions */

	if (val( $_GET, "internaljump" ) != "true")
	{
		$source = val( $_GET, "source" );
		
		if ($source == "")
			$source = "organic";

		$_SESSION['source'] = $source;

		log_hits( $source, $cxn );
	}

		// 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>";
//
//
//	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, true );


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

	$query = "SELECT DISTINCT ip_address FROM hits WHERE hit_date >= '".date( "Y-m-d", strtotime( date( "Y-m-d") ) - 7*24*60*60 )."'";
 	$result = run_query( $query, $cxn );
	
	$num_visitors = query_num_rows( $result );


	if (! low_res_screen())
    {
    	echo "<style> html, body {";
    	echo "margin:0;";
    	echo "padding:0;";
    	echo "}";
    	echo "</style>";
    
        $menu_text_color = "#0000bb";
        $menu_background_color = "#eeeeee";
        $menu_highlight_color = "#cccccc";
        
    	show_dropdown_styles( $menu_text_color, $menu_background_color, $menu_highlight_color );
    
        // background-color: #004499 #008a00
        
    	echo "<table cellpadding='0' cellspacing='0' width='100%'><tr><td style='line-height: 45px; opacity: 0.9; font-family: Calibri; font-size: 20pt; color: #ffffff; background-color: #007500' align='left'>&nbsp;&nbsp;Australian Businesses for Sale Platform</td></tr></table>";
    
        echo "<table width='100%' style='border-collapse: collapse;'><tr>";
    
        show_main_menu_bar( $country, $menu_background_color );
    
    	echo "</tr></table>";
    	
		echo "<br>";
		
		echo "<table width='100%'><tr><td width='80%'></td><td>";

//		show_google_translate();

		echo "</td></tr></table>";
		
		echo "<table width='100%'><tr><td width='5%'></td><td align='left' align='left' width='20%'><img style='opacity: 0.8' src='images/melbourne_skyline_narrow.jpg' height='250'></td>";		
		
		echo "<td width='35%'></td><td width='15%'><span class='gblue'>List your business for sale in Australia for free.<br><br>".$num_visitors." site visitors this week.</span></td><td width='30%'></td>";

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

    }	
	else
    {
		echo "<style> html, body {";
		echo "margin:0;";
		echo "padding:0;";
		echo "}";
		echo "</style>";


//		echo "<style> td {";
//									//echo "    padding-top: 0.8em;";
//		echo "    padding-bottom: 0.7em;";
//		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='left'>&nbsp;&nbsp;Australian Businesses for Sale Platform</td></tr></table>";

        echo "<br>";
        
		echo "<table width='100%'><td width='5%'></td><td align='left' width='25%'><img style='opacity: 0.8' src='images/melbourne_skyline_narrow.jpg' height='120'></td><td></td>";

//		show_google_translate();
		
    	echo "<td width='20%'></td>";

		echo "<td width='25%'><span class='gblue'><br>List your business for sale in Australia for free. ".$num_visitors." site visitors this week.</span></td><td width='5%'></td></tr></table>";

        show_mobile_home_page_buttons();
	}


	if (! low_res_screen())
		echo "<br><br><br>";

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

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

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


	echo "<br>";

	if (! low_res_screen())
	{
		echo "<br><br><table width='100%'><tr><td width='20%'></td><td width='60%'>";

		$s1 = "Australian Businesses for Sale Platform is new website for listing businesses for sale in the Australia.<br><br>";
		
		$s1 .= "It is free to list businesses for sale on this site.<br><br>";

		$s1 .= "Established 2017.<br><br>";	
		
        $s1 .= "<br>";
    	$s1 .= "<br>";

		echo blue( $s1 );

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


    if (! low_res_screen())
        show_ads( $cxn );
    else
    {
        echo "<br><br>";
    
        echo "<table width='100%'><tr><td width='100%' align='center'>";
        
        show_ads_large_square();
        
        echo "</td></tr></table>";
    }

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

	echo "&nbsp;&nbsp;<span class='pgheading'>Recent listings</span><br><br>";

    echo "<br><br>";


    show_latest_listings( $cxn );
    

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

        
		// blank menu options
		
	function show_blank_entry()
	{
		$color_scheme = val( $_SESSION, "color_scheme" );
		
		if ($color_scheme == 2)		// black background
			$background_color = "#000000";
		else
			$background_color = "#f3f3f3";
	
		if (! low_res_screen())	
			echo "<td style='background-color: ".$background_color."'></td><td></td>";
		else
			echo "<td></td><td></td>";
	}		
        


        // 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 );		    
		}


        $menu_text_color = "#008500";

        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 "}";
        
		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 " }";

        echo ".mainmenu_seperate_item {";
        echo "  color: ".$menu_text_color.";";        
        echo "  background-color: ".$menu_background_color.";";
        echo "  padding: 13px;";
        echo "  font-size: ".$fs."pt;";
        echo "  border: none;";
        echo "  font-family:verdana;";
        echo "  text-decoration:none;";
        echo "}";

		echo ".mainmenu_seperate_item: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 " }";
				
        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";
		    
		    
            // Search
            
    	echo "<td width='10%' height='".$height."pt' align='center' id='ID1' style='background-color: ".$menu_background_color."'>";

        echo "<div class='dropdown'>";
        echo "<button class='mainmenuitem'>Search</button>";
        echo "<div class='dropdown-content'>";
        
        echo "<a href='".url_encode( "search_listings.php" )."'>Search listings</a>";
        echo "<a href='".url_encode( "mailboxes.php", "box", "remembered" )."'>Remembered list</a>";
        
        echo "</div>";
        echo "</div>";
    
        echo "</td>";


            // Listings
            
    	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'>Listings</button>";
        echo "<div class='dropdown-content'>";
        
        echo "<a href='".url_encode( "edit_listing.php", "newlisting", "true" )."'>Create listing</a>";
        echo "<a href='".url_encode( "view_my_listings.php" )."'>View my listings</a>";

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


            // Accounts
            
    	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'>Accounts</button>";
        echo "<div class='dropdown-content'>";
        
        echo "<a href='".url_encode( "edit_account.php", "newaccount", "true" )."'>Create an account</a>";
        echo "<a href='".url_encode( "edit_account.php", "newaccount", "false" )."'>Edit my account</a>";

        echo "</div>";
        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", "remembered" )."'>Remembered</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( "charges.php" )."'>Costs</a>";
        echo "<a href='".url_encode( "policies.php" )."'>Policies</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>";

        echo "<td width='25%' style='background-color: ".$menu_background_color."'>";

        echo "</td>";


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

//        echo "<a href='".url_encode( "buy_credits.php" )."'>Buy Credits</a>";        
        echo "<a href='".url_encode( "main_menu_login.php" )."' class='mainmenu_seperate_item' style='text-decoration: none; color: #000000;'>Login</a>";

        echo "</td>";

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

        echo "<a href='".url_encode( "session_kill.php" )."' class='mainmenu_seperate_item' style='text-decoration: none; color: #000000;'>Logout</a>";        


        echo "</td>";

        echo "<td width='10%' style='background-color: ".$menu_background_color."'>";

        echo "</td>";

	}


    function show_mobile_home_page_buttons()
    {
        echo "<br><br>";
        
        
        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( "Search", 112, "show_mobile_menus.php", "menu", "search" );
    	
    	echo "</td><td width='30%' align='center'>";

        show_green_button3( "Listings", 112, "show_mobile_menus.php", "menu", "listings" );
    	
    	echo "</td><td width='30%' align='center'>";

    	show_green_button3( "Accounts", 112, "show_mobile_menus.php",  "menu", "accounts" );
    	
    	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( "Messages", 112, "show_mobile_menus.php",  "menu", "messages" );
    	
    	echo "</td><td width='30%' align='center'>";
    	
    	show_green_button3_bottom( "Information", 112, "show_mobile_menus.php",  "menu", "information" );
    	
    	echo "</td><td width='30%' align='center'>";
    	
    	show_green_button3_bottom( "Other", 112, "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, $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: 48px; 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: 48px; width:100%;'>".$text."</div> ";			
	    }
	    else
    		echo "<div class='greenbuttonmobile3_bottom' style='line-height: 48px; width:100%;'>&nbsp;</div> ";				    
	}



?>