<?php

	include "library.php";

	$cxn = start_code();
	

    $account_id = val( $_SESSION, "account_id" );
    
	
			/* get variables */

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

//	$photo_number = val( $_GET, "photonumber" );


	if ($account_id == "")
	{
		$_SESSION['nextpage'] = url_encode( "show_contact_details.php", "listing_id", $listing_id );

		jump_to_page( "login.php" );	/* must happen before print output */

		exit();
	}

	
	if ($account_id != "")
	{
		$query = "SELECT * FROM contact_details_shown WHERE account_id = ".$account_id." AND listing_id = ".$listing_id;

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

        if (query_num_rows( $result ) >= 1)
        {
			header( "Location: show_contact_details_go.php?listing_id=".$listing_id );
			exit();
        }
	}



header( "Location: show_contact_details_go.php?show=yes&listing_id=".$listing_id );


	
	page_header( "", $cxn );


		/* check parameters */

	crash_if_missing( $listing_id, "listing_id missing in show_contact_details", $cxn );




		/* prompt the user */

	echo black( "<br>It costs 1 credit ($10) to see the contact details for a listed business. Would you like to continue?<br><br><br>" );

	echo "<br>";


		/* yes */

	echo sp(2);

	show_green_button( "Yes", 70, "show_contact_details_go.php", "show", "yes", "listing_id", $listing_id );



		/* no */

	echo sp(2);

	show_green_button( "No", 70, "show_contact_details_go.php", "show", "no", "listing_id", $listing_id );

?>
