<?php

include("../includes/config.php");
include("../classes/common.class.php");

$image_file_path = '../images/icons/';
$dir = dir($image_file_path) or die("Wrong path: $image_file_path");

$icon_html = '';
//List files in images directory
 $i=0;
 while (($file = $dir->read()) !== false)
	{
		if ($file != '.' && $file != '..' && !is_dir($image_file_path.$file) && $file != '_notes' && $file !='Thumbs.db'){ 
			$i ++;
			//$fname = substr($file,0, stripos($file,"."));
			$fname = $file;
			
			if (i == 1) $icon_html .= '<tr>';
			
			$icon_html .= '<td align="center"><input type="radio" name="icons" onclick="selectIcon(\''.$fname.'\');" /><img src="../images/icons/'.$fname.'" alt="'.$fname.'"></td>';
			
			if ($i == 2) { $icon_html .= '</tr>'; $i=0; }
		}
		
	} 
	
$dir->close();

?>

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Select Icon</title>
<style>
body {
	font-family:Verdana,Arial,sans-serif;
	font-size:12px;
	margin:0;
	padding:0;
}

.tr_bgcolor {
	background-color:#dcdcdc;
}

.tr_bgcolor2 {
	background-color:#f5f5f5;
}

table tr td {
	font-family:Verdana,Arial,sans-serif;
	font-size:12px;
}
</style>
<script type="text/javascript" src="../js/jquery.js"></script>

<script type="text/javascript">
	
	function closeOpenWindow() {
		//window.close();
		$('#GB_overlay', window.parent.document).hide();
		$('#GB_window', window.parent.document).hide();
	}
	
	function selectIcon(icon)
		{
			parent.document.getElementById('icon').value = icon;
			parent.document.getElementById('icon_sec').innerHTML = '<img src="../images/icons/'+icon+'"/>';
		}
</script>
</head>

<body>
	
	<table width="100%" border="0" align="center" cellpadding="0" cellspacing="2">
		<tr class="tr_bgcolor" style="line-height:30px;">
			<th>Select Icon from the list below </th>
		</tr>
		<tr class="tr_bgcolor2">
			<td align="center">
				<table align="center" width="80%" cellpadding="2" cellspacing="2">
					<?php echo $icon_html ?>
				</table>
			</td>
		</tr>
		<tr class="tr_bgcolor">
			<td>&nbsp;</td>
		</tr>
		<tr class="tr_bgcolor2" align="center">
			<td>
				<input type="button" name="btn_ok" id="btn_ok" value="Submit" onclick="closeOpenWindow();" />
			</td>
		</tr>
		<tr class="tr_bgcolor">
			<td>&nbsp;</td>
		</tr>
	</table>
	
</body>
</html>
