function ShowOnlyDate(grdatestring) {
    grdatestring2 = grdatestring.split(" ");
    document.write(grdatestring2[0]);
}

function dezInt(num,size,prefix) {
    prefix=(prefix)?prefix:"0";
    var minus=(num<0)?"-":"", result=(prefix=="0")?minus:""; num=Math.abs(parseInt(num,10)); size-=(""+num).length; for(var i=1;i<=size;i++) { result+=""+prefix; } result+=((prefix!="0")?minus:"")+num;
    return result; }

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

var win;

function NewWindow(mypage, myname, w, h, scroll) {
if (mypage.toLowerCase().search('.jpg') != -1){
is_img = true;
} else {
is_img = false;
}
if (is_img) {
w = 100;
h = 100;
scroll = "no";
var imgep = new Image;
imgep.onload = function () {
var winl = (screen.availWidth - w) / 2;
var wint = (screen.availHeight - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops);
win.document.body.onunload = function () {win.opener.focus();};
win.document.body.onblur = function () {if (win && win.open && !win.closed) win.close();};
win.document.body.onkeypress = function () {if (win.event.keyCode == 27) win.close();};
winiw = win.document.body.clientWidth;
winih = win.document.body.clientHeight;
if ((imgep.width > screen.availWidth) || (imgep.height > screen.availHeight)) {
w = imgep.width/imgep.height*screen.availHeight;
h = imgep.height/imgep.width*screen.availWidth;}
else {
w = imgep.width;
h = imgep.height;
}
tl = (screen.availWidth - w) / 2;
tp = (screen.availHeight - h) / 2;
win.moveTo(tl,tp);
wc = w - winiw;
hc = h - winih;
win.resizeBy(wc,hc);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); } }
imgep.src = mypage; } else {
var winl = (screen.availWidth - w) / 2;
var wint = (screen.availHeight - h) / 2;
winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
win = window.open(mypage, myname, winprops);
if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
}
}

function closeDep() {
if (win && win.open && !win.closed) win.close();
}

function noTime(dt){result=dt.substring(0,10);return result;}

function swing(x,nimg,cimg,ucimg) {
if(document.getElementById(x).style.display == "block") {
	document.getElementById(x).style.display = "none";
  document.getElementById(nimg).src = ucimg;
} else {
	document.getElementById(x).style.display = "block";
  document.getElementById(nimg).src = cimg;
}}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+";";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

function changefan() {
var Fanart_d = 0;
if(document.getElementById('FANART_CONTAINER').style.display == "block") {
 document.getElementById('FANART_CONTAINER').style.display = "none";
  var el = document.getElementById('Fanart-Toggle');
  el.innerHTML = 'Show Fanart';
 Fanart_d = 0;
} else {
 document.getElementById('FANART_CONTAINER').style.display = "block";
  var el = document.getElementById('Fanart-Toggle');
  el.innerHTML = 'Hide Fanart';
 Fanart_d = 1;
}
createCookie("Fanart-bookscard-bigcover",Fanart_d,3650);
}

function show_hide_fanart(){
  var Fanart_d = 0;
  Fanart_d = readCookie("Fanart-bookscard-bigcover");
  if (Fanart_d == ''){
  Fanart_d = 0;}
  if (Fanart_d == 0) {
        document.getElementById("FANART_CONTAINER").style.display = "none";
        var el = document.getElementById('Fanart-Toggle');
        el.innerHTML = 'Show Fanart';
    }
    if (Fanart_d == 1) {
        document.getElementById("FANART_CONTAINER").style.display = "block";
        var el = document.getElementById('Fanart-Toggle');
        el.innerHTML = 'Hide Fanart';
    }
}

function hide_empty_img() {
var imgs,i;
 imgs=document.getElementsByTagName('img');
 for(i=0;i<imgs.length;i++)
  {
  var extfanart = imgs[i].src
  if ((imgs[i].className == "my_img") && (extfanart.search('white.gif') != -1 )) {
			imgs[i].style.display = "none"
		}
  }
}

function add_styles_menu() {
var options = {minWidth: 80, onClick: function(e, menuItem){$.Menu.closeAll(); setActiveStyleSheet($(this).text()); createCookie("style-books-bigcover", $(this).text(), 3650);}};

//creating a menu without items
	var menu = new $.Menu('#menustyle', null, options);

  var i, a, title;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      title = a.getAttribute("title");
      menu.addItems([new $.MenuItem({src: title}, options)]);
    }
  }
}