db = $idetail->db;
	$pDetail->header_include = 0;			# header include 完了フラグ
	## パラメータチェック 半角数字以外が含まれる場合は、エラー
	if( !is_numeric($_GET['products']) || $_GET['products'] == ""){
		WriteLog::writelog( "parameta Error parameta:".$_GET['products'] );
		$pDetail->viewError('該当の商品は登録を削除されました。');
	}
	$view_count = 4;				# 表示するアイテム数
	
	## 詳細ページ表示タイプ取得( 旧テンプレート使用 or CMS用テンプレート使用 )
	$products_no = mysql_real_escape_string($_GET['products']);
	$pDetail->products_no = $products_no;
	$pvParam     = $pDetail->getPVmode($products_no);
	##------------------##
	##  旧テンプレート  ##
	##------------------##
	
	if( $pvParam['page_type'] == 0 ){
	
		#include("../header02.html");
		$pDetail->header_include = 1;				# include 確認用
	
		$goback = "../index.html";
		$items         = $_SESSION['itemlist'];
		$category_name = $_SESSION['category_name'];
		$sub_name      = $_SESSION['sub_name'];
	
		$res = $idetail->getItemDetail($products_no);
		
		if($res && $idetail->data[products_no]){
	
			$shouhin = "";
			$shouhin = $idetail->data;
			$shouhin['material'] = ereg_replace("(\r\n|\r)", "
", $shouhin['material']);
			$shouhin['note']     = ereg_replace("(\r\n|\r)", "
", $shouhin['note']);
	
			## ラッピングイメージ
			$wrapage = "";
			if(File_Exists("../shop/wrapping/".$shouhin['stores_no3'].".html")){
				$wrapage = "/shop/wrapping/".$shouhin['stores_no3'].".html";
			}
			
			## ショップ詳細ページ
			$concept_page = "";
			if( file_exists("/var/www/html/shop/".$shouhin['concept_page']) != false ){
				$concept_page = $shouhin['concept_page'];
			}
			
			## NEW フラグ
			$new_flg = "0";
			if( strtotime($shouhin['entry_date']) >= strtotime("-2 week",time()) ){
				$smarty->assign("new_flg", "1"); 
			}
	
			## セット組アイテム
			$set_item_num = "";
			for($i=0;$i<$shouhin['set_item_num'];$i++){
				$set_item_num[] = $i+1;
			}
	
			## 熨斗対応 贈答好適品として登録されている商品のみ商品詳細ページに熨斗対応状況を表示する。
			$noshi_viewFlg = $ctgrys->getNoshiViewFlg($products_no);
	
			## 関連商品表示情報 ##
	
			# 同一カテゴリ商品はデフォルトで表示
			$recomMode = "";
			
			# session が無ければ、取得
			if(!$_SESSION['recomItemBasic'.$products_no]){
				# 関連商品表示アイテム取得
				$recomItemBasicList = $pDetail->getRecommendList($recomMode,$shouhin['cpflg']);
				if($recomItemBasicList){
					# ランダムにアイテム取得
					shuffle($recomItemBasicList);
					# ランダムに取得する数。
					# 取得したアイテム数が $view_count 以上なら$view_count。 
					# $view_count以下なら取得した数。
					if( count($recomItemBasicList) > $view_count){
						$count = $view_count;
					}else{
						$count = count($recomItemBasicList);
					}
					for($j=0;$j<$count;$j++){
						$recomBasicList[] = $recomItemBasicList[$j];
					}
					$_SESSION['recomItemBasic'.$products_no] = $recomBasicList;
				}
			}else{
				$recomBasicList = $_SESSION['recomItemBasic'.$products_no];
			}
	
	
			# 設定した商品表示
			$recomMode = $pDetail->getRecomMode();
			if ($recomMode != "" && $recomMode != 3 ){
				# session が無ければ、取得
				if(!$_SESSION['recomItem'.$products_no]){
					# 関連商品表示アイテム取得
					$recomItemList = $pDetail->getRecommendList($recomMode,$shouhin['cpflg']);
					if($recomItemList){
						# ランダムにアイテム取得
						shuffle($recomItemList);
						# ランダムに取得する数。
						# 取得したアイテム数が $view_count 以上なら$view_count。 
						# $view_count以下なら取得した数。
						if( count($recomItemList) > $view_count){
							$count = $view_count;
						}else{
							$count = count($recomItemList);
						}
						for($j=0;$j<$count;$j++){
							$recomList[] = $recomItemList[$j];
						}
						$_SESSION['recomItem'.$products_no] = $recomList;
					}
				}else{
					$recomList = $_SESSION['recomItem'.$products_no];
				}
			}
			
		# 商品がない
		}else{
			$pDetail->viewError('該当の商品は登録を削除されました。');
		}
	
		## 戻り制御/パンクズフラグ
		if( preg_match('/shop/',$_SERVER['PHP_SELF']) ){
		
			if($_SESSION['cartcont'] == ""){
				$panFlg = '';
			}else{
				$goback = $_SESSION['cartcont'];
				$panFlg = 'shop';
			}
		}
		
		if( preg_match('/search/',$_SERVER['PHP_SELF']) && $_SESSION['sgoback']){
			$goback = $_SESSION['sgoback'];
			$_SESSION['sgoback'] = "";
			$panFlg = 'search';
		}
		
		if( preg_match('/item/',$_SERVER['PHP_SELF']) ){
		
			if($_SESSION['cartcont'] == ""){
				//トップから?
				if($_SERVER['HTTP_REFERER']){
					$goback = $_SERVER['HTTP_REFERER'];
				}
			}else if( ( preg_match('/category_list\.html/',$_SESSION['cartcont']) || preg_match('/category_sub\.html/',$_SESSION['cartcont']) ) && !preg_match('/sitem\.html/',$_SESSION['cartcont']) ){
				$category_name = "".$category_name."";
				if($sub_name == ""){
					$goback = "category_list.html?pg=".$_SESSION['fpage'];
					$sub_name = $shouhin['products_name'];
				}else{
					$goback = $_SESSION['cartcont'];
					if($stores_no!=300){
						$sub_name = "{$sub_name} >{$shouhin['products_name']}";
					}else{
						$sub_name = "{$shouhin['products_name']}";
					}
				}
			#}
			}else{
				$goback = $_SESSION['cartcont'];
				if($stores_no!=300){
					$sub_name = "商品一覧 >{$shouhin['products_name']}";
				}else{
					$sub_name = "{$shouhin['products_name']}";
				}
				$category_name_outFlg = 1;
			}
			$panFlg = 'item';
		}
	
		if( preg_match('/mypage/',$_SERVER['PHP_SELF']) ){
			$goback = SECUURL."mypage/12.html?".$_SESSION['rireki'];
			$_SESSION['rireki'] = "";
		}
	
	
		$sVal = "{$shouhin['products_name']} | {$shouhin['shop_name']} ";
		if( !isset($stores_no) ){ $stores_no = intval($shouhin['stores_no3']); }
		include("../header.html");
	
		### メイン出力
		#$smarty->assign("stores_no",$shouhin['stores_no']);
		$smarty->assign("stores_no",$stores_no);
		$smarty->assign("shopname",$shouhin['shop_name']);
		$smarty->assign("concept_page", $concept_page); 
		$smarty->assign("shouhin", $shouhin); 
		$smarty->assign("wrapage", $wrapage); 
		$smarty->assign("option_s", $idetail->option_s); 
		$smarty->assign("option_c", $idetail->option_c); 
		$smarty->assign("option_i", $idetail->option_i); 
		$smarty->assign("cnt_s", Count($idetail->option_s)); 
		$smarty->assign("cnt_c", Count($idetail->option_c)); 
		$smarty->assign("cnt_i", Count($idetail->option_i));
		$smarty->assign("bln_s", $idetail->cnt_s); 
		$smarty->assign("bln_c", $idetail->cnt_c); 
		$smarty->assign("bln_i", $idetail->cnt_i);
		$smarty->assign("zaiko", $idetail->zaiko);
		$smarty->assign("products_no", $products_no);
		$smarty->assign("stockTable", $idetail->stockTable); 
		$smarty->assign("optionTable", $idetail->optionTable);
		$smarty->assign("new_flg", $new_flg);							# new フラグ
		$smarty->assign("set_item_num", $set_item_num);					# セットアイテム
		$smarty->assign("noshi_viewFlg", $noshi_viewFlg);				# 熨斗対応表示フラグ
		$smarty->assign("recomList", $recomList);						# 関連商品
		$smarty->assign("recomBasicList", $recomBasicList);				# 関連商品(デフォルト)
		$smarty->assign("cpflg", $shouhin['cpflg']);					# キャンペーンフラグ
		$smarty->assign("user_name", $_SESSION['user_name']);
		if(!$category_name_outFlg){
			$smarty->assign("category_name", $category_name);
		}
		$smarty->assign("sub_name", $sub_name);
		$smarty->assign("goback", $goback);
		$smarty->assign("panFlg", $panFlg);
	
		( $disp_tmpl == 'foods.tpl' ) ? $smarty->display('shop/03.tpl') : $smarty->display('shop/03.tpl') ;
		include("../footer02.html");
	
	}
	##------------------##
	##  新テンプレート  ##
	##------------------##
	if( $pvParam['page_type'] == 1 ){
	
		require_once("ItemCategory.inc");
		$ctgrys = new ItemCategory;
	
		$smarty   = new Smarty_es;
		$pDetail->smarty = $smarty;
	
		$category_name = $_SESSION['category_name'];
		$sub_name      = $_SESSION['sub_name'];
	
		## 商品情報 ##
		if( $idetail->getItemDetail($products_no) ){
		
			$itemInfo = $idetail->data;
	
			# material/note の改行コードを
に変換
			$itemInfo['material'] = ereg_replace("(\r\n|\r)", "
", $itemInfo['material']);
			$itemInfo['note']     = ereg_replace("(\r\n|\r)", "
", $itemInfo['note']);
		
			# リンクページ設定
			if(File_Exists("../shop/wrapping/".$itemInfo['stores_no3'].".html")){ $wrapage = "/shop/wrapping/".$itemInfo['stores_no3'].".html"; }
			(file_exists("/var/www/html/shop/".$itemInfo['concept_page']) == false) ? $concept_page = "" :$concept_page = $itemInfo['concept_page'];
		
			# new表示用フラグ
			( strtotime($itemInfo['entry_date']) >= strtotime("-2 week",time()) ) ? $newFlg = 1 : $newFlg = 0 ;
		
			## セット組アイテム選択対応
			$set_item_num = "";
			for($i=0;$i<$itemInfo['set_item_num'];$i++){ $set_item_num[] = $i+1; }
		
			## 熨斗対応 ##
			## 贈答好適品として登録されている商品のみ商品詳細ページに熨斗対応状況を表示する。
			$noshi_viewFlg = $pDetail->ctgrys->getNoshiViewFlg($products_no);
		
		}
		
		## 戻り制御/パンクズフラグ
		if( preg_match('/shop/',$_SERVER['PHP_SELF']) ){
	
			if($_SESSION['cartcont'] == ""){
	
				$panFlg = '';
	
			}else{
			
				#$goback = "02.html?pg=".$_SESSION['fpage'];
				$goback = $_SESSION['cartcont'];
				$panFlg = 'shop';
	
			}
	
		}
		
		if( preg_match('/search/',$_SERVER['PHP_SELF']) && $_SESSION['sgoback']){
			$goback = $_SESSION['sgoback'];
			$_SESSION['sgoback'] = "";
			$panFlg = 'search';
		}
		
		if( preg_match('/item/',$_SERVER['PHP_SELF']) ){
		
			if($_SESSION['cartcont'] == ""){
				//トップから?
				if($_SERVER['HTTP_REFERER']){
					$goback = $_SERVER['HTTP_REFERER'];
				}
			#}else{
			}else if( ( preg_match('/category_list\.html/',$_SESSION['cartcont']) || preg_match('/category_sub\.html/',$_SESSION['cartcont']) ) && !preg_match('/sitem\.html/',$_SESSION['cartcont']) ){
				$category_name = "".$category_name."";
				if($sub_name == ""){
					$goback = "category_list.html?pg=".$_SESSION['fpage'];
					$sub_name = $shouhin['products_name'];
				}else{
					$goback = $_SESSION['cartcont'];
					$sub_name = "{$sub_name} >{$itemInfo['products_name']}";
				}
			#}
			}else{
				$goback = $_SESSION['cartcont'];
				$sub_name = "商品一覧 >{$shouhin['products_name']}";
				$category_name_outFlg = 1;
			}
			$panFlg = 'item';
		}
	
		if( preg_match('/mypage/',$_SERVER['PHP_SELF']) ){
			$goback = SECUURL."mypage/12.html?".$_SESSION['rireki'];
			$_SESSION['rireki'] = "";
		}
		
		if(!$category_name_outFlg){
			$smarty->assign("category_name", $category_name);
		}
		#$smarty->assign("category_name", $category_name);
		$smarty->assign("sub_name", $sub_name);
		$smarty->assign("goback", $goback);
		$smarty->assign("panFlg", $panFlg);
	
		### 基本情報出力 ###
		$smarty->assign("stores_no",$itemInfo['stores_no']);
		$smarty->assign("shopname",$itemInfo['shop_name']);
		$smarty->assign("concept_page", $concept_page); 
		$smarty->assign("shouhin", $itemInfo); 
		$smarty->assign("wrapage", $wrapage); 
		$smarty->assign("option_s", $idetail->option_s); 
		$smarty->assign("option_c", $idetail->option_c); 
		$smarty->assign("option_i", $idetail->option_i); 
		
		$smarty->assign("cnt_s", Count($idetail->option_s)); 
		$smarty->assign("cnt_c", Count($idetail->option_c)); 
		$smarty->assign("cnt_i", Count($idetail->option_i));
		
		$smarty->assign("bln_s", $idetail->cnt_s); 
		$smarty->assign("bln_c", $idetail->cnt_c); 
		$smarty->assign("bln_i", $idetail->cnt_i);
		
		$smarty->assign("zaiko", $idetail->zaiko); 
		$smarty->assign("products_no", $products_no);
		
		$smarty->assign("stockTable", $idetail->stockTable); 
		$smarty->assign("optionTable", $idetail->optionTable);
		$smarty->assign("new_flg", $newFlg); 
		
		$smarty->assign("set_item_num", $set_item_num);
		$smarty->assign("noshi_viewFlg", $noshi_viewFlg);
	
		$smarty->assign("cpflg", $itemInfo['cpflg']);					# キャンペーンフラグ
		$smarty->assign("user_name", $_SESSION['user_name']);
		# tab 生成
		$tabHtml    = $pDetail->createTabHtml();
	
		# ナビゲーション生成
		$pDetail->header = $header;	# ナビゲーション用追加
		$naviHtml   = $pDetail->createNaviHtml();
	
		# 商品表示要素を取得
		$objectList = $pDetail->createCmsObjct( $products_no , sprintf("%03d",$itemInfo['stores_no']) , $pvParam['template_id'] );
	
		## 関連商品表示情報 ##
		# 同一カテゴリ商品はデフォルトで表示
		$recomMode = "";
			
		# session が無ければ、取得
		if(!$_SESSION['recomItemBasic'.$products_no]){
			
			# 関連商品表示アイテム取得
			#$recomItemBasicList = $pDetail->getRecommendList($recomMode);
			$recomItemBasicList = $pDetail->getRecommendList($recomMode,$itemInfo['cpflg']);
	
	
			if($recomItemBasicList){
			
				# ランダムにアイテム取得
				shuffle($recomItemBasicList);
							
				# ランダムに取得する数。
				# 取得したアイテム数が $view_count 以上なら$view_count。 
				# $view_count以下なら取得した数。
				if( count($recomItemBasicList) > $view_count){
					$count = $view_count;
				}else{
					$count = count($recomItemBasicList);
				}
				
				for($j=0;$j<$count;$j++){
					$recomBasicList[] = $recomItemBasicList[$j];
				}
					
				$_SESSION['recomItemBasic'.$products_no] = $recomBasicList;
			}
	
		}else{
	
			$recomBasicList = $_SESSION['recomItemBasic'.$products_no];
	
		}
	
	
		# 設定した商品表示
	
		$recomMode = $pDetail->getRecomMode();
		if ($recomMode != "" && $recomMode != 3 ){
			
			# session が無ければ、取得
			if(!$_SESSION['recomItem'.$products_no]){
			
				# 関連商品表示アイテム取得
				#$recomItemList = $pDetail->getRecommendList($recomMode);
				$recomItemList = $pDetail->getRecommendList($recomMode,$itemInfo['cpflg']);
	
				if($recomItemList){
			
					# ランダムにアイテム取得
					shuffle($recomItemList);
						
					# ランダムに取得する数。
					# 取得したアイテム数が $view_count 以上なら$view_count。 
					# $view_count以下なら取得した数。
					if( count($recomItemList) > $view_count){
						$count = $view_count;
					}else{
						$count = count($recomItemList);
					}
				
					for($j=0;$j<$count;$j++){
						$recomList[] = $recomItemList[$j];
					}
						
					$_SESSION['recomItem'.$products_no] = $recomList;
				}
				
			}else{
				
				$recomList = $_SESSION['recomItem'.$products_no];
				
			}
		}
	
		# テンプレート情報を取得
		$template   = $pDetail->getTemplate($pvParam['template_id']);
		
		# ヘッダ情報出力
		$headerInfo = $pDetail->getHeaderInfo();
	
		if( $headerInfo['keywords'] == "" ){ $headerInfo['keywords'] = KEYWORDS; }
		if( $headerInfo['description'] == "" ){ $headerInfo['description'] = DESCRIPTION; }
		if( $headerInfo['title'] == "" ){ $headerInfo['title'] = TITLE; }
	
		# 表示要素出力
		for($i=0;$iassign($objectList[$i]['object_item'],$objectList[$i]['value']);
		}
		$smarty->assign("style_file", $template['style_css']);			# スタイルシートファイル名
		$smarty->assign("keywords", $headerInfo['keywords']);			# キーワード
		$smarty->assign("description", $headerInfo['description']);		# 説明文
		$smarty->assign("title", $headerInfo['title']);					# ページタイトル
		$smarty->assign("recomList", $recomList);						# 関連商品
		$smarty->assign("recomBasicList", $recomBasicList);				# 関連商品(デフォルト)
	
	
		# ヘッダ出力
		$headerHtml = $smarty->fetch('products_page/products_header.tpl');
		$pDetail->header_include = 1;
	
		# メインページ出力
		$mainHtml   = $smarty->fetch("products_page/{$template['template_file']}");
	
		## ページ表示
		print $headerHtml;
		print $tabHtml;
	
		print '';
		print '';
	
		print $naviHtml;
		print $mainHtml;
	
		include("../footer_products.html");
		
	}
?>