<?php

	/*
	*	Gekko - Open Source Web Development Framework
	*	------------------------------------------------------------------------
	*	Copyright (C) 2004-2005, J. Carlos Nieto <xiam@users.sourceforge.net>
	*	This program is Free Software.
	*
	*	@package	Gekko
	*	@license	http://www.gnu.org/copyleft/gpl.html GNU/GPL License 2.0
	*	@author		J. Carlos Nieto <xiam@users.sf.net>
	*	@version	CVS: $Id:$
	*	@link		http://www.gekkoware.org
	*/

	if (!defined("IN-GEKKO")) die("Get a life!");

	gpGlobalize("size, selected, icon, object, popup, relpath");

	$size = intval($size);

	$path = "media/icons/"._l("C_SITE.ICONTHEME")."/{$size}/";
	$iconpath = GEKKO_ROOT.$path;

	$buff = "";

	if (file_exists($iconpath)) {
		$icons = listdir($iconpath);
		if (!in_array($selected, $icons)) {
			$icons[] = $selected;
		}
		$e = 0;

		$buff .= "<div class=\"iconchooser\">\n";
		foreach ($icons as $i) {
			if (!is_dir("$iconpath/$i")) {
				$buff .= "<img onclick=\"chooseIcon(this, '{$icon}', '{$object}', '{$popup}')\" src=\"".fetchIcon($i, $size, $relpath.$path)."\" width=\"{$size}\" height=\"{$size}\" alt=\"{$i}\" ".(($selected == $i) ? " class=\"selected\" ": "")."/>";
				if ($e%10 == 9) $buff .= "<br />\n";
				$e++;
			}
		}
		$buff .= "</div>";
		if (ereg("MSIE", $_SERVER["HTTP_USER_AGENT"])) {
			include GEKKO_ROOT."lib/msie.lib.php";
			msie_hack($buff);
		}
	}
	echo $buff;

?>