function Page_Main()
 {
     $qs = new cQueryString();
     if ($qs->Count > 0) {
         $Sql = $qs->getValue("s");
         $Sql = TEAdecrypt($Sql, EW_RANDOM_KEY);
         if ($Sql != "") {
             // Get the filter values (for "IN")
             $Value = ew_AdjustSql($qs->getConvertedValue("f"));
             if ($Value != "") {
                 $arValue = explode(",", $Value);
                 $FldType = $qs->getValue("lft");
                 // Filter field data type
                 if (is_numeric($FldType)) {
                     $FldType = intval($FldType);
                 }
                 $cnt = count($arValue);
                 for ($i = 0; $i < $cnt; $i++) {
                     $arValue[$i] = ew_QuotedValue($arValue[$i], $FldType);
                 }
                 $Sql = str_replace("{filter_value}", implode(",", $arValue), $Sql);
             }
             // get the query value (for "LIKE" or "=")
             $Value = ew_AdjustSql($qs->getConvertedValue("q"));
             if ($Value != "") {
                 $Sql = str_replace("{query_value}", $Value, $Sql);
             }
             $this->GetLookupValues($Sql);
         }
     } else {
         die("Missing querystring.");
     }
 }
// Turn on output buffering
include "ewcfg50.php";
include "ewmysql50.php";
include "phpfn50.php";
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
// Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate");
// HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// HTTP/1.0
$LnkFldType = 0;
$LnkCount = 0;
$qs = new cQueryString();
if ($qs->Count > 0) {
    $Sql = $qs->getValue("s");
    $Sql = TEAdecrypt($Sql, EW_RANDOM_KEY);
    $Value = $qs->getConvertedValue("q");
    $Value = ew_AdjustSql($Value);
    $LnkType = $qs->getValue("lt");
    // Get link type
    if ($LnkType == "2") {
        // Auto fill
        $LnkCount = 1;
        $LnkFld = -1;
        $LnkDisp1 = 0;
        $LnkDisp2 = -1;
    } elseif ($LnkType == "1") {
        // Auto suggest
<?php

define("EW_PAGE_ID", "ewaddopt", TRUE);
// Page ID
ob_start();
// Turn on output buffering
include "ewcfg50.php";
include "ewmysql50.php";
include "phpfn50.php";
$bError = FALSE;
$qs = new cQueryString();
if ($qs->Count > 0) {
    $LookupTableName = $qs->getConvertedValue("ltn");
    $LinkFieldName = $qs->getConvertedValue("lfn");
    $DisplayFieldName = $qs->getConvertedValue("dfn");
    $DisplayField2Name = $qs->getConvertedValue("df2n");
    $ParentFieldName = $qs->getConvertedValue("pfn");
    $LinkField = $qs->getConvertedValue("lf");
    if ($DisplayFieldName == $LinkFieldName) {
        $DisplayField = $LinkField;
    } else {
        $DisplayField = $qs->getConvertedValue("df");
    }
    if ($DisplayField2Name == $LinkFieldName) {
        $DisplayField2 = $LinkField;
    } elseif ($DisplayField2Name == $DisplayFieldName) {
        $DisplayField2 = $DisplayField;
    } else {
        $DisplayField2 = $qs->getConvertedValue("df2");
    }
    $ParentField = $qs->getConvertedValue("pf");