document.base_href=document.location.href;
need_focus=1;
focus_en_lock=0;
image_reloaded=0;

about_path=new Array('o_nas','about');
searc_path=new Array('szukaj','search');
world_path=new Array('swiat','world');
realm_path=new Array('krainy','realms');
creat_path=new Array('stworzenia','creatures');
books_path=new Array('ksiazki','books');
auths_path=new Array('autorzy','authors');
serie_path=new Array('serie','series');
artic_path=new Array('artykuly','articles');
users_path=new Array('uzytkownicy','users');
contt_path=new Array('kontakt','contact');

about_text=new Array('O stronie','About');
searc_text=new Array('Szukaj','Search');
faqqs_text=new Array('Często zadawane pytania','Frequently Asked Questions');
world_text=new Array('Świat fantasy','World of Fantasy');
creat_text=new Array('Stworzenia','Creatures');
realm_text=new Array('Krainy','Realms');
books_text=new Array('Książki','Books');
auths_text=new Array('Autorzy','Authors');
serie_text=new Array('Serie','Series');
artic_text=new Array('Artykuły','Articles');
contt_text=new Array('Kontakt','Contact');

to_page_text=new Array('przejdź do strony','go to page');
of_text=new Array('z','of');

function main(query) {
 document.query_form.query.value=query;
 document.query_form.submit();
 //top.location.href='/cgi-bin/fantasy/index?query='+query;
 }


function right(query,frag) {
 if (frag!=null) query+='#'+frag;
 if (frames['right_page']) frames['right_page'].location.href='/cgi-bin/fantasy/right?query='+query;
 else main(query);}


function login(sesid,path) {
 setCookie('AB_sesid',sesid);
 top.location.href=path;}


function logout() {
 var sesid;
 if (getCookie('AB_sesid')) {
  sesid=getCookie('AB_sesid');
  setCookie('AB_sesid',sesid+':');
  // top.location.reload();
  top.location.href=top.location.href;
  delCookie('AB_sesid');}}


function setCookie(name, value, expires) {
 document.cookie=name+'='+escape(value)+'; path=/'+((expires) ? '; expires='+expires.toGMTString() : '');}


function getCookie(name) {
 var dc=document.cookie;
 var pr=name+'=';
 var bg=dc.indexOf('; '+pr);
 if (bg == -1) {
  bg=dc.indexOf(pr);
  if (bg != 0) return null;}
 else bg+=2;
 var en=document.cookie.indexOf(';', bg);
 if (en == -1) en = dc.length;
 return unescape(dc.substring(bg+pr.length, en));}


function delCookie(name) {
 if (getCookie(name)) document.cookie=name+'=; path=/; expires=Thu, 01-Jan-70 00:00:01 GMT';}


function getElemById(elem) {
  if (document.all) elem=eval('document.all.'+elem);
  else {elem=document.getElementById(elem);}
  return elem;}


function focus_scroll(div) {
 if ( div.childNodes && need_focus ) {
  var s=div.scrollTop;
  getElemById('homeLink').focus();
//div.childNodes[1].focus();
  div.scrollTop=s;
  need_focus=0;
  setTimeout('focus_enable',2000);}}


function focus_enable() {
 if (!document.forms[1]) need_focus=1;}


function med_res(image) {
 if (!image_reloaded) {
  image_reloaded=1;
  image.src=image.src.replace(/\.(jpg|gif)$/,"_med.$1");}}


function print_menu(l) {
 document.write(
  '<br>'+

  '<table border=0 cellpadding=1 cellspacing=1 width="100%">'+
    '<tr><td class="tag1"><br>'+
	'<a href="/">'+
	'<img src="/img/menu/start.gif" border=0 alt="Start"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/'+about_path[l]+'.html">'+
	'<img src="/img/menu/'+about_path[l]+'.gif" border=0'+
	' alt="'+about_text[l]+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/faq.html">'+
	'<img src="/img/menu/faq.gif" border=0'+
	' alt="'+faqqs_text[l]+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/'+searc_path[l]+'/">'+
	'<img src="/img/menu/'+searc_path[l]+'.gif" border=0'+
	' alt="'+searc_text[l]+'"></a></td></tr>'+

    '<tr><td height=10></td></tr>'+

    '<tr><td class="tag1">'+
	'<a href="/'+books_path[l]+'/">'+
	'<img src="/img/menu/'+books_path[l]+'.gif" border=0'+
	' alt="'+books_text[l]+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/'+auths_path[l]+'/">'+
	'<img src="/img/menu/'+auths_path[l]+'.gif" border=0'+
	' alt="'+auths_text[l]+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/'+books_path[l]+'/'+serie_path[l]+'.html">'+
	'<img src="/img/menu/'+serie_path[l]+'.gif" border=0'+
	' alt="'+serie_text+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/'+artic_path[l]+'/">'+
	'<img src="/img/menu/'+artic_path[l]+'.gif" border=0'+
	' alt="'+artic_text[l]+'"></a></td></tr>'+

    '<tr><td height=10></td></tr>'+

    '<tr><td class="tag1">'+
	'<a href="/fantasy/">'+
	'<img src="/img/menu/'+world_path[l]+'.gif" border=0'+
	' alt="'+world_text[l]+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/fantasy/'+realm_path[l]+'/">'+
	'<img src="/img/menu/'+realm_path[l]+'.gif" border=0'+
	' alt="'+realm_text[l]+'"></a></td></tr>'+

    '<tr><td class="tag2">'+
	'<a href="/fantasy/'+creat_path[l]+'/">'+
	'<img src="/img/menu/'+creat_path[l]+'.gif" border=0'+
	' alt="'+creat_text[l]+'"></a></td></tr>'+

    '<tr><td height=10></td></tr>'+

    '<tr><td class="tag1">'+
	'<a href="/login.html">'+
	'<img src="/img/menu/login.gif" border=0 alt="Login"></a></td></tr>'+

     '<tr><td class="tag1">'+
	 '<a href="/'+contt_path[l]+'.html">'+
	 '<img src="/img/menu/'+contt_path[l]+'.gif" border=0'+
	 ' alt="'+contt_text[l]+'"></a></td></tr>'+

  '</table>');

 document.write(
  '<form method=post action="'+document.location.href+'" name="query_form">'+
  '<input type=hidden name=query>'+
  '</form>');

 return true;}


function print_layout(l) {
 document.write('<div class=menu>');
 print_menu(l);
 document.write('</div><div class=ruler2></div>');

 return true;}


function print_navbr() {
 document.write('<br');
 if (document.all) document.write(' clear=all');
 document.write('>');

 return true;}


function print_toplogo() {
 document.write(
	'<table border=0 width="98%" class=tlogo>'+
	    '<tr><td class=headr><br></td>'+
		'<td width=120 align=center>'+
		'<a href="/">'+
		'<img src="/img/another-book.gif" border=0 width=114 height=22 alt="Another Book"></a></td>'+
		'<td class=headr><br></td></tr>'+
	'</table>');

// TODO: add usermenu here to reduce http transfer

 return true;}


function print_top(section) {
 document.write(
//'<a href="#"></a>'+

  '<table border=0 width="99%" height="100%" cellspacing=0 cellpadding=5>'+
    '<tr><td valign=top>');

 if (section) print_toplogo();

 return true;}


function print_middle() {
 document.write('</td></tr><tr><td align=center valign=bottom>');
 return true;}


function print_bottom() {
 document.write('</td></tr></table>');
 return true;}


function print_contact_link(l) {
 document.write(
  '<a href="/'+contt_path[l]+'.html" title="'+contt_text[l]+
  '">'+contt_text[l]+'</a>');

 return true;}


function print_util_links(l) {
 document.write(
  '<a href="/'+about_path[l]+'.html" title="'+about_text[l]+
  '">'+about_text[l]+'</a> | '+

  '<a href="/faq.html" title="'+faqqs_text[l]+
  '">FAQ</a> | '+

  '<a href="/'+searc_path[l]+'.html" title="'+searc_text[l]+
  '">'+searc_text[l]+'</a> | ');

 print_contact_link(l);
 print_toplogo();

 return true;}


function print_range(l,items,count,sel,path) {
 var lim=25;
 var from=(sel-1)*lim;
 var to=(from+lim>count) ? count : (from+lim);
 var pages=1+Math.floor((count-1)/lim);

 document.write(
  '<div class=range align=right>'+
  '<small>'+items+' '+(from+1)+
  '-'+to+' '+of_text[l]+' '+count+'</small><br>'+
  '<small>');

 print_range_sel(l,count,sel,path);

 document.write('</small></div>');
 return true;}


function print_range_sel(l,count,sel,path) {
 var lim=25;
 var from=(sel-1)*lim;
 var to=(from+lim>count) ? count : (from+lim);
 var pages=1+Math.floor((count-1)/lim);

 document.write(to_page_text[l]+' ');

 if (sel!=1) print_range_link('&lt;&lt;',sel-1,path);

 for (i=1; i<=pages; i++) {
  if (i==sel) document.write('<b>'+i+'</b> ');
  else print_range_link(i,i,path);}

 if (sel<pages) print_range_link('&gt;&gt;',sel+1,path);

 return true;}


function print_range_link(text,sel,path) {
 document.write('<a href="'+path);
 if (sel!=1) document.write('?start='+sel);
 document.write('">'+text+'</a> ');
 return true;}


function print_toplists() {
 document.write(
  '<a href="http://literatura.top-100.pl/?we=another85"><img src="http://www.mythai.info/images/listaliteratura.jpg" width=120 height=38 border=0 alt="Najlepsze strony o literaturze - RANKING"></a>&nbsp;'+
  '<a href="http://fantasy.najlepsze.net/?we=another85"><img src="http://www.mythai.info/images/listanajfantasy.jpg" width=120 height=38 border=0 alt="Najlepsze strony fantasy"></a>'+
  '<br><br>');

 return true;}

