<HTML><HEAD><TITLE>Classifieds</TITLE>

  <SCRIPT LANGUAGE="Javascript">
  <!-
    function openStatusWindow(file, width, height) {
      unique = "cahelpwin";
      Win = open(file, unique, 
        'toolbar=0,location=0,directories=0,status=0,menubar=0,resizeable=1'+
        'width=' + width + ',height=' + height + ',scrollbars=yes');
      Win.focus();
    }
  //->
  </SCRIPT>


</HEAD>
<BODY BGCOLOR=cornsilk>
<?
include("common.inc");
include("show.inc");
include("head.inc");
$errstring="";
// This fires if we are not editing (save ad)
if (($title!="" || $text!="" || $response!="") && $edit!=1 ) {
  if ($response=="" || strchr($response,"@")=="") $errstring="Please enter a valid e-mail address";
  if ($text=="") $errstring="Please enter some ad text";;
  if ($title=="") $errstring="Please enter a title";
// get rid of " characters
  $text=str_replace("\"","&quot;",$text);
  $title=str_replace("\"","&quot;",$title);
  $response=str_replace("\"","&quot;",$response);
  if ($errstring=="") {
  $expire=strftime("%Y/%m/%d %H:%M",time()+86400*5);  // 86400=1 day
  include("db.inc");


  if ($adid=="") {
    $title=enquote($title);
    $text=enquote($text);
    $result=query($sql_insert);
 $adid=insert_id();
 }
 else {
  $result=query($sql_update);
 }
 echo "<H1>Here is a preview of your ad:</H1>";

 $r1=query($sql_query1);
 $row=fetch_array($r1);
 showad($row);
?>
<HR>
<TABLE BORDER=0><TR><TD>
<FORM METHOD=POST ACTION=add.php>
<INPUT TYPE=HIDDEN NAME=edit VALUE=1>
<INPUT TYPE=HIDDEN NAME=title VALUE="<?= $title ?>">
<INPUT TYPE=HIDDEN NAME=text VALUE="<?= $text ?>">
<INPUT TYPE=HIDDEN NAME=response VALUE="<?= $response ?>">
<INPUT TYPE=HIDDEN NAME=graphicurl VALUE="<?= $graphicurl ?>">
<INPUT TYPE=HIDDEN  NAME=adid VALUE='<?= $adid ?>'>
<INPUT TYPE=HIDDEN NAME=cat VALUE='<?= $cat ?>'>
<INPUT TYPE=SUBMIT VALUE='Edit Ad'>
</FORM>
</TD><TD>
<FORM METHOD=POST ACTION=del.php>
<INPUT TYPE=HIDDEN NAME=adid VALUE='<?= $adid ?>'>
<INPUT TYPE=SUBMIT VALUE='Cancel Ad'>
</FORM>
</TD><TD>
<FORM METHOD=POST ACTION=pay.php>
<INPUT TYPE=HIDDEN NAME=adid VALUE='<?= $adid ?>'>
<INPUT TYPE=SUBMIT VALUE='Place Ad'>
</FORM>
</TD></TR></TABLE>
<?
   } // no error
} // done with add

// This fires for new requests, edit requests, or errors
if ($title=="" || $edit==1 || $errstring!="") { 
  if ($errstring!="") echo "<h3><FONT COLOR=RED>$errstring</FONT></h3>";
?>
 
  <FORM METHOD=POST ACTION=add.php>
<TABLE BORDER=0><TR><TD>
  <INPUT TYPE=HIDDEN NAME=cat VALUE='<?= $cat ?>'>
<?
  if ($edit==1) {
    echo "<INPUT TYPE=HIDDEN NAME=adid VALUE='$adid'>";
 }
?>
  Title:<BR><FONT SIZE=1><A HREF=javascript:openStatusWindow('help.php?tag=addtitle',600,200);>help
  </A></FONT></TD><TD> <INPUT SIZE=80 NAME=title VALUE="<?= $title ?>">
  </TD></TR>
<TR><TD VALIGN=TOP>Ad copy:<BR><FONT SIZE=1><A HREF=javascript:openStatusWindow('help.php?tag=addcopy',600,200);>help
  </A></FONT></TD><TD><TEXTAREA NAME=text ROWS=12 COLS=60>
  <?= $text ?></TEXTAREA></TD></TR>
<TR><TD>Your e-mail:<BR>
<FONT SIZE=1><A HREF=javascript:openStatusWindow('help.php?tag=addemail',600,200);>help
  </A></FONT></TD><TD><INPUT SIZE=80 NAME=response VALUE="<?= $response ?>">
  </TD></TR>
<TR><TD>Graphic URL:<BR>
<FONT SIZE=1><A HREF=javascript:openStatusWindow('help.php?tag=addurl',600,200);>help</A></FONT></TD><TD><INPUT SIZE=80 NAME=graphicurl VALUE="<?= $graphicurl ?>">
  </TD></TR>
<TR><TD>&nbsp;</TD><TD><INPUT TYPE=SUBMIT VALUE="Preview Ad"></TD></TR>
</TABLE>
</FORM>
<HR>
<H3>Terms of Service:</H3>
<UL>
<LI>All ads must be on topic.
<LI>We reserve the right to refuse any ad.
</UL>
<? 
}
?>


</BODY></HTML>