if ($prm==`CS_Event_Create`)
{
  $UserId=$_SESSION[`UserId`];
  $CaseId=$_SESSION[`CaseId`];
  $sql="insert into Responses (qID,rValue,uID,rInstance)" . 
       " select `CS_Event_Desc`,`New Event`,`$UserId`,`$CaseId`";
  ExecuteSQL($sql);
  $ord=ShowQueryResultScalar("select count(*) from Responses where rInstance=`$CaseId` and qID=`CS_Event_Desc`");
  $_SESSION[`Instance`]=$CaseId;
  $inst=$CaseId;
  $tId=ShowQueryResultScalar("select max(rUnique) from Responses where rInstance=`$CaseId` and qID=`CS_Event_Desc`");
  ExecuteSQL("update Responses set CaseID=`$tId` where rUnique=`$tId` and qID=`CS_Event_Desc`");
  $CaseId=$tId;
  $_SESSION[`CaseId`]=$CaseId;  
  $sql="insert into Responses (CaseID,qID,rValue,uID,rInstance)" . 
       " select `$CaseId`,`CS_Event_Order`,`$ord`,`$UserId`,`$inst`";
  ExecuteSQL($sql);
  SetForm(`CS_Event_Edit`);
}
$stat=1;