   var nn4 = ( document.layers )
   var ie4 = ( document.all )
   var old = ( navigator.appName == "Netscape" && !document.layers && !document.getElementById )
   var nn6 = ( window.sidebar )


   var x, y
   var timebuffer = null
   var lastmenu   = ''
   var hidden     = ''
   var  hiddenselects = new Array()
   var hiddens = false

   window.onresize = function(){ location.reload() }
// document.onmousemove = xcoords

   with( document ){
      writeln( "<STYLE>" )
                writeln( '.section { position:absolute; width:100; height:auto; top:0; left:0; visibility:hidden; z-index:100 }' )
      if( ie4 ) writeln( '.point   { position:relative }' )
      writeln( "</STYLE>" )
   }

function xcoords() {
   window.status = 'x:' + event.y + ' y:' + event.x
}

function hidemenu( id, t ){
   if( t ){ timebuffer = setTimeout( 'hide( "' + id + '" )', t )}
   else   { hide( id )}
}

function showmenu( id, islast ){

   clearTimeout( timebuffer )

   if( lastmenu != '' ) hide( lastmenu )
   lastmenu = id

   pointer = 'point' + id
   x = ie4 ? document.all[pointer].offsetTop  : document.images[pointer].y
   y = ie4 ? document.all[pointer].offsetLeft : document.images[pointer].x

   id = 'menu' + id
   if( id != 'menuSmiles' ){
      x += 10
      y -= 11
   }
   else {
      if ( ie4 ){
         obj = document.all[id]
      }
      else if( nn4 ){
         obj = document.layers[id]
         y -= 110
      }
      else if( nn6 ){
         obj = document.getElementById( id )
      }
      x -= getHeight( obj )
   }

   if( ie4 ){
//      if( islast && document.all['menuHide'] ){
//         hide( 'Hide' )
//         hidden = 'menuHide'
//      }

      obj = document.all[id]
      if( !obj ){ return }
      obj.style.top  = x
      obj.style.left = y
      obj.style.visibility = "visible"

      menuBottom = x + getH( obj ) - 1
      menuRight  = y + getW( obj ) - 1

      hiddenselects.length = 0
      hiddens = false
      j = 0
      for( formx in document.forms ){
         arrx = document.forms[formx].elements
         if( !arrx ) continue
         for( i=0; i<arrx.length; i++ ){
            if( arrx[i].type.indexOf( 'select' ) == -1 ) continue
            if(( getT( arrx[i] )        ) > menuBottom ) continue
            pLarr = getL( arrx[i] )
            if(( pLarr                  ) > menuRight  ) continue
            if(( pLarr + getW( arrx[i] )) < y          ) continue
            arrx[i].style.visibility = 'hidden'
            hiddenselects[j++] = arrx[i]
            hiddens = true
         }
      }
      m2 = document.all['midbaner']
      if( m2 ){
         if( getT( m2 ) <= menuBottom ){
            pLarr = getL( m2 )
            pRarr = pLarr + getW( m2 ) - 1
            if(( menuRight >= pLarr && menuRight <= pRarr ) || ( y >= pLarr && y <= pRarr )){
               m2.style.visibility = 'hidden'
               hiddenselects[j++] = m2
               hiddens = true
            }
         }
      }

   }
   else if( nn4 ){
      if( islast && document.layers['menuHide'] ){
         hide( 'Hide' )
         hidden = 'menuHide'
      }
      obj = document.layers[id]
      obj.top  = x
      obj.left = y
      obj.visibility = "show"
   }
   else if( nn6 ){
      obj = document.getElementById( id )
      obj.style.top  = x + 'px'
      obj.style.left = y + 'px'
      obj.style.visibility = "visible"
   }
   return true

}

function hide( id ){

   id = 'menu' + id
   if( ie4 ){
      if( document.all[id] ){
         document.all[id].style.visibility = 'hidden'
         if( hiddens ){
            for( ix=0; ix<hiddenselects.length; ix++ ){
               hiddenselects[ix].style.visibility = 'visible'
           }
         }
         hiddens = false
      }
   }
   else if( nn4 ) document.layers[id].visibility    = 'hide'
   else if( nn6 ) document.getElementById( id ).style.visibility = 'hidden'

   if( hidden ){
      if     ( ie4 ){
         document.all[hidden].style.visibility = 'visible'
      }
      else if( nn4 ) document.layers[hidden].visibility    = 'show'
      hidden = ''
   }
}

function wopen( url, game, ww, hh ){

   if( game ){
      ww = '650'
      hh = '350'
   }
//   else {
//      ww = '550'
//      hh = '350'
//   }
   if( !ww ) ww = '550'
   if( !hh ) hh = '350'

   if( document.all ){
      wtop  = ",left=" + ( screen.availWidth  - ww )/2
      wleft = ",top="  + ( screen.availHeight - hh )/2
   }
   else if( document.layers ){
      wtop  = ",screenX=" + ( screen.availWidth  - ww )/2
      wleft = ",screenY=" + ( screen.availHeight - hh )/2
   }
   else {
      wtop  = ""
      wleft = ""
   }
   if( game ) wnd = window.open( url, "game_pass", 'scrollbars=yes,width=' + ww + ',height=' + hh + wtop + wleft )
   else       wnd = window.open( url, "sendlink" , 'scrollbars=no,width=' + ww + ',height=' + hh + wtop + wleft )
   wnd.focus()
}

function scrollInit(){   

   nrTop = -1
   sL = (nn4) ? document.images.scroller.x : scroller.offsetLeft
   sT = (nn4) ? document.images.scroller.y : scroller.offsetTop
   sH = (nn4) ? document.images.scroller.height : scroller.height
   sW = (nn4) ? document.images.scroller.width  : scroller.width

   for( i=0; i<messages.length; i++ ){
      createScroll( i, sL, sT, sW, sH, messages[i] )
   }

   moveDivTo( messages[0], sL, sT )
   showDiv( messages[0] )
   if( messages.length > 1 ) setTimeout( "newBanner()", pauza )

}
function newBanner() {

   if( ++nrTop > messages.length-1 ){ nrTop = 0 }
   nrBot = nrTop+1
   if( nrBot > messages.length-1 ){ nrBot = 0 }

   clipDiv( messages[nrBot], 0, 0, 0, 0 )
   moveDivTo( messages[nrBot], sL, sT+sH )
   showDiv( messages[nrBot] )
   timer = setInterval( "krokDoGory()", interwal )
}


function krokDoGory() {

   pos = getTop( messages[nrBot] )

   if( pos == sT ) {
      clearInterval( timer )
      setTimeout( "newBanner()", pauza )
   }
   else {
      if( pos >= sT+krok ) step = krok
      else                 step = sT-pos
      clipDiv( messages[nrTop], 0, sT+sH-pos+step, sW, sH )
      clipDiv( messages[nrBot], 0, 0, sW, sT+sH-pos+step )
      moveDivBy( messages[nrTop], 0, -step )
      moveDivBy( messages[nrBot], 0, -step )

   }
}


function createScroll( id, left, top, width, height, txt ) {

   name = 'scrollname' + id
   if( ie4 ){
      txt = '<DIV id=' + name + ' style="visibility:hidden; overflow:hidden; position:absolute; top:'+top+'; left:'+left+'; width:'+width+'; height:'+height+'">' + txt + '</DIV>'
      document.body.insertAdjacentHTML( "BeforeEnd", txt )
      messages[id] = eval('document.all.' + name)
   }
   else if( nn4 ){
      obj = new Layer( width )
      obj.name = name
      obj.left = left
      obj.top  = top
      obj.clip.height = height
      obj.visibility  = 'hide'
      obj.document.open()
      obj.document.write( txt )
      obj.document.close()
      messages[id] = obj
   }

}

//-----------------------------------------------------------------------------
function formerror( txt ){

   if( !txt ){
      txt = 'Popraw pola oznaczone na czerwono';
      if( ie4 ){ txt += '\n(opis w "dymku" pod czerwonym tekstem)' }
   }
   alert( txt )

}

//-----------------------------------------------------------------------------

function hideDiv( layer ) {

  if( nn4 ) layer.visibility = "hide"
  if( ie4 ) layer.style.visibility = "hidden"
}

function showDiv(layer) {

  if( nn4 ) layer.visibility = "show"
  if( ie4 ) layer.style.visibility = "visible"
}

function moveDivTo( layer, x, y ) {

  if( nn4 ) layer.moveTo( x, y )
  if( ie4 ) {
     layer.style.left = x
     layer.style.top  = y
  }
}

function moveDivBy( layer, dx, dy ) {

  if( nn4 ) layer.moveBy(dx, dy)
  if( ie4 ) {
     layer.style.pixelLeft += dx
     layer.style.pixelTop  += dy
  }
}

function getTop( layer ) {

  if( nn4 ) return( layer.top )
  if( ie4 ) return( layer.style.pixelTop )
  return -1
}

function getLeft( layer ) {

  if( nn4 ) return( layer.left )
  if( ie4 ) return( layer.style.pixelLeft )
  return -1
}

function getHeight( layer ) {

  if ( nn4 ) {
    if ( layer.document.height ) return( layer.document.height )
    else                         return( layer.clip.bottom - layer.clip.top )
  }
  if ( ie4 ) {
      return( layer.clientHeight );
  }

  return -1;
}

function clipDiv( layer, clipleft, cliptop, clipright, clipbottom ) {

  if( nn4 ) {
     layer.clip.left   = clipleft
     layer.clip.top    = cliptop
     layer.clip.right  = clipright
     layer.clip.bottom = clipbottom
  }
  if( ie4 ) layer.style.clip = 'rect(' + cliptop + ' ' +  clipright + ' ' + clipbottom + ' ' + clipleft +')'
}

//-------------------
function wprint( url ){

   if( document.all ){
      wtop  = ",left=0"
      wleft = ",top=0"
      hh    = screen.availHeight
   }
   else if( document.layers ){
      wtop  = ",screenX=0"
      wleft = ",screenY=0"
      hh    = screen.availHeight
   }
   else {
      wtop  = ""
      wleft = ""
      hh    = 480
   }
   hh -= 80

   wnd = window.open( url, "kartka", 'menubar=yes,resizable=no,scrollbars=yes,width=520,height=' + hh + wtop + wleft )
}

//-----------------
function iwnd( src ){

   if( ie4 ){
      wtop  = ",left=0"
      wleft = ",top=0"
      hh    = screen.availHeight - 30
      ww    = screen.availWidth  - 130
   }
   else if( nn4 ){
      wtop  = ",screenX=0"
      wleft = ",screenY=0"
      hh    = screen.availHeight - 30
      ww    = screen.availWidth  - 130
   }
   else {
      wtop  = ""
      wleft = ""
   }

   wnd = window.open( "", "powiekszenie", 'resizable=yes,scrollbars=yes,width=' + ww + ',height=' + hh + wtop + wleft )
   wnd.focus()
   with ( wnd.document ){
      writeln( "<HEAD><TITLE>Powiększenie</TITLE></HEAD><BODY onLoad='focus()' topmargin=0 leftmargin=0 marginwidth=0 marginheight=0>" )

      writeln( "<img border=0 hspace=0 vspace=0 src='" + src + "'>" )

      writeln( "</BODY></HTML>" )
      close()
   }
   return false
}
// ===================================


var skin_xo = 17
var skin_yo = 20
var skin_w  = 130
var skin_bg = 'darkgray'
var skin_fg = 'white'
var skin
document.write( "<DIV ID='skinId' style='position:absolute; left:-1000; width:" + skin_w + "'> </DIV>" )

function skin_mouse( e ){

   if( !skin ){ return }

   x = skin_xo
   y = skin_yo

   if( nn4 || nn6 ){
      x += e.pageX
      y += e.pageY
      mx = window.innerWidth - skin_w
   }
   else {
      x += event.x + document.body.scrollLeft;
      y += event.y
      if( navigator.appVersion.indexOf( "MSIE 4" ) == -1 ) y += document.body.scrollTop
      mx = document.body.clientWidth - skin_w + document.body.scrollLeft
   }
   if( x > mx ) x = mx

   skin.top  = y + 'px'
   skin.left = x + 'px'
}
function skin_pop( msg, bgc ){

   if( !skin ){
      if( nn6 ){
         skin = document.getElementById("skinId").style
         document.addEventListener( "mousemove", skin_mouse, true )
      }
      else if( nn4 || ie4 ){
         if( nn4 ){
            skin = document.skinId
            document.captureEvents( Event.MOUSEMOVE )
         }
         else { skin = skinId.style }
         document.onmousemove = skin_mouse
      }
      else { return }
   }

   content = "<TABLE width='"+skin_w+"' border='1' bordercolor="+skin_bg+" cellpadding=1 cellspacing=0 bgcolor="+bgc+"><TD align='center' class=txts><FONT color="+skin_fg+">"+msg+"</FONT></TD></TABLE>"

   if( nn4 ){ 
      skin.document.open()
      skin.document.write( content )
      skin.document.close()
   }
   else if( ie4 ){ skinId.innerHTML = content }  
   else if( nn6 ){ document.getElementById( "skinId" ).innerHTML = content }

   return
}

function skin_kill(){
   if( !old ){
      skin.left = '-1000px'
      skin = false
   }
}
function cookie_set( name, val, y, m, d ){

//alert( val )
   if( !y ) y = 2100
   if( !m ) m = 12
   if( !d ) d = 31
   d = new Date( y, m, d )
   document.cookie = name + '=' + escape( val ) + '; path=/; expires=' + d.toGMTString()
}

// ===================================

function trcolor( obj, color, url ){
   if( ie4 ){
      obj.style.backgroundColor = color
      if( url ){
         obj.style.cursor = 'hand'
         obj.onclick = function(){ document.location.href= url }
         window.status = url
      }
      else window.status = ''
   }
}

// ===================================

function ibop_vote( obj, vote ){

   found = ''
   for( i=0; i<obj.form.elements.length; i++ ){
      el = obj.form.elements[i]
      if(( el.type == 'radio' || el.type == 'checkbox' ) && el.checked ){
         found += '/' + ( i+1 )
      }
   }

   if( !found ){ alert( 'Zaznacz coś...' )}
   else if( vote ){
      wopen( '/cgi-bin/echo/ibop/vote/vote/' + vote + found, 0, 300, 80 )
      wnd.opener = self
   }
}

function mod_sendform(){

   ww = '300'
   hh = '200'

   if( document.all ){
      wtop  = ",left=" + ( screen.availWidth  - ww )/2
      wleft = ",top="  + ( screen.availHeight - hh )/2
   }
   else if( document.layers ){
      wtop  = ",screenX=" + ( screen.availWidth  - ww )/2
      wleft = ",screenY=" + ( screen.availHeight - hh )/2
   }
   else {
      wtop  = ""
      wleft = ""
   }
   wnd = window.open( '', 'formwnd' , 'scrollbars=no,width=' + ww + ',height=' + hh + wtop + wleft )

}

