// (c)1999/2001 r0k@tap.de

// buttons
////////////////////////////////////////////////////////////////////////////////////////
var totalGraphics = 0;
var graphic       = new Array();

var picked        = -1;
var highlighted   = -1;

imageSubdirectory = "./_gfx/";
imagePrefix       = "";
offSuffix         = "_n.gif";
onSuffix          = "_a.gif";
dispSuffix        = "_p.jpg";
pickSuffix        = "";

function geGraphic( width, height, name, statusText, linked, display ) {

  this.height   = height;
  this.width    = width;
  this.name     = name;
//  this.link     = link;
  this.off      = new Image( width, height );
  this.off.src  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.offname  = imageSubdirectory + imagePrefix + name + offSuffix;
  this.disp     = false;
  
  // 'linked' images are hoovers
  if( linked == true ) {
    this.on         = new Image (width, height);
    this.on.src     = imageSubdirectory + imagePrefix + name + onSuffix;
    this.pick       = new Image (width, height);
    this.pick.src   = imageSubdirectory + imagePrefix + name + pickSuffix;
    this.statusText = statusText;
  }
  
  // 'display' images have a unique area do show
  if( display == true ) {
    this.disp       = new Image();
    this.disp.src   = imageSubdirectory + imagePrefix + name + dispSuffix;
  }
}


function geButton( width, height, name, statusText, linked, display ) {
  graphic[totalGraphics++] = new geGraphic(width, height, name, statusText, linked, display);
}

// mouseover (with 'center' display)
function doOver( num ) {

  if( num != picked ) {
    document.images[graphic[num].name].src = graphic[num].on.src;
    if( graphic[num].disp != false )
      document.images['center'].src = graphic[num].disp.src;
  }

  if( highlighted != picked && highlighted != num )
    document.images[graphic[highlighted].name].src = graphic[highlighted].off.src;
    
  highlighted = num;
  self.status = graphic[num].statusText;
}

// mouseoverex, indexnummer und grafiknummer (r0k3 -> dritte kopie vom ersten bild)
function doOverEX( num, val ) {
  
  if( num != picked )
    document.images[(graphic[num].name + val )].src = graphic[num].on.src;
    
  if( highlighted != picked && highlighted != num )
    document.images[(graphic[highlighted].name + val )].src = graphic[highlighted].off.src;
    
  highlighted = num;
  self.status = graphic[num].statusText;
}


// mouseout
function doOut( num ) {

  if (highlighted != picked) {
    document.images[graphic[highlighted].name].src = graphic[highlighted].off.src;
    // temp ;)
    document.images['center'].src = imageSubdirectory + 'center.jpg';
  }
  self.status = "";
}

// mouseoutex, indexnummer und grafiknummer (r0k3 -> dritte kopie vom ersten bild)
function doOutEX( num, val ) {
   
  if (highlighted != picked)
    document.images[(graphic[highlighted].name + val )].src = graphic[highlighted].off.src;
  self.status = "";
}

// shows a link with correct status bar display
////////////////////////////////////////////////////////////////////////////////////////
function doLINK( name, URL ) {
 document.write('<a href="javascript:openLINK( \'http://'+URL+'\')" onmouseover="javascript:self.status=\''+URL+'\'; return true;" onmouseout="javascript:self.status=\'\'">'+name+'</a>'  );
}

// opens an link
////////////////////////////////////////////////////////////////////////////////////////
function openLINK( filename ) {
 window.open( filename );
}

// opens a url with width / height or fullscreen
////////////////////////////////////////////////////////////////////////////////////////
function openURL( filename, wx, wy ) {
   
 // enshure params are numbers
 cx     = parseInt(wx);
 cy     = parseInt(wy);
 
 // window style
 config =  'resizable=no,';
 config += 'channelmode=no,';
 config += 'location=no,';
 config += 'menubar=no,';
 config += 'scrollbars=no,';
 config += 'statusbar=yes,';
 config += 'toolbar=no,';

 // fullscreen check
 if( !cx || !cy ) {
    
  config += 'fullscreen=yes';
 } 
 else {
    
  config += 'width=';
  config += cx;
  config += ',height=';
  config += cy;
 }

 mywin = window.open( filename, "myWindow", config );

 // second fullscreen check
 if( !cx || !cy ) {
    
  if( mywin.moveTo ) {
     
     mywin.moveTo( 0, 0 );
     mywin.resizeTo( screen.availWidth, screen.availHeight );
  }
 }
}