var CCat = 0;

var Content = new Array();
var ContentType = new Array();
var ContentComment = new Array();
var ContentCount = 0;
var CImage = 0;

function SetMenu(Cat) {
	if (CCat != 0) {
		document.getElementById("menusub"+CCat).style.display = 'none';
	}
	if (CCat == Cat) {
		document.getElementById("menusub"+Cat).style.display = 'none';
		CCat = 0;
		return;
	}
	document.getElementById("menusub"+Cat).style.display = 'block';
	CCat = Cat;
}

function NextImage() {
	CImage++;
	if (CImage > ContentCount) CImage = 1;
	SetImage();
}

function PrevImage() {
	CImage--;
	if (CImage == 0) CImage = ContentCount;
	SetImage();
}

function SetImage() {
	document.getElementById("image").innerHTML = "<img src='"+Content[CImage]+"' onclick='Javascript:NextImage();' height='550' />";
	if (ContentComment[CImage] == "") {
		document.getElementById("comment").innerHTML = "";
	} else {
		document.getElementById("comment").innerHTML = ContentComment[CImage];
	}
	document.getElementById("imgcount").innerHTML = CImage;
	if (CImage == ContentCount) {
		document.getElementById("nbtn").innerHTML = "&gt;";
	} else {
		document.getElementById("nbtn").innerHTML = "<a href='javascript:NextImage();'>&gt;</a>";
	}
	
	if (CImage == 1) {
		document.getElementById("pbtn").innerHTML = "&lt;";
	} else {
		document.getElementById("pbtn").innerHTML = "<a href='javascript:PrevImage();'>&lt;</a>";
	}
}

function ShowSequence(GID) {
	GetWindow("sequence.php?GAL="+GID);
}

function GetWindow(url)
{
  // Fudge factors for window decoration space.
  // In my tests these work well on all platforms & browsers.
  var w = 900; //screen.width - 40;
  var h = 600;
  w += 32;
  h += 96;
  wleft = (screen.width - w) / 2;
  wtop = (screen.height - h) / 2;
  // IE5 and other old browsers might allow a window that is
  // partially offscreen or wider than the screen. Fix that.
  // (Newer browsers fix this for us, but let's be thorough.)
  if (wleft < 0) {
    w = screen.width;
    wleft = 0;
  }
  if (wtop < 0) {
    h = screen.height;
    wtop = 0;
  }
  var win = window.open(url,
    "windowName"+Math.round(Math.random()*2000+1),
    'width=' +  + ', height=' + h + ', ' +
    'left=' + wleft + ', top=' + wtop + ', ' +
    'location=no, menubar=no, ' +
    'status=no, toolbar=no, scrollbars=yes, resizable=yes');
  // Just in case width and height are ignored
  win.resizeTo(w, h);
  // Just in case left and top are ignored
  win.moveTo(wleft, wtop);
  win.focus();
}
