# incoming, needs the following defined:
# @para_title
# @para_text
# @para_type (paragraph, news, address, links)
#
# @para_pic
# @para_align (picture left, right, center/below)
# @para_caption
# @para_morelink (requires $moretext text set, or defaults to "More...")
#
# $headlinelogo (image or text)
# $headlinetag (short description text)
1;

sub creator {
  $file_to_create=$_[0];
  $para_count=0;

  $file_to_create.=".html" unless ($file_to_create =~ m~\.html?$~i);
  # define output filename based on $file_to_create
  $outputfile="${homesite}$file_to_create";

  # load template file...
  $tempdir="$serverroot/templates";
  $template_dir_to_read="$tempdir/$template";

  $template_data="";

  $err=0;
  open TEMPLATE, "<$template_dir_to_read/index.html" or $err=1;
  if ($err==1) {
    open TEMPLATE, "<$template_dir_to_read/template.html" or $err=2;
    $err=0 if ($err<2);
  }

  if ($err!=0) {
    headline("Error: unable to open template file","red","","The template file could not be read (even tried alternative filename), and so no web page can be made.  Please contact <a href=\"mailto:$support_email\">$company support</a>.");
    return 1;
  }

  while ($line = <TEMPLATE>) {
    $template_data.=$line;
  }
  close TEMPLATE;

  # define addresses based on .wiz-details
  $address=$user_address;
  $address =~ s/\n/<br>\n/g;
  $address="<h4>$user_longorg</h4>\n".$address.".<br>\n";
  $address.="$user_postcode\n<br>\n" if ($user_postcode ne "");

  $phone_test=0;
  $phone_test=1 if ((($user_phone ne "") && ($user_phone ne "01")) || (($user_fax ne "") && ($user_fax ne "01")));
  $address.="\n<br>\n" if ($phone_test > 0);

  if (($user_phone ne "") && ($user_phone ne "01")) {
    if ($user_phone =~ m~^0[5|8]00~) {
      $address.="Freephone: $user_phone<br>\n";
    } else {
      $address.="Phone: $user_phone<br>\n";
    }
  }
  if (($user_fax ne "") && ($user_fax ne "01")) {
    $address.="Fax: $user_fax<br>\n";
  }
  if ($user_email ne "") {
    $address.="<br>\nEmail: <a href=\"mailto:$user_email\">$user_email</a><br>\n";
  }
  if ($user_contact ne "") {
    $address.="<br>\nSo why not get in touch and ask $user_contact for more information?";
  }

  for ($extloop=0; $extloop<6; $extloop++){
    $ext="gif"  if ($extloop == 0);
    $ext="jpeg" if ($extloop == 1);
    $ext="jpg"  if ($extloop == 2);
    $ext="jpe"  if ($extloop == 3);
    $ext="png"  if ($extloop == 4);
    $ext="swf"  if ($extloop == 5);
    $ext="svg"  if ($extloop == 6);
    if (-r "$homesite/uploads/header-logo.$ext") {
      $headlinelogo="<img src=\"uploads/header-logo.$ext\" alt=\"$user_longorg\" />";
    }
   }

  $headlinelogo=$user_longorg if ($headlinelogo eq "");

  #define other safe defaults
  nowdate();
  $sidelogo="";
  $sidelogodefault="";

     $text="000000";
  $bgcolor="FFFFFF";
     $link="0000FF";
    $alink="FF0000";
    $vlink="CC00CC";
    $hover="FF0000";
$formcolor="ffffff";
  $linkbullet="";
  $moretext="More...";

  # read in defaults for template
  # (could define stuff which is overridden in colours version -
  # subproc it with filename as variable?)
  read_style_file("${serverroot}$templatepos/${template}/defaults.txt");
  # start reading in proper "defaults" for this colour
  read_style_file("$templatedir/$colourscheme/defaults.txt");

  # do translation of template->styled template
  $hover=$alink if ($hover eq "");
  $sidelogo=$sidelogodefault if ($sidelogodefault ne "");

  $do_news = 2 if ($template_data =~ m~<!--\s*news.*section\s*-->.*?<!--\s*/\s*news.*section\s*-->~si);

  while ($template_data =~ m~(\[wiz-([a-z0-9\_\-]+)\])~ig) {
    $tag=$1;
    $tagtype=$2;
    $tag=~ s~\[~\\\[~g;
    $tag=~ s~\]~\\\]~g;
    $tagtype=lc($tagtype);
    $tagtype =~ s/colour/color/g;
    $temp_address=$user_address;
    $temp_address=~ s/\n/<br>\n/g;

    $user_shortorg=$user_longorg if ($user_shortorg eq "");

    $template_data =~ s~$tag~$user_shortorg~g if ($tagtype eq "ownername");
    $template_data =~ s~$tag~$user_longorg~g  if ($tagtype eq "fullname");
    $template_data =~ s~$tag~$user_contact~g  if ($tagtype eq "contactname");
    $template_data =~ s~$tag~$user_address~g  if ($tagtype eq "address");
    $template_data =~ s~$tag~$user_postcode~g if ($tagtype eq "postcode");
    $template_data =~ s~$tag~$user_phone~g    if ($tagtype eq "phone");
    $template_data =~ s~$tag~$user_fax~g      if ($tagtype eq "fax");
    $template_data =~ s~$tag~$user_email~g    if ($tagtype eq "email");

    $template_data =~ s~$tag~$address~g       if ($tagtype eq "fulladdress");

    if ($tagtype eq "headlinelogo") {
      if ($headlinelogo ne "") {
        $template_data =~ s~$tag~<h1>$headlinelogo</h1>~g;
      } else {
        $template_data =~ s~$tag~~g;
      }
    }

    if ($tagtype eq "headlinetag") {
      if ($headlinetag ne "") {
        $template_data =~ s~$tag~<h4>$headlinetag</h4>~g;
      } else {
        $template_data =~ s~$tag~~g;
      }
    }
    $template_data =~ s~$tag~$sidelogo~g              if ($tagtype eq "sidelogo");
    $template_data =~ s~$tag~$linkbullet~g            if ($tagtype eq "linkbullet");
    if ($tagtype eq "pagename") {
      $page_name=page_name("$file_to_create");
      $template_data =~ s~$tag~$page_name~g;
    }

    $template_data =~ s~$tag~$user_description~g if ($tagtype eq "description");
    $template_data =~ s~$tag~$user_keywords~g    if ($tagtype eq "keywords");

    $template_data =~ s~$tag~$year~g       if ($tagtype eq "year");
    $template_data =~ s~$tag~$month~g      if ($tagtype eq "month");
    $template_data =~ s~$tag~$day~g        if ($tagtype eq "day");
    $template_data =~ s~$tag~$weekday~g    if ($tagtype eq "weekday");
    $template_data =~ s~$tag~$date~g       if ($tagtype eq "date");
    $template_data =~ s~$tag~$hour~g       if ($tagtype eq "hour");
    $template_data =~ s~$tag~$minute~g     if ($tagtype eq "minute");
    $template_data =~ s~$tag~$second~g     if ($tagtype eq "second");
    $template_data =~ s~$tag~$pubdate~g    if ($tagtype eq "pubdate");
    $template_data =~ s~$tag~$lastupdate~g if ($tagtype eq "lastupdate");

    $template_data =~ s~$tag~$servername~g if ($tagtype eq "master-server");

    $template_data =~ s~$tag~$text~g    if ($tagtype eq "text");
    $template_data =~ s~$tag~$bgcolor~g if ($tagtype eq "bgcolor");
    $template_data =~ s~$tag~$link~g    if ($tagtype eq "link");
    $template_data =~ s~$tag~$alink~g   if ($tagtype eq "alink");
    $template_data =~ s~$tag~$vlink~g   if ($tagtype eq "vlink");
    $template_data =~ s~$tag~$hover~g   if ($tagtype eq "hover");

    if ($tagtype =~ m~^color([0-9a-z\_\-]+)~i) {
      $colorval=$1;
      $template_data =~ s~$tag~$colors{$colorval}~g;
    }

    if ($tagtype =~ m~^shadow([0-9a-z\_\-]+)~i) {
      $shadowval=$1;
      $template_data =~ s~$tag~$shadows{$shadowval}~g;
    }
  }

  #########################################################
  ## work through paragraph definitions to create "meat" ##
  #########################################################

  # paragraph list: headline, text, parastyle (address etc.), picture file, alignment, caption
  $maintext="<!-- paragraph list -->\n\n<!-- / paragraph list -->";

  $do_news=0;

  for ($para_loop=0;$para_loop<@para_title;$para_loop++) {
    $temp_para="";
    $paratype=lc($para_type[$para_loop]);
    $paratype="paragraph" if ($paratype eq "");
    $paratitle=$para_title[$para_loop];
    $paratext=$para_text[$para_loop];
    $para_start="\n<!-- #BeginEditable \"$paratype\" -->";
    $para_end="<!-- #EndEditable -->\n";

    if ($paratype eq "address") {
      $paratext=$address;
      $paratitle="Address";
      generate_paragraph();
      $maintext=~ s~\n<!-- / paragraph list -->~$para_start\n$temp_para\n$para_end<p>\n<!-- / paragraph list -->~;

    } elsif ($paratype eq "mailform") {
      generate_mailform();
      $maintext=~ s~\n<!-- / paragraph list -->~$para_start\n$temp_para\n$para_end<p>\n<!-- / paragraph list -->~;

    } elsif ($paratype eq "news") {
      if ($do_news == 0) {
        $maintext="<table width=\"100%\" cellpadding=\"5\" cellspacing=\"0\" border=\"0\"><tr valign=\"top\"><td>".$maintext."</td><td><!-- news section -->\n<h2>Latest news</h2>\n\n<!-- / news section --></td></tr></table>";
        $do_news = 1;
      }
      generate_paragraph();
      if ($do_news < 2) {
        $maintext=~ s~\n<!-- / news section -->~$para_start\n$temp_para\n$para_end<p>\n<!-- / news section -->~;
      } else {
        $template_data=~ s~\n<!--\s*/\s*news.*section\s*-->~$para_start\n$temp_para\n$para_end<p>\n<!-- / news section -->~;
      }

    } elsif ($paratype eq "links") {
      # panic, as I have not added that option yet!
    } else {
      generate_paragraph();
      $maintext=~ s~\n<!-- / paragraph list -->~$para_start\n$temp_para\n$para_end<p>\n<!-- / paragraph list -->~;
    }
  }
  unless (($paratype eq "news") && ($do_news == 2)) {
    $template_data=~ s~<!--\s?main\s?section\s?-->.*?<!--\s+/\s?main\s?section\s?-->~<!-- main section -->\n$maintext\n<!-- / main section -->~si;
  }

  # list of pages ("navigation")
  $err=0;
  open OUTPUT, ">$outputfile" or $err=1;
  if ($err==1) {
    headline("Error: unable to open '$file_to_create' file for writing","red","","An attempt to write to the file $file_to_create has failed; please contact <a href=\"mailto:$support_email\">$company support</a>");
    return 1;
  }
  print OUTPUT "temp file for link generation";
  close OUTPUT;
  if ($template_data=~ s~<!--\s?links\s*(type=\"?(.*?)\"?\s*)?-->.*?<!--\s+/\s?links\s?-->~<!-- links -->\n$links\n<!-- / links -->~si) {
    $link_type=$2;
    $link_type=lc($link_type);
    if ($link_type eq "horizontal") {
      link_generate(1);
    } else {
      link_generate(0);
    }
    $template_data=~ s~<!--\s?links.*?-->.*?<!--\s+/\s?links\s?-->~<!-- links -->\n$links\n<!-- / links -->~si;
  }

  # output result
  $err=0;
  open OUTPUT, ">$outputfile" or $err=1;
  if ($err==1) {
    headline("Error: unable to open '$file_to_create' file for writing","red","","An attempt to write to the file $file_to_create has failed; please contact <a href=\"mailto:$support_email\">$company support</a>");
    return 1;
  }

  print OUTPUT $template_data;
  close OUTPUT;
  system "chmod 664 $outputfile";

  # print some stuff to let people know this page has been updated (?)
  # headers and footers the responsibility of the calling code?
  headline("Page created","","","The page $file_to_create has been written to file.");
  print "\n<p>\n";
  #end
}

sub generate_paragraph {
  $parapic=$para_pic[$para_loop];
  $paracaption=$para_caption[$para_loop];
  $paraalign=lc($para_align[$para_loop]);
  $paralink=$para_morelink[$para_loop];
  $linktext=$moretext;
  $linktext="Contact us..." if ($paralink eq "contact_us.html");
  $linktext="About us..." if ($paralink eq "about_us.html");

  $para_count++;
  $parasize="2";
  $parasize="3" if ($para_count>1);
  $parasize="4" if ($paratype eq "news");

  $temp_para="<h$parasize>$paratitle</h$parasize>\n";
  $temp_para.="$paratext\n" if ($paratext ne "");
  $temp_para.="<br><!-- link --><a href=\"$paralink\">$linktext</a><!-- / link -->" if ($paralink ne "");
  if ($parapic ne "") {
    if ($paraalign eq "left") {
      $temp_para="<h$parasize>$paratitle</h$parasize>\n<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr valign=\"top\"><td align=\"center\">";
      #$temp_para.="</td><td align=\"center\">\n";
      $temp_para.="<!-- image align=\"left\" -->\n";
      $temp_para.="<a href=\"$paralink\">" if ($paralink ne "");
      $temp_para.="<img src=\"$parapic\" alt=";
      if ($paracaption ne "") {
        $temp_para.="\"$paracaption\"";
      } else {
        $temp_para.="\"[image]\"";
      }
      $temp_para.=">";
      $temp_para.="</a>" if ($paralink ne "");
      $temp_para.="<!-- / image -->";
      if ($paracaption ne "") {
        $temp_para.="\n<br>\n<!-- caption -->\n<small><i>$paracaption</i></small>\n<!-- / caption -->\n";
      }
      $temp_para.="</td><td>$paratext\n";
      $temp_para.="<br><!-- link --><a href=\"$paralink\">$linktext</a><!-- / link -->" if ($paralink ne "");
      $temp_para.="</td></tr></table>";


    } elsif ($paraalign eq "right") {

      $temp_para="<h$parasize>$paratitle</h$parasize>\n<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr valign=\"top\"><td>";

      $temp_para.="$paratext\n";
      $temp_para.="<br><!-- link --><a href=\"$paralink\">$linktext</a><!-- / link -->" if ($paralink ne "");
      $temp_para.="</td>";

      $temp_para.="<td align=\"center\">";
      $temp_para.="<!-- image align=\"right\" -->\n";
      $temp_para.="<a href=\"$paralink\">" if ($paralink ne "");
      $temp_para.="<img src=\"$parapic\" alt=";
      if ($paracaption ne "") {
        $temp_para.="\"$paracaption\"";
      } else {
        $temp_para.="\"[image]\"";
      }
      $temp_para.=">";
      $temp_para.="</a>" if ($paralink ne "");
      $temp_para.="<!-- / image -->";
      if ($paracaption ne "") {
        $temp_para.="\n<br>\n<!-- caption -->\n<small><i>$paracaption</i></small>\n<!-- / caption -->\n";
      }
      $temp_para.="</td></tr></table>";



      ##$temp_temp_para=$temp_para;
      ##$temp_para ="<td align=\"center\">";
      ##$temp_para.="<!-- image align=\"right\" -->\n<img src=\"$parapic\" alt=";
      ##if ($paracaption ne "") {
      ##  $temp_para.="\"$paracaption\"";
      ##} else {
      ##  $temp_para.="\"[image]\"";
      ##}
      ##$temp_para.=">";
      ##if ($paracaption ne "") {
      ##  $temp_para.="\n<br>\n<!-- caption -->\n<small><i>$paracaption</i></small>\n<!-- / caption -->\n";
      ##}
      ##$temp_para="<table width=\"100%\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\"><tr valign=\"top\"><td>$temp_temp_para</td>$temp_para</td></tr></table>";


    } else {
      $temp_para.="<!-- image align=\"center\" -->\n";
      $temp_para.="\n<p align=\"center\">\n";
      $temp_para.="<a href=\"$paralink\">" if ($paralink ne "");
      $temp_para.="<img src=\"$parapic\" alt=";
      if ($paracaption ne "") {
        $temp_para.="\"$paracaption\"";
      } else {
        $temp_para.="\"[image]\"";
      }
      $temp_para.=">";
      $temp_para.="</a>" if ($paralink ne "");
      $temp_para.="<!-- / image -->";
      if ($paracaption ne "") {
        $temp_para.="\n<br>\n<!-- caption -->\n<small><i>$paracaption</i></small>\n<!-- / caption -->\n";
      }
      $temp_para.="</p>";
    }
  }
  return $temp_para;
}

sub read_style_file {
my $stylefile=$_[0];
$err=0;
open STYLE, "<$stylefile" or $err=1;
if ($err==1){
    headline("Error: unable to read style file","red","",ucfirst($program)." was unable to read the style file $stylefile.   Please contact <a href=\"mailto:$support_email\">$company support</a>");
  return 1;
}

while ($line=<STYLE>) {
  chomp $line;
  if ($line =~ m~^([a-z0-9\-\_]+)\s+(.*?)$~i) {
      $tag=$1;
      $content=$2;
      $tag=lc($tag);
      $tag =~ s/colour/color/gi;
      if ($content =~ m~#[0-9a-z]+~i) {
        $content=substr($content,1);
      }

      if ($content =~ m~([0-9a-z]+)~i) {
        $text=$1      if ($tag eq "text");
        $bgcolor=$1   if ($tag eq "bgcolor");
        $link=$1      if ($tag eq "link");
        $alink=$1     if ($tag eq "alink");
        $vlink=$1     if ($tag eq "vlink");
        $hover=$1     if ($tag eq "hover");
        $formcolor=$1 if ($tag eq "form");

        if ($tag =~ m~^color([0-9a-z\_\-]+)~i) {
          $colorval=$1;
          $colors{$colorval}=$content;
        }

        if ($tag =~ m~^shadow([0-9a-z\-\_]+)~i) {
          $shadowval=$1;
          $shadows{$shadowval}=$content;
        }
      }
      $linkbullet=$content if ($tag eq "linkbullet");
      $sidelogodefault=$content if ($tag eq "side-logo-default");
      $moretext=$content if ($tag eq "moretext");
  }
}
close STYLE;
}

sub link_generate {
  my $link_style=$_[0];
  my $err=0;
  my $nude_name;
  opendir DIRLIST, "${homesite}" or $err=1;
  if ($err == 1) {
    headline("Error: unable to read directory","red","",ucfirst($program)." was unable to read your web site directory to generate a list of links.   Please contact <a href=\"mailto:$support_email\">$company support</a>");
    return 1;
  }
  my $templink="";
  $links="";
  hashed_page_list();
  while ($read_filename = readdir(DIRLIST)) {
    if (($read_filename =~ m~^(.+)\.html$~i) && (!($read_filename =~ m~^\.~s))) {
      $nude_name = $1;
      $templink="<a href=\"$read_filename\">";
      $page_name=page_name($read_filename);
      $templink.="$page_name</a>\n";
      $templink.="<br>\n" unless ($link_style == 1);
      if ($linkbullet ne "") {
        $templink=$linkbullet.$templink;
      }
      $links.=$templink if (($default_pages{"$nude_name"}==1) || ($user_link_prefs eq "all"));
    }
  }
}

sub hashed_page_list {
  $default_pages{"index"}=1;
  $default_pages{"about"}=1;
  $default_pages{"about_me"}=1;
  $default_pages{"about_us"}=1;
  $default_pages{"address"}=1;
  $default_pages{"contact"}=1;
  $default_pages{"contact_me"}=1;
  $default_pages{"contact_us"}=1;
  $default_pages{"email"}=1;
  $default_pages{"how_to_find_us"}=1;
  $default_pages{"driving"}=1;
  $default_pages{"tour"}=1;
  $default_pages{"tours"}=1;
  $default_pages{"travel"}=1;
  $default_pages{"trips"}=1;
  $default_pages{"visits"}=1;
  $default_pages{"calendar"}=1;
  $default_pages{"events"}=1;
  $default_pages{"cv"}=1;
  $default_pages{"archive"}=1;
  $default_pages{"awards"}=1;
  $default_pages{"docs"}=1;
  $default_pages{"documentation"}=1;
  $default_pages{"faq"}=1;
  $default_pages{"help"}=1;
  $default_pages{"how_to"}=1;
  $default_pages{"info"}=1;
  $default_pages{"information"}=1;
  $default_pages{"links"}=1;
  $default_pages{"features"}=1;
  $default_pages{"columns"}=1;
  $default_pages{"news"}=1;
  $default_pages{"news_and_press"}=1;
  $default_pages{"press"}=1;
  $default_pages{"reviews"}=1;
  $default_pages{"partners"}=1;
  $default_pages{"site"}=1;
  $default_pages{"sites"}=1;
  $default_pages{"support"}=1;
  $default_pages{"terms"}=1;
  $default_pages{"terms_of_use"}=1;
  $default_pages{"usage"}=1;
  $default_pages{"use"}=1;
  $default_pages{"privacy"}=1;
  $default_pages{"website"}=1;
  $default_pages{"welcome"}=1;
  $default_pages{"changes"}=1;
  $default_pages{"new"}=1;
  $default_pages{"updates"}=1;
  $default_pages{"whats_new"}=1;
  $default_pages{"business"}=1;
  $default_pages{"education"}=1;
  $default_pages{"charities"}=1;
  $default_pages{"community"}=1;
  $default_pages{"departments"}=1;
  $default_pages{"admin"}=1;
  $default_pages{"administration"}=1;
  $default_pages{"admissions"}=1;
  $default_pages{"office"}=1;
  $default_pages{"library"}=1;
  $default_pages{"staff"}=1;
  $default_pages{"students"}=1;
  $default_pages{"pupils"}=1;
  $default_pages{"parents"}=1;
  $default_pages{"children"}=1;
  $default_pages{"kids"}=1;
  $default_pages{"home"}=1;
  $default_pages{"family"}=1;
  $default_pages{"customers"}=1;
  $default_pages{"users"}=1;
  $default_pages{"hiring"}=1;
  $default_pages{"jobs"}=1;
  $default_pages{"previews"}=1;
  $default_pages{"prices"}=1;
  $default_pages{"products"}=1;
  $default_pages{"projects"}=1;
  $default_pages{"revision"}=1;
  $default_pages{"approach"}=1;
  $default_pages{"care"}=1;
  $default_pages{"copyright"}=1;
  $default_pages{"philosophy"}=1;
  $default_pages{"policies"}=1;
  $default_pages{"medical"}=1;
  $default_pages{"overview"}=1;
  $default_pages{"legal"}=1;
  $default_pages{"learning"}=1;
  $default_pages{"funding"}=1;
  $default_pages{"trust"}=1;
  $default_pages{"special_needs"}=1;
  $default_pages{"collections"}=1;
  $default_pages{"courses"}=1;
  $default_pages{"holidays"}=1;
  $default_pages{"exams"}=1;
  $default_pages{"revision"}=1;
  $default_pages{"art"}=1;
  $default_pages{"drawings"}=1;
  $default_pages{"photographs"}=1;
  $default_pages{"photos"}=1;
  $default_pages{"pictures"}=1;
  $default_pages{"screenshots"}=1;
  $default_pages{"images"}=1;
  $default_pages{"video"}=1;
  $default_pages{"slideshow"}=1;
  $default_pages{"animations"}=1;
  $default_pages{"computing"}=1;
  $default_pages{"download"}=1;
  $default_pages{"software"}=1;
  $default_pages{"hardware"}=1;
  $default_pages{"music"}=1;
  $default_pages{"performance"}=1;
  $default_pages{"books"}=1;
  $default_pages{"clubs"}=1;
  $default_pages{"crafts"}=1;
  $default_pages{"food"}=1;
  $default_pages{"games"}=1;
  $default_pages{"hobbies"}=1;
  $default_pages{"humanities"}=1;
  $default_pages{"it"}=1;
  $default_pages{"languages"}=1;
  $default_pages{"lifestyle"}=1;
  $default_pages{"reading"}=1;
  $default_pages{"recipes"}=1;
  $default_pages{"science"}=1;
  $default_pages{"sports"}=1;
  $default_pages{"toys"};
}

sub generate_mailform {
$para_count++;
$parasize="2";
$parasize="3" if ($para_count>1);
$mailbackcolor=$formcolor;
$mailbackcolor=$link  if ($mailbackcolor =~ m~ffffff~i);
$mailbackcolor=$text  if ($mailbackcolor =~ m~ffffff~i);
$mailbackcolor=$vlink if ($mailbackcolor =~ m~ffffff~i);
$temp_para="<h$parasize>Email form</h$parasize>\n";
$page_name=page_name("$file_to_create");
$temp_para.= "<center>\n";
$temp_para.= "<form method=\"post\" action=\"http://$servername/cgi-bin/.admin/templates/send_mail\">\n";
$temp_para.= "<input type=\"hidden\" name=\"mailto\" value=\"$user_email\">\n";
$temp_para.= "<input type=\"hidden\" name=\"mailsubject\" value=\"Message from '$page_name' page\">\n";
$temp_para.= "<input type=\"hidden\" name=\"linkto\" value=\"$baseurl$file_to_create\">\n";
$temp_para.= "\n";

$temp_para.= "<table cellpadding=\"2\" cellspacing=\"0\" border=\"0\"><tr><td  bgcolor=\"#$mailbackcolor\">\n";


$temp_para.= "<table width=\"300\" border=\"0\" cellpadding=\"2\" cellspacing=\"0\" style=\"border-color:#000000;\">\n";
$temp_para.= "<tr align=\"center\"><td colspan=\"2\" bgcolor=\"#$mailbackcolor\">\n";
$temp_para.= "<big><b><font color=\"#$alink\">Send a message to<br>$user_longorg</font></b></big></td></tr>\n";
$temp_para.= "\n";
$temp_para.= "<tr align=\"center\"><td colspan=\"2\" bgcolor=\"#ffffff\">\n";
$temp_para.= "<b><font color=\"#$mailbackcolor\">Your details:</font></b></td></tr>\n";
$temp_para.= "<tr align=\"center\" valign=\"top\"><td width=\"150\" bgcolor=\"#ffffff\">\n";
$temp_para.= "<font color=\"#$mailbackcolor\"><b>Name:</b></font><br><font face=\"courier new,courier\" size=\"3\">\n";
$temp_para.= "<input type=\"text\" name=\"name\" size=\"16\" maxlength=\"64\" value=\"\">\n";
$temp_para.= "</font></td><td width=\"150\" bgcolor=\"#ffffff\">\n";
$temp_para.= "<font color=\"#$mailbackcolor\"><b>Email address:</b></font><br><font face=\"courier new,courier\" size=\"3\">\n";
$temp_para.= "<input type=\"text\" name=\"mailfrom\" size=\"16\" maxlength=\"64\" value=\"\">\n";
$temp_para.= "</font></td></tr>\n";
$temp_para.= "\n";
$temp_para.= "<tr><td colspan=\"2\" bgcolor=\"#$mailbackcolor\">\n";
$temp_para.= "<img src=\"gfx/pad.gif\" alt=\"\" width=\"100\" height=\"1\">";
$temp_para.= "</td></tr>\n";
$temp_para.= "\n";
$temp_para.= "<tr align=\"center\"><td colspan=\"2\" bgcolor=\"#ffffff\"><font color=\"#$mailbackcolor\"><b>Message:</b></font><br><font face=\"courier new,courier\">\n";
$temp_para.= "<textarea name=\"message\" rows=\"10\" cols=\"32\" wrap=\"virtual\">";
$temp_para.= "</textarea></font></td></tr>\n";
$temp_para.= "\n";
$temp_para.= "<tr><td colspan=\"2\" bgcolor=\"#$mailbackcolor\">\n";
$temp_para.= "<img src=\"gfx/pad.gif\" alt=\"\" width=\"100\" height=\"1\">";
$temp_para.= "</td></tr>\n";
$temp_para.= "\n";
$temp_para.= "<tr valign=\"top\" align=\"center\">\n";
$temp_para.= "<td bgcolor=\"#ffffff\"><input type=\"submit\" value=\"Send message\"></td>\n";
$temp_para.= "<td bgcolor=\"#ffffff\"><input type=\"reset\" value=\"Wipe it clean\"></td></tr>\n";
$temp_para.= "</table>";

$temp_para.= "</td></tr></table>";

$temp_para.= "</form></center>\n";
}
