<?php echo  '<?php xml version="1.0" encoding="utf-8"?>'; ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><?php echo  $this->lang['title']; ?> (<?php echo  ($this->data['gd_support'] ? "GD enabled" : "GD disabled"); ?> <?php echo  ($this->data['exif_support'] ? "EXIF enabled" : "EXIF disabled"); ?>)</title>
<script language="javascript" type="text/javascript">
	var disabledTools = '<?php echo  $this->data['disabled_tools'] ?>';
	var hasReadAccess = <?php echo $this->data['hasReadAccess'] ?>;
	var hasWriteAccess = <?php echo $this->data['hasWriteAccess'] ?>;
	var path = "<?php echo  $this->data['path'] ?>";
	var full_path = "<?php echo  $this->data['full_path'] ?>";
	var errorMsg = "<?php echo  $this->data['errorMsg'] ?>";
	var formname = "<?php echo  $this->data['formname'] ?>";
	var elementnames = "<?php echo  $this->data['elementnames'] ?>";
	var js = "<?php echo  $this->data['js'] ?>";
	var demo = "<?php echo  $this->data['demo'] ?>";
	var demo_msg = "<?php echo  $this->data['demo_msg'] ?>";
	var filemanger_urlprefix = "<?php echo  $this->data['filemanager_urlprefix']; ?>";
	var deleteConfirm = '<?php echo $this->lang["confirm_delete"] ?>';
	var editNoWriteAccess = "<?php echo $this->lang["editwriteaccess"]; ?>";
</script>
<script language="javascript" type="text/javascript">
	

	function insertURL(url) {
		// Crop away query
		if ((pos = url.indexOf('?')) != -1)
			url = url.substring(0, url.indexOf('?'));

		// Handle custom js call
		if (window.opener && js != "") {
			eval("window.opener." + js + "(url);");
			top.close();
			return;
		}

		// Handle form item call
		if (window.opener && formname != "") {
			var elements = elementnames.split(',');

			for (var i=0; i<elements.length; i++) {
				var elm = window.opener.document.forms[formname].elements[elements[i]];
				if (elm && typeof elm != "undefined")
					elm.value = url;
			}

			top.close();
		}
		top.close();
	} 

	function selectPath(select) {
		var value = select.options[select.selectedIndex].value;
		document.location.href = "images.php?path="+ escape(value) +"&formname="+ formname +"&elementnames="+ elementnames + "&js="+ js +"";
	}

	function imagePreview(width, height, path) {
		if (width < 200)
			width = 200;

		if (height < 200)
			height = 200;

		openPop("preview.php?path="+ escape(path), width, height);
	}

	function imageInfo(name, set_style) {
		var elm = document.getElementById("img_"+ name);
		if (elm != null)
			elm.style.display = set_style;
	}

	function imageDelete(del_path) {
		if (!demo) {
			if (confirm(deleteConfirm)) {
				document.location.href = "images.php?action=delete&path="+ full_path +"&file_01="+ del_path +"&formname="+ formname +"&elementnames="+ elementnames + "&js="+ js +"&time="+ new Date().getTime();
			}
			else
				return;
		} else
			alert(demo_msg);
	}

	function imageEdit(path) {
		if (!hasWriteAccess) {
			alert(editNoWriteAccess);
			return;
		}

		if (path != "")
			openImageEditor(path);
	}

	function gotoAnchor(anchor) {
		if ((typeof(anchor) != "undefined") || (anchor != ""))
			document.location.href = "#f_"+ anchor +"";
	}

</script>
<script language="javascript" type="text/javascript" src="themes/<?php echo  $this->theme ?>/jscripts/general.js"></script>
<script language="javascript" type="text/javascript" src="themes/<?php echo  $this->theme ?>/jscripts/imagetools.js"></script>
<link href="themes/<?php echo  $this->theme ?>/css/general.css" rel="stylesheet" media="screen" type="text/css" />
<style>
	.thumbnail { width: <?php echo  $this->data['thumbnail_width']; ?>px; height: <?php echo  ($this->data['thumbnail_height'] + 20); ?>px; margin: 0 <?php echo  $this->data['thumbnail_margin_around']; ?>px <?php echo  $this->data['thumbnail_margin_around']; ?>px <?php echo  $this->data['thumbnail_margin_around']; ?>px; }
	.image { width: <?php echo  $this->data['thumbnail_width']+2; ?>px;	height: <?php echo  $this->data['thumbnail_height']+2; ?>px; border: <?php echo  $this->data['thumbnail_border_style']; ?>; }
	.imagename { width: <?php echo  $this->data['thumbnail_width']; ?>px; }
	.imageinfo { width: <?php echo  $this->data['thumbnail_width']; ?>px; border: <?php echo  $this->data['thumbnail_border_style']; ?>; }
	.infotable, .infotable td, .infotable .tr { background-color: #ffffff; font-size: 10px; }
</style>
</head>
<body onload="init(errorMsg);gotoAnchor('<?php echo  $this->data['anchor']; ?>');">
	<div class="toolbar">
		<div class="toolbarwrap">
			<fieldset style="width: auto;">
			<legend align="left"><?php echo  $this->lang['subtitle']; ?></legend>
				<div style="margin: 5px;vertical-align: middle; line-height: 25px;">
				<div style="float: left;"><?php echo  $this->lang['select_directory']; ?>&nbsp;<select name="folder" onchange="selectPath(this);">
				
				<?php foreach($this->data['dirlist'] as $dir) { ?>
					<option value="<?php echo  $dir['abs_path']; ?>" <?php if ($this->data['selectedPath'] == $dir['path']) { echo "selected"; } ?>><?php echo $dir['path']; ?></option>
				<?php } ?>
				</select></div>
				<div style="float: right;">
					<nobr>
						<?php
							foreach ($this->data['toolbar'] as $item) {
								if ($item['command'] == "separator")
									echo '<img src="themes/' . $this->theme . '/images/spacer.gif" width="1" height="15" class="mceSeparatorLine" />';
								else
									echo '<a href="javascript:execFileCommand(\'' . $item['command'] . '\');"><img id="' . $item['command'] . '" src="themes/' . $this->theme . '/images/' . $item['icon'] . '" alt="' . $this->lang[$item['command']] . '" title="' . $this->lang[$item['command']] . '" border="0" class="mceButtonDisabled" width="20" height="20" /></a>';
							}
						?>
					</nobr>
				</div>
				</div>
				<br style="clear:both;" />
			</fieldset>
		</div>
	</div>
	<div class="thwrapper">
		<div class="thwrapperwrapper">
			<?php if (count($this->data['files']) == 0) { ?>
				<?php echo $this->lang['no_files']; ?>
			<?php } ?>

			<?php foreach($this->data['files'] as $file) { ?>
				<div class="thumbnail">
					<a name="f_<?php echo $file['name']; ?>"></a>
					<div class="image">
						<div class="imagewrapper">
							<div style="float: left;">
							<?php if (in_array("preview", $this->data['image_tools'])) { ?>
								<a href="javascript:imagePreview(<?php echo $file['real_width']; ?>,<?php echo $file['real_height']; ?>,'<?php echo  $file['path'] ?>');"><img src="themes/<?php echo  $this->theme ?>/images/tool_preview.gif" width="16" height="16" border="0" /></a>
							<?php } ?>
							<?php if (in_array("info", $this->data['image_tools'])) { ?>
								<a href="javascript:imageInfo('<?php echo $file['name'] ?>', 'block');"><img src="themes/<?php echo $this->theme ?>/images/tool_info.gif" width="16" height="16" onmouseover="imageInfo('<?php echo  $file['name'] ?>', 'block');" onmouseout="imageInfo('<?php echo  $file['name'] ?>', 'none');" border="0" /></a>
							<?php } ?>
							<?php if (in_array("delete", $this->data['image_tools'])) { ?>
								<a href="javascript:imageDelete('<?php echo $file['path'] ?>');"><img src="themes/<?php echo $this->theme ?>/images/tool_del.gif" width="16" height="16" border="0" /></a>
							<?php } ?>
							<?php if (in_array("edit", $this->data['image_tools']) && $file['editable']) { ?>
								<a href="javascript:imageEdit('<?php echo $file['path'] ?>');"><img src="themes/<?php echo $this->theme ?>/images/tool_edit.gif" width="16" height="16" border="0" /></a>
							<?php } ?>
							</div>
							<?php if ($this->data['extension_image']) { ?>
							<div style="float: right;"><img src="themes/<?php echo $this->theme ?>/images/filetypes/<?php echo $file['icon']; ?>" width="16" height="16"></div>
							<?php } ?>
							<br style="clear:both;" />
							<div class="imageinfo" id="img_<?php echo  $file['name']; ?>">
								<div style="margin: 5px;">
									<?php if (in_array("name", $this->data['information'])) { ?>
										<?php echo  $file['name']; ?><br />
									<?php } ?>
									<?php if (count($this->data['information']) != 0) { ?>
										<table border="0" cellspacing="0" cellpadding="0" width="100%" class="infotable">
										<?php if (in_array("width", $this->data['information'])) { ?>
										<tr>
											<td><?php echo $this->lang['width']; ?></td>
											<td><?php echo $file['real_width']; ?> px</td>
										</tr>
										<?php } ?>
										<?php if (in_array("height", $this->data['information'])) { ?>
										<tr>
											<td><?php echo $this->lang['height']; ?></td>
											<td><?php echo $file['real_height']; ?> px</td>
										</tr>
										<?php } ?>
										<?php if (in_array("type", $this->data['information'])) { ?>
										<tr>
											<td><?php echo $this->lang['type']; ?></td>
											<td><?php echo $this->lang[$file['type']] ?></td>
										</tr>
										<?php } ?>
										<?php if (in_array("size", $this->data['information'])) { ?>
										<tr>
											<td><?php echo $this->lang['size']; ?></td>
											<td><?php echo $file['size']; ?></td>
										</tr>
										<?php } ?>
										<?php if (in_array("scale", $this->data['information'])) { ?>
											<?php if ($file['scale'] != 0) { ?>
											<tr>
												<td><?php echo $this->lang['scale']; ?></td>
												<td><?php echo $file['scale']; ?>%</td>
											</tr>
											<?php } ?>
										<?php } ?>
										</table>
									<?php } ?>
								</div>
							</div>
						</div>
						<div style="text-align: center;">
							<?php if ($this->data['insert']) { ?>
							<a href="javascript:insertURL('<?php echo  $file['previewurl']; ?>');"><img src="<?php echo  $file['url']; ?>" width="<?php echo  $file['width']; ?>" height="<?php echo  $file['height']; ?>" id="<?php echo  $file['name']; ?>" style="margin-top: <?php echo  $file['margin']; ?>px;" title="<?php echo  $file['name']; ?>" alt="<?php echo  $file['name']; ?>" border="0" /></a>
							<?php } else { ?>
							<img src="<?php echo  $file['url']; ?>" width="<?php echo  $file['width']; ?>" height="<?php echo  $file['height']; ?>" id="<?php echo  $file['name']; ?>" style="margin-top: <?php echo  $file['margin']; ?>px;" title="<?php echo  $file['name']; ?>" alt="<?php echo  $file['name']; ?>"  />
							<?php } ?>
						</div>
					</div>
					<div class="imagename" style="position: absolute; top: <?php echo  $this->data['thumbnail_height']+5; ?>px; width:<?php echo  $this->data['thumbnail_width']+2; ?>px; text-align: center;"><?php echo  $file['name']; ?></div>
				</div>
			<?php } ?>
		</div>
	</div>
</body>
</html>
