// scGallery v.01.01.02 - copyright 2006-2007 Stefan Schmohl, scido.de - all rights reserved 

//  ######## get element by id ########
function scGlyIdF( idS ) {    if ( idS == "" ) return false ; var idO = document.getElementById( idS ) ; 
    if ( ! idO ) alert( "ID \"" + idS + "\" not found !" ) ;    return idO ; } ; 
//  ######## set whether new location has to display images from end ( "1" ) or beginning ( "0" ) ########
function scGlyEndSetF( aN ) {    if ( this.ckIdS == "" ) return ; 
    var nS = this.ckIdS + "=" ; var nN = nS.length ;    // cookie variable name
    dO = new Date( ) ; var dN = dO.getTime( ) + ( 60 * 60 * 1000 ) ; dO.setTime( dN ) ; 
    var cG = ";expires=" + dO.toGMTString( ) + ";" ; 
    document.cookie = nS + aN + cG ;    return ; } ; 
//  ######## query whether new location has to display images from end or beginning ########
function scGlyEndGetF( ) {    if ( this.ckIdS == "" ) return 0 ; 
    var nS = this.ckIdS + "=" ; var nN = nS.length ;    // cookie variable name
    var vN = document.cookie.indexOf( nS ) + nN ;    // position of begin of value
    if ( vN < nN ) return 0 ; 
    var vS = document.cookie.substr( vN ) ;    // substring starting with value
    vN = vS.indexOf( ";" ) ;    // position of end of value = length of value
    if ( vN != -1 ) { vS = vS.substr( 0, vN ) ; } ;    // substring with value
    vN = vS - 0 ;    return vN ; } ; 
//  ######## display text "aS" at id "iS" ########
function scGlyTxtSetF( aS, iS ) { 
    var idO = scGlyIdF( iS ) ;                if ( ! idO ) return false ; 
    var ntO = document.createTextNode( aS ) ; if ( ! ntO ) return false ; 
    var otO = idO.firstChild ;                if ( ! otO ) return false ; 
    if ( ! ( idO.replaceChild( ntO, otO ) ) )              return false ; 
    return true ; } ; 
//  ######## preoad image "aN" ########
function scGlyImgPldF( aN ) {     aN = this.curImgN + aN ; 
    if ( ( aN < 1 ) || ( aN >= this.bigImgSA.length ) ) return ; 
    this.pldImgIA[ aN ] = new Image ; this.pldImgIA[ aN ].src = this.bigImgSA[ aN ] ; 
    return ; } ; 
//  ######## display image "aN" ########
function scGlyImgSetF( aN ) {    var idO ;    
    if ( aN < 1 ) {                         if ( this.prvLocS == "" ) return ; 
        this.setEndF( 1 ) ; location.href = this.prvLocS ; return ; } ; 
    if ( aN >= this.bigImgSA.length ) {     if ( this.nxtLocS == "" ) return ; 
        location.href = this.nxtLocS ; return ; } ; 
    idO = scGlyIdF( this.imIdS + "0" ) ;          if ( idO ) idO.src = this.bigImgSA[ 0 ] ;            
    idO = scGlyIdF( this.imIdS + this.curImgN ) ; if ( idO ) idO.src = this.smlImgSA[ this.curImgN ] ; 
    idO = scGlyIdF( this.imIdS + aN ) ;           if ( idO ) idO.src = this.smlImgSA[ 0 ] ; 
    idO = scGlyIdF( this.imIdS + "0" ) ;          if ( idO ) idO.src = this.bigImgSA[ aN ] ; 
    this.setTxtF( "(" + aN + "/" + ( this.bigImgSA.length - 1 ) + ")", this.nbIdS ) ; 
    this.setTxtF( this.txtSA[ aN ], this.dcIdS ) ; 
    this.curImgN = aN ; return ; } ; 
//  ######## display image "this.curImgN + aN" ########
function scGlyImgSrlF( aN ) {
    return this.setImgF( this.curImgN + aN ) ; } ; 
//  ######## set first image of new location ########
function scGlyImgFstF( ) { 
    if ( this.getEndF( ) == 0 ) { this.setImgF( 1 ) ;                        this.pldImgF( +1 ) ; } 
     else {   this.setEndF( 0 ) ; this.setImgF( this.bigImgSA.length - 1 ) ; this.pldImgF( -1 ) ; }
    return ; } ; 
//  ######## scGallery object constructor ########
function ScGalleryO( imIdS, nbIdS, dcIdS, ckIdS, prvLocS, nxtLocS, smlImgSA, bigImgSA, txtSA ) {
    this.imIdS = imIdS ; this.nbIdS = nbIdS ; this.dcIdS = dcIdS ; 
    this.ckIdS = ckIdS ; this.prvLocS = prvLocS ; this.nxtLocS = nxtLocS ; 
    this.smlImgSA = smlImgSA ; this.bigImgSA = bigImgSA ; 
    this.pldImgIA = new Array( ) ; this.txtSA = txtSA ; this.curImgN = 1 ; 
    this.setEndF = scGlyEndSetF ; this.getEndF = scGlyEndGetF ; 
    this.pldImgF = scGlyImgPldF ; this.setImgF = scGlyImgSetF ; this.setTxtF = scGlyTxtSetF ; 
    this.srlImgF = scGlyImgSrlF ; this.fstImgF = scGlyImgFstF ; 
    this.fstImgF( ) ; } ; 

/*
<a href="#1" onmousedown="scGaO.srlImgF( -1 ); scGaO.pldImgF( -1 );">one step FORWARD</a>
<a href="#1" onmousedown="scGaO.srlImgF( +1 ); scGaO.pldImgF( +1 );">one step BACKWARD</a>
<!-- THUMBNAIL --><img onmouseover="scGaO.setImgF(  3 ) id="scGaIm3" src="s03.jpg" width="48" height="48">
<!-- IMAGE --><table><tr><td align="center"><img id="scGaIm0" src="b00.jpg"></td></tr></table>
<div id="scGaNb">number of image</div>
<div id="scGaDc">description of image</div>

<script type="text/javascript" src="./scGallery.js"></script>
<script type="text/javascript"><!--
scGaO = new ScGlyO 
  ( "scGaIm" // image elements id
  , "scGaNb" // number text element id  ( empty to inactivate )
  , "scGaDc" // description text element id  ( emptry to inactivate )
  , "scGaCk" // cookie variable name  ( empty to inactivate )
  , "prevUrl.htm" // previous url  ( empty to inactivate )
  , "nextUrl.htm" // next url  ( empty to inactivate )
  , Array (              "./i/g00-s.jpg", "./i/g01-s.jpg", "./i/g02-s.jpg", "./i/g03-s.jpg", "./i/g04-s.jpg"
      , "./i/g05-s.jpg", "./i/g06-s.jpg", "./i/g07-s.jpg", "./i/g08-s.jpg", "./i/g09-s.jpg", "./i/g10-s.jpg"
      , "./i/g11-s.jpg", "./i/g12-s.jpg", "./i/g13-s.jpg", "./i/g14-s.jpg", "./i/g15-s.jpg", "./i/g16-s.jpg"
      ) // thumbnail images, [ 0 ] is blank image
  , Array (              "./i/g00-b.jpg", "./i/g01-b.jpg", "./i/g02-b.jpg", "./i/g03-b.jpg", "./i/g04-b.jpg"
      , "./i/g05-b.jpg", "./i/g06-b.jpg", "./i/g07-b.jpg", "./i/g08-b.jpg", "./i/g09-b.jpg", "./i/g10-b.jpg"
      , "./i/g11-b.jpg", "./i/g12-b.jpg", "./i/g13-b.jpg", "./i/g14-b.jpg", "./i/g15-b.jpg", "./i/g16-b.jpg"
      ) // dispaled images, [ 0 ] is blank image
  , Array ( ""
      , "One of our motorboats at Butterfly beach on sunset."
      , "Butterfly beach on sunset."
      , "Butterfly beach on daylight."
      ) // description of images, [ 0 ] is a dummy
  ) ;   
// --></script>
*/
