/*
 * Program - Photo Album Script Generator
 * File Name - pas_gen.js
 * Author - ShuvoRim
 * Web site - http://www.shuvorim.tk
 * Email - shuvorim@hotmail.com
 * (c)ShuvoRim Pvt. Ltd. 2002 - 03
 * All rights reserved.
 * --------------------------------
 * Visit our web site for free open
 * source Applications, Applets,
 * Scripts and Games. Thank you for
 * using our program.
 */



 /* DECLARING AND INITIALIZING NECESSARY VARIABLES */

  var prevWin = "";		/* PREVIEW WINDOW */
  var codeWin = "";		/* CODE WINDOW */
  var writeAll = "";		/* TO STORE ALL CODES */
  var pgTitle = "";		/* PAGE TITLE */
  var phtGal = "";		/* GALLERY TITLE */
  var phtPage = "";		/* NUMBER OF ROWS */
  var phtRow = "";		/* NUMBER OF PHOTOS IN EACH ROW */
  var thmWidth = "";		/* THUMB NAIL WIDTH */
  var thmHeight = "";		/* THUMB NAIL HEIGHT */
  var phtTitle = "";		/* TITLE/DESCRIPTION WITH PHOTOS */
  var defStyle = "";		/* DEFAULT STYLE SHEETS */
  var serial = 1;		/* SERIAL NUMBER OF EACH PHOTO */



/* THIS FUNCTION WILL COLLECT ALL NECESSARY INFORMATION
   AND STORE THEM TO THE writeAll VARIABLE */

 function collect()
 {

/* COLLECTING VALUES FROM form1 */

  pgTitle = document.form1.page_title.value;
  phtGal = document.form1.pht_gal.value;
  phtPage = document.form1.pht_page.value;
  phtRow = document.form1.pht_row.value;
  thmWidth = document.form1.thm_width.value;
  thmHeight = document.form1.thm_height.value;
  phtTitle = document.form1.pht_title.value;
  defStyle = document.form1.def_style.value;


  writeAll += "<!-- DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' -->\n\n";
  writeAll += "<html>\n<head>\n<title>" + pgTitle + "</title>\n\n";
  writeAll += "<meta http-equiv='pragma' content='no-cache'>\n";
  writeAll += "<meta http-equiv='content-type' content='text/html; charset=iso-8859-1'>\n";
  writeAll += "<meta name='generator' content='Photo Album Script Generator'>\n\n";
  writeAll += "<!-- Please provide necessary content informations below -->\n";
  writeAll += "<meta name='reply-to' content='Enter your email address here.'>\n";
  writeAll += "<meta name='author' content='Enter your name here.'>\n";
  writeAll += "<meta name='copyright' content='Enter your company name here.'>\n";
  writeAll += "<meta name='description' content='Enter your page description here.'>\n";
  writeAll += "<meta name='keywords' content='Enter your keywords here.'>\n\n";
  writeAll += "<link rel=stylesheet type='text/css' href='./styles/style" + defStyle + ".css'>\n\n";
  writeAll += "</head>\n<body><div id=EchoTopic>\n\n";
  writeAll += "<table cellpadding=8 cellspacing=8 border=0 align=center width=70%>\n";
  writeAll += "<tr valign=top align=center>\n<td class=extra colspan=" + phtRow + ">\n";
  writeAll += phtGal + "</td>\n</tr>\n\n";


  for(i = 0; i < phtPage; i++)
  {

    writeAll += "<tr valign=top align=center>\n\n";

    for(j = 0; j < phtRow; j++)
    {

      writeAll += "<td><a href='images/pic.jpg' target='_new' title='Click to enlarge'>\n";
      writeAll += "<img src='pic.jpg' width=" + thmWidth + " height=" + thmHeight + " border=0></a>\n";

      if(document.form1.pht_title.value == "y")
       writeAll += "<br>Photo" + (serial++) + "</td>\n\n";

    }

   writeAll += "</tr>\n\n";

  }


  writeAll += "<tr valign=top align=center>\n<td class=extra colspan=" + phtRow + ">\n";
  writeAll += "<a href='#' title='Previous Page'>&lt;&lt; Back</a> | \n";
  writeAll += "<a href='#' title='Next Page'>Next &gt;&gt;</a>";
  writeAll += "</td>\n<tr>\n</table>\n\n";
  writeAll += "<!-- You are not authorized to remove the code below -->\n";
  writeAll += "<p align=right><font size=1>";
  writeAll += "<a href='http://www.shuvorim.tk' target='_new' title='Click here to visit us!'>";
  writeAll += "&copy;ShuvoRim Pvt. Ltd.</a></font></p>";
  writeAll += "\n<!-- You are not authorized to remove the code above -->\n\n";
  writeAll += "</div></body>\n</html>\n";

 }



/* THIS FUNCTION WILL GENERATE THE PREVIEW OF THE CUSTOMIZED PAGE */

 function showPrev()
 {

   prevWin = window.open("", "preview", "status,resizable,scrollbars");

   collect();		/* CALLING THE collect() FUNCTION */

   prevWin.document.write(writeAll);


/* SET TO DEFAULT VALUES */

   writeAll = "";
   serial = 1;

/* DONE */

 }


/* THIS FUNCTION WILL SHOW THE GENERATED CODE */

 function showCode()
 {

   codeWin = window.open("", "code", "status,resizable,scrollbars");

   with(codeWin.document)
   {

     write("<html><head><title>Your codes are ready to serve!</title></head><body><div id=EchoTopic>");
     write("<h2>Your codes are ready to serve!</h2><hr>Copy the following codes to ");
     write("any text editor and save it as a HTML page. Please also copy the style ");
     write("sheet along with the background picture. ");
     write("You have to provide the path of your own images. Thank you very much ");
     write('for using "Photo Album Script Generator".');
     write("<p><form name='form2'><textarea cols=70 rows=20 READONLY>");

     collect();		/* CALLING THE collect() FUNCTION */

     write(writeAll + "</textarea></form></p>");
     write("<a href='javascript: self.close();'>Close Window!</a></div></body></html>");


/* SET TO DEFAULT VALUES */

   writeAll = "";
   serial = 1;

/* DONE */

   }

 }


/* THE END */
