<?php

/*

		用户头像设置

*/

//载入全局配置和函数包
require_once(dirname(__FILE__)."/../include/global.php");

?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $Project["charset"];?>" />
<title>更换头像 - Powered By VeryIDE</title>

<?php

echo loader_style(array(VI_BASE."style/dialog.css"),$Project["charset"],$Project["version"]);

echo loader_script(array(VI_BASE."js/mo.js"),$Project["charset"],$Project["version"]);

?>

<script>

Mo.reader(function(){

	//高亮当前主题
	Mo("#avatars li").each( function(){

		if( Mo(this).attr("rel") == Mo.get('avatar') ){
			this.className = 'active';			
		}

	});
	
	//高亮选中主题
	Mo("#avatars li").bind( 'click', function( ele, index, e ){

		//设置主题
		parent.Serv.System.avatar( Mo(this).attr("rel") );
		
		//取消高亮所有主题
		Mo("#avatars li").each( function(){
			this.className = '';	
		});		
		
		//高亮当前主题
		var obj = Mo.Event( e ).element();
	
		if( obj == this || obj.parentNode == this ){
			this.className = 'active';
		}

	});

});

</script>

</head>

<body>

	<div id="wrapper">

		<?php
	
		//未登录
		if( !$_SESSION["Manager"]["id"] ){
	
			exit('<div id="error">未登录，请先登录</div>');
	
		}
	
		?>
	
		<ul id="avatars">
	
			<?php
			//遍历皮肤目录
			$root = VI_ROOT."/image/avatar/";
	
			if ($handle = opendir($root)) {
				while (false !== ($file = readdir($handle))) {
	
					if(stripos($file,".jpg")){
	
						//
						echo '<li rel="'.$file.'"><img src="'.VI_BASE.'image/avatar/'.$file.'" /> <br /> '.str_replace(".jpg","",ucfirst($file)).' </li>';
						//echo '<li rel="'.$file.'"><img src="'.VI_BASE.'image/avatar/'.$file.'" /></li>';
	
						$i++;
					}
	
				}
				closedir($handle);
			}
			?>	
	
		</ul>
	
	</div>
	
</body>
</html>