   var n4 = ( document.layers ) ? true : false
   var i4 = ( document.all ) ? true : false
   var n6 = ( document.getElementById && !i4 ) ? true : false
   var op = ( navigator.appName.indexOf( "Opera" ) != -1 ) ? true : false
   var wnd
   fldobj = ''
   var clicked = new Array()

function ao1(obj){obj.style.backgroundColor='#FFFFFF'}
function ao2(obj){obj.style.backgroundColor='#F3F2F0'}
function ao0(obj){obj.style.backgroundColor=''}

function nao0(obj,nr){if(clicked[nr]){obj.style.backgroundColor='#FFFF00'}else{obj.style.backgroundColor=''}}
function nac0(obj,nr){if(clicked[nr]){clicked[nr]=false}else{clicked[nr]=true;obj.style.backgroundColor='#66DD00'}}

function alltrim ( str ){ return str.replace( /^\s+|\s+$/g, '' )}

function spoiler( btn, txtshow, txthide ){

   btn.blur()
   obj = btn.parentNode.getElementsByTagName('div')[0]
   if( btn.value == txtshow ){
      btn.value = txthide
      obj.style.display = ''
   }
   else {
      btn.value = txtshow
      obj.style.display = 'none'
   }

}

function spoiler_can_on( btn ){
   if( btn.value == 'show' ) btn.className = 'btn_spoiler_show_on'
   else                      btn.className = 'btn_spoiler_hide_on'

}
function spoiler_can_off( btn ){
   if( btn.value == 'show' ) btn.className = 'btn_spoiler_show'
   else                      btn.className = 'btn_spoiler_hide'
}
function spoiler_can( btn, txtshow, txthide ){
   btn.blur()
   obj = btn.parentNode.getElementsByTagName('div')[0]
   if( btn.value == txtshow ){
      btn.value = txthide
      obj.style.display = ''
      btn.className     = 'btn_spoiler_hide'
   }
   else {
      btn.value = txtshow
      obj.style.display = 'none'
      btn.className     = 'btn_spoiler_show'
   }
}

function myscroll(){

   obj = getO( 'form_error_div' )
   x = getT( obj )
   window.scrollTo( 0, x-20 )
   alert( 'Popraw pola zaznaczone na czerwono\n(opis błędu w "dymku" pod nazwą pola)' )
}

function myscrollend(){
   window.scrollTo( 0, 1000000 )
   alert( 'Popraw pola zaznaczone na czerwono\n(opis błędu w "dymku" pod nazwą pola)' )
}

function zapisz( btn, p ){
   form = btn.form

   btn.style.cursor = 'wait'
   if( btn.value == 'czekaj...' ){
      alert( 'Trwa zapisywanie danych...' )
      return false
   }
   else {
      btn.disabled = true
      btn.value    = 'czekaj...'
      if( p ){
         form.target = '_self'
//         if( top != self ) top.cms_preview( 0 )
      }
      form.submit()
      return false
   }
}

function preview0( act ){
   top.cms_preview( 1 )
   top.pview.document.location.href = act
}

function preview( obj, act ){
   form = obj.form
   form.target = 'pview'
   form.action.value = act
   form.submit()
}

function preview2( obj, act ){
   top.cms_preview( 1 )
   doc = top.pview.document
   doc.open()
   doc.write( '<HTML><HEAD><LINK REL="stylesheet" TYPE="text/css" HREF="/!cms/admin/admin/styles.css"></HEAD><BODY scroll="no"><TABLE height=100% width=100% cellpadding=10 cellspacing=0><TR><TD align=center valign=middle width=100%><IFRAME name=pviewiframe id=pviewiframe width=100% height=100% src=""></IFRAME></TD></TR></TABLE></BODY></HTML>' )
   doc.close()

   form = obj.form
   form.target = 'pviewiframe'
   form.action.value = act
   form.submit()
}

function check_vote( btn, txt ){
   form = btn.form

   if( btn.value != 'czekaj...' ){
      for( i=0; i<form.elements.length; i++ ){
         el = form.elements[i]
         if(( el.name == 'pts' || el.name.substr( 0, 4 ) == 'vote' ) && el.checked ){
            btn.disabled     = true
            btn.style.cursor = 'wait'
            btn.value        = 'czekaj...'
            form.submit()
            return false
         }
      }
   }
   else {
      alert( 'Trwa zapisywanie danych...' )
      return flase
   }
   if( !txt ){ txt = 'Zaznacz liczbę punktów...' }
   alert( txt )
   return false
}

function galeria( xtitle, xjpg, xcopy ){

   if( !wnd || wnd.closed ) wnd = window.open( '', '', 'toolbar=no,menubar=yes,scrollbars=yes,resizable=yes' )
   with( wnd.document ){
      open()
      write( '<HTML><HEAD><META http-equiv="content-type" content="text/html; charset=iso-8859-2"><TITLE>' + xtitle + '</TITLE></HEAD><BODY bgcolor="#000000" onload="focus()" style="margin:0px"><CENTER>' )
      write( '<img src="' + xjpg + '">' )
      if( xcopy ) write( '<P style="margin-top:5px; color:#999999; font-family:verdana; font-size:10px">Copyright &copy; by '+ xcopy +'<BR>&nbsp;' )
      write( '</CENTER></BODY></HTML>' )
      close()
   }
   wnd.focus()
}

function blank2(){
   if( top != self ) top.blank( 2 )
}

function edit( url, obj ){
   if( top == self ){ alert( 'W "nowym" okienku edycja nie jest możliwa.' )}
   else {
      strAttr = "status:no;dialogWidth:640px;dialogHeight:400px;help:no;scroll:no";
      html = showModalDialog( url, obj, strAttr );
   }
}

function edit_end(){
   alert( 'ok' )
}

function save( obj, act ){
   form = obj.form
   if( obj.value != 'czekaj...' ){
      if( top == self ){ alert( 'W "nowym" okienku zapis nie jest możliwy.' )}
      else {
         obj.value = 'czekaj...'
         form.target       = '_self'
         form.action.value = act
         form.submit()
      }
   }
}

//---------------------------------------------------------------
function post_authdiv( auth, clsp, fld_nick ){
   if( !auth ) return
   form = document.forms['post']
   o1   = getO( 'authdiv1' )
   o2   = getO( 'authdiv2' )
   o1.style.display = 'none'
   o2.style.display = 'none'  
   if     ( auth == 1 ){ o1.style.display = 'block' }
   else if( fld_nick  ){ o2.style.display = 'block' }
   if( clsp ){ form.auth.value = auth }
}

var checkit_obj = ''
//---------------------------------------------------------------
function tvfavorite( obj, site, id ){

   checkit_obj = obj
   onoff       = checkit_obj.checked ? 1 : 0
   url         = '/!cms/rjs_tvfavorite.php?' + site + '-' + id + '-' + onoff
   checkit_obj.disabled = true 
   httpGET( url, checkit_response )

}
function tvfavorite_zig( site, id, onoff ){
   url = '/!cms/rjs_tvfavorite.php?' + site + '-' + id + '-' + onoff
   httpGET( url, tvfavorite_zig_response )
}
function tvfavorite_zig_response( err, txt ){
   if( err != 'ok' ) alert( err )
   else {
      onoff = txt.substr( 0, 1 )
      txt   = txt.substr( 1 )
      alert( txt )
      obj_add = getO( 'tvfav_add' )
      obj_del = getO( 'tvfav_del' )
      if( onoff == 1 ){ obj_add.style.display = 'none';    obj_del.style.display = 'block' }
      else            { obj_add.style.display = 'block';   obj_del.style.display = 'none'  }
   }
}

function watch_topic( obj, site, id, locked ){ 

   checkit_obj = obj
   checkit_obj.blur()
   onoff = checkit_obj.checked ? 1 : 0
   if( locked && onoff ){
      locked = locked == 'M' ? 'pewien' : 'pewna'
      if( !confirm( 'Jesteś ' + locked + ', że chcesz śledzić zablokowany temat?' )){
         obj.checked = false 
         return
      }
   }

   checkit_obj.disabled = true
   params = 'includeid=' + site + '-' + id + '-' + onoff
   url = '/!cms/admin/forum/lib_watch_topic.php'
   httpPOST( url, watch_topic_response, params )
}

function watch_topic_response( err, txt ){

   if( err == 'ok' ) err = ''
   alert( err + txt )
   checkit_obj.disabled=false
}

function mailtopic( obj, site, id, locked ){

   checkit_obj = obj
   checkit_obj.blur()
   onoff = checkit_obj.checked ? 1 : 0
   if( locked && onoff ){
      locked = locked == 'M' ? 'pewien' : 'pewna'
      if( !confirm( 'Jesteś ' + locked + ', że chcesz śledzić zablokowany temat?' )){
         obj.checked = false 
         return
      }
   }

   checkit_obj.disabled = true 
   url = '/!cms/rjs_mailtopic.php?' + site + '-' + id + '-' + onoff
   httpGET( url, checkit_response )

}

function checkit_response( err, txt ){

   if( err != 'ok' ) alert( err )
   else              alert( txt )
   checkit_obj.disabled=false
}


var forum_button_clicked = false
//---------------------------------------------------------------
function post_del( url ){

   if( forum_button_clicked ){
      alert( 'Chwileczkę...' )
      return
   }

   if( fixed_div ) return false

   if( confirm( 'Potwierdź, że zgłaszasz ten post do usunięcia.' )){
      forum_button_clicked = true
      url = '/!cms/rjs_forum_post.php?del-' + url
      httpGET( url, post_del_response )
   }

}
function post_del_response( err, txt ){
   forum_button_clicked = false
   alert( err+txt )
}

//var post_move_site = '';
//var post_move_id   = '';


function post_move( site, id, fixed ){

   if( fixed_div ) return false
   fixed_open( 'post_move_div', 250, 100 )

   url = '/!cms/rjs_post_move.php?show-' + site + '-' + id + '-' + Math.random()
   httpGET( url, fixed_response )
}

function post_move_send( action, site, topic ){

   if( action == 'move' && !confirm( 'Are you sure na pewno?' )) return

   form = document.forms.postmove

   params = 'site=' + site + '&action=' + action + '&topic=' + topic
   for( i=0; i<form.elements.length; i++ ){
      el   = form.elements[i]
      name = el.name
      if( name ){
         if( el.type == 'checkbox' ) params += '&' + name + '=' + ( el.checked ? 1 : 0 ) 
         else                        params += '&' + name + '=' + encodeURIComponent( el.value )
      }
   }
   url = '/!cms/rjs_post_move.php'

   if( action == 'topics' ) {
      obj = getO( 'post_move_topics' )
      obj.innerHTML = "<img src='/!cms/images/loading.gif' style='margin-top:90px; margin-left:300px'>"
      httpPOST( url, post_move_topics_response, params )
   }
   else {
      fixed_wait()
      httpPOST( url, fixed_response, params )
   }
	return
}

function post_move_topics_response( err, txt ){

//alert( err + txt )
//return

   obj = getO( 'post_move_topics' )
   obj.innerHTML = txt

}
function post_topics_set( nr ){
   document.forms.postmove.merge_id.value = nr
   return false
}

// ---
function topic_edit( par ){

   if( fixed_div ) return false
   fixed_open( 'topic_edit_div', 250, 100 )

   url = '/!cms/rjs_topic_edit.php?' + par + '-' + Math.random()
   httpGET( url, fixed_response )
	return false
}

function topic_edit_send( action, site, topic ){

   if(( action == 'merge' || action == 'deltopic' ) && !confirm( 'Are you sure na pewno?' )) return

   form = document.forms.topicedit

   params = 'site=' + site + '&action=' + action + '&topic=' + topic
   for( i=0; i<form.elements.length; i++ ){
      el   = form.elements[i]
      name = el.name
      if( name ){
         if( el.type == 'checkbox' ) params += '&' + name + '=' + ( el.checked ? 1 : 0 ) 
         else                        params += '&' + name + '=' + encodeURIComponent( el.value )
      }
   }
   url = '/!cms/rjs_topic_edit.php'
   if( action == 'topics' ) {
      obj = getO( 'topic_edit_topics' )
      obj.innerHTML     = "<img src='/!cms/images/loading.gif' style='margin-top:90px; margin-left:300px'>"
      obj.style.display = 'block'
      httpPOST( url, topic_topics_response, params )
   }
   else {
      fixed_wait()
      httpPOST( url, fixed_response, params )
   }
}

function topic_topics_response( err, txt ){
   obj = getO( 'topic_edit_topics' )
   obj.innerHTML = txt
}

function topic_topics_set( nr ){
   document.forms.topicedit.merge_id.value = nr
   return false
}

function post_edit( url, fixed ){

   if( fixed_div ) return

   if( fixed ){
      if( fixed_div ) return false
      fixed_open( 'post_edit_div', 0, 0, 1 )
   }
   else {
      obj = getO( 'post_edit_div' )
      obj.parentNode.removeChild( obj )
      document.body.appendChild( obj )
      setPosCenter( obj )
   }

   form = document.forms['editpost']
   form.txt.value = ''
   form.par.value = url
   if( form.usun ) form.usun.disabled = true
   if( form.save ) form.save.disabled = true

   url = '/!cms/rjs_forum_post.php?edit-' + url
   httpGET( url, post_edit_response )
}
function post_edit_response( err, txt ){

   objcheck = form['fld_checkbox_txt']
   if( err ){
      objcheck.disabled = true
      alert( err )
   }
   else {
      form = document.forms['editpost']
      form.txt.value = txt
      if( form.usun ) form.usun.disabled = false
      if( form.save ) form.save.disabled = false
      objcheck.disabled  = false
      objcheck.checked   = ( form.txt.wrap == 'soft' ) ? true : false
   }

}

function post_edit_del( url ){

//   if( fixed_div ) return

   if( confirm( 'Are you sure na pewno?' )){
      url = '/!cms/rjs_forum_post.php?edit_del-' + url
      httpGET( url, post_edit_del_response )
      if( form.usun ) form.usun.disabled = true
      if( form.save ) form.save.disabled = true
   }
}
function post_edit_del_response( err, txt ){

//alert( err + txt )

   if( err == 'ok' ){ 
      post_edit_close()
      alert( 'Post został usunięty' )

      if( txt.length > 3 ){ document.location.href = txt }
      else                { history.go( 0 )}
   }
   else if( err != 'notlast' ){ 
      alert( err )
   }
   else if ( confirm( 'Możesz usuwać tylko swój ostatni post w danym temacie.\nCzy chcesz zgłosić ten post do usunięcia?' )){
      post_del( txt )
   }
   if( form.usun ) form.usun.disabled = false
   if( form.save ) form.save.disabled = false
}

function post_edit_save( form ){

   if( form.usun ) form.usun.disabled = true
   if( form.save ) form.save.disabled = true
   par    = form.par.value
   txt    = form.txt.value
   params = 'par=edit_save-' + par + '&txt=' + encodeURIComponent( txt )

   url = '/!cms/rjs_forum_post.php'
   httpPOST( url, post_edit_save_response, params )

}
function post_edit_save_response( err, txt ){

   form = document.forms['editpost']
   if( form.usun ) form.usun.disabled = false
   if( form.save ) form.save.disabled = false

   if( err ){
      form.txt.value = txt
      alert( err )
   }
   else { history.go( 0 )}

}

function post_cite( url ) {

//alert( url )
//return

   if( fixed_div ) return

   url = '/!cms/rjs_forum_post.php?cite-' + url
   httpGET( url, post_cite_response )
}
function post_cite_response( err, txt ){

   if( err ){
      alert( err )
   }
   else {
      form = document.forms['post']
      mT   = getT( form )
      window.scrollTo( 0, mT )
      if( form.txt.value ) txt = '\n\n' + txt
      form.txt.value += txt
   }

}

function post_edit_close(){
   obj = getO( 'post_edit_div' )
   setPos( obj, 0, -1000 )
   showElems( 'visible' )
}


//---------------------------------------------------------------
poll_div = ''

function poll_edit( par, c ){

   pool_wait( c )
   url = '/!cms/rjs_topic_poll.php?' + par
   httpGET( url, poll_edit_response )

}
function poll_edit_response( err, txt ){
//poll_div.innerHTML = err + txt
//return

   if     ( err.substr( 0, 1 ) == '?'  ){ poll_div.innerHTML = "<p align=center><b style='color:red'>" + err + "</b></p>" }
   else if( err == 'ok' ){ poll_div.innerHTML = txt }
   else                  { history.go( 0 )}

}
function poll_write( site, topic, amin, amax, date, show, revote, question, answer, sesid, c ){

   pool_wait( c )
   amin     = '&poll_amin='     + encodeURIComponent( amin )
   amax     = '&poll_amax='     + encodeURIComponent( amax )
   date     = '&poll_date='     + encodeURIComponent( date )
   revote   = '&poll_revote='   + encodeURIComponent( revote ? 1 : 0 )
   show     = '&poll_show='     + encodeURIComponent( show )
   question = '&poll_question=' + encodeURIComponent( question )
   answer   = '&poll_answer='   + encodeURIComponent( answer )
   params   = 'sesid=' + sesid + '&site=' + site + '&topic=' + topic + amin + amax + date + show + revote + question + answer
   url      = '/!cms/rjs_topic_poll.php'
   httpPOST( url, poll_edit_response, params )

}

function pool_wait( c ){
   if( !poll_div ) poll_div = getO( 'topic_poll' )
   h = getH( poll_div )
   poll_div.innerHTML = "<TABLE width=100% height=" + h + " cellpadding=0 cellspacing=0 border=0><TR><TD align=center valign=middle style='border:2px solid " + c + "; padding:10px'><img src='/!cms/images/loading.gif' /></TD></TR></TABLE>"
}

function poll_vote( btn, amin, amax, old, site, topic, sesid, c ){

   form = btn.form
	x    = 0
   par  = ''
   if( btn.value != 'czekaj...' ){
      btn.disabled     = true
      btn.style.cursor = 'wait'
      for( i=0; i<form.elements.length; i++ ){
         el = form.elements[i]
         if(( el.name == 'poll_vote[]' ) && el.checked ){
            x++
            par += '.' + el.value
         }
      }
   }
   else {
      alert( 'Trwa zapisywanie danych...' )
   }

   if( x >= amin && x <= amax ){
      par = par.substr( 1 )
      if( par == old ){
         txt = 'to nic nie zmieni...'
      }
      else {
         par = sesid + '-vote-' + site + '-' + topic + '-' + par
         btn.value = 'czekaj...'
         poll_edit( par, c )
         return
      }
   }
   else if( amin == amax && amin == 1 && !x ){ txt = 'zaznacz odpowiedź' }
   else { txt = 'zaznacz minimum ' + amin + ', maksimum ' + amax }    
   alert( txt )
   btn.disabled     = false
   btn.style.cursor = ''

}

oldobj = ''
//---------------------------------------------------------------
function post_preview( site, W, fixed ){

   if( fixed_div ) return false

   x = getPS()
   h = Math.max( 300, parseInt( 0.8 * x[3] ))
   w = W + 40

   fixed_open( 'post_preview_div', w, h )
   if( !fixed ){
      setPosCenter( fixed_div )
   }

/*
   if( fixed ){
      fixed_open( 'post_preview_div', w, h )
   }
   else {
      fixed_div = getO( 'post_preview_div' )
      fixed_div.parentNode.removeChild( fixed_div )
      document.body.appendChild( fixed_div )
      setPosCenter( fixed_div )
   }
*/

   form   = document.forms.post
   params = 'sesid=0&site=' + site + '&width=' + W

   for( i=0; i<form.elements.length; i++ ){
      el   = form.elements[i]
      name = el.name
      if( !name || name.substr( 0, 6 ) == 'utils_' ) continue
      params += '&' + name + '=' + encodeURIComponent( el.value )
   }
   url = '/!cms/rjs_post_preview.php'

//alert( params )

   httpPOST( url, fixed_response, params )

   return false

}
function post_utils_select( btn ){

   if( fixed_div ) return false

   if( oldobj ) oldobj.style.display = 'none'
   if( !btn.value ){ return }
   if( btn.value == 'poll' ){
      post_utils_poll_show( 1 )
   }
	else {
      document.forms.post.txt.focus()
      oldobj = getO( 'post_utils_' + btn.value )
      oldobj.style.display = 'block'
   }
}

function post_utils_poll_show( onoff ){
   document.forms.post.is_poll.value = onoff
   document.forms.post.utils_sel.selectedIndex = 0
   document.forms.post.utils_sel.blur()
   pollobj = getO( 'post_utils_poll' )
   onoff   = onoff ? 'block' : 'none'
   pollobj.style.display = onoff
   return false
}

function post_utils_link( what, txt1, txt2 ){
   txt1 = alltrim( txt1 )
   txt2 = alltrim( txt2 )
   if( !txt2 || ( what == 'link' && txt2 == 'http://' )){
      if( what == 'link' ){ alert( 'Podaj adres url' );     document.forms.post.utils_link_url.focus()}
      else                { alert( 'Podaj adres e-mail' );  document.forms.post.utils_mail_url.focus()}
      return
   }
   if( txt1 ) txt1 = '=' + txt1
   insertAtCaret( document.forms.post.txt, '[' + what + txt1 + ']' + txt2 + '[/' + what + ']' )
   document.forms.post.txt.focus()
}

function post_utils_spoiler(){
   txt = alltrim( document.forms.post.utils_spoiler_tyt.value )
   if( txt ) txt = '=' + txt
   insertAtCaret( document.forms.post.txt, '[spoiler' + txt + ']' )
   document.forms.post.txt.focus()
   return false
}

function post_utils_txt( obj, txt ){
   obj.blur()
   insertAtCaret( document.forms.post.txt, txt )
   document.forms.post.txt.focus()
   return false
}

album_fixed = false
//---------------------------------------------------------------
function album( site, par, fixed, cms ){
 
   if( fixed ){
      if( fixed_div ) return false
      fixed_open( 'album_div', 200, 100 )
      album_fixed = true
   }
   else {
      album_fixed = false
   }

   cms = cms ? 1 : 0
   url = '/!cms/rjs_galeria_album.php?' + site + '-' + par + '-' + cms + '-' + Math.random()
   httpGET( url, album_response, 1 )
   return false

}

function album_response( err, txt ){
   if( !album_fixed ){
      obj = getO( 'album_div' )
      fixed_div = obj
      
   }
   fixed_response( err, txt )
   if( !album_fixed ){
      obj.parentNode.removeChild( obj )
      document.body.appendChild( obj )
      setPosCenter( obj )
   }
   album_item( -item_img )
}

function album_close(){
   if( album_fixed ){ fixed_close()}
   else {
      obj = getO( 'album_div' )
      setPos( obj, 0, -1000 )
      showElems( 'visible' )
	}
}
function album_item( nr ){

   if( item_img == nr ) return

   obj = getO( 'album' + nr )
   obj.blur()

   if( item_img > 0 ) item_link.className = 'albumimg1'

   x = getO( 'item_nr' )
   x.innerHTML = nr

   x = getO( 'item_tyt' )
   x.innerHTML = item_arr[nr-1][3] + '&nbsp;'

   x = getO( 'item_lead' )
   x.innerHTML = item_arr[nr-1][4]

   x = getO( 'item_maxi' )
   txt = item_arr[nr-1][2]
   img = item_arr[nr-1][0]
   if     ( txt == 'jpg' ) txt = album_jpg( img )
   else if( txt == 'txt' || txt == 'rev' ) txt = album_txt( img )

   x.innerHTML = txt

   item_link  = obj
   item_img   = nr
   item_link.className = 'albumimg2'

   x = getO( 'item_menu' )
   h = getH( x )

   xmin = (nr-1)*96
   xmax = xmin + 95
   xcur = x.scrollTop

   if( xmin < xcur ) x.scrollTop = xmin
   if( xcur + h - 1 < xmax ) x.scrollTop = (nr-6)*96

   return false

}
function album_go( nr ){
   nr = item_img + nr
   if( nr < 1 || nr > item_max ) return
   album_item( nr )
}

//---------------------------------------------------------------
function storeCaret( obj ) {
   if ( obj.createTextRange ){
      obj.caretPos = document.selection.createRange().duplicate()
      top.copycont = obj
   }
}
function insertAtCaret( obj, text ) {
   if ( obj.createTextRange && obj.caretPos ){
      var caretPos  = obj.caretPos
      caretPos.text = caretPos.text.charAt( caretPos.text.length - 1 ) == ' ' ? text + ' ' : text
   }
   else {
      obj.value += text
   }
}

//---------------------------------------------------------------
function label_show( obj, id, form, inline ){

   obj2   = document.forms[form][id]
   fldobj = 'fld_check_' + id
   fldobj = getO( fldobj )

   t = getT( obj ) + getH( obj )

   if( inline ){ l = getL( obj ) - 42; t += 1 }
   else        { l = getL( obj ) + getW( obj ) - 36 }
   setPos( fldobj, t, l )

   objcheck = document.forms[form]['fld_checkbox_' + id]
   objcheck.checked = ( obj2.wrap == 'soft' ) ? true : false
   objcheck.blur()
   obj.onmouseover  = ''

}
function label_wrap( form, id ){

   obj2 = document.forms[form][id]
   if( obj2.wrap == 'soft' ){
      obj2.wrap = 'off'
      obj2.rows--
   }
   else {
      obj2.wrap = 'soft'
      obj2.rows++
   }
}

//---------------------------------------------------------------
function getO( e, doc ){
   if( !doc ){ doc = document }
   return doc.getElementById( e )

//   if( i4 ){ return doc.all[e] }
//   if( n4 ){ return doc.layers[e] }
//   if( n6 ){ return doc.getElementById( e )}
}

function setPos( e, t, l ){
   if( e ){
      if     ( i4 ){ e.style.top  = t;   e.style.left = l }
      else if( n4 ){ e.moveTo( l, t )}
      else if( n6 ){ e.style.top  = t + 'px'; e.style.left = l + 'px' }
   }
}

function newO( name, pT, pL, txt ){
   if( i4 ){
      div = document.body
      txt = '<DIV id="' + name + '" name="' + name + '" style="visibility:visible; position:absolute; top:'+pT+'; left:'+pL +'">' + txt + '</DIV> \n'
      div.insertAdjacentHTML( "BeforeEnd", txt )
      obj = document.all( name )
   }
   return obj
}

function getT( e ){
   var curtop = 0;
   if ( e.offsetParent ){
      while( e.offsetParent ){
         curtop += e.offsetTop
         e = e.offsetParent;
      }
   }
   else if ( e.y ) curtop += e.y
   return curtop
}

function getL( e ){
   var curtop = 0;
   if( e.offsetParent ){
      while( e.offsetParent ){
         curtop += e.offsetLeft
         e = e.offsetParent;
      }
   }
   else if ( e.x ) curtop += e.x;
   return curtop;
}

function getW( e ){
   result = 0
   if      ( e.offsetWidth ) result = e.offsetWidth
   else if ( e.clip && e.clip.width ) result = e.clip.width
   else if ( e.style && e.style.pixelWidth ) result = e.style.pixelWidth
   return parseInt( result )
}
function getH( e ) {
   result = 0
   if      ( e.offsetHeight ) result = e.offsetHeight
   else if ( e.clip && e.clip.height ) result = e.clip.height
   else if ( e.style && e.style.pixelHeight ) result = e.style.pixelHeight
   return parseInt( result )
}

function setW( e, w ){ e.style.width  = w + 'px' }
function setH( e, h ){ e.style.height = h + 'px' }

function getST(){
   x = 0;
   if      ( self.pageYOffset ) x = self.pageYOffset
   else if ( document.documentElement && document.documentElement.scrollTop ) x = document.documentElement.scrollTop
   else if ( document.body ) x = document.body.scrollTop
   return parseInt( x )
}
function getSL(){
   x = 0;
   if      ( self.pageXOffset ) x = self.pageXOffset
   else if ( document.documentElement && document.documentElement.scrollLeft ) x = document.documentElement.scrollLeft
   else if ( document.body ) x = document.body.scrollLeft
   return parseInt( x )
}

function setPosCenter( obj ){
   hideElems()

   a  = getPS()
   wT = getST()
   wT = Math.max( wT, wT     + parseInt(( a[3] - getH( obj ) )/2 ))
   wL = Math.max( 0, getSL() + parseInt(( a[2] - getW( obj ) )/2 ))
   setPos( obj, wT, wL )

//   obj.style.left = "50%"
//   obj.style.top  = "50%"
//   wT = getST() + getT( obj ) - parseInt( getH( obj )/2 )
//   wL = getSL() + getL( obj ) - parseInt( getW( obj )/2 )
//   if( wT < 0 ) wT = 0
//   if( wL < 0 ) wL = 0
//   setPos( obj, wT, wL )
}

function load_event( func ) {
   var oldonload = window.onload;
   if( typeof window.onload != 'function' ) window.onload = func
   else window.onload = function(){ oldonload(); func()}
}

//---------------------------------------------------------------
var backupElems = []
function hideElems(){
// badElems = [ "SELECT", "IFRAME", "APPLET", "EMBED", "OBJECT" ];
   badElems = [ "APPLET", "EMBED", "OBJECT" ];
//return
   if( document.all && ( window.navigator.userAgent.indexOf( "Opera" ) == -1 )){ 
      for( i=0; i < badElems.length; i++){
         backupElems[i] = document.getElementsByTagName ? document.getElementsByTagName( badElems[i] ) : document.all ? document.all.tags( badElems[i] ) : ""
      }
      showElems( 'hidden' )
   }
}   
function showElems( vis ){
   if( backupElems && ( backupElems.length > 0 )) {
      for( i=0; i < backupElems.length; i++) {
         if( backupElems[i].length > 0 ) for( j=0; j < backupElems[i].length;j++ ) if( backupElems[i][j].style ) backupElems[i][j].style.visibility=vis
      } 
   } 
}
var httpOBJ = undefined
//---------------------------------------------------------------
function makeHTTP(){

   if( window.XMLHttpRequest ){
      httpOBJ = new XMLHttpRequest()
      if( httpOBJ.overrideMimeType ) httpOBJ.overrideMimeType('text/html')
   }
   else if( window.ActiveXObject ){
      try {
         httpOBJ = new ActiveXObject( "Msxml2.XMLHTTP" );
      } catch( e ) {
         try {
            httpOBJ = new ActiveXObject( "Microsoft.XMLHTTP" );
         } catch ( e ) {}
      }
   }
   if( !httpOBJ ){
      alert( "Brak polaczenia http" )
   }
   return httpOBJ
}

function abortHTTP(){
	if( httpOBJ ){
      if( httpOBJ.readyState != 4 && httpOBJ.readyState != 0 ){ httpOBJ.abort() }
      httpOBJ = undefined
   }
}

function httpGET( url, func, isjs ){
   obj = makeHTTP()
   obj.onreadystatechange = function(){
      if( obj.readyState == 4 && obj.status == 200 ){
         pos  = obj.responseText.indexOf( ':' )
         mess = obj.responseText.substr( 0, pos )
         txt  = obj.responseText.substr( pos+1 )
         if( isjs ){ evalhtml( txt )}
         func( mess, txt )
      }
   }
   obj.open( 'GET', url, true );
   obj.send( null );
}
function httpPOST( url, func, params, isjs ){
   obj = makeHTTP()
   obj.onreadystatechange = function(){
      if( obj.readyState == 4 && obj.status == 200 ){
         pos  = obj.responseText.indexOf( ':' )
         mess = obj.responseText.substr( 0, pos )
         txt  = obj.responseText.substr( pos+1 )
         while( mess.substr( 0, 1 ) == "\n" || mess.substr( 0, 1 ) == "\r" || mess.substr( 0, 1 ) == " " ){ mess = mess.substr( 1 )}
         if( isjs ){ evalhtml( txt )}
         func( mess, txt )
      }
   }
   obj.open( 'POST', url, true );
   obj.setRequestHeader( "Content-type", "application/x-www-form-urlencoded; charset=iso-8859-2");
   obj.setRequestHeader( "Content-length", params.length );
   obj.setRequestHeader( "Connection", "close" );
   obj.send( params );
}

function evalhtml( content ){ 
   data = content.split( '\n' )
   arraylen = data.length
   i   = 0
   str = ''
   while( i < arraylen ){	
      if( data[i].indexOf( "<script" ) > -1 ){
		   i++
		   while(data[i].indexOf( "/script>" ) < 0 ){
            str += data[i] + "\n"
			   i++
		   }
         oScript = document.createElement( 'script' ) 
         oScript.text = str 
         document.getElementsByTagName( "head" ).item(0).appendChild( oScript ) 
         return
	   }
	   i++
   }
}

function getPS(){

   if( window.innerHeight && window.scrollMaxY ){   
      xScroll = document.body.scrollWidth
      yScroll = window.innerHeight + window.scrollMaxY
   }
   else if( document.body.scrollHeight > document.body.offsetHeight ){
      xScroll = document.body.scrollWidth
      yScroll = document.body.scrollHeight
   }
   else {
      xScroll = document.body.offsetWidth
      yScroll = document.body.offsetHeight
   }
   
   if( self.innerHeight ){
      windowWidth  = self.innerWidth
      windowHeight = self.innerHeight
   }
   else if( document.documentElement && document.documentElement.clientHeight ){
      windowWidth  = document.documentElement.clientWidth
      windowHeight = document.documentElement.clientHeight
   }
   else {
      windowWidth  = document.body.clientWidth
      windowHeight = document.body.clientHeight
   }   

   if( yScroll < windowHeight ){ pageHeight = windowHeight } else { pageHeight = yScroll }
   if( xScroll < windowWidth  ){ pageWidth  = windowWidth  } else { pageWidth  = xScroll }

   return new Array( pageWidth, pageHeight, windowWidth, windowHeight ) 
}

function galleryShow( nr, copyright ){

   a = getPS()

   this.border    = 1
   this.opacity   = 0.55
   this.nr        = nr
   this.copyright = copyright ? 'Copyright &copy by ' + copyright : ''
   this.images    = new Array()

   for( i=2; i<arguments.length; i++ ){
      this.images[i-1] = arguments[i] 
   }

   hideElems()
//   this.W = Math.min( 800 + 2*this.border, parseInt( 0.9  * a[2] ))
//   this.H = Math.min( 600 + 2*this.border, parseInt( 0.95 * a[3] ))
   this.W = Math.min( 802+2*this.border, parseInt( 0.9  * a[2] ))
   this.H = Math.min( 602+2*this.border, parseInt( 0.95 * a[3] ))

this.H = 602+2*this.border

   this.T = Math.max( 0, getST() + parseInt(( a[3] - this.H )/2 - this.border ))
   this.L = Math.max( 0, getSL() + parseInt(( a[2] - this.W )/2 - this.border ))

   txt  = "<div id='galleryINNER' style='position:absolute; z-index: 1002; display:block; left:" + this.L + "px; top:" + this.T + "px; width:" + this.W + "px; height:" + this.H + "px; border: solid " + this.border + "px #000000; background-color:#000000; overflow:auto; text-align:center' title=''>"
   txt += "<img id='galleryIMG' src='/!cms/images/gallery_pixel.gif' style='display:block'>"
   txt += "</div>"
   this.newdiv( 'galleryDIV', txt )

   txt = "<img src='/!cms/images/gallery_pixel.gif' style='display:block; top:0; left:0; width:" + a[0] + "px; height:" + a[1] + "px; z-index: 1001; filter: alpha(opacity=" + parseInt( this.opacity*100 ) + "); position: absolute; background-color: #000000; -moz-opacity:"+this.opacity+"; opacity:"+this.opacity+"; cursor:hand' title='zamknij galerię'/>"
   this.newdiv( 'galleryFADE', txt )

   t = parseInt( this.T + ( this.H-16 )/2 )
   l = parseInt( this.L + ( this.W-16 )/2 )
   txt = "<img src='/!cms/images/loading.gif' style='top:" + t + "px; left:" + l + "px; z-index: 1003; position:absolute' />"
   this.newdiv( 'galleryLOADING', txt )
   this.newdiv( 'galleryNAVI', '' )

   this.div     = getO( 'galleryDIV'  )
   this.fade    = getO( 'galleryFADE' )
   this.img     = getO( 'galleryIMG'  )
   this.loading = getO( 'galleryLOADING' )
   this.navi    = getO( 'galleryNAVI' )
   this.inner   = getO( 'galleryINNER' )

   xxx = this
   this.fade.onclick = function(){ xxx.hide(); return false; }
   this.load( nr )

}

galleryShow.prototype.load = function( nr ){

   if( typeof( this.images[nr] ) != 'object' ){
      this.loading.style.display = 'inline'
      tmp = new Image()
      tmp.src = this.images[nr]
      this.images[nr] = tmp
   }
   this.preload( nr )

   xxx = this
   txt = ''
   for( i=1; i<this.images.length; i++ ){
      if( i == nr ){ xcolor = '#FFFFFF' ; xborder = 'border:1px solid #EEEEEE; margin-right:6px' }
      else         { xcolor = '#555555' ; xborder = 'margin-left:1px; margin-right:7px' }
      txt += "<A HREF='#' onclick='xxx.load( "+i+" ); return false' style='font-size:14px; font-family:\"courier new\"; text-decoration:none; color:" + xcolor + "; background-color:#222222; line-height:24px; " + xborder + "'><B>&nbsp;" + i + "&nbsp;</B></A>";
   }

   t = parseInt( this.T + this.H - 55 )
   l = parseInt( this.L + this.border + 6 )

   nrprew = Math.max( nr-1, 1 )
   nrnext = Math.min( nr+1, this.images.length-1 )
//   txt    = "<A HREF='#' onclick='xxx.load( " + nrprew + " ); return false' style='font-size:14px; font-family:webdings; text-decoration:none; color:#333333; line-height:18px; text-align:center; margin-right:6px; margin-left:6px'><B>&nbsp;3&nbsp;</B></A>" + txt
//   txt   += "<A HREF='#' onclick='xxx.load( " + nrnext + " ); return false' style='font-size:14px; font-family:webdings; text-decoration:none; color:#333333; line-height:18px; text-align:center; margin-right:6px'><B>&nbsp;4&nbsp;</B></A>"

//   txt    = "<A HREF='#' onclick='xxx.load( " + nrprew + " ); return false'><img src='/images/gallery_prev.gif' width=26 height=18 border=0 /></A>" + txt
//   txt   += "<A HREF='#' onclick='xxx.load( " + nrnext + " ); return false'><img src='/images/gallery_next.gif' width=26 height=18 border=0 /></A>"

   btn_prev  = "<A HREF='#' onclick='xxx.load( " + nrprew + " ); return false'><img src='/!cms/images/gallery_prev.gif'  width=26 height=18 border=0 /></A>"
   btn_next  = "<A HREF='#' onclick='xxx.load( " + nrnext + " ); return false'><img src='/!cms/images/gallery_next.gif'  width=26 height=18 border=0 /></A>"
   btn_close = "<A HREF='#' onclick='xxx.hide(); return false'><img src='/!cms/images/gallery_close.gif' width=26 height=18 border=0 alt='zamknij galerię' /></A>"

   txt    = "<TABLE cellpadding=0 cellspacing=0 border=0 width=" + ( this.W-40 ) + " style='top:" + t + "px; left:" + l + "px; z-index: 1004; position:absolute'><TR><TD style='border:1px solid #666666; background-color:#999999'><table border=0 cellpadding=0 cellspacing=0 border=0><tr><td>&nbsp;</td><td>"+btn_prev+"</td><td>&nbsp;</td><td>" + txt + "</td><td>"+btn_next+"</td><td>"+btn_close+"</td><td>&nbsp;</td></tr></table></TD><TD style='color:#333333; font-family:tahoma; font-size:10px' align=right width=90%>" + this.copyright + "</TD></TR></TABLE>"
//   txt    = "<TABLE cellpadding=0 cellspacing=0 border=0 width=" + ( this.W-40 ) + " style='top:" + t + "px; left:" + l + "px; z-index: 1004; position:absolute'><TR><TD style='border:1px solid #666666; background-color:#999999'>" + txt + "</TD><TD style='color:#333333; font-family:tahoma; font-size:10px' align=right width=90%>" + this.copyright + "</TD></TR></TABLE>"
   this.navi.innerHTML = txt
}

galleryShow.prototype.preload = function( nr ){

   if( this.images[nr].complete ) {
      this.img.src = this.images[nr].src
      this.loading.style.display = 'none'
      this.center( this.images[nr] )
      this.inner.scrollTop  = 0
      this.inner.scrollLeft = 0
   }
   else {
      xxx = this
      window.setTimeout( 'xxx.preload(' + nr + ')', 250 );
   }
}

galleryShow.prototype.center = function( img ){
   this.img.style.marginTop = Math.max( 0, parseInt(( this.H - img.height )/2 )) + 'px'
}

galleryShow.prototype.newdiv = function( id, txt ){
   obj = document.createElement( 'div' );
   obj.id = id
   obj.innerHTML = txt
   document.body.insertBefore( obj, document.body.firstChild )
}

galleryShow.prototype.hide = function(){
   document.body.removeChild( this.fade );
   document.body.removeChild( this.div  );
   document.body.removeChild( this.navi );
   document.body.removeChild( this.loading );
   showElems( 'visible' )
}

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

wideokonkurs_fade = '';
function wideokonkurs( site, id ){

   if( fixed_div ) return false

   a = getPS()
// opacity = 0.80
   opacity = 0.55

   txt = "<img src='/!cms/images/gallery_pixel.gif' style='display:block; top:0; left:0; width:" + a[0] + "px; height:" + a[1] + "px; z-index: 199; filter: alpha(opacity=" + parseInt( opacity*100 ) + "); position: absolute; background-color: #000000; -moz-opacity:"+opacity+"; opacity:"+opacity+"; cursor:hand' />"
   wideokonkurs_fade    = document.createElement( 'div' )
   wideokonkurs_fade.id = 'wideokonkurs_fade'
   wideokonkurs_fade.innerHTML = txt
   wideokonkurs_fade.onclick = function(){ wideokonkurs_close(); return false; }
   document.body.insertBefore( wideokonkurs_fade, document.body.firstChild )

   obj = getO( 'wideokonkurs_div' )
   if( !obj ){
      wideokonkurs_div = document.createElement( 'div' )
      wideokonkurs_div.id             = 'wideokonkurs_div'
      wideokonkurs_div.style.position = 'absolute'
      wideokonkurs_div.style.zIndex   = '200'
      document.body.insertBefore( wideokonkurs_div, document.body.firstChild )
   }

   fixed_open( 'wideokonkurs_div', 150, 100 )
   fixed_div.style.width  = 'auto'
   fixed_div.style.height = 'auto'

   url = '/!cms/rjs_wideokonkurs.php?show-' + site + '-' + id + '-' + Math.random()
   httpGET( url, wideokonkurs_response )

}
function wideokonkurs_response( err, txt ){
   if( err == 'alert' ){
      wideokonkurs_close()
      alert( txt )
      return
   }
   fixed_response( err, txt )
   obj = getO( 'wideokonkurs_swf' )
   if( obj ) obj.style.visibility = 'visible'
}
function wideokonkurs_close(){
   document.body.removeChild( wideokonkurs_fade );
   wideokonkurs_fade = '';
   fixed_close()
}
function wideokonkurs_send( site, id ){
   form  = document.forms.wideokonkurs_form
   check = form.check.checked ? 1 : 0
   if( !check ){
      alert( 'zaakceptuj zgodę' )
      return
   }
   params  = 'site=' + site + '&action=write&par=' + id
   params += '&answer=' + encodeURIComponent( form.answer.value )
   params += '&mail='   + encodeURIComponent( form.mail.value )
   params += '&check='  + check
   obj = getO( 'wideokonkurs_swf' )
   obj.style.visibility = 'hidden'
   obj = getO( 'wideokonkurs_swf_div' )
   x = getW( obj ) / 2 - 10
   y = getH( obj ) / 2 - 10
   obj.innerHTML  = "<img src='/!cms/images/loading.gif' style='margin-top:"+y+"px; margin-left:"+x+"px'>"
   httpPOST( url, wideokonkurs_response, params )
}


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

fixed_div = ''
isFixed   = false

function fixcenterH( obj ){
   if( !fixed_div ) return
   X = obj.offsetWidth
   if( document.documentElement.clientWidth ){
      W = document.documentElement.clientWidth
      S = document.documentElement.scrollLeft  
   }
   else {
      W = document.body.clientWidth
      S = document.body.scrollLeft
   }
	X = Math.max( 0, parseInt(( W-X )/2 ) + S )
   return X + 'px' 
}

function fixcenterV( obj ){
   if( !fixed_div ) return
   X = obj.offsetHeight
   if( document.documentElement.clientHeight ){
      W = document.documentElement.clientHeight
      S = document.documentElement.scrollTop  
   }
   else {
      W = document.body.clientHeight
      S = document.body.scrollTop
   }
	X = Math.max( 0, parseInt(( W-X )/2 ) + S )
   return X + 'px' 
}

function fixed_response( err, txt ){

   if( fixed_div.className == 'fixed2' ){
      fixed_div.style.width  = 'auto'
      fixed_div.style.height = 'auto'
   }

   if( err == 'go' ){
      fixed_close()
      if     ( txt == 'reftop' ){ parent.wtop.history.go( 0 )}
      else if( txt == 'ref' )   { history.go( 0 )}
      else                      { document.location.href = txt }
   }
   else if( err == 'gotop' ){
      fixed_close()
      parent.wtop.location.href = txt
   }
   else if( err == 'alert' ){
      fixed_close()
      alert( txt )
   }
   else if( err == 'ok' ) fixed_div.innerHTML = txt
   else fixed_div.innerHTML = "<p align=center><b style='color:red'>" + err + txt + "</b></p>"

   if( fixed_div && !isFixed ){
      setPosCenter( fixed_div )
   }

}
function fixed_close(){
   if( fixed_div ){
      if( isFixed ) fixed_div.style.display = 'none'
		else          setPos( fixed_div, 0, -2000 )
      showElems( 'visible' )
//    fixed_div.innerHTML = ''
      fixed_div = ''
   }
}

function fixed_open( id, w, h, wait ){

   fixed_div = getO( id )
   isFixed   = fixed_div.className == 'fixed'

   if( fixed_div.parentNode ){
//      if( parent == self ){
         fixed_div.parentNode.removeChild( fixed_div )
         document.body.appendChild( fixed_div )
//      }
//      else {
//         top.main.wbot.document.body.removeChild( fixed_div )
//         top.main.wbot.document.body.appendChild( fixed_div )
//      }
   }

//   hideElems()

   if( w ) fixed_div.style.width  = w + 'px'
   if( h ) fixed_div.style.height = h + 'px'
   if( !wait ) fixed_wait( w, h )
   if( isFixed ) fixed_div.style.display = 'block'
	else          setPosCenter( fixed_div )

}

function fixed_wait( w, h ){
   if( !w ) w = getW( fixed_div )
   if( !h ) h = getH( fixed_div )
   fixed_div.innerHTML = "<table width="+(w-6)+" height="+(h-6)+"><tr><td align=center valign=middle><img src='/!cms/images/loading.gif'></td></tr></table>"
}
