<?
// scroll_wml.php
//
// Copyright, Exolution GmbH / Michael Kerrisk, Sep 2000
// http://www.exolution.com/wapsh   mailto:wapsh@exolution.de
//
// This software is Open Source licensed under the terms of the Trolltech QPL
// version 1.0.  See http://www.exolution.de/wapsh for further information.
//
// -------------------------------------------------------------------
//
// WML Scroll/search page
//
//
    require("common.inc");
    require("common_wml.inc");
    header("Content-type: text/vnd.wap.wml");
    require("displayfuncs.inc");
    
    //require("command_html.inc");

    // srand ((double) microtime() * 1000000);

    //$scrCommFields = $commFields .  '<postfield name="scrForm" value="y" />'; 

    echo '<?xml version="1.0" encoding="iso-8859-1"?>';
?><!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<wml>

<card title="<? echo SYSTEM_NAME; ?> Scroll/Search" newcontext="true">

<?
    $charsRemaining = $outputBufLen - $outputPos - $lastOutputBlockSize;
     
    if ($outputBufLen <= 0) {
	echo sParaBlk("No output yet received from server\n");
    } else {
    
	if ($charsRemaining > 0 || $outputPos > 0) {
	    
	    echo '<p>';
	    echo 'Search ';
	    //echo '<br/>';
	    echo '<input name="fss" type="text" size="20" value="';
	    if (isset($lastSrchStr))
	        echo escBrowserSpecialChars($lastSrchStr);
	    echo '"/>';
	    echo '</p>';
	    
	    if ($charsRemaining > 0) {
	        echo '<p>';
	        //echo '<br/>';
		wmlSubmitAnchor("Find forward", "command.php", "post", 
	        	$scrCommFields .
			'<postfield name="srchStr" value="$(fss)"/>' .
	        	'<postfield name="fwdSrch" value="y"/>');

		echo '</p>';
	    } // if 

	    if ($outputPos > 0) {
	        echo '<p>';
	        //echo '<br/>';
	        
		wmlSubmitAnchor("Find backward", "command.php", "post", 
	        	$scrCommFields .
			'<postfield name="srchStr" value="$(fss)"/>' .
	        	'<postfield name="backSrch" value="y"/>');
	        
		echo '</p>';
	    } // if 
	} // if

	if (isUpPhone())
	    echo '<p>*** Scrolling...</p>';
        if ($outputPos > 0) {
    	    wmlSoftkeyItem("doPrev", "Previous screen", "command.php", "post", 
    	    	$scrCommFields . '<postfield name="scrPrev" value="y"/>');
        }
        if ($outputPos + $lastOutputBlockSize < $outputBufLen) {
    	    wmlSoftkeyItem("doNext", "Next screen", "command.php", "post", 
    	    	$scrCommFields . '<postfield name="scrNext" value="y"/>');
        }
    
        if ($outputPos > $outputWindowSize) {
    	    wmlSoftkeyItem("doTop", "Top screen", "command.php", "post", 
    	    	$scrCommFields . '<postfield name="scrTop" value="y"/>');
        }
    
        if ($outputPos + $lastOutputBlockSize + $outputWindowSize < 
	    	    $outputBufLen) {
    	    wmlSoftkeyItem("doBot", "Bottom screen", "command.php", "post", 
    	    	$scrCommFields . '<postfield name="scrBot" value="y"/>');
        }


    } // if 

    wmlSoftkeyHomeLink();

    echo '<p>';
    echo 'Total chars: ' . $outputBufLen;
    echo '<br/>';
    echo 'Curr char: ' . $outputPos;
    echo '<br/>';
    echo 'Last screen: ' . $lastOutputBlockSize;
    echo '<br/>';
    echo 'Remaining: ' .  $charsRemaining;
    echo '</p>';
?>

</card>
</wml>
