function init()
{
   window.defaultStatus="100% Melanie C - Photo Galleries...";
	img_base="../../images/buttons/";

   return true;
}

function link_active(index)
{
   if(index==0) document.head_1.src=img_base+"main_y.gif";
   if(index==1) document.head_2.src=img_base+"back_y.gif";
   if(index==2) document.foot_1.src=img_base+"main_y.gif";
   if(index==3) document.foot_2.src=img_base+"back_y.gif";
   return true;
}

function link_inactive(index)
{
   if(index==0) document.head_1.src=img_base+"main_g.gif";
   if(index==1) document.head_2.src=img_base+"back_g.gif";
   if(index==2) document.foot_1.src=img_base+"main_g.gif";
   if(index==3) document.foot_2.src=img_base+"back_g.gif";
   return true;
}

function image_info(id,width,height,alt)
{
   this.id = id;
   this.width = width;
   this.height = height;
   this.alt = alt;
}

function insert_images()
{
   define_image_list();

   if(location.search == '?fs') gallery_type = 'fs';
   else if(location.search == '?th') gallery_type = 'th';
   else gallery_type = 'th';

   document.writeln('<P ALIGN=CENTER>');   
   for(loop=0;loop<image_list.length;loop++)
   {
      // handler for titles embedded within image list
      if(image_list[loop].id == 0)
      {
         document.writeln('</P>');
         document.writeln('<P ALIGN=CENTER>');
         document.writeln(image_list[loop].alt,'<BR>');
      }
      else
      {
         image_dir_base = (Math.floor((image_list[loop].id - 1) / 100) * 100) + 1;
         image_dir_top = image_dir_base + 99;

         if(image_dir_base == 1) image_dir = '0001-';
         else if(image_dir_base < 1001) image_dir = '0'+image_dir_base+'-';
         else image_dir = image_dir_base+'-';
         if(image_dir_top < 1000) image_dir += '0'+image_dir_top;
         else image_dir += image_dir_top;

         image_id = image_list[loop].id+'.jpg';
         if(image_list[loop].id < 1000) image_id = '0'+image_id;
         if(image_list[loop].id < 100) image_id = '0'+image_id;
         if(image_list[loop].id < 10) image_id = '0'+image_id;

         if(gallery_type == 'th')
         {
            document.write('<A HREF="../../pics/fs/',image_dir,'/',image_id,'">');
            document.write('<IMG SRC="../../pics/th/',image_dir,'/',image_id,'" WIDTH=',image_list[loop].width/3,' HEIGHT=',image_list[loop].height/3,' ALT="',image_list[loop].alt,'">');
            document.writeln('</A>');
         }
         else
         {
            document.writeln('<IMG SRC="../../pics/fs/',image_dir,'/',image_id,'" WIDTH=',image_list[loop].width,' HEIGHT=',image_list[loop].height,' ALT="',image_list[loop].alt,'">');
         }
      }
   }
   document.writeln('</P>');   
}

function insert_article_link()
{
   define_article_link();

   if(article_link.length > 0)
   {
      document.writeln('<P ALIGN=CENTER>');
      document.writeln('<A HREF="',article_link,'.html">Read the associated article here...</A>');
      document.writeln('</P>');
   }
}

function draw_nav_bar(loc)
{
   referrer = document.referrer;
   referrer = referrer.substring(referrer.lastIndexOf('/')+1);

   if(loc=='head')
   {
      link_base=0;
      back_url="../../base_photos.html";
   }
   else if(loc=='art-head')
   {
      link_base=0;
      back_url=referrer;
      loc="head";
   }
   else if(loc=='foot')
   {
      link_base=2;
      back_url="../../base_photos.html";
   }
   else if(loc=='art-foot')
   {
      link_base=2;
      back_url=referrer;
      loc="foot";
   }

   document.writeln('<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">');
   document.writeln('<TR>');
   document.writeln('<TD BGCOLOR="#000000">');
   document.writeln(' <IMG SRC="../../images/core/shade_left.gif" ALT="" WIDTH=20 HEIGHT=40><IMG');
   document.writeln('  SRC="../../images/core/sect_photos.gif" ALT="Photo Galleries..." WIDTH=80 HEIGHT=40><IMG');
   document.writeln('  SRC="../../images/core/vert_spacer.gif" ALT="|" WIDTH=16 HEIGHT=40><A');
   document.writeln('  HREF="../../../melaniec.html" ONMOUSEOVER="link_active(',link_base,');return true;" ONMOUSEOUT="link_inactive(',link_base,');return true;"><IMG SRC="../../images/buttons/main_g.gif" ALT="Main" WIDTH=72 HEIGHT=40 BORDER=0 NAME="',loc,'_1"></A><A');
   document.writeln('  HREF="',back_url,'" ONMOUSEOVER="link_active(',link_base+1,');return true;" ONMOUSEOUT="link_inactive(',link_base+1,');return true;"><IMG SRC="../../images/buttons/back_g.gif" ALT="Back" WIDTH=72 HEIGHT=40 BORDER=0 NAME="',loc,'_2"></A><IMG');
   document.writeln('  SRC="../../images/core/vert_spacer.gif" ALT="|" WIDTH=16 HEIGHT=40></TD>');
   document.writeln('<TD ALIGN=RIGHT BGCOLOR="#000000">');
   document.writeln(' <IMG SRC="../../images/core/title_small.gif" ALT="Site Title" WIDTH=142 HEIGHT=40><IMG');
   document.writeln('  SRC="../../images/core/shade_right.gif" ALT="" WIDTH=20 HEIGHT=40></TD>');
   document.writeln('</TR>');
   document.writeln('</TABLE>');
}

function insert_title_date()
{
   define_gallery_data();

   document.writeln('<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH="100%">');
   document.writeln('<TR>');
   document.writeln('<TD>');
   document.writeln(' <H1>',gallery_title,'</H1></TD>');
   document.writeln('<TD VALIGN=TOP ALIGN=RIGHT>');
   document.writeln(' <FONT SIZE="-1">Last update: ',gallery_date,'</FONT></TD>');
   document.writeln('</TR>');
   document.writeln('</TABLE>');
}

