<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo  $this->lang['title']; ?> - <?php echo  $this->data['name']; ?> - <?php echo  $this->data['width']; ?>x<?php echo  $this->data['height']; ?> - <?php echo  $this->data['size']; ?></title>
<link href="themes/<?php echo  $this->theme ?>/css/preview.css" rel="stylesheet" type="text/css" />
<script language="javascript" type="text/javascript" src="themes/<?php echo  $this->theme ?>/jscripts/general.js"></script>

<script language="javascript" type="text/javascript">
	var nexturl = "<?php echo  $this->data['next']['path']; ?>";
	var nextwidth = <?php echo  $this->data['next']['width']; ?>;
	var nextheight = <?php echo  $this->data['next']['height']; ?>;

	var previousurl = "<?php echo  $this->data['previous']['path']; ?>";
	var previouswidth = <?php echo  $this->data['previous']['width']; ?>;
	var previousheight = <?php echo  $this->data['previous']['height']; ?>;

	var heightmodifier = 75; // 50 + 25 for prev/next links
	var widthmodifier = 150;

	function nextimage() {
		if (nexturl != "")
			window.document.location.href = "preview.php?path=" + nexturl +"";
	}

	function previousimage() {
		if (previousurl != "")
			window.document.location.href = "preview.php?path=" + previousurl +"";
	}

	function setsize(width, height) {
		height += heightmodifier;
		width += widthmodifier;

		// need to have space for previous / next buttons
		if (width < 200)
			width = 200;

		if (height < 100)
			height = 100;

		var isMSIE = (navigator.appName == "Microsoft Internet Explorer");
		var x = parseInt(screen.width / 2.0) - (width / 2.0);
		var y = parseInt(screen.height / 2.0) - (height / 2.0);

		if (!isMSIE) {
			window.innerWidth = width;
			window.innerHeight = height;
		} else {
			width = width+7;
			height = height+35;
			//window.resizeTo(width, height);
			// ugly hack, msie is crappy
			setTimeout("window.resizeTo("+ width +", "+ height +")", 1);
		}
		window.moveTo(x,y);
	}

	function checkKey(event) {
		var key = getkey(event);
		switch (key) {
			case 32: // space
			case 110: // n
			case 34: // page down
			case 39: // right arrow
				nextimage();
			break;
			case 102: // p
			case 33: // page up
			case 37: // left arrow
				previousimage();
			break;
		}

		if (key == 27)
			window.close(); // escape
	}

	function getkey(e) {
		if (window.event)
			return window.event.keyCode;
		else if (e)
			return e.keyCode;
		else
			return null;
	}

	setsize(<?php echo  $this->data['width']; ?>,<?php echo  $this->data['height']; ?>);

</script>
</head>
<body onkeypress="checkKey(event);" onkeydown="checkKey(event);">
<div class="next_prev">
<?php if ($this->data['previous']['path'] != "") { ?>
	<a href="javascript:previousimage();" alt="<?php echo  $this->lang['keyboard_prev']; ?>" title="<?php echo  $this->lang['keyboard_prev']; ?>">&lt;&lt;&nbsp;<?php echo  $this->lang['prev']; ?></a>
<?php } else { ?>
	&lt;&lt;&nbsp;<?php echo  $this->lang['prev']; ?>
<?php } ?>
&nbsp;|&nbsp;
<?php if ($this->data['next']['path'] != "") { ?>
<a href="javascript:nextimage();" alt="<?php echo  $this->lang['keyboard_next']; ?>" title="<?php echo  $this->lang['keyboard_next']; ?>"><?php echo  $this->lang['next']; ?>&nbsp;&gt;&gt;</a>
<?php } else { ?>
	<?php echo  $this->lang['next']; ?>&nbsp;&gt;&gt;
<?php } ?>
</div>
<div class="preview_image">
	<img src="<?php echo  $this->data['previewurl']; ?>?time=<?php echo  time(); ?>" width="<?php echo  $this->data['width']; ?>" height="<?php echo  $this->data['height']; ?>" alt="<?php echo  $this->data['name']; ?>" title="<?php echo  $this->data['name']; ?>" />
</div>
</body>
</html>
