startgame.htm

<html>
<head>
    <title>The Switch</title>

<script src="include.js" type="text/javascript"></script>
<script type="text/javascript">

       //Declare variables
       var urlGet = "getswitch.php?id=1"; 
       var urlPost = "putswitch.php"; 

    varExpiries = 1;

var httpGet = getHttpObject(false);
var httpSuggest = getHttpObject(false);
        
       function handleGetHttpResponse() 
       {   
           var results="The current suggestion is "+ httpGet.responseText + " (" + varExpiries + ")";

           document.getElementById('divCustomerInfo').innerHTML = results;
            document.getElementById('buttonAgree').style.visibility = "visible"

           varExpiries++;

       setTimeout("getSuggestions()",3000);
        }

    function handleSuggestHttpResponse() 
    {   
            //Nothing yet
        }
       
        function getSuggestions() 
        {    
            doHttpRequest(httpGet, handleGetHttpResponse, urlGet, "GET");
        }
       
        function suggest() 
    {    
        var sSuggestion = document.getElementById("txtSuggestion").value;
        var urlPostWithParameters = urlPost + "?suggestion=" + sSuggestion; 
            doHttpRequest(httpSuggest, handleSuggestHttpResponse, urlPostWithParameters, "POST");
        }

        function agree() 
        {   
        top.location="colour.htm";
        }

        function handleReturn(param1, param2)
        {
            suggest();
        }

        setTimeout("getSuggestions()",3000);

</script>
</head>
<body>
        <h1>The Switch</h1>
    <p>Make a suggestion: <input type="text" id="txtSuggestion" value="" onKeyPress="handleKeyPress(event, 0, 0)"/></p>
    <p><input type="button" value="Suggest" onclick="suggest()" /></p>
    <p><i><span id="divCustomerInfo">Waiting for a suggestion...</span></i></p>
    <p><INPUT ID="buttonAgree" TYPE="button" VALUE="Agree" onclick="agree()" style="position: absolute; visibility: hidden;" /></p>
</body>
</html>