MayaChemTools

   1 package HTMLUtil;
   2 #
   3 # File: HTMLUtil.pm
   4 # Author: Manish Sud <msud@san.rr.com>
   5 #
   6 # Copyright (C) 2024 Manish Sud. All rights reserved.
   7 #
   8 # This file is part of MayaChemTools.
   9 #
  10 # MayaChemTools is free software; you can redistribute it and/or modify it under
  11 # the terms of the GNU Lesser General Public License as published by the Free
  12 # Software Foundation; either version 3 of the License, or (at your option) any
  13 # later version.
  14 #
  15 # MayaChemTools is distributed in the hope that it will be useful, but without
  16 # any warranty; without even the implied warranty of merchantability of fitness
  17 # for a particular purpose.  See the GNU Lesser General Public License for more
  18 # details.
  19 #
  20 # You should have received a copy of the GNU Lesser General Public License
  21 # along with MayaChemTools; if not, see <http://www.gnu.org/licenses/> or
  22 # write to the Free Software Foundation Inc., 59 Temple Place, Suite 330,
  23 # Boston, MA, 02111-1307, USA.
  24 #
  25 
  26 use strict;
  27 use Exporter;
  28 
  29 use vars qw(@ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
  30 
  31 @ISA = qw(Exporter);
  32 @EXPORT = qw(InsertHTMLTags SetupHTMLAlignmentBegin SetupHTMLAlignmentEnd SetupHTMLButtonRef SetupHTMLDivBegin SetupHTMLDivEnd SetupHTMLEmptyLines SetupHTMLPageHeader SetupHTMLHRef SetupHTMLPageEnd SetupHTMLPageTitle SetupHTMLStyleSheetTags SetupHTMLTableHeader SetupHTMLTableEnd SetupHTMLTableColumnHeader SetupHTMLTableColumnEnd SetupHTMLTableRowHeader SetupHTMLTableRowEnd SetupHTMLTableRowHeaderValue SetupHTMLTableRowDataValue SetupJavaScriptCmds SetupStrViewerJSInitCmd SetupStrViewerJMEApplet SetupStrViewerJmolApplet SetupStrViewerChimePlugIn SetupStrViewerChem3DActiveX SetupStrViewerChemDrawActiveX SetupStrViewerChemDrawPlugIn SetupStrViewerMarvinViewApplet SetupStrViewerAccelrysActiveX);
  33 @EXPORT_OK = qw();
  34 
  35 %EXPORT_TAGS = (all  => [@EXPORT, @EXPORT_OK]);
  36 
  37 # Default window size for various supported structure viewers...
  38 my($StrViewerWidth, $StrViewerHeight) = (250, 170);
  39 
  40 # Insert specfied tags into existing tag string...
  41 sub InsertHTMLTags {
  42   my($Tag, %TagsMap) = @_;
  43   my($NewTag, $TagName, $TagValue, $TagPart1, $TagPart2);
  44 
  45   $NewTag = $Tag; $TagPart1 = ""; $TagPart2 = "";
  46   ($TagPart1) = $Tag =~ /^(.*?)>/;
  47 
  48   if ($TagPart1 && length($TagPart1)) {
  49     $TagPart2 = $Tag;
  50     $TagPart2 =~ s/^(.*?)>//;
  51     if ($TagPart2 && length($TagPart2)) {
  52       for $TagName (keys %TagsMap) {
  53         $TagValue = $TagsMap{$TagName};
  54         $TagPart1 .= qq( $TagName="$TagValue" );
  55       }
  56       $NewTag = "${TagPart1}>${TagPart2}";
  57     }
  58   }
  59 
  60   return $NewTag;
  61 }
  62 
  63 sub SetupHTMLAlignmentBegin {
  64   my($AlignmentTag, $Alignment);
  65 
  66   $Alignment = (@_ == 1) ? $_[0] : "left";
  67   $AlignmentTag = qq(<$Alignment>\n);
  68 
  69   return $AlignmentTag;
  70 }
  71 
  72 sub SetupHTMLAlignmentEnd {
  73   my($AlignmentTag, $Alignment);
  74 
  75   $Alignment = (@_ == 1) ? $_[0] : "left";
  76   $AlignmentTag = qq(</$Alignment>\n);
  77 
  78   return $AlignmentTag;
  79 }
  80 
  81 # Setup a button reference...
  82 sub SetupHTMLButtonRef {
  83   my($ButtonLabel, $RefFile, $ButtonTags);
  84 
  85   ($ButtonLabel, $RefFile) = @_;
  86 
  87   $ButtonTags = qq(<input type="button" value="$ButtonLabel" onClick="document.location='$RefFile'">);
  88   return $ButtonTags;
  89 }
  90 
  91 sub SetupHTMLDivBegin {
  92   my($Id) = @_;
  93   my($DivTag);
  94 
  95   $DivTag = qq(<div id="$Id">\n);
  96 
  97   return $DivTag;
  98 }
  99 
 100 sub SetupHTMLDivEnd {
 101   my($DivTag);
 102 
 103   $DivTag = qq(</div>\n);
 104 
 105   return $DivTag;
 106 }
 107 sub SetupHTMLEmptyLines {
 108   my($LineCount, $Index, $EmptyLineTags);
 109 
 110   $LineCount = 1;
 111   $EmptyLineTags = qq(<p>&nbsp</p>);
 112   ($LineCount) = @_;
 113   if ($LineCount > 1) {
 114     for $Index (2 .. $LineCount) {
 115       $EmptyLineTags .= qq(<p>&nbsp</p>);
 116     }
 117   }
 118   return $EmptyLineTags;
 119 }
 120 
 121 # Setup HTML page header...
 122 sub SetupHTMLPageHeader {
 123   my($HeaderTitle, $Stylesheet, $JavaScript, $PageHeader);
 124 
 125   $HeaderTitle = "";  $Stylesheet = ""; $JavaScript = "";
 126   if (@_ == 3) {
 127     ($HeaderTitle, $Stylesheet, $JavaScript) = @_;
 128   }
 129   elsif (@_ == 2) {
 130     ($HeaderTitle, $Stylesheet) = @_;
 131   }
 132   else {
 133     ($HeaderTitle) = @_;
 134   }
 135   $PageHeader = qq(<html>\n);
 136   $PageHeader .= qq(<head>\n);
 137   $PageHeader .= qq(<title>$HeaderTitle</title>\n);
 138   $PageHeader .= qq(<meta http-equiv="content-type" content="text/html;charset=utf-8">\n);
 139   if ($Stylesheet) {
 140     $PageHeader .= qq(<link rel="stylesheet" type="text/css" href="$Stylesheet">\n);
 141   }
 142   if ($JavaScript) {
 143     $PageHeader .= qq(<script src="$JavaScript"></script>\n);
 144   }
 145   $PageHeader .= <<ENDPAGEHEADER;
 146 </head>
 147 <body>
 148 <p>&nbsp</p>
 149 ENDPAGEHEADER
 150 
 151   return $PageHeader;
 152 }
 153 
 154 # Setup page title...
 155 sub SetupHTMLPageTitle {
 156   my($Title, $Alignment, $PageTitle);
 157 
 158   $Alignment = "center";
 159   if (@_ == 2) {
 160     ($Title, $Alignment) = @_;
 161   }
 162   else {
 163     ($Title) = @_;
 164   }
 165 
 166   $PageTitle=<<ENDPAGETITLE;
 167 <$Alignment>
 168 <h3>$Title</h3>
 169 </$Alignment>
 170 ENDPAGETITLE
 171 
 172   return $PageTitle;
 173 }
 174 
 175 # Setup HTML page end...
 176 sub SetupHTMLPageEnd {
 177   my($PageEnd, $Footer);
 178 
 179   $Footer = "";
 180   if (@_ == 1) {
 181     ($Footer) = @_;
 182   }
 183   if ($Footer) {
 184     $Footer = qq(<span class="Footer">$Footer</span>);
 185   }
 186   $PageEnd=<<ENDPAGE;
 187 <center>
 188 <p>&nbsp</p>
 189 $Footer
 190 </center>
 191 </body>
 192 </html>
 193 ENDPAGE
 194 
 195   return $PageEnd;
 196 }
 197 
 198 # Setup HTML link tags...
 199 sub SetupHTMLHRef {
 200   my($Value, $RefFile, $HRef, $Title);
 201 
 202   $Title = "";
 203   if (@_ == 3) {
 204     ($Value, $RefFile, $Title) = @_;
 205   }
 206   else {
 207     ($Value, $RefFile) = @_;
 208   }
 209 
 210   $HRef = qq(<a href="$RefFile");
 211   if ($Title) {
 212     $HRef .= qq( title="$Title");
 213   }
 214   $HRef .= qq(>$Value</a>);
 215   return $HRef;
 216 }
 217 
 218 #
 219 sub SetupHTMLStyleSheetTags {
 220   my($StyleSheetTags);
 221 
 222   $StyleSheetTags=<<ENDSTYLESHEET;
 223 body
 224 {
 225     background-color: #ffffff;
 226     font-family: Verdana, Arial, Helvetica, sans-serif;
 227     font-size: 11px;
 228 }
 229 p
 230 {
 231     font-family: Verdana, Arial, Helvetica, sans-serif;
 232     font-size: 11px;
 233 }
 234 h1
 235 {
 236     font-family: Verdana, Arial, Helvetica, sans-serif;
 237     font-size: 25px;
 238     font-weight: bold;
 239     color: #0054aa;
 240 }
 241 h2
 242 {
 243     font-family: Verdana, Arial, Helvetica, sans-serif;
 244     font-size: 18px;
 245     font-weight: bold;
 246     color: #0054aa;
 247 }
 248 h3
 249 {
 250     font-family: Verdana, Arial, Helvetica, sans-serif;
 251     font-size: 14px;
 252     font-weight: bold;
 253     color: #0054aa;
 254 }
 255 b
 256 {
 257     font-weight: bold;
 258 }
 259 td
 260 {
 261     font-family: Verdana, Arial, Helvetica, sans-serif;
 262     font-size: 11px;
 263 }
 264 th
 265 {
 266     font-family: Verdana, Arial, Helvetica, sans-serif;
 267     font-size: 11px;
 268     color: #0054aa;
 269     font-weight: bold;
 270 }
 271 .box {
 272   border-color: #000000;
 273   border-style: solid;
 274   border-top-width: 1px;
 275   border-bottom-width: 1px;
 276   border-left-width: 1px;
 277   border-right-width: 1px;
 278 }
 279 a
 280 {
 281     color: #0000bb;
 282     text-decoration: none;
 283     font-family: Verdana, Arial, Helvetica, sans-serif;
 284     font-size: 11px;
 285 }
 286 a:hover
 287 {
 288     color: #ff0000;
 289 }
 290 #tablenav {
 291     font-family: Verdana, Arial, Helvetica, sans-serif;
 292     font-size: 11px;
 293 }
 294 #tablenav td
 295 {
 296     font-family: Verdana, Arial, Helvetica, sans-serif;
 297     font-size: 11px;
 298 }
 299 #tablenav th
 300 {
 301     font-family: Verdana, Arial, Helvetica, sans-serif;
 302     font-size: 11px;
 303     font-weight: bold;
 304 }
 305 #tablenav a
 306 {
 307     color: #0000bb;
 308     text-decoration: none;
 309     font-family: Verdana, Arial, Helvetica, sans-serif;
 310     font-size: 11px;
 311 }
 312 #tablenav a:hover
 313 {
 314     color: #ff0000;
 315 }
 316 .footer
 317 {
 318     font-family: Arial, Verdana, Helvetica, sans-serif;
 319     font-size: 9px;
 320     color: #888888;
 321 }
 322 ENDSTYLESHEET
 323 
 324   return $StyleSheetTags;
 325 }
 326 
 327 # Setup HTML table header...
 328 sub SetupHTMLTableHeader {
 329   my($TableHeader, $BorderWidth, $CellPadding, $CellSpacing, $Width, $Height);
 330 
 331   $BorderWidth = 1; $CellPadding = 2; $CellSpacing = 0; $Width = ""; $Height = "";
 332   if (@_ == 5) {
 333     ($BorderWidth, $CellPadding, $CellSpacing, $Width, $Height) = @_;
 334   }
 335   elsif (@_ == 4) {
 336     ($BorderWidth, $CellPadding, $CellSpacing, $Width) = @_;
 337   }
 338   elsif (@_ == 3) {
 339     ($BorderWidth, $CellPadding, $CellSpacing) = @_;
 340   }
 341   elsif (@_ == 2) {
 342     ($BorderWidth, $CellPadding) = @_;
 343   }
 344   elsif (@_ = 1) {
 345     ($BorderWidth) = @_;
 346   }
 347   $TableHeader = qq(<table border=$BorderWidth cellpadding=$CellPadding cellspacing=$CellSpacing);
 348   if ($Width) {
 349     $TableHeader .= qq( width=$Width);
 350   }
 351   if ($Height) {
 352     $TableHeader .= qq( height=$Height);
 353   }
 354   $TableHeader .= qq(>\n);
 355 
 356   return $TableHeader;
 357 }
 358 
 359 # Setup HTML table end...
 360 sub SetupHTMLTableEnd {
 361   my($TableEnd);
 362 
 363   $TableEnd=<<ENDTABLE;
 364 </table>
 365 ENDTABLE
 366 
 367   return $TableEnd;
 368 }
 369 
 370 # Setup HTML table column header...
 371 sub SetupHTMLTableColumnHeader {
 372   my($BgColor, $Width, $ColumnHeader);
 373 
 374   $BgColor = ""; $Width = "";
 375   if (@_ == 1) {
 376     ($BgColor) = @_;
 377   }
 378   elsif (@_ == 2) {
 379     ($BgColor, $Width) = @_;
 380   }
 381   $ColumnHeader = qq(<td);
 382   if ($BgColor) {
 383     $ColumnHeader .= qq( bgcolor="$BgColor")
 384   }
 385   if ($Width) {
 386     $ColumnHeader .= qq( width="$Width")
 387   }
 388   $ColumnHeader .= qq(>);
 389   return $ColumnHeader;
 390 }
 391 
 392 # Setup HTML table column end...
 393 sub SetupHTMLTableColumnEnd {
 394   my($ColumnEnd);
 395 
 396   $ColumnEnd = qq(</td>);
 397   return $ColumnEnd;
 398 }
 399 
 400 # Setup HTML table row header...
 401 sub SetupHTMLTableRowHeader {
 402   my($RowHeader, $HAlignment, $BgColor, $VAlignment);
 403 
 404   $HAlignment = "center"; $BgColor = ""; $VAlignment = "top";
 405   if (@_ == 3) {
 406     ($HAlignment, $BgColor, $VAlignment) = @_;
 407   }
 408   elsif (@_ == 2) {
 409     ($HAlignment, $BgColor) = @_;
 410   }
 411   elsif (@_ == 1) {
 412     ($HAlignment) = @_;
 413   }
 414   if ($BgColor) {
 415     $RowHeader = qq(<tr bgcolor="$BgColor" align="$HAlignment" valign="$VAlignment">);
 416   }
 417   else {
 418     $RowHeader = qq(<tr align="$HAlignment" valign="$VAlignment">);
 419   }
 420 
 421   return $RowHeader;
 422 }
 423 
 424 # Setup HTML table row end...
 425 sub SetupHTMLTableRowEnd {
 426   my($RowEnd);
 427 
 428   $RowEnd = qq(</tr>\n);
 429   return $RowEnd;
 430 }
 431 
 432 # Setup HTML table header values...
 433 sub SetupHTMLTableRowHeaderValue {
 434   my($HeaderValue, $Value);
 435 
 436   $Value = "";
 437   if (@_ >= 1) {
 438     ($Value) = @_;
 439   }
 440   if (defined $Value && length $Value) {
 441     $HeaderValue = qq(<th>$Value</th>);
 442   }
 443   else {
 444     $HeaderValue = qq(<th>&nbsp</th>);
 445   }
 446   return $HeaderValue;
 447 }
 448 
 449 # Setup HTML table row data values...
 450 sub SetupHTMLTableRowDataValue {
 451   my($RowValues, $Value, $BgColor, $FontColor, $FontBold, $FontBoldTag1, $FontBoldTag2);
 452 
 453   $Value = ""; $BgColor = ""; $FontColor = ""; $FontBold = "";
 454   if (@_ == 1) {
 455     ($Value) = @_;
 456   }
 457   elsif (@_ == 2) {
 458     ($Value, $BgColor) = @_;
 459   }
 460   elsif (@_ == 3) {
 461     ($Value, $BgColor, $FontColor) = @_;
 462   }
 463   elsif (@_ == 4) {
 464     ($Value, $BgColor, $FontColor, $FontBold) = @_;
 465   }
 466   if (!(defined $Value && length $Value)) {
 467     $Value = qq(&nbsp);
 468   }
 469   $FontBoldTag1 = ""; $FontBoldTag2 = "";
 470   if ($FontBold) {
 471     $FontBoldTag1 = qq(<b>);
 472     $FontBoldTag2 = qq(</b>);
 473   }
 474   if ($BgColor || $FontColor) {
 475     my ($BgColorTag, $FontTag1, $FontTag2);
 476 
 477     $BgColorTag = "";
 478     if ($BgColor) {
 479       $BgColorTag = qq( bgcolor="$BgColor");
 480     }
 481     $FontTag1 = ""; $FontTag2 = "";
 482     if ($FontColor) {
 483       $FontTag1 = qq(<font color="$FontColor">);
 484       $FontTag2 = qq(</font>);
 485     }
 486     if ($FontBold) {
 487       $RowValues = "<td" . $BgColorTag . ">" . $FontBoldTag1 . $FontTag1 . "$Value" . $FontTag2 . $FontBoldTag2 .  "</td>";
 488     }
 489     else {
 490       $RowValues = "<td" . $BgColorTag . ">" . $FontTag1 . "$Value" . $FontTag2 .  "</td>";
 491     }
 492   }
 493   elsif ($FontBold) {
 494     $RowValues = "<td>" . $FontBoldTag1 . "$Value" . $FontBoldTag2 . "</td>";
 495   }
 496   else {
 497     $RowValues = qq(<td>$Value</td>);
 498   }
 499   return $RowValues;
 500 }
 501 
 502 # Setup Java scripts command...
 503 sub SetupJavaScriptCmds {
 504   my(@JSCmdList) = @_;
 505   my($JSTags, $JSCmd);
 506 
 507   $JSTags = qq(<script>\n);
 508   for $JSCmd (@JSCmdList) {
 509     $JSTags .= qq($JSCmd\n);
 510   }
 511   $JSTags .= qq(</script>\n);
 512 
 513   return $JSTags;
 514 }
 515 
 516 # Setup Java script initialize command...
 517 sub SetupStrViewerJSInitCmd {
 518   my($StrViewerType, $CodeBase) = @_;
 519   my($JSTag);
 520 
 521   $JSTag = "";
 522   if ($StrViewerType eq "Jmol") {
 523     $JSTag = qq(<script>jmolInitialize("$CodeBase", "JmolApplet.jar");</script>\n);
 524   }
 525   elsif ($StrViewerType eq "ChemDrawPlugIn" || $StrViewerType eq "ChemDrawActiveX") {
 526     $JSTag = qq(<script>cd_includeWrapperFile("$CodeBase/");</script>\n);
 527   }
 528   elsif ($StrViewerType eq "Chem3DActiveX") {
 529   }
 530   return $JSTag;
 531 }
 532 
 533 
 534 # Setup Jmol applet...
 535 sub SetupStrViewerJmolApplet {
 536   my($MolString, $CodeBase, $ParamsMapRef, %ParamsMap, $AppletTags, $JavaScriptTags, $ReturnTags, $Name, $Code, $Archive, $Width, $Height, $ParamName, $ParamValue, $JSFileName, $UseJavaScript);
 537   my($ProgressBar, $ProgressColor, $BoxMessage, $BoxFgColor, $BoxBgColor, $BgColor, $JMolScript);
 538 
 539   $AppletTags = "";  $JavaScriptTags = ""; $ReturnTags = "";
 540   $ParamsMapRef = ""; %ParamsMap = ();
 541   $Name = "Jmol"; $Code = "JmolApplet"; $Archive = "JmolApplet.jar"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 542   $ProgressBar = "true"; $ProgressColor = "#0000ff"; $BgColor = "#000000";
 543   $BoxMessage = "Setting up JmolApplet..."; $BoxFgColor = "#000000"; $BoxBgColor = "#ffffff";
 544   $UseJavaScript = 0; $JSFileName = "";
 545   $JMolScript = "select *; set frank off; wireframe on; spacefill off";
 546 
 547  PARAMS: {
 548     if (@_ == 3) { ($MolString, $CodeBase, $ParamsMapRef) = @_; last PARAMS; }
 549     ($MolString, $CodeBase) = @_;
 550   }
 551 
 552   if ($ParamsMapRef) {
 553     %ParamsMap = %$ParamsMapRef;
 554     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 555     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 556     if (exists $ParamsMap{code} ) { $Code = $ParamsMap{code}; $ParamsMap{code} = ""; }
 557     # if (exists $ParamsMap{archive} ) { $Archive = $ParamsMap{archive}; $ParamsMap{archive} = ""; }
 558     if (exists $ParamsMap{archive} ) { $ParamsMap{archive} = ""; }
 559     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 560     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 561     if (exists $ParamsMap{progressbar} ) { $ProgressBar = $ParamsMap{progressbar}; $ParamsMap{progressbar} = ""; }
 562     if (exists $ParamsMap{progresscolor} ) { $ProgressColor = $ParamsMap{progresscolor}; $ParamsMap{progresscolor} = ""; }
 563     if (exists $ParamsMap{boxmessage} ) { $BoxMessage = $ParamsMap{boxmessage}; $ParamsMap{boxmessage} = ""; }
 564     if (exists $ParamsMap{script} ) { $JMolScript = $ParamsMap{script}; $ParamsMap{script} = ""; }
 565     if (exists $ParamsMap{bgcolor}) {
 566       $BgColor = $ParamsMap{bgcolor};
 567       if (length($BgColor)) {
 568         if ($BgColor =~ /black/i || $BgColor =~ /#000000/ ) {
 569           $BoxFgColor = "#ffffff";
 570           $BoxBgColor = "#000000";
 571         }
 572       }
 573     }
 574     if (exists $ParamsMap{boxbgcolor} ) { $BoxBgColor = $ParamsMap{boxbgcolor}; $ParamsMap{boxbgcolor} = ""; }
 575     if (exists $ParamsMap{boxfgcolor} ) { $BoxFgColor = $ParamsMap{boxfgcolor}; $ParamsMap{boxfgcolor} = ""; }
 576   }
 577 
 578   $MolString =~ s/(\r\n)|(\r)|(\n)/|/g;
 579   if ($UseJavaScript) {
 580     $JavaScriptTags = qq(\n<script>\n);
 581     my($Size) = ($Width > $Height ) ? $Width : $Height;
 582     $JavaScriptTags .= qq(var $Name = \n);
 583     my(@MolLines) = split /\|/, $MolString;
 584     my($LineIndex);
 585     $JavaScriptTags .= qq("$MolLines[0]\\n");
 586     for $LineIndex (1 .. $#MolLines) {
 587       $JavaScriptTags .= qq( + \n"$MolLines[$LineIndex]\\n");
 588     }
 589     $JavaScriptTags .= qq(;\n);
 590     $JavaScriptTags .= qq(jmolSetAppletColor("$BgColor", "$BoxBgColor", "$BoxFgColor", "$ProgressColor");\n);
 591     # "set frank off turns" off JMol logo. For wireframe display; use wireframe on; spacefill off...
 592     # $JavaScriptTags .= qq(jmolAppletInline($Size, $Name);\n);
 593     $JavaScriptTags .= qq(jmolAppletInline([$Width,$Height], $Name, \"$JMolScript\");\n);
 594     $JavaScriptTags .= qq(</script>\n);
 595     $ReturnTags = $JavaScriptTags;
 596   }
 597   else {
 598     # Setup applet header...
 599     $AppletTags = qq(\n<applet name="$Name" id="$Name" code="$Code" archive="$Archive" codebase="$CodeBase" width="$Width" height="$Height">\n);
 600 
 601     # Setup molecule data...
 602     $AppletTags .= qq(<param name="loadInline" value="$MolString">\n);
 603 
 604     # Setup prograss bar...
 605     $AppletTags .= qq(<param name="progressbar" value="$ProgressBar">\n<param name="progresscolor" value="$ProgressColor">\n<param name="boxmessage" value="$BoxMessage">\n<param name="boxbgcolor" value="$BoxBgColor">\n<param name="boxfgcolor" value="$BoxFgColor">\n);
 606 
 607     # "set frank off turns" off JMol logo. For wireframe display; use wireframe on; spacefill off...
 608     $AppletTags .= qq(<param name="script" value="$JMolScript">);
 609 
 610     #Setup other parameters...
 611     for $ParamName (sort keys %ParamsMap) {
 612       $ParamValue = $ParamsMap{$ParamName};
 613       if (length $ParamValue) {
 614         $AppletTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 615       }
 616     }
 617     #Finish it up...
 618     $AppletTags .= qq(</applet>\n);
 619     $ReturnTags = $AppletTags;
 620   }
 621   return $ReturnTags;
 622 }
 623 
 624 # Setup JME applet...
 625 sub SetupStrViewerJMEApplet {
 626   my($MolString, $CodeBase, $ParamsMapRef, %ParamsMap, $AppletTags, $Name, $Code, $Archive, $Width, $Height, $ParamName, $ParamValue);
 627   my($Options);
 628 
 629   $AppletTags = "";  $ParamsMapRef = ""; %ParamsMap = ();
 630   $Name = "JME"; $Code = "JME"; $Archive = "JME.jar"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 631   $Options = "depict";
 632 
 633   if (@_ == 3) {
 634     ($MolString, $CodeBase, $ParamsMapRef) = @_;
 635   }
 636   else {
 637     ($MolString, $CodeBase) = @_;
 638   }
 639   $MolString =~ s/(\r\n)|(\r)|(\n)/|/g;
 640 
 641   if ($ParamsMapRef) {
 642     %ParamsMap = %$ParamsMapRef;
 643     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 644     if (exists $ParamsMap{code} ) { $Code = $ParamsMap{code}; $ParamsMap{code} = ""; }
 645     if (exists $ParamsMap{archive} ) { $Archive = $ParamsMap{archive}; $ParamsMap{archive} = ""; }
 646     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 647     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 648     if (exists $ParamsMap{options} ) { $Options = $ParamsMap{options}; $ParamsMap{options} = ""; }
 649   }
 650 
 651   # Setup applet header...
 652   $AppletTags = qq(\n<applet name="$Name" id="$Name" code="$Code" archive="$Archive" codebase="$CodeBase" width="$Width" height="$Height">\n);
 653 
 654   # Setup molecule data...
 655   $AppletTags .= qq(<param name="mol" value="$MolString">\n<param name="options" value="$Options">\n);
 656 
 657   #Setup other parameters...
 658   for $ParamName (sort keys %ParamsMap) {
 659     $ParamValue = $ParamsMap{$ParamName};
 660     if (length $ParamValue) {
 661       $AppletTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 662     }
 663   }
 664 
 665   #Finish it up...
 666   $AppletTags .= qq(</applet>\n);
 667 
 668   return $AppletTags;
 669 }
 670 
 671 # Setup MarvinView applet...
 672 sub SetupStrViewerMarvinViewApplet {
 673   my($MolString, $CodeBase, $ParamsMapRef, %ParamsMap, $AppletTags, $JavaScriptTags, $ReturnTags, $Name, $Code, $Archive, $Width, $Height, $ParamName, $NavMode, $ParamValue, $JSFileName, $UseJavaScript, $MarvinJVM);
 674 
 675   $AppletTags = "";  $JavaScriptTags = ""; $ReturnTags = "";
 676   $ParamsMapRef = ""; %ParamsMap = ();
 677   $Name = "MView"; $Code = "MView"; $Archive = "marvin.jar"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 678   $NavMode = "zoom";
 679   $UseJavaScript = 0; $JSFileName = ""; $MarvinJVM = "";
 680 
 681   if (@_ == 3) {
 682     ($MolString, $CodeBase, $ParamsMapRef) = @_;
 683   }
 684   else {
 685     ($MolString, $CodeBase) = @_;
 686   }
 687 
 688   if ($ParamsMapRef) {
 689     %ParamsMap = %$ParamsMapRef;
 690     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 691     if (exists $ParamsMap{marvin_jvm} ) { $MarvinJVM = $ParamsMap{marvin_jvm}; $ParamsMap{marvin_jvm} = ""; }
 692     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 693     if (exists $ParamsMap{code} ) { $Code = $ParamsMap{code}; $ParamsMap{code} = ""; }
 694     if (exists $ParamsMap{archive} ) { $Archive = $ParamsMap{archive}; $ParamsMap{archive} = ""; }
 695     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 696     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 697     if (exists $ParamsMap{bgcolor}) {
 698       $ParamsMap{background} = "$ParamsMap{bgcolor}";
 699       $ParamsMap{molbg} = "$ParamsMap{bgcolor}";
 700       $ParamsMap{bgcolor} = "";
 701     }
 702     if (exists $ParamsMap{navmode}) {
 703       $NavMode = $ParamsMap{navmode};
 704       $ParamsMap{navmode} = "";
 705     }
 706   }
 707   $MolString =~ s/(\r\n)|(\r)|(\n)/\\/g;
 708   if ($UseJavaScript) {
 709     $JavaScriptTags = qq(\n<script>\n);
 710     $JavaScriptTags .= qq(var marvin_name = "$Name";\n);
 711     $JavaScriptTags .= qq(var marvin_jvm = "$MarvinJVM";\n);
 712 
 713     $JavaScriptTags .= qq(mview_begin("$CodeBase", $Width, $Height);\n);
 714 
 715     $JavaScriptTags .= qq(var $Name = \n);
 716     my(@MolLines) = split /\\/, $MolString;
 717     my($LineIndex);
 718     $JavaScriptTags .= qq("$MolLines[0]\\n");
 719     for $LineIndex (1 .. $#MolLines) {
 720       $JavaScriptTags .= qq( + \n"$MolLines[$LineIndex]\\n");
 721     }
 722     $JavaScriptTags .= qq(;\n);
 723     $JavaScriptTags .= qq(mview_param("mol", $Name);\n);
 724 
 725     $JavaScriptTags .= qq(mview_param("navmode", "$NavMode");\n);
 726 
 727     for $ParamName (sort keys %ParamsMap) {
 728       $ParamValue = $ParamsMap{$ParamName};
 729       if (length $ParamValue) {
 730         $JavaScriptTags .= qq(mview_param("$ParamName", "$ParamValue");\n);
 731       }
 732     }
 733     $JavaScriptTags .= qq(mview_end();\n);
 734     $JavaScriptTags .= qq(</script>\n);
 735     $ReturnTags = $JavaScriptTags;
 736   }
 737   else {
 738     # Setup applet header...
 739     $AppletTags = qq(\n<applet name="$Name" id="$Name" code="$Code" archive="$Archive" codebase="$CodeBase" width="$Width" height="$Height">\n);
 740 
 741     # Setup molecule data...
 742     $AppletTags .= qq(<param name="mol" value="$MolString">\n);
 743 
 744     $AppletTags .= qq(<param name="navmode" value="$NavMode">\n);
 745 
 746     #Setup other parameters...
 747     for $ParamName (sort keys %ParamsMap) {
 748       $ParamValue = $ParamsMap{$ParamName};
 749       if (length $ParamValue) {
 750         $AppletTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 751       }
 752     }
 753     $AppletTags .= qq(</applet>\n);
 754     $ReturnTags = $AppletTags;
 755   }
 756   return $ReturnTags;
 757 }
 758 
 759 # Setup MDL chime plug-in...
 760 sub SetupStrViewerChimePlugIn {
 761   my($MolFile, $ParamsMapRef, %ParamsMap, $Width, $Height, $ParamName, $ParamValue, $PlugInTags);
 762   my($Display2D);
 763 
 764   $PlugInTags = ""; $ParamsMapRef = ""; %ParamsMap = ();
 765   $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 766   $Display2D = "true";
 767 
 768   if (@_ == 2) {
 769     ($MolFile, $ParamsMapRef) = @_;
 770   }
 771   else {
 772     ($MolFile) = @_;
 773   }
 774 
 775   if ($ParamsMapRef) {
 776     %ParamsMap = %$ParamsMapRef;
 777     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 778     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 779     if (exists $ParamsMap{display2d} ) { $Display2D = $ParamsMap{display2d}; $ParamsMap{display2d} = ""; }
 780   }
 781   # Start plug-in tag...
 782   $PlugInTags = qq(<embed src="$MolFile" width="$Width" height="$Height" display2d="$Display2D");
 783 
 784   #Setup other parameters...
 785   for $ParamName (sort keys %ParamsMap) {
 786     $ParamValue = $ParamsMap{$ParamName};
 787     if (length $ParamValue) {
 788       $PlugInTags .= qq( $ParamName="$ParamValue");
 789     }
 790   }
 791 
 792   # Finish it off...
 793   $PlugInTags .= qq( >);
 794 
 795   return $PlugInTags;
 796 }
 797 
 798 # Setup Accelrys ViewerActiveX controls...
 799 sub SetupStrViewerAccelrysActiveX {
 800   my($MolFile, $ParamsMapRef, %ParamsMap, $ActiveXTags, $Name, $Width, $Height, $ParamName, $ParamValue);
 801   my($ClassId, $Convert2DTo3D, $Style, $Mouse);
 802 
 803   $ActiveXTags = "";  $ParamsMapRef = ""; %ParamsMap = ();
 804   $Name = "ViewerActiveX"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 805   $ClassId = "clsid:90690CB6-BC07-11D4-AEF7-0050DA948176";
 806   $Convert2DTo3D = "0";
 807   $Mouse = 4;
 808 
 809   if (@_ == 2) {
 810     ($MolFile, $ParamsMapRef) = @_;
 811   }
 812   else {
 813     ($MolFile) = @_;
 814   }
 815 
 816   if ($ParamsMapRef) {
 817     %ParamsMap = %$ParamsMapRef;
 818     if (exists $ParamsMap{classid} ) { $ClassId = $ParamsMap{classid}; $ParamsMap{classid} = ""; }
 819     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 820     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 821     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 822     if (exists $ParamsMap{Convert2Dto3D} ) { $Convert2DTo3D = $ParamsMap{Convert2Dto3D}; $ParamsMap{Convert2Dto3D} = ""; }
 823     if (exists $ParamsMap{Mouse} ) { $Mouse = $ParamsMap{Mouse}; $ParamsMap{Mouse} = ""; }
 824     if (exists $ParamsMap{bgcolor} ) {
 825       my($BgColor) = $ParamsMap{bgcolor};
 826       $ParamsMap{bgcolor} = "";
 827       # Get OLE color value: &aabbggrr&
 828       # Set it to white for now...
 829       $BgColor = "16777215";
 830       $ParamsMap{BackColor} = "$BgColor";
 831     }
 832   }
 833   $Style = qq(style="height: ) . $Height . qq(px; width: ) . $Width . qq(px");
 834 
 835   # Setup object header...
 836   $ActiveXTags = qq(\n<object id="$Name" classid="$ClassId" $Style>\n);
 837 
 838   # Setup molecule data...
 839   $ActiveXTags .= qq(<param name="Source" value="$MolFile">\n<param name="Mouse" value="$Mouse">\n<param name="Convert2Dto3D" value="$Convert2DTo3D">\n);
 840 
 841   #Setup other parameters...
 842   for $ParamName (sort keys %ParamsMap) {
 843     $ParamValue = $ParamsMap{$ParamName};
 844     if (length $ParamValue) {
 845       $ActiveXTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 846     }
 847   }
 848 
 849   # Finish it off...
 850   $ActiveXTags .= qq(</object>\n);
 851 
 852   return $ActiveXTags;
 853 }
 854 
 855 # Setup Chem3D ActiveX 8.0 control...
 856 sub SetupStrViewerChem3DActiveX {
 857   my($MolFile, $ParamsMapRef, %ParamsMap, $ActiveXTags, $JavaScriptTags, $ReturnTags, $Name, $Width, $Height, $ParamName, $ParamValue);
 858   my($ClassId, $Style, $DisplayType, $RotationBars, $MovieController, $JSFileName, $UseJavaScript);
 859 
 860   $ActiveXTags = ""; $JavaScriptTags = ""; $ReturnTags = "";
 861   $ParamsMapRef = ""; %ParamsMap = ();
 862   $Name = "Chem3D"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 863   $ClassId = "clsid:B7A6B8E4-3E8B-4D18-8F8F-B4057EFC784B";
 864   $DisplayType = "Ball&Stick";
 865   $RotationBars = "false";
 866   $MovieController = "false";
 867 
 868   if (@_ == 2) {
 869     ($MolFile, $ParamsMapRef) = @_;
 870   }
 871   else {
 872     ($MolFile) = @_;
 873   }
 874 
 875   if ($ParamsMapRef) {
 876     %ParamsMap = %$ParamsMapRef;
 877     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 878     if (exists $ParamsMap{classid} ) { $ClassId = $ParamsMap{classid}; $ParamsMap{classid} = ""; }
 879     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 880     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 881     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 882     if (exists $ParamsMap{displaytype} ) { $DisplayType = $ParamsMap{displaytype}; $ParamsMap{displaytype} = ""; }
 883     if (exists $ParamsMap{rotationbars} ) { $RotationBars = $ParamsMap{rotationbars}; $ParamsMap{rotationbars} = ""; }
 884     if (exists $ParamsMap{moviecontroller} ) { $MovieController = $ParamsMap{moviecontroller}; $ParamsMap{moviecontroller} = ""; }
 885   }
 886   $Style = qq(style="height: ) . $Height . qq(px; width: ) . $Width . qq(px");
 887 
 888   if ($UseJavaScript) {
 889     #Setup parameters...
 890     my($Params) = "";
 891     for $ParamName (sort keys %ParamsMap) {
 892       $ParamValue = $ParamsMap{$ParamName};
 893       if (length $ParamValue) {
 894         $Params .= qq( $ParamName='$ParamValue');
 895       }
 896     }
 897     $JavaScriptTags = qq(\n<script>\n);
 898     $JavaScriptTags .= qq(c3d_insert3dStr("name='$Name' src='$MolFile' width='$Width' height='$Height' displaytype='$DisplayType' rotation_bars_visible='$RotationBars' movie_controller_visible='$MovieController' $Params");\n);
 899     $JavaScriptTags .= qq(</script>\n);
 900     $ReturnTags = $JavaScriptTags;
 901   }
 902   else {
 903     # Setup object header...
 904     $ActiveXTags = qq(\n<object id="$Name" classid="$ClassId" $Style>\n);
 905 
 906     # Setup molecule data...
 907     $ActiveXTags .= qq(<param name="src" value="$MolFile">\n<param name="displaytype" value="$DisplayType">\n<param name="rotationbars" value="$RotationBars">\n<param name="moviecontroller" value="$MovieController">\n);
 908 
 909     #Setup other parameters...
 910     for $ParamName (sort keys %ParamsMap) {
 911       $ParamValue = $ParamsMap{$ParamName};
 912       if (length $ParamValue) {
 913         $ActiveXTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 914       }
 915     }
 916     $ActiveXTags .= qq(</object>\n);
 917     $ReturnTags = $ActiveXTags;
 918   }
 919   return $ReturnTags;
 920 }
 921 
 922 # Setup ChemDraw ActiveX 8.0 control...
 923 # Problems: "bgcolor" parameter doesn't work.
 924 sub SetupStrViewerChemDrawActiveX {
 925   my($MolFile, $ParamsMapRef, %ParamsMap, $ActiveXTags, $JavaScriptTags, $ReturnTags, $Name, $Width, $Height, $ParamName, $ParamValue);
 926   my($ClassId, $Style, $ViewOnly, $ShrinkToFit, $ShowToolsWhenVisible, $JSFileName, $UseJavaScript);
 927 
 928   $ActiveXTags = "";  $JavaScriptTags = ""; $ReturnTags = "";
 929   $ParamsMapRef = ""; %ParamsMap = ();
 930   $Name = "ChemDraw"; $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 931   $ClassId = "clsid:51A649C4-3E3D-4557-9BD8-B14C0AD44B0C";
 932   $ViewOnly = "1"; $JavaScriptTags = "";
 933   $ShrinkToFit = "1";
 934   $ShowToolsWhenVisible = "1";
 935 
 936   if (@_ == 2) {
 937     ($MolFile, $ParamsMapRef) = @_;
 938   }
 939   else {
 940     ($MolFile) = @_;
 941   }
 942 
 943   if ($ParamsMapRef) {
 944     %ParamsMap = %$ParamsMapRef;
 945     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
 946     if (exists $ParamsMap{classid} ) { $ClassId = $ParamsMap{classid}; $ParamsMap{classid} = ""; }
 947     if (exists $ParamsMap{name} ) { $Name = $ParamsMap{name}; $ParamsMap{name} = ""; }
 948     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
 949     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
 950     if (exists $ParamsMap{ViewOnly} ) { $ViewOnly = $ParamsMap{ViewOnly}; $ParamsMap{ViewOnly} = ""; }
 951     if (exists $ParamsMap{ShrinkToFit} ) { $ShrinkToFit = $ParamsMap{ShrinkToFit}; $ParamsMap{ShrinkToFit} = ""; }
 952     if (exists $ParamsMap{ShowToolsWhenVisible} ) { $ShowToolsWhenVisible = $ParamsMap{ShowToolsWhenVisible}; $ParamsMap{ShowToolsWhenVisible} = ""; }
 953   }
 954   if ($UseJavaScript) {
 955     #Setup parameter...
 956     my($Params) = "";
 957     for $ParamName (sort keys %ParamsMap) {
 958       $ParamValue = $ParamsMap{$ParamName};
 959       if (length $ParamValue) {
 960         $Params .= qq( $ParamName='$ParamValue');
 961       }
 962     }
 963     $JavaScriptTags = qq(\n<script>\n);
 964     $JavaScriptTags .= qq(cd_insertObjectStr("name='$Name' src='$MolFile' width='$Width' height='$Height' shrinktofit='$ShrinkToFit' viewonly='$ViewOnly' $Params");\n);
 965     $JavaScriptTags .= qq(</script>\n);
 966     $ReturnTags = $JavaScriptTags;
 967   }
 968   else {
 969     $Style = qq(style="height: ) . $Height . qq(px; width: ) . $Width . qq(px");
 970 
 971     # Setup object header...
 972     $ActiveXTags = qq(\n<object id="$Name" classid="$ClassId" $Style>\n);
 973 
 974     # Setup molecule data...
 975     $ActiveXTags .= qq(<param name="SourceURL" value="$MolFile">\n<param name="ShrinkToFit" value="$ShrinkToFit">\n<param name="ViewOnly" value="$ViewOnly">\n<param name="ShowToolsWhenVisible" value="$ShowToolsWhenVisible">\n);
 976 
 977     #Setup other parameters...
 978     for $ParamName (sort keys %ParamsMap) {
 979       $ParamValue = $ParamsMap{$ParamName};
 980       if (length $ParamValue) {
 981         $ActiveXTags .= qq(<param name="$ParamName" value="$ParamValue">\n);
 982       }
 983     }
 984     $ActiveXTags .= qq(</object>\n);
 985     $ReturnTags = $ActiveXTags;
 986   }
 987   return $ReturnTags;
 988 }
 989 
 990 # Setup ChemDraw plug-in used for Netscape browsers...
 991 # Problems: "bgcolor" parameter doesn't work.
 992 sub SetupStrViewerChemDrawPlugIn {
 993   my($MolFile, $Name, $ParamsMapRef, %ParamsMap, $Width, $Height, $ParamName, $ParamValue, $PlugInTags, $JavaScriptTags, $ReturnTags,);
 994   my($MimeType, $ViewOnly, $ShrinkToFit, $ShowToolsWhenVisible, $JSFileName, $UseJavaScript);
 995 
 996   $Name = "ChemDraw"; $PlugInTags = ""; $ParamsMapRef = ""; %ParamsMap = ();
 997   $Width = $StrViewerWidth; $Height = $StrViewerHeight;
 998   $MimeType = "chemical/x-mdl-molfile";
 999   $ViewOnly = "1";
1000   $ShrinkToFit = "1";
1001   $ShowToolsWhenVisible = "1"; $JavaScriptTags = "";
1002 
1003   if (@_ == 2) {
1004     ($MolFile, $ParamsMapRef) = @_;
1005   }
1006   else {
1007     ($MolFile) = @_;
1008   }
1009 
1010   if ($ParamsMapRef) {
1011     %ParamsMap = %$ParamsMapRef;
1012     if (exists $ParamsMap{usejavascript} ) { $JSFileName = $ParamsMap{usejavascript}; $UseJavaScript = 1; $ParamsMap{usejavascript} = ""; }
1013     if (exists $ParamsMap{height} ) { $Height = $ParamsMap{height}; $ParamsMap{height} = ""; }
1014     if (exists $ParamsMap{width} ) { $Width = $ParamsMap{width}; $ParamsMap{width} = ""; }
1015     if (exists $ParamsMap{type} ) { $MimeType = $ParamsMap{type}; $ParamsMap{type} = ""; }
1016     if (exists $ParamsMap{viewonly} ) { $ViewOnly = $ParamsMap{viewonly}; $ParamsMap{viewonly} = ""; }
1017     if (exists $ParamsMap{shrinktofit} ) { $ShrinkToFit = $ParamsMap{shrinktofit}; $ParamsMap{shrinktofit} = ""; }
1018     if (exists $ParamsMap{showtoolswhenvisible} ) { $ShowToolsWhenVisible = $ParamsMap{showtoolswhenvisible}; $ParamsMap{showtoolswhenvisible} = ""; }
1019   }
1020   if ($UseJavaScript) {
1021     $JavaScriptTags = qq(\n<script>\n);
1022     $JavaScriptTags .= qq(cd_insertObjectStr("name='$Name' src='$MolFile' type='$MimeType' width='$Width' height='$Height' shrinktofit='$ShrinkToFit' viewonly='$ViewOnly'");\n);
1023     $JavaScriptTags .= qq(</script>\n);
1024     $ReturnTags = $JavaScriptTags;
1025   }
1026   else {
1027     # Start plug-in tag...
1028     $PlugInTags = qq(<embed src="$MolFile" width="$Width" height="$Height" type="$MimeType" viewonly="$ViewOnly" shrinktofit="$ShrinkToFit" showtoolswhenvisible=''$ShowToolsWhenVisible");
1029 
1030     #Setup other parameters...
1031     for $ParamName (sort keys %ParamsMap) {
1032       $ParamValue = $ParamsMap{$ParamName};
1033       if (length $ParamValue) {
1034         $PlugInTags .= qq(" $ParamName"="$ParamValue");
1035       }
1036     }
1037     # Finish it off...
1038     $PlugInTags .= qq( >);
1039     $ReturnTags = $PlugInTags;
1040   }
1041 
1042   return $ReturnTags;
1043 }
1044 
1045