<?php
header("Content-Type: text/html;chartset=UTF-8");
?>
<?php
//打开get和post的封装
$getpost_power=true;
//打开session
$session_power=true;
//引入系统文件的支持文件
include_once(dirname(__file__)."/../includes.php");
//引入自己的配制文件
include_once(dirname(__file__)."/config.php");
//引入礼品资源
include_once(dirname(__file__)."/gift_info.php");
//得到礼品的类型
$type=get_args('type');
$gifts=array();
$path="general";
//取得对应礼品的数组信息
switch($type)
{
	case 0: {$gifts=$gift_general;$path="general";break;}
	case 1: {$gifts=$gift_advanced;$path="advanced";break;}
	case 2: {$gifts=$gift_super;$path="super";break;}
}
//如果用户在线
if(get_sess_userid())
{
	//列出对应的礼品信息
	$size=12;
	$totalpage= floor((count($gifts)-1)/$size)+1;
	$gift_array=array_chunk($gifts,$size,true);	
	$index=intval(get_args('index'));
	$gifts=$gift_array[$index];
	foreach($gifts as $title=>$value)
	{
		echo "<div class='giftbox'><img  width=70 height=70 src='".self_url(__file__)."images/$path/{$value}'/><span>$title</span><input type='radio' name='gift_img' value='images/$path/{$value}'/></div>";
	}
	if($totalpage>1)
	{
		$str="<div/><div id='gift_page_list' style='clear:both'>";
		for($i=1;$i<=$totalpage;$i++)
		{
			if($i==($index+1))$str.="<a href='#' onclick='getGifts($type,".($i-1).")' class='active'>$i</a>";
			else $str.="<a href='#' onclick='getGifts($type,".($i-1).")'>$i</a>";
		}
		$str.="</div>";
		echo $str;
	}
	else
	{
		$str="<div/><div id='gift_page_list' style='clear:both;height:20px'>";
		$str.="&nbsp;</div>";
		echo $str;
	}
}
?>
