var actualpage=1;
var smallimagewidth=120;
var smallimageheight=90;
var landscapeimagewidth=1024;
var landscapeimageheight=768;
var portraitimagewidth=576;
var portraitimageheight=768;
var columns=4;
var rows=6;

function ShowGallery(page) {
  var id;
  var pages=Math.ceil((landscapecount+portraitcount)/(columns*rows));
  switch (page) {
    case "prev": page=actualpage-1;break;
    case "next": page=actualpage+1;break;
  }
  id="table"+actualpage;
  document.getElementById(id).style.display="none";
  id="table"+page;
  document.getElementById(id).style.display="";
  id="linkpage"+actualpage;
  document.getElementById(id).className="g-menu0";
  id="linkpage"+page;
  document.getElementById(id).className="g-menu1";
  id="prevlink";
  if (page==1)
    document.getElementById(id).style.visibility="hidden";
  else
    document.getElementById(id).style.visibility="";
  id="nextlink";
  if (pages==page)
    document.getElementById(id).style.visibility="hidden";
  else
    document.getElementById(id).style.visibility="";
  actualpage=page+0;
  return false;
}

function GalleryMenu() {
  var pages=Math.ceil((landscapecount+portraitcount)/(columns*rows));
  if (pages<2) return;
  document.write("<TABLE border=0><TR height=30>");
  document.write("<TD valign=bottom><A HREF=\"#\" return onClick='return ShowGallery(\"prev\")' class=\"g-menu0\" id=\"prevlink\" style=\"visibility:hidden\"><NOBR><< předchozí </NOBR></A></TD>");
  for (var i=1; i<=pages; i++) {
    if (i==1) 
  	  document.write("<TD valign=bottom>&nbsp; <A HREF=\"#\" return onClick=\"return ShowGallery("+i+")\" class=\"g-menu1\" id=\"linkpage1\">"+i+"</A></TD>");
    else 
  	  document.write("<TD valign=bottom>&nbsp; <A HREF=\"#\" return onClick=\"return ShowGallery("+i+")\" class=\"g-menu0\" id=\"linkpage"+i+"\">"+i+"</A></TD>");
  }
  if (pages>1) 
	document.write("<TD valign=bottom>&nbsp; <A HREF=\"#\" return onClick='return ShowGallery(\"next\")' class=\"g-menu0\" id=\"nextlink\"><NOBR>další>></NOBR></A></TD>");
  else
	document.write("<TD valign=bottom>&nbsp; <A HREF=\"#\" return onClick='return ShowGallery(\"next\")' class=\"g-menu0\" id=\"nextlink\" style=\"visibility:hidden\"><NOBR>další>></NOBR></A></TD>");
  document.write("</TR></TABLE>");
}

function AddChar(string,addchar,length) {
  string+="";
  for (var i=string.length;i<length;i++) {
    string=addchar+string;
  }
  return string;
}

function CreateGalleryTable() {
  var path=gallerypath;
  var rotate="landscape";
  var file=1;
  var imagewidth=landscapeimagewidth;
  var imageheight=landscapeimageheight;
  var tablecount=1;
  document.write("<DIV ALIGN=CENTER>");

  GalleryMenu();
    
  for (var count=0; count<landscapecount+portraitcount; tablecount++)  {
  if (count==0) 
    document.write("<TABLE cellpadding=3 id=\"table1\">");
  else
    document.write("<TABLE cellpadding=3 id=\"table"+tablecount+"\" style=\"display:none\">");
  for (var i=0; i<rows;i++)  {
      document.write("<TR valign=center height="+smallimageheight+">");
    for (var j=0; j<columns; j++) {
      if (rotate=="landscape" && file>landscapecount) {
        file-=landscapecount;
        rotate="portrait";
        imagewidth=portraitimagewidth;
        imageheight=portraitimageheight;
      }
      if (rotate=="portrait" && file>portraitcount) break;
      smallstring=path+rotate+"/small/"+AddChar(file,"0",4)+".jpg";
      fullstring=path+rotate+"/"+AddChar(file,"0",4)+".jpg";
      file++;
      count++;
      document.write("  <TD width="+smallimagewidth+" height="+smallimageheight+" align=center><A HREF=\"#\" return onClick='return parent.ShowBigImage(\""+fullstring+"\","+imagewidth+","+imageheight+")'><IMG src=\""+smallstring+"\" border=0></A></TD>");
    }
    document.write("</TR>");
  }
  document.write("</TABLE>");
  }
//  GalleryMenu();

  return false;
}

