// Library of common functions

//------------ Functions to discard right mouse click --------------


function clickIE() {

   if( document.all) {

      return false ;

   }
}

function clickNS(znObject) {

   if( document.layers || (document.getElementById &&! document.all)) {

      if ( znObject.which == 2 || znObject.which == 3) {

         return false;

      }

   }

}

//-------- End of functions to discard right mouse click -----------


//--------------------------- function datetotext ------------------------------
function datetotext( tdDate, tlDOW) {

   var zaDays = new Array('Sunday','Monday','Tuesday','Wednesday',
    'Thursday','Friday','Saturday');
   var zaMonths = new Array('January','February','March','April',
     'May','June','July','August','September', 'October','November',
     'December');

   zcTextDate = ( tlDOW ? zaDays[tdDate.getDay()] + ', ' : '') +
     zaMonths[tdDate.getMonth()] + ' ' +
     tdDate.getDate() + ', ' +
     (tdDate.getYear() < 200 ? tdDate.getYear() + 1900 : tdDate.getYear()) ;

  return zcTextDate ;
}

//------------------------ end of function datetotext --------------------------

//----------------------------- function loadbio -------------------------------
function loadbio() {

// Open modal window for biography
// Declare window location variables ( attempt centering window)
var   znWindowW,  // Window width
      znWindowH,  // Window height
      znOuterW,   // Parent window width
      znOuterH,   // Parent window height
      znLeft,     // Left offset
      znTop ;     // Top offset


// Window dimensions
znWindowW = 520 ;
znWindowH = 550 ;

// Browser specific computations
if ( document.all) {

     // Explorer
     znOuterW = screen.width  ;
     znOuterH = screen.height ;
}
else {

     if (document.layers) {

         // Netscape
         znOuterW = window.outerWidth  ;
         znOuterH = window.outerHeight ;
     }
     else {

         // WAG!
         znOuterW = 640 ;
         znOuterH = 480 ;


     }//endif

}//endif

// Compute left and top
znLeft = (znOuterW - znWindowW) / 2 ;
znTop  = (znOuterH - znWindowW) / 2 ;


// Display the image -- NOTE: This call interrupts the program flow
window.open("bio.html", '', "scrollbars=no, width=" +
  znWindowW + ", height=" + znWindowH + ", screenX=" +
  znLeft + ", screenY=" + znTop + ", top=" + znTop + ", left=" + znLeft + "") ;
return false;

}

//------------------------- end of function loadbio ----------------------------


//----------------------------- function loadlnk -------------------------------
function loadlnk() {

// Open modal window for links
// Declare window location variables ( attempt centering window)
var   znWindowW,  // Window width
      znWindowH,  // Window height
      znOuterW,   // Parent window width
      znOuterH,   // Parent window height
      znLeft,     // Left offset
      znTop ;     // Top offset


// Window dimensions
znWindowW = 520 ;
znWindowH = 510 ;

// Browser specific computations
if ( document.all) {

     // Explorer
     znOuterW = screen.width  ;
     znOuterH = screen.height ;
}
else {

     if (document.layers) {

         // Netscape
         znOuterW = window.outerWidth  ;
         znOuterH = window.outerHeight ;
     }
     else {

         // WAG!
         znOuterW = 640 ;
         znOuterH = 480 ;


     }//endif

}//endif

// Compute left and top
znLeft = (znOuterW - znWindowW) / 2 ;
znTop  = (znOuterH - znWindowW) / 2 ;


// Display the image -- NOTE: This call interrupts the program flow
window.open("links.html", '', "scrollbars=no, width=" +
  znWindowW + ", height=" + znWindowH + ", screenX=" +
  znLeft + ", screenY=" + znTop + ", top=" + znTop + ", left=" + znLeft + "") ;
return false;

}

//------------------------- end of function loadlnk ----------------------------


//---------------------------- function copyright ------------------------------
function copyright( tdDate) {

zcCopyright =  'Images and content Copyright &copy; Dwight Smith, ' +
  (tdDate.getYear() < 200 ? tdDate.getYear() + 1900 : tdDate.getYear()) +
  '. <br> Publication rights and prints available via email.' ;

return zcCopyright ;

}

//------------------------ end of function copyright ---------------------------


//---------------------------- function setfocus -------------------------------

// Runs upon the body onload event
function setFocus() {

   // Focus first form field
   document.forms[0].elements[0].focus() ;

   // Clear out the Results fields
   //document.forms[0].elements[2].value = "" ;
   //document.forms[0].elements[3].value = "" ;
}

//------------------------- end of function setfocus ---------------------------


//--------------------------- function changegroup -----------------------------

// Move to the next image group
function changegroup( zcAmount) {

   pcImageGroup = ( zcAmount == '1'
     ? ( pcImageGroup ++ < pnPageCount ? pcImageGroup ++ : '1')
     : ( pcImageGroup -- > 1 ? pcImageGroup -- : pnPageCount) ) ;

   // Update the images
   document.image1.src = 'media/thumbs/' + pcImageGroup + '1.jpg' ;
   document.image2.src = 'media/thumbs/' + pcImageGroup + '2.jpg' ;
   document.image3.src = 'media/thumbs/' + pcImageGroup + '3.jpg' ;
   document.image4.src = 'media/thumbs/' + pcImageGroup + '4.jpg' ;
   document.image5.src = 'media/thumbs/' + pcImageGroup + '5.jpg' ;
   document.image6.src = 'media/thumbs/' + pcImageGroup + '6.jpg' ;

   return true;

}

//----------------------- end of function changegroup --------------------------


//------------------------------ function popup --------------------------------

// Open modal window for larger images
function popup( zcimage) {

// Declare window location variables ( attempt centering window)
var   znWindowW,  // Window width
      znWindowH,  // Window height
      znOuterW,   // Parent window width
      znOuterH,   // Parent window height
      znLeft,     // Left offset
      znTop ;     // Top offset


// Window dimensions
znWindowW = 520 ;
znWindowH = 510 ;

// Browser specific computations
if ( document.all) {

     // Explorer
     znOuterW = screen.width  ;
     znOuterH = screen.height ;
}
else {

     if (document.layers) {

         // Netscape
         znOuterW = window.outerWidth  ;
         znOuterH = window.outerHeight ;
     }
     else {

         // WAG!
         znOuterW = 640 ;
         znOuterH = 480 ;


     }//endif

}//endif

// Compute left and top
znLeft = (znOuterW - znWindowW) / 2 ;
znTop  = (znOuterH - znWindowW) / 2 ;


// Display the image -- NOTE: This call interrupts the program flow
window.open("popup.html", zcimage, "scrollbars=no, width=" +
  znWindowW + ", height=" + znWindowH + ", screenX=" +
  znLeft + ", screenY=" + znTop + ", top=" + znTop + ", left=" + znLeft + "") ;
return false;

}
//-------------------------- end of function popup -----------------------------


//--------------------------- function changeimage -----------------------------

// Handler for <Previous> and <   Next   > objects
function changeimage( zcAmount) {

   // Determine current image by parsing the window name
   zcGroup = this.name.substr(0, 1) ;
   zcImage = this.name.substr(1, 1) ;

   // Calculate the next image number
   if ( zcAmount == '-1') {

      zcImage -- ;

   }
   else {

      zcImage ++ ;

   }//endif


   // Keep the image number between 1 and 6
   if ( zcImage == 7) {

      zcImage = '1'

   }//endif


   if ( zcImage == '0') {

      zcImage = 6

   }//endif

   this.name =  zcGroup + zcImage   ;

   document.theimage.src='media/images/' + this.name + '.jpg' ;
   document.thetitle.src='media/images/titles/' + this.name + '.gif' ;

}

//----------------------- end of function changeimage --------------------------