///////////////////////////////////////////////////////////////////
////
//// website utilities - A.R. Galiano 
////
///////////////////////////////////////////////////////////////////

///////////////////////////////////////////////////////////////////
//// Turn pop-ups on and off

var announce_on   = 0  ;  //// 0 = off ; 1 = on
var guest_book_on = 5 ;  //// 0 = off ; n = trigger on nth page
var check_browser = 1  ;  //// 0 = off ; 1 = on
var protection    = 1  ;  //// 0 = off ; 1 = on
var popups        = 1  ;  //// 0 = off ; 1 = on
var browser       = "IE"  //// string IE | NS

///////////////////////////////////////////////////////////////////

var home = "/" ;
var fn = new String( window.location ) ;

if ( fn.indexOf( "http://127.0.0.1" ) >= 0 
  || fn.indexOf( "http://home" )      >= 0 
  || fn.indexOf( "file://" )          >= 0 
   )
    {
    check_browser = 0 ;
    announce_on   = 0 ;
    guest_book_on = 0 ;
    popups        = 0 ;
    protection    = 0 ;
    home = "/scuba/"  ;
    }

///////////////////////////////////////////////////////////////////

function DoStuff()
    {
    BrowserCheck() ; //// aborts page load if necessary
    ProtectPage() ;
    PopUps() ;
    FloatMenu() ;
    }

///////////////////////////////////////////////////////////////////

function BrowserCheck()
    {
    //// acceptable browsers:
    if( navigator.appName == "Microsoft Internet Explorer" && parseFloat(navigator.appVersion) >= 4.0 )
      {
      browser = "IE" ;
      return 0 ;
      }
    if( navigator.appName == "Opera" && parseFloat(navigator.appVersion) >= 7.11 )
      {
      browser = "IE" ;
      return 0 ;
      }
    if( navigator.appName == "Netscape" && parseFloat(navigator.appVersion ) >= 5.0 ) 
      {
      browser = "NS" ;
      return 0 ;
      }
    if ( ! check_browser ) return 0 ;

    //// reject the rest:
    //alert( "This website requires MS Internet Explorer 5.0+ or Netscape 6.0+\n\nPlease upgrade your browser." ) ;
    window.location.replace( "ieupgrade.html" ) ;
    return 1 ;

    }

///////////////////////////////////////////////////////////////////
////once-per-session Announcement

function PopUps() 
  {
  var popitup = 0 ;
  var cnt = 0 ;

  if ( ! popups )
    return 0 ;

  if ( document.cookie )
    cnt = eval( document.cookie ) + 1 ;

  document.cookie = cnt + ";path=/" ;
  ////alert( document.cookie ) ;

  //// avoid endless loop if cookies are disabled !!
  if ( ! document.cookie ) return ;

  if ( announce_on && ! cnt ) 
    {
    fname = "addsite1.html?popup" ;
    ////window.open( fname, "_blank", "" ) ;
    this.location.href = fname ;
    return ;
    }

  if ( guest_book_on > 0 && cnt == guest_book_on   )
    {
    var msg = "You seem to like this website.\n\nWould you like to sign the guest book ?\n\n( Please ignore this message if you already have ... )" ;
    if ( confirm( msg ) ) 
      {
      this.location.href = home + "links/frameGB.html" ; 
      }
    }
  }

///////////////////////////////////////////////////////////////////
////Make Menus float

function FloatMenu()
  {
  window.FloatIt = function()
    {
    var pY = ns ? pageYOffset : document.body.scrollTop ;
    var dY = parseInt( ( pY + startY - MenuLayer.y ) / 2 ) ;
    //// avoid needless redraws
    if( dY*dY < 1 ) return ;
    MenuLayer.y += dY ;
    MenuLayer.style.top = MenuLayer.y ;
    }

  //// don't float menu at low screen resolutions
  if ( window.screen.availHeight < 599 ) return 0 ;

  var id = "FloatingMenu" ; //// name of layer to float
  var startY  = 25 ;        //// vertical starting point for floating menu
  var speed   = 10 ;        //// lower=faster, but with performance price

  var ns = ( navigator.appName.indexOf( "Netscape" ) != -1 ) ;
  var MenuLayer = document.getElementById ? document.getElementById(id) : document.all ? document.all[id] : document.layers[id] ;
  if( document.layers ) MenuLayer.style = MenuLayer ;

  MenuLayer.y = startY ;
  MenuLayer.style.top = MenuLayer.y ;

  FloatIt() ;
  setInterval( "FloatIt()" , speed ) ;

  }


////FloatMenu() ;

///////////////////////////////////////////////////////////////////
//// Disable right-clicking

function click( e )
  {
  if ( browser == "IE" && event.button == 2 )
    {
    if ( confirm( "Reload page ?" ) ) location.reload() ; 
    ////this.location.href = "diveclubs.html" ; 
    } 
  else if ( browser == "NS" && e.which == 3 )
    {
    document.onmousedown = new Function ( "return false" ) ;
    ////if ( confirm( "Reload page ?" ) ) location.reload() ; 
    this.location.href = "diveclubs.html" ; 
    } 
  }

function ProtectPage()
  {
  if ( ! protection ) return 0 ;
  document.onmousedown = click ; 
  if ( browser == "IE" )
    {
    //// stops text selection - obnoxious ?
    document.onselectstart = new Function ( "return false" ) ;
    }
  else if ( browser == "NS" )
    {
    ////document.captureEvents( Event.MOUSEDOWN ) ;
    }
  }

