<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
        <html>
        <head>
                <title>Einfache Suche </title>
                <meta http-equiv="content-type" content="text/html; charset=UTF-8"><link href="style.css" rel="stylesheet" type="text/css">
                
                
                <!-- HERE OCCURS THE ERROR -->
                
                <?php $target=$_GET('target');?>
        
                
                <!-- expand/collapse function -->
         <SCRIPT type=text/javascript>
                function collapseElem(obj)
                {
                        var el = document.getElementById(obj);
                        el.style.display = 'none';
                }
                
                function expandElem(obj)
                {
                        var el = document.getElementById(obj);
                        el.style.display = '';
                }
                </SCRIPT>
                <!-- expand/collapse function -->
                <!-- expand/collapse function -->
                 <SCRIPT type=text/javascript>
                        // collapse all elements, except the first one
                        function collapseAll()
                        {
                                var numFormPages = 1;
                                for(i=2; i <= numFormPages; i++)
                                {
                                        currPageId = ('mainForm_' + i);
                                        collapseElem(currPageId);
                                }
                        }
                        </SCRIPT>
                <!-- expand/collapse function -->
                 <!-- validate -->
                <SCRIPT type=text/javascript>
                        function validateField(fieldId, fieldBoxId, fieldType, required)
                        {
                                fieldBox = document.getElementById(fieldBoxId);
                                fieldObj = document.getElementById(fieldId);
                                if(fieldType == 'text' || fieldType == 'textarea' || fieldType == 'password' || fieldType == 'file' || fieldType == 'phone' || fieldType == 'website')
                                {        
                                        if(required == 1 && fieldObj.value == '')
                                        {
                                                fieldObj.setAttribute("class","mainFormError");
                                                fieldObj.setAttribute("className","mainFormError");
                                                fieldObj.focus();
                                                return false;                                        
                                        }
                                }
                                else if(fieldType == 'menu' || fieldType == 'country' || fieldType == 'state')
                                {        
                                        if(required == 1 && fieldObj.selectedIndex == 0)
                                        {                                
                                                fieldObj.setAttribute("class","mainFormError");
                                                fieldObj.setAttribute("className","mainFormError");
                                                fieldObj.focus();
                                                return false;                                        
                                        }
                                }
                        }
                        function validateDate(fieldId, fieldBoxId, fieldType, required, minDateStr, maxDateStr)
                        {
                                retValue = true;
                                fieldBox = document.getElementById(fieldBoxId);
                                fieldObj = document.getElementById(fieldId);        
                                dateStr = fieldObj.value;
                                if(required == 0 && dateStr == '')
                                {
                                        return true;
                                }
                                if(dateStr.charAt(2) != '/' || dateStr.charAt(5) != '/' || dateStr.length != 10)
                                {
                                        retValue = false;
                                }        
                                else        // format's okay; check max, min
                                {
                                        currDays = parseInt(dateStr.substr(0,2),10) + parseInt(dateStr.substr(3,2),10)*30 + parseInt(dateStr.substr(6,4),10)*365;
                                        //alert(currDays);
                                        if(maxDateStr != '')
                                        {
                                                maxDays = parseInt(maxDateStr.substr(0,2),10) + parseInt(maxDateStr.substr(3,2),10)*30 + parseInt(maxDateStr.substr(6,4),10)*365;
                                                //alert(maxDays);
                                                if(currDays > maxDays)
                                                        retValue = false;
                                        }
                                        if(minDateStr != '')
                                        {
                                                minDays = parseInt(minDateStr.substr(0,2),10) + parseInt(minDateStr.substr(3,2),10)*30 + parseInt(minDateStr.substr(6,4),10)*365;
                                                //alert(minDays);
                                                if(currDays < minDays)
                                                        retValue = false;
                                        }
                                }
                                if(retValue == false)
                                {
                                        fieldObj.setAttribute("class","mainFormError");
                                        fieldObj.setAttribute("className","mainFormError");
                                        fieldObj.focus();
                                        return false;
                                }
                        }
                </SCRIPT>
                <!-- end validate -->
                <SCRIPT type=text/javascript>
                function getXMLHTTP()
                {
                        xmlhttp=null;
                        // code for Mozilla, etc.
                        if (window.XMLHttpRequest)
                        {
                                xmlhttp=new XMLHttpRequest();
                        }
                        // code for IE
                        else if (window.ActiveXObject)
                        {
                                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
                        }
                        return xmlhttp;
                }
                
                function getBezirk(Id)
                {
                 var strURL="findBezirk.php?f_bezirk="+Id;
                 var req = getXMLHTTP();
                 if (req)
                 {
                         req.onreadystatechange = function()
                         {
                         if (req.readyState == 4)
                         {
                         // only if "OK"
                         if (req.status == 200)
                                 {
                                document.getElementById('fb_kg').innerHTML=req.responseText;
                         } else {
                         alert("There was a problem while using XMLHTTP:\n" + req.statusText);
                         }
                         }
                         }
                 req.open("GET", strURL, true);
                 req.send(null);
                 }
                }
                </script>        
        </head>
        <body onLoad="collapseAll()">
        <div id="mainForm">
                <div id="formHeader">
                                <h2 class="formInfo">Einfache Suche</h2>
                                <p class="formInfo"></p>
                </div>
                
                <?php
                        include("config.inc.php");
                        $db = pg_connect($conn_string) or die('connection failed');
                        
                        $queryBezirk= "Select \"IDRegion\", \"Region\" from \"tbl_region\" ORDER BY \"Region\" ASC";
                        
                        $resultBezirk = pg_query($queryBezirk);
                
                        // if there are no results --> end up here
                        checkresult($resultBezirk,$queryBezirk);                
                ?>
                <BR/><!-- begin form -->
                <form method=get enctype=multipart/form-data action=searchNormal.php onSubmit="return validatePage1();"><ul class=mainForm id="mainForm_1">
                                <li class="mainForm" id="fb_bezirk">
                                        <label class="formFieldQuestion">Bezirk * <a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Bezirk auswählen</span></a></label><select class=mainForm name=f_bezirk id=f_bezirk onchange="getBezirk(this.value)"><option value='Auswählen ...'>Auswählen ...</option>
                <?php
                                $i=0;
                                $val=0;
                                while($myrow = pg_fetch_assoc($resultBezirk)) {
                                        foreach ($myrow as $index => $value)
                                        {
                                                //%2, because I only want the Name to show into the dropdown list
                                                if($i%2){
                                                        echo "<option value=".$val.">".$value."</option>";
                                                }
                                                // ID of Bezirk
                                                else {
                                                        $val=$value;
                                                }
                                                $i=$i+1;
                                        }
                                }
                                echo "</select></li>"
                ?>
                                <li class="mainForm" id="fb_kg">
                                        <label class="formFieldQuestion">KG * <a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Katastralgemeinde auswählen</span></a></label><select class=mainForm name=f_kg id=f_kg><option>Vorher Bezirk auswählen ...</option></select>
                                <li class="mainForm" id="fb_gnr">
                                        <label class="formFieldQuestion">Grundstücksnr <a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Grundstücksnummer (optional)</span></a></label><input class=mainForm type=text name=f_gnr id=f_gnr size='20' value=''></li>
                                <li class="mainForm" id="fb_uk">
                                        <label class="formFieldQuestion">Umkreis <a class=info href=#><img src=imgs/tip_small.png border=0><span class=infobox>Auswahl eines Buffers indem Massenbewegung gesucht werden soll (optional)</span></a></label><select class=mainForm name=f_uk id=f_uk><option value="genau">genau</option><option value="500">500m</option><option value="1000">1.000m</option></select></li>
                
                
                <!-- end of this page -->
                <!-- page validation -->
                <SCRIPT type=text/javascript>
                        function validatePage1()
                        {
                                retVal = true;
                                if (validateField('f_bezirk','fb_bezirk','menu',1) == false)
                                 retVal=false;
                                if (validateField('f_kg','fb_kg','menu',1) == false)
                                 retVal=false;
                                if (validateField('f_gnr','fb_gnr','text',0) == false)
                                 retVal=false;
                                if (validateField('f_uk','fb_uk','menu',0) == false)
                                 retVal=false;
                                if(retVal == false)
                                {
                                        alert('Ein Fehler ist aufgetreten. Bitte füllen Sie alle Pflichtfelder (*) aus');
                                        return false;
                                }
                                return retVal;
                        }
                </SCRIPT>
                <!-- end page validaton -->
                <!-- next page buttons -->
                <li class="mainForm">
                                        <input id="saveForm" class="mainForm" type="submit" value="Suchen" />
                                        <input id="saveForm" class="mainForm" type="reset" value="Zurücksetzen" />
                </li>
                </form>
                        <!-- end of form -->
                <!-- close the display stuff for this page -->
                </ul></div>
        </body>
        </html>