
function getAppVersion() {
  appname= navigator.appName;
  appversion = navigator.appVersion;
  majorver = appversion.substring(0, 1);
  if ( (appname == "Netscape") && ( majorver >= 3 ) ) return 1;
  if ( (appname == "Microsoft Internet Explorer") && (majorver >= 4) ) return 1;
  return 0;
}

///////////////////////////////////////////////////////////////////////////////
////////////////////////////////OtevriOkno/////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/*var obrazkoveokno;

function OtevriOkno(url) {
    OtevriOknospecial(url,"top=50,left=100,width=822,height=628");
}

function OtevriOknospecial(url,winfeatures) {
  alert(obrazkoveokno);
  if(obrazkoveokno != undefined) {
    obrazkoveokno.close();
  }
    obrazkoveokno = window.open(url,"obrazek",winfeatures);
  alert(obrazkoveokno);
}
*/

///////////////////////////////////////////////////////////////////////////////
////////////////////////////////Projector//////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
var LTO = 500 //miliseconds to wait for check if images are loaded...

function Projector(screen,slides,timeout,name) {
  this.screen = screen || null
  this.slides = slides || []
  this.timeout = timeout || 1000
  this.name = name || ''

  this.start = start
  this.play = play
  this.stop = stop
  this.next = next
  this.toggle = toggle
  if ( screen ) {
    this.gettimeout = gettimeout
    this.timerID = null
    this.timerRunning = false
    this.wait4load = false
    this.counter = 0
    this.loop = true
  }
}
function gettimeout() {
  return this.timeout
}
function hrefProjector(screen,slides,timeout,name) {
  this.base = Projector
  this.base(screen,slides,timeout,name)
  this.change = href_change
  this.screenloadedp = href_loadedp
}
hrefProjector.prototype = new Projector

function imageProjector(screen,slides,timeout,name) {
  this.base = Projector
  this.base(screen,preloadimages(slides),timeout,name)
  this.change = img_change
  this.screenloadedp = img_loadedp
}
imageProjector.prototype = new Projector

function imageProjector2(screen,slidesandtimeouts,loop,name) {
  this.base = imageProjector
  this.timeouts = new Array()
  var slides = new Array()
  for (i=0;i < slidesandtimeouts.length; i++){
    this.timeouts[i] = slidesandtimeouts[i].to
    slides[i] = slidesandtimeouts[i].img
  }
  this.base(screen,slides,this.timeouts[0],name)
  this.loop = loop
  this.gettimeout = imageProjector2gettimeout
}
imageProjector2.prototype = new imageProjector

function imageProjector2gettimeout(){
  return this.timeouts[this.counter]
}

function play(){
  this.stop()
  this.timerRunning = true
  this.next()
}

function start(){
  this.stop()
  projector_setnext(this)
}


function projector_setnext(p){
  p.timerID = setTimeout(p.name + '.next()' , p.gettimeout())
  p.timerRunning = true
}

function stop() {
  if ( this.timerRunning ) {
    clearTimeout(this.timerID)
  }
  this.timerRunning = false
}

function img_loadedp() {
  if ( !this.screen.complete ) { return false }
  else { return true }
}
function href_loadedp() {
    imgs = this.screen.document.images
    for (var i = 0; i < imgs.length; i++) {
      if (!imgs[i].complete) { return false }
    }
  return true
}

function href_change() {
  this.screen.location.href = this.slides[this.counter] }
function img_change() {
   this.screen.src = this.slides[this.counter].src
}

function next() {
    if ( !this.screenloadedp() ) {
      this.wait4load = true
      this.timerID = setTimeout(this.name + '.next()' , LTO)
    } else {
      if ( this.wait4load ) {
        this.wait4load = false
        this.timerID = setTimeout(this.name + '.next()' , this.gettimeout())
      } else {
        this.change()
        if ( this.counter < this.slides.length - 1) {
            this.counter++ }
        else {
          this.counter = 0
          if ( !this.loop ) {
            this.stop()
      		}
      	}
        if ( this.timerRunning ) { projector_setnext(this) }
    	}
    }
}

function toggle() {
  if ( this.timerRunning ) {
    this.stop()
  }
  else { this.play() }
}

function preloadimages(srcs) {
  if ( srcs ) {
    var preloaded = new Array()
    for (i=0; i < srcs.length; i++){
        preloaded[i] = new Image()
        preloaded[i].src = srcs[i]
    }
    return preloaded
  }
}

////////////////////////////
////////////menu////////////
////////////////////////////

var defaultstatustext = 'Northsea / Tools +'
top.window.defaultStatus = defaultstatustext

function Menumanager(nameprefix,activemenuitem,menuitems){
  this.name = nameprefix || ''
  this.activemenuitem = activemenuitem || 0
  this.menuitems = loadmenuitems(menuitems)
  this.change = changemenuitem
  this.menuimgname = menuimgname
  this.over = menuover
  this.out = menuout
}

function menuimgname(suffix){
  return this.name + suffix
}
function changemenuitem(menuitem){
  document[this.menuimgname(this.activemenuitem)].src = this.menuitems[this.activemenuitem].L.src
  document[this.menuimgname(menuitem)].src = this.menuitems[menuitem].A.src
  this.activemenuitem = menuitem
}

function menuover(menuitem) {
    document[this.menuimgname(menuitem)].src = this.menuitems[menuitem].H.src
   top.window.status = this.menuitems[menuitem].statusline
}

function menuout(menuitem) {
    if (menuitem == this.activemenuitem){
     document[this.menuimgname(menuitem)].src = this.menuitems[menuitem].A.src}
   else {
     document[this.menuimgname(menuitem)].src = this.menuitems[menuitem].L.src}
   top.window.status = defaultstatustext

}
function loadmenuitems(menuitems) {
  if ( menuitems ) {
    var loadeditems = new Array()
    for (i=0; i < menuitems.length; i++){
        loadeditems[i] = new menuitemimg(menuitems[i])
    }
    return loadeditems
  }
}

function menuitemimg(params){
  this.statusline = params[0]
  this.L = new Image
  this.L.src = params[1]
  this.A = new Image
  this.A.src = params[2]
  this.H = new Image
  this.H.src = params[3]
}



