<?php

	include "library.php";

	$cxn = start_code();

	$cxn_common = db_common_login();


		// *****************************************************************
		// NOTE: don't put ads on the login page it's against Adsense policies


	$on_load = "";
	

		// relaod this page after setting thehe 'screen_width' and 'screen_height' values using javascript
		// only execute this reload once per entire session
		
	if (val( $_SESSION, "screen_width" ) == "")
		echo "<script language='JavaScript'> document.location=\"login.php?screen_width=\"+screen.width+\"&screen_height=\"+screen.height; </script>";


	if (val( $_GET, "screen_width" ) != "" && val( $_GET, "screen_height" ) != "" && 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, "mainmenulogin" ) == "true")
    {
    		$is_main_login = true;
    		
    		$_SESSION['nextpage'] = "index.php";
    }
    else
    {
        if (strpos( val( $_SESSION, 'nextpage' ), "index.php" ) === false)
    		$is_main_login = false;
    	else
    		$is_main_login = true;
    }
    
    
	page_header( "Login", $cxn, $cxn_common, $on_load );


	if (! $is_main_login)
	{
		echo red( "<br>You must be a member to access this screen.<br><br>" );

		echo black( "To join the site please click on " );

		echo show_link( "Join the Site", "edit_profile.php", "newprofile", "true" );

		echo black( "<br><br>If you are already a member please type in your handle name and password and click 'Login'." );
	}		

	echo black( "<br><br>If you have forgotton your handle name or password click " );

	echo show_link( "forgotten password", "forgotten_password.php" );

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

	echo "<table width='100%'><tr><td width='10%'></td><td>";
	
	form_start( "accept_login.php" );

	write_yellow_input_boxes();
	
//	echo "<tr></tr><tr><td>&nbsp;</td></tr>";

	form_text( "Handle Name&nbsp;&nbsp;", "handle", 14, "", "true" );

	form_password( "Password", "password", 14, "" );


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

	echo "<tr><td>".show_link( "Join the Site", "edit_profile.php", "newprofile", "true" )."</td></tr>";

    	
//	echo "</table>";
//	echo "<table>";
	
	form_submit_new( "Login", 82 );
	

//	echo "<br><br><tr><td></td><td><br><br><a href='".url_encode( "display_profile.php", "returnpoint", "main", "sample", "true" )."'>".red( "Example Profile" )."</a></td></tr>";

	form_end();

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

		// NOTE: don't put ads on the login page it's against Adsense policies
//	show_ads( $cxn );

?>