/******************************************************************/
/***********      Brians Windsurfing: Gallery    ******************/
/******************************************************************/

function Gallery_Object() {
   this.Path         = "./pix/gallery/";
   this.Root         = "bws_gal_";
   this.PicInFocus   = 1;
   this.PageCount    = 2;
   this.PagePicNum   = [ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21],
                         [22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,00] ];
   this.PageInFocus  = 1;
   this.PopUpFile    = "bws_hr_gallery_popup.htm";
   this.PopUpWidth   = "510";
   this.PopUpHeight  = "420";
}

Gallery_Object.prototype.Show_Page_Options= function() {
   document.write( '<div style="padding: 0px 0px 4px 0px;">' );
   document.write( 'Page:&nbsp;&nbsp;' );
   for (var i=1; i<=this.PageCount; i++) { 
      document.write(  '<a class="GalleryPager" href="javascript:Gallery.Update_Page(' + i +')">' );
      document.write( i ); 
      document.write( '</a>&nbsp;&nbsp;' ); 
   }
   document.write( '</div>' );
}

/******************************/
/****   Init the Page  ********/
/******************************/

Gallery_Object.prototype.Init_Page = function() {
   document.write( '<div style="padding: 0px 0px 0px 0px;">' );
   document.write( '<table cellpadding="2" cellspacing="0" border="0" width="100%">' );
   this.Init_Row( 1,5 ); 
   this.Init_Row( 6,10 ); 
   this.Init_Row( 11,15 );
   this.Init_Row( 16,20 );
   document.write( '</table>' );
   document.write( '</div>' );

}

Gallery_Object.prototype.Init_Row = function(x,y) {
   document.write( '<tr>' );
   for (var i=x; i<=y; i++) { this.Init_Cell( i ); }
   document.write( '</tr>' );
}

Gallery_Object.prototype.Init_Cell = function( nNum ) {
   document.write( '<td>' );
   document.write( '   <a href="javascript:PopUpGallery(' + nNum +')">' );
   document.write( '      <img name="gal' + nNum + '" src="./images/spacer.gif" border="0" alt="">' );
   document.write( '   </a>' );
   document.write( '</td>' )
}

Gallery_Object.prototype.Update_Page = function( nPage ) {
   this.PageInFocus = nPage;
   for (var i=1; i<=20; i++) {
      if (this.PagePicNum[(nPage-1)][(i-1)]!=0) {
         cStr = 'document.images.gal' + i +'.src = "' + this.Path + this.Root + 
                ZeroFill( ( + this.PagePicNum[(nPage-1)][(i-1)] )) + '_sm.jpg"';
        
      } else cStr = 'document.images.gal' + i +'.src = "./images/spacer.gif"';
      eval( cStr );
   }
}

Gallery = new Gallery_Object();

function PopUpGallery( nNum ) {
   Gallery.PicInFocus = nNum;
   cHTML = Gallery.PopUpFile + '?p1=' + Gallery.PageInFocus + '&p2=' + Gallery.PicInFocus;
   cWidth = 'width=' + Gallery.PopUpWidth +',';
   cHeight = 'height=' + Gallery.PopUpHeight +',';
   cPanel = 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,' + 
            cWidth + cHeight + 'left = 0,top = 100';
   day = new Date();
   id = day.getTime();
   eval( "page" + id + " = window.open( cHTML, '" + id + "', cPanel );" );
}

/******************************/
/****   Gallery PopUp  ********/
/******************************/

var p1  = "";       /* Gallery Page Number        */
var p2  = "";       /* Gallery Picture In Focus   */
var p3  = "";       /* Open                       */
var np1 = 1;
var np2 = 1;

function GalleryPop_Object() {
   this.Path         = "./pix/gallery/";
   this.Root         = "./pix/gallery/";
   this.ScrHeight    = "500"
   this.PageCount    = 2;
   this.PageInFocus  = 1;
   this.PicInFocus   = 1;
   this.PagePicNum  = [ [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,20,21],
                        [22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,00] ];
   this.PopUpFile    = "bws_hr_gallery_popup.htm";
}

GalleryPop_Object.prototype.GetParameters = function() {
   var ParamStr  = window.location.href.split("?");
   var params    = new Array();     

   if (ParamStr[1]) {
     var pairs= ParamStr[1].split("&")
     for (var i=0; i<pairs.length; i++) {
        nameVal = pairs[i].split('=');
        params[nameVal[0]] = nameVal[1];
     } 
     p1  = unescape(params["p1"]?params["p1"]:"");
     p2  = unescape(params["p2"]?params["p2"]:"");
     p3  = unescape(params["p3"]?params["p3"]:"");
     np1 = parseInt( p1, 10 ); 
     np2 = parseInt( p2, 10 );  
   }
} 

GalleryPop_Object.prototype.ShowParameters = function() {
   if(p1||p2||p3||p4)document.write("Parameters detected:");
   if(p1) document.write("<BR>P1="+p1);
   if(p2) document.write("<BR>P2="+p2);
   if(p3) document.write("<BR>P3="+p3);
   if(np3) document.write("<BR>nP3="+np3);
}

GalleryPop_Object.prototype.GoNext = function() {
   var nNext = this.PagePicNum[(this.PageInFocus-1)][this.PicInFocus];
   if ((this.PicInFocus==20)||(nNext==0)) { 
       this.PicInFocus=1;
       this.PageInFocus++; 
       if (this.PageInFocus>this.PageCount) { this.PageInFocus=1; }
   } else { this.PicInFocus++; }
   this.SetPic();
}

GalleryPop_Object.prototype.GoPrevious = function() {
   if (this.PicInFocus==1) { 
      if (this.PageInFocus==1) { this.PageInFocus=this.PageCount; } else { this.PageInFocus--; }
      this.PicInFocus = this.SetPic_EOP();
   } else { this.PicInFocus--; }
   this.SetPic();
}

GalleryPop_Object.prototype.SetPic_EOP = function() {
   this.PicInFocus=20;
   var ii = 20;
   while (ii >= 1) {
      if (this.PagePicNum[(this.PageInFocus-1)][(ii-1)]!=0) { 
        return ii; 
      }
      ii--;
  }
}

GalleryPop_Object.prototype.Show = function() {
   document.write('<center>' );
   document.write('<table width="100%" height="' + this.ScrHeight + '" cellpadding="0" cellspacing="0" border="0">' );
   document.write('<tr>' );
   document.write('   <td height="100%" colspan="2" align="center" valign="middle">' );
   document.write('   <img src="' + this.PicStr() +'" name="gallerypopup" alt="" border="0">' );  
   document.write('   </td>' ); 
   document.write('</tr>' );
   document.write('<tr><td colspan="2"><img src="./images/spacer.gif" alt="" border="0"></td>' );
   document.write('<tr>' );
   document.write('    <td height="20" align="left" valign="middle">&nbsp;&nbsp;' );
   document.write('    <a class="GallerySlideShow" href="javascript:GalleryPopUp.GoPrevious();">' );
   document.write('       &#171;&nbsp;Previous' );
   document.write('    </a>' );
   document.write('   </td>')
   document.write('   <td height="20" align="right" valign="middle">' );
   document.write('      <a class="GallerySlideShow" href="javascript:GalleryPopUp.GoNext();">' );
   document.write('         Next&nbsp;&#187;' );
   document.write('      </a>&nbsp;&nbsp;' );
   document.write('    </td>');
   document.write('</tr>' );
   document.write('</table>' );
   document.write('</center>' );
}

GalleryPop_Object.prototype.SetPic = function() {
   document.images.gallerypopup.src = this.Path + this.Root + ZeroFill(this.GetPicNum()) + '.jpg';
}

GalleryPop_Object.prototype.GetPicNum = function() {
   return( this.PagePicNum[(this.PageInFocus-1)][(this.PicInFocus-1)] );
}

GalleryPop_Object.prototype.PicStr = function() {
    return this.Path + this.Root + ZeroFill( this.GetPicNum() ) + '.jpg';
}

GalleryPopUp = new GalleryPop_Object();

/******************************************************************/
/*********************        End of Document     ******************/
/******************************************************************/
