
books = new Object;

var st = '';
var sl = '';

books.showBookPart = function(bookId,title) {

  if( typeof( window.pageYOffset ) == 'number' ) {
    st = window.pageYOffset;
    sl = window.pageXOffset;
  } else if( document.body && ( document.body.scrollLeft || document.body.scrollTop ) ) {
    st = document.body.scrollTop;
    sl = document.body.scrollLeft;
  } else if( document.documentElement && ( document.documentElement.scrollLeft || document.documentElement.scrollTop ) ) {
    st = document.documentElement.scrollTop;
    sl = document.documentElement.scrollLeft;
  }

  if (document.getElementById('upperbottom')) { document.getElementById('upperbottom').style.visibility='hidden'; }
  if (document.getElementById('bottom')) { document.getElementById('bottom').style.visibility='hidden'; }

  intranet.overlay.show();
  intranet.overlay.update();
    document.getElementById('readfrombooktitle').innerHTML = title;

  xmlHttp_loadBookText = ajaxObj();

  xmlHttp_loadBookText.onreadystatechange=function() {
    if(xmlHttp_loadBookText.readyState==4) {
      if (xmlHttp_loadBookText.responseText) {
        document.getElementById('readfrombookinnertext').innerHTML = xmlHttp_loadBookText.responseText;
        document.getElementById('readfrombooktext').style.marginLeft='0px';
        document.getElementById('readfrombooktext').style.visibility='visible';
        scroll(0,190);
      } else {
        intranet.overlay.hide();
      }
    }
  }

  xmlHttp_loadBookText.open("GET",lnk+"modules/post/bookText.php?bookId="+bookId,true);
  xmlHttp_loadBookText.send(null);

}

books.hideBookPart = function() {
  document.getElementById('readfrombooktitle').innerHTML = '';
  document.getElementById('readfrombookinnertext').innerHTML = '';
  document.getElementById('readfrombooktext').style.visibility='hidden';
  if (document.getElementById('upperbottom')) { document.getElementById('upperbottom').style.visibility='visible'; }
  if (document.getElementById('bottom')) { document.getElementById('bottom').style.visibility='visible'; }
  intranet.overlay.hide();
  scroll(sl,st);
}


books.loadTabs = function(type,bookId,cat) {

  xmlHttp_loadTabs = ajaxObj();

  xmlHttp_loadTabs.onreadystatechange=function() {
    if(xmlHttp_loadTabs.readyState==4) {
      document.getElementById('bookTabs').innerHTML = xmlHttp_loadTabs.responseText;
      books.loadLeftMenu(type,bookId,cat);
    }
  }

  xmlHttp_loadTabs.open("GET",lnk+"modules/post/bookTabs.php?type="+type+"&bok="+bookId+"&cat="+cat,true);
  xmlHttp_loadTabs.send(null);

}

books.loadLeftMenu = function(type,bookId,cat) {

  xmlHttp_loadLeftMenu = ajaxObj();

  xmlHttp_loadLeftMenu.onreadystatechange=function() {
    if(xmlHttp_loadLeftMenu.readyState==4) {
      document.getElementById('leftMenu').innerHTML = xmlHttp_loadLeftMenu.responseText;
    }
  }

  xmlHttp_loadLeftMenu.open("GET",lnk+"modules/menus/menu.utgavur.ajax.php?type="+type+"&bok="+bookId+"&cat="+cat,true);
  xmlHttp_loadLeftMenu.send(null);

}
