#!/usr/bin/perl
$convert_use =1;	#ImageMagicを使った画像変換処理を行なわない場合は0にする。
#///////////////////////////////////////////////////////////////////////////////
#							Digital Contents Cart Ver11.00

#                      ----- 2008(C) WEB INVENTOR(Solve) -----
#                                 solve@wb-i.net
#                                 http://wb-i.net/
#

#///////////////////////////////////////////////////////////////////////////////
#================================ [注意事項] ===================================
# このスクリプトはシェアウエアです。このスクリプトを使用したいかなる損害に対して
# も作者は一切の責任を負いません。
#====================================使用法=====================================
# 次のようにして呼び出してください。
#	１．商品画面
#			http://・・/shop.cgi		PC用
#			http://・・/k-shop.cgi		（自動的に機種を判別する）
#	２．検索窓の設置
#			<form method="post" action="http://・・/shop.cgi">
#			<input type="text" size=15 name="keyword" value="">
#    		<input type="hidden" name="FF" value='0'>
#    		<input type="hidden" name="class" value="all">
#			<input type="hidden" name="superkey" value="1">
#			検索キー<input type='submit' value=商品検索>
#			</form>
#	３．キーワード及び分類表からの呼び出しかた
#			<a href="http://・・/shop.cgi?keyword=当店お勧め&amp;class=all&amp;superkey=1&amp;FF=0">当店お勧め</a>
#			<a href="http://・・/shop.cgi?class=0&amp;keyword=&amp;superkey=1&amp;FF=0">分類A</a>
#			<a href="http://・・/shop.cgi?class=all&amp;keyword=&amp;superkey=1&amp;FF=0">$class_all</a>
#	４．管理者用
#			http://・・/admin.html
#
#===============================================================================
# ▼設定▼
#===============================================================================

# jcode.plへのパス
require './jcode.pl';

# cgi-lib.plへのパス
require './cgi-lib.pl';

# MIMEコード変換ライブラリ
require './mimew.pl';

# ===============================================================================
# ▲設定終了▲
# ===============================================================================
@kenmei=('-都道府県-','北海道','青森県','岩手県','秋田県','宮城県','山形県','福島県','東京都','神奈川県','埼玉県','千葉県','茨城県','栃木県','群馬県','新潟県','富山県','石川県','福井県','山梨県','長野県','岐阜県','静岡県','愛知県','三重県','滋賀県','京都府','大阪府','兵庫県','奈良県','和歌山県','鳥取県','島根県','岡山県','広島県','山口県','徳島県','香川県','愛媛県','高知県','福岡県','佐賀県','長崎県','熊本県','大分県','宮崎県','鹿児島県','沖縄県');

&ReadParse;

while (($key,$val) = each %in) {
	$form{$key} = $val;

	&jcode'convert(*val, "sjis");
	$val =~ s/<>//g;

	if($form{'mode'} eq 'adm4' || $form{'mode'} eq 'order_form' || $form{'mode'} eq 'order_mail'){
		$val =~ s/&quot;/\"/g;
		if ($key eq "MESS" || $key eq "setumei") {
			$val =~ s/&lt;/</g;
			$val =~ s/&gt;/>/g;
			$val =~ s/<br$xslash>/\n/g;
			$val =~ s/\.\n/\. \n/g;

		}else{
			$val =~ s/</&lt;/g;
			$val =~ s/>/&gt;/g;	

			$val =~ s/\r\n//g;
			$val =~ s/\r//g;
			$val =~ s/\n//g;
#			$val =~ s/\s//g;
		}
			
	}else{
		$val =~ s/\"/&quot;/g;
		$val =~ s/\0/ /g;
		if ($key eq "MESS" || $key eq "setumei" || $key eq "setumei2" || $key eq "setumei3" ) {
			$val =~ s/\r\n/<br$xslash>/g;
			$val =~ s/\r/<br$xslash>/g;
			$val =~ s/\n/<br$xslash>/g;
			if ($val =~ /<br$xslash>$/) {
				while ($val =~ /<br$xslash>$/) { $val =~ s/<br$xslash>$//g; }
			}	
#			$val =~ s/\s//g;

		} else {
			$val =~ s/</&lt;/g;
			$val =~ s/>/&gt;/g;	
			$val =~ s/\r\n//g;
			$val =~ s/\r//g;
			$val =~ s/\n//g;
#			$val =~ s/\s//g;
		}
	}

	$in{$key} = $val;

}

#=================注文加算============================================
if($in{'order'} eq ""){
# Cookieの値を得る
&getCookie();
	$in{'order'} = $COOKIE{'ORDER'};
}elsif($in{'order'} eq "emp"){
	$in{'order'} ='';
}	

$order=$in{'order'};
$order_new =$in{'g_no'}.",".$in{'op1'}.",".$in{'op2'};
if($in{'amount'} ne "" and $in{'amount'} ne "0"){
		if($order eq ""){
			$order =$in{'g_no'}.",".$in{'op1'}.",".$in{'op2'}.":".$in{'amount'};
	    }else{
			@order_1 = split(/!/,$order);
			foreach (@order_1) {
				($i,$j) = split(/:/,$_);
				($j,$book) = split(/\,/,$j);
                if($i eq $order_new){
                	$j = $j + $in{"amount"};
                	if($order_2 eq ""){
                		$order_2 =$order_new.":"."$j,$book";
                	}else{
                    	$order_2 .="!".$order_new.":"."$j,$book";
                    }
                    $k =1;
                }else{
                	if($order_2 eq ""){
                		$order_2 =$_;
                	}else{
                    	$order_2 .="!".$_;
                    }
                }
	        }

	        if($k ne 1){
	    		$order .="!".$in{'g_no'}.",".$in{'op1'}.",".$in{'op2'}.":".$in{'amount'};
	    	}else{
	    	    $order =$order_2;
	    	}
	    }
$in{'order'}=$order;
}
#=================注文減算============================================

if($in{'del_no'} ne ""){
	$order ="";
	@order_1 = split(/!/,$in{'order'});
	foreach (@order_1) {
		($s,$t) = split(/:/,$_);
		($t,$book) = split(/\,/,$t);
		if($s eq $in{'del_no'} && $book eq $in{'book'}){next;}
		if($order eq ""){
			$order = $s.":"."$t,$book";
		}else{
			$order .="!".$s.":"."$t,$book";
		}
	}
	$in{'order'}=$order;
}

#=================再計算================================================
if($in{'recmp_no'} ne ""){
	$t =int($in{"re_suu"});		#数値の整数化
	if($t < 0){$t =1;}
	$in{"re_suu"}=$t;

	$order ="";
	@order_1 = split(/!/,$in{'order'});
	foreach (@order_1) {
		($s,$t) = split(/:/,$_);
		($t,$book) = split(/\,/,$t);
		if($s eq $in{'recmp_no'} && $book eq $in{'book'}){
			$t=$in{"re_suu"};
		}
		if($order eq ""){
			$order = $s.":"."$t,$book";
		}else{
			$order .="!".$s.":"."$t,$book";
		}
	}
	$in{'order'}=$order;
}
#===============	
#クッキーの設定
print &setCookie_0("ORDER", $order);

#==================キーワードの半角ブランクを全角に変換============================
#$in{'keyword'} =~ s/\ /\　/g;

$keyword_encode =$in{'keyword'};
$keyword_encode =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;    #ここでエンコード

$order_encode =$in{'order'};
$order_encode =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;    #ここでエンコード
$order_encode2 =$order_encode;

$class_encode =$in{'class'};
$class_encode =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;    #ここでエンコード

# 設定ファイル====================================================================
if ( $in{'mode'} eq 'order_mail' ) {
	$order_encode ='emp';
	require './set.pl';
	$order_encode =$order_encode2;

}else{
	require './set.pl';
}

#===== 戻り先========================================================
$save_data="$script?&amp;keyword=&amp;FF=$in{'FF'}&amp;class=$class_encode";
$modoru_adding = "$save_data&amp;mode=adm2&amp;pass=$adm_pass";
$modoru_dell = "$save_data&amp;mode=adm3&amp;pass=$adm_pass";
$modoru_renew = "$save_data&amp;mode=adm4&amp;pass=$adm_pass";

$modoru_goods ="$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=$in{'FF'}&amp;price_sort=$in{'price_sort'}&amp;pic_only=$in{'pic_only'}";
$modoru_goods_2 ="$script?class=$class_encode&amp;keyword=$keyword_encode&amp;FF=$in{'FF'}&amp;price_sort=$in{'price_sort'}&amp;pic_only=$in{'pic_only'}";
$modoru_goods_end ="$script?class=$class_encode&amp;keyword=$keyword_encode&amp;FF=$in{'FF'}&amp;price_sort=$in{'price_sort'}&amp;pic_only=$in{'pic_only'}";
$modoru_goods_8 ="$script?order=$order_encode&amp;class=$class_encode&amp;keyword=&amp;FF=$in{'FF'}&amp;price_sort=$in{'price_sort'}&amp;pic_only=$in{'pic_only'}";

#===============HTTP_REFERERの使用================
unless($in{'back'}){

$referer_url =$ENV{'HTTP_REFERER'};
$in{'back'} =$referer_url;
$referer_url_encode = $referer_url;
$referer_url_encode =~ s/&/%26/g;

if($referer_url =~ /mode=top/){		#TOP1〜TOP5のときの対策

}elsif($referer_url eq '' || $referer_url =~ /$script/ || $referer_url =~ /$script_ssl/ || $referer_url =~ /$script_charm/ || $referer_url =~ /$script_e/ || $referer_url =~ /$script_ent/ || $referer_url =~ /$script_h/){
	$referer_url =$modoru_goods;	#HTTP_REFERERがブランクのときの対策
	$in{'back'} ='';
	$referer_url_encode ='';
}elsif($referer_url =~ /\/shop_html\//){
	$referer_url =$home_url;	#HTTP_REFERERがインナーフレームのときの対策
	$in{'back'} =$referer_url;
	$referer_url_encode = $referer_url;
	$referer_url_encode =~ s/&/%26/g;
}

}else{	#戻りアドレスが組み込まれている場合
	$referer_url =$in{'back'};
	$referer_url_encode = $referer_url;
	$referer_url_encode =~ s/&/%26/g;
}
#===============管理用入り口======================
if ( $in{'mode'} eq 'adm1' ) { &adm1; exit;}
if ( $in{'mode'} eq 'adm_menu' ) { &adm_menu; exit;}

#=============================問合せ＆特定商取引法======================
if ( $in{'mode'} eq 'ask' ) { &ask_put; exit;}
if ( $in{'mode'} eq 'howto' ) { &howto_put; exit;}
if ( $in{'mode'} eq 'law' ) { &law_put; exit;}

#===============カートの一時停止==================
if($cart_stop_mess){&error($cart_stop_mess);}

#====================インナーフレームの表示==========================
if ( $in{'iframe'} ne '' ) { &iframe_put(); exit;}

#===============ログイン時のみショッピングが可能======================
if ( ($id_pass_C eq '' && $id_pass2_C eq '') && $non_member_able == 2) {
	print "Location: $log_in_out_url\n\n";
}
#==================消費税の扱い====================
$syouhi_tax_save =$syouhi_tax;
#内税と消費税なしの場合：
if($tax_flag == 1){
	$syouhi_tax =0;
}elsif($tax_flag == 2){
	$syouhi_tax =0;
	$tax_syu = '';
}

#==================商品データの読み込み===============================
if (!open(IN,"$data_file")) { &error('データベース読取エラー','復旧をお待ちください.'); }
@BASE = <IN>;
close(IN);

#====================================================================
	if ( $in{'mode'} eq 'look' ) { &look; exit;}
	if ( $in{'mode'} eq 'order_form' ) { &order_form; exit;}
	if ( $in{'mode'} eq 'sure' ) { &sure; exit;}
	if ( $in{'mode'} eq 'order_mail' ) { &order_mail; exit;}

#====================================================================
# Cookieの値を得る
&getCookie();
$classmei = $COOKIE{'BUNRUIMEI'};
$ff_no = $COOKIE{'FF'};
if($ff_no eq ''){$ff_no =0;}

$pas_word = $COOKIE{'WORD'};

if($in{'class'} ne ""){
	$classmei = $in{'class'};
	print &setCookie_0("BUNRUIMEI", $classmei);
}
if($in{'FF'} ne ""){
	$ff_no = $in{'FF'};
	print &setCookie_0('FF', $ff_no);
}
if($in{'keyword'} ne "" or $in{'superkey'} eq "1"){
	$pas_word = $in{'keyword'};
	print &setCookie_0('WORD', $pas_word);
}elsif($start_ctgry ne '' && $pas_word eq '' && $classmei eq '' && $ff_no == 0){
	$pas_word =$start_ctgry;			#デフォルトカテゴリー
	$keyword_encode =$start_ctgry;
	$keyword_encode =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;    #ここでエンコード
}

$in{'keyword'} = $pas_word;
$in{'class'}=$classmei;
#===================会員専用ページのチェック====================
if($in{'class'} ne '' && $in{'class'} ne 'all'){
	($a,$b)  =split(/\//,$in{'class'});
	&class_name_get();
	$class_B_now =$class_B;
	if(index($class_B_now,$member_only) >= 0){
		if($id_pass_C eq '' && $id_pass2_C eq ''){
			print "Location: $log_in_out_url\n\n";
		}
	}
}
#===================================================================
if($in{'pic_only'}){
	if($page_pic_only){$page =$page_pic_only;}		#画像のみ表示の表示数
}

#========キーワードを整理==========
if($pas_word ne ''){
$word = $pas_word;
$word =~ s/\　/ /g;
$word =~ s/  / /g;
$word =~ s/  / /g;
$word =~ s/\＋/\+/g;
$word =~ s/\+\+/\+/g;
$word =~ s/\+\+/\+/g;
$pas_word =$word;

@pairs_0 = split(/ /,$word);
foreach $pair (@pairs_0){

# ===全角英数字を半角に変換===
	$pair_check =$pair;
	$pair =~ s/([\x83-\x99])\x82/&x82_put($1)/geo;
	$pair =~ s/\x82([\x60-\x79]|[\x81-\x9A])/&zen_han_alp($1)/geo;
	$pair =~ s/\xFF([\xA3-\xB9])/&x82_get($1)/geo;
	if($pair_check ne $pair){$eisuu_check =1;}else{$eisuu_check =0;}

	$pair_check =$pair;
	$pair =~ s/\x82([\x4F-\x58])/&zen_han_num($1)/geo;
	if($pair_check ne $pair){$suuzi_check =1;}else{$suuzi_check =0;}


	if($pair =~ /[\x80-\xff]/){#===全角有り===
		&jcode'h2z_sjis(*pair);		#全角カタカナに変換
		$pair_save =$pair;
		if($kensaku_mode eq '2'){#高速検索−小文字に変換しない
			&jcode'convert(*pair,"euc","sjis");#eucへ変換
			if($pair =~ /[0-9]/ ){
				$suuzi_flag =1;			#数字有り
			}else{$suuzi_flag =0;}
			if($pair =~ /[a-zA-Z]/ || $eisuu_check){
				$eizi{"$pair_save"} =2;	#英字有り
			}else{$pair =$pair_save ;$eizi{"$pair_save"} =0;}
			$pair =$pair_save
		}else{
			&jcode'convert(*pair,"euc","sjis");#eucへ変換
			if($pair =~ /[0-9]/ ){
				$suuzi_flag =1;			#数字有り
			}else{$suuzi_flag =0;}
			if($pair =~ /[a-zA-Z]/ || $eisuu_check){
				$pair =~ tr/A-Z/a-z/;	#///小文字に変換///
				$eizi{"$pair"} =2;		#英字有り
			}else{$pair =$pair_save ;$eizi{"$pair"} =0;}
		}
		if($pair_save =~ /\x83[\x40-\x96]/ || $pair_save =~ /\x81[\x40-\x42]/ || $pair_save =~ /\x81\x5B/ ){
			$zenkaku{"$pair"} =1;	#カタカナ有り
		}else{
			$zenkaku{"$pair"} =2;	#カタカナなし
		}

	}else{#===全角なし===
		$pair_save =$pair;
		if($kensaku_mode eq '1'){&jcode'convert(*pair,"euc","sjis");}#eucへ変換
		if($pair =~ /[0-9]/ ){$suuzi_flag =1;}else{$suuzi_flag =0;}
		if($pair =~ /[a-zA-Z]/ || $eisuu_check){
			$pair =~ tr/A-Z/a-z/;	#///小文字に変換///
			$eizi{"$pair"} =1;		#英字有り
		}else{$pair =$pair_save ;$eizi{"$pair"} =0;}
	}

	if($suuzi_flag || $suuzi_check){$suuzi{"$pair"} =1;#数字有り
	}else{$suuzi{"$pair"} =0;}
	
	push(@pairs,$pair);
}
}
#===================================
$data_su= 0;
$data_ff =0;
foreach $data (@BASE) {
		$data2 = $data ;

		$data =~ s/\r\n//g;
		$data =~ s/\r//g;
		$data =~ s/\n//g;

		$data =~ s/<n>//g;

($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$data);

	($limit_a,$limit_b) = split(/\:/,$limit);
	if($limit_a eq '0' && $goods_hide == 1){ next;}		#購入制限で=0のとき、商品非表示

	($a,$b)  =split(/\//,$class);
	&class_name_get();

		if(index($class_B,$member_only) >= 0){
			if($id_pass_C eq '' && $id_pass2_C eq ''){next;}
		}

		if ($in{'id'} ne '' or $in{'mode'} eq 'p_wide') {
			if ($goods_no eq $in{'id'}) {
		 		push(@NEW,$data2);
		 		@REFER =();
		 		$data_su =1;
			 	last; 
			 }elsif($kigou ne '' && $kigou eq $in{'kigou'}){
			 	$in{'id'} =$goods_no;
			 	push(@NEW,$data2);
		 		@REFER =();
		 		$data_su =1;
			 	last; 
			 } else { next; }
		}

		if ($classmei ne "all" && $classmei ne "") {
			($a1,$a2)  =split(/\//,$class);
			($b1,$b2)  =split(/\//,$classmei);
			if ($a1 ne $b1) { next; }
			if ($b2 ne ''){
				if($a2 ne $b2){ next;}
			}
		}

	if($pas_word ne "") {

if($sale_type){
	($kaitori,$lent)= split(/\//,$sale_type);
	if($aux6){
		$aux6 =$lent;		#レンタル
	}else{
		$aux6 =$kaitori;	#買取り
	}
}

	# 検索処理
		$flag_k = 0;
		foreach $pair (@pairs){

#==========新着情報
if($new_info_days ne '' && index($pair,'新着') >= 0){
	if(&new_check($free5)){last;}else{$flag_k = 1;last;}
}
#==========
			if (&compare($kigou,$pair)) {
				 next;
			}elsif (&compare($name,$pair)) {
				 next;
			}elsif (&compare($goods_no,$pair)) {
				 next;
			}elsif (&compare($class_B,$pair)) {
				 next;
			}elsif (&compare($class_S,$pair)) {
				 next;
			}elsif (&compare($option,$pair)) {
				 next;
			}elsif (&compare($option2,$pair)) {
				 next;
			}elsif (&compare($setumei,$pair)) {
				 next;
			}elsif (&compare($bikou,$pair)) {
				 next;
			}elsif (&compare($price,$pair)) {
				 next;
			}elsif (&compare($free1,$pair)) {
				 next;
			}elsif (&compare($free2,$pair)) {
				 next;
			}elsif (&compare($free3,$pair)) {
				 next;
			}elsif (&compare($free4,$pair)) {
				 next;
			}
			$flag_k = 1;
			last;
		}
		if ($flag_k == 1) { next; }

    }

		$data_su++;
		push(@REFER,$data2);

}

#===================ソート処理====================================
if(1 < $data_su && $data_su <= $sort_upper){	#ソートの条件

if($in{'price_sort'} == 1){
	@REFER = sort { (split(/\<\>/,$a))[8] <=> (split(/\<\>/,$b))[8] } @REFER;
}elsif($in{'price_sort'} == 2){
	@REFER = sort { &suutika((split(/\<\>/,$b))[15]) <=> &suutika((split(/\<\>/,$a))[15]) } @REFER;
}elsif($in{'price_sort'} == 3){
	@REFER = sort { &suutika((split(/\<\>/,$a))[15]) <=> &suutika((split(/\<\>/,$b))[15]) } @REFER;
}elsif($in{'price_sort'} == 4){
	@REFER = sort { &suutika((split(/\<\>/,$b))[18]) <=> &suutika((split(/\<\>/,$a))[18]) } @REFER;
	
}elsif($zyunzyo == 0 or  $zyunzyo eq ''){
	@REFER = reverse @REFER;
}elsif($zyunzyo == 1){
}elsif($zyunzyo == 5){
	@REFER = sort { &suutika5((split(/\<\>/,$a))[$zyunzyo]) <=> &suutika5((split(/\<\>/,$b))[$zyunzyo]) } @REFER;
}else{
	@REFER = sort { &suutika((split(/\<\>/,$a))[$zyunzyo]) <=> &suutika((split(/\<\>/,$b))[$zyunzyo]) } @REFER;
}

}

$hit = 0;
$next_num = '';
$over_no = 0;

#=====================ページ処理=========================
foreach $data3 (@REFER) {
		if ($hit == $page) { $next_num = $data_ff; $over_no ++; $hit++; next; }
		elsif($hit < $page && $data_ff >= $ff_no){
			push(@NEW,$data3); $hit++;
		}elsif($hit > $page && $data_ff >= $ff_no){
			$over_no ++;
		}
		$data_ff ++;
}

if($over_no > $page){
	$over_no = $page;
}
#=====================================================================
	if ( $in{'id'} ne '' ||  $in{'mode'} eq 'p_wide' ) { &p_wide; exit;}
	else { &shop_form; exit;}
	
#=================ソートのための処理ルーチン==========================
sub suutika{
$data_sort =$_[0];
$data_sort =~ s/\n//g;
$data_sort =~ s/[a-zA-Z]//g;		#アルファベットを除去。
$data_sort =~ s/\-/\//g;
$data_sort =~ s/\:/\//g;

$k ='/';
if(index($data_sort,$k) >= 0){

	@suuti_data =split(/\//,$data_sort);

	$output_data ='';
	foreach(@suuti_data){
		$i =$_ + 100000;
		$j =substr("$i",1,5);
		$output_data .=$j;
	}

}else{
	$output_data =$data_sort;
}

return($output_data);
}
#=================ソートのための処理ルーチン（分類）===================
sub suutika5{

	($i,$j) =split(/\//,$_[0]);

	$i =$i + 10000;
	$i =substr("$i",1,4);

	$j =$j + 10000;
	$j =substr("$j",1,4);

	$output_data =$i.$j;

	return($output_data);
}
#================比較サブルーチン=========================
$katakana_convert =1;	#商品データの半角カタカナを全角カタカナに変換（PC）
sub compare{
	$falg_or =0;
	$obj =$_[0];
	$p_or =$_[1];
	if($eizi{"$p_or"}){		#全角英字を半角に変換
		$obj =~ s/([\x83-\x99])\x82/&x82_put($1)/geo;
		$obj =~ s/\x82([\x60-\x79]|[\x81-\x9A])/&zen_han_alp($1)/geo;
		$obj =~ s/\xFF([\xA3-\xB9])/&x82_get($1)/geo;
	}
	if($suuzi{"$p_or"}){	#全角数字を半角に変換
		$obj =~ s/\x82([\x4F-\x58])/&zen_han_num($1)/geo;
	}
	if($zenkaku{"$p_or"}){
		if($katakana_convert && $zenkaku{"$p_or"} eq '1'){&jcode'h2z_sjis(*obj);}#全角カタカナに変換
		if($eizi{"$p_or"} eq '2' && $kensaku_mode ne '2'){
			&jcode'convert(*obj,"euc","sjis");	#eucへ変換
			$obj =~ tr/A-Z/a-z/;	#小文字に変換
		}
	}elsif($eizi{"$p_or"}  eq '1'){
		if($kensaku_mode eq '1'){&jcode'convert(*obj,"euc","sjis");}	#eucへ変換
		$obj =~ tr/A-Z/a-z/;		#小文字に変換
	}
	@p_or  =split(/\+/,$p_or);
	foreach $pair_one(@p_or){
		if (index($obj,$pair_one) >= 0) {$falg_or =1;last;}
	}
    return($falg_or);
}
#=====全角英数字を半角に変換（sjis）======
sub zen_han_alp{
	$han =$_[0];
	$han =~ tr/\x60-\x79/\x41-\x5A/;
	$han =~ tr/\x81-\x9A/\x61-\x7A/;
	return($han);
}
sub zen_han_num{
	$han =$_[0];
	$han =~ tr/\x4F-\x58/\x30-\x39/;
	return($han);
}
#=====\x83\x82-\x99\x82の変換と復元======
sub x82_put{
	$x82 =$_[0];
	$x82 =~ tr/\x83-\x99/\xA3-\xB9/;
	$x82 ="\xFF$x82";
	return($x82);
}
sub x82_get{
	$x82 =$_[0];
	$x82 =~ tr/\xA3-\xB9/\x83-\x99/;
	$x82 ="$x82\x82";
	return($x82);
}

#===============================================
sub new_check{
	$new_goods_flag =0;
	unless($_[0]){return($new_goods_flag);}

    # タイムゾーンを日本時間に合わせる
	$ENV{'TZ'} = "JST-9";
	$times = time;
	$times1 =int($times/(24*60*60));
	$times2 =int($_[0]/(24*60*60)) + $new_info_days;
	if($times2 > $times1){$new_goods_flag =1;}

	return($new_goods_flag);
}
#===============トップページの生成===============
sub top_html{

$script_save ="$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=$in{'FF'}&amp;pic_only=$in{'pic_only'}";
$url_goods_no =$script_save."&amp;mode=p_wide&amp;id";
$into_cart_url =$script_save."&amp;mode=look";
$url_class ="$script?order=$order_encode&amp;keyword=&amp;superkey=1&amp;FF=0&amp;pic_only=$in{'pic_only'}&amp;class";
$url_keyword ="$script?order=$order_encode&amp;FF=0&amp;pic_only=$in{'pic_only'}&amp;class=all&amp;keyword";
$url_top ="$script?order=$order_encode&amp;pic_only=$in{'pic_only'}&amp;mode";

$kensaku_form = <<"EOF";
<form method='post' action="$script" style='margin: 0px;'>
<input type="text" size='20' name="keyword" value="$pas_word" class='kensaku'$xslash>
<input type="hidden" name="class" value="all"$xslash>
<input type='submit' value="商品検索" class='submit' class='submit'$xslash>
<input type="hidden" name="FF" value='0'$xslash>
<input type="hidden" name="superkey" value="1"$xslash>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
</form>
EOF

$into_cart_form = <<"EOF";
<form method="post" action="$script" style='margin: 0px;'>
<input type="hidden" name="order" value=$in{'order'}$xslash>
<input type="hidden" name="class" value=$in{'class'}$xslash>
<input type="hidden" name="keyword" value=$in{'keyword'}$xslash>
<input type="hidden" name="superkey" value=$in{'superkey'}$xslash>
<input type="hidden" name="price_sort" value=$in{'price_sort'}$xslash>
<input type="hidden" name="pic_only" value=$in{'pic_only'}$xslash>
<input type="hidden" name="mode" value="look"$xslash>
<input type='submit' value="カートの中" class='submit' class='submit'$xslash>
</form>
EOF

&html_header();

if($in{'mode'} eq 'top1'){
	$top_html =$top1_html;
}elsif($in{'mode'} eq 'top2'){
	$top_html =$top2_html;
}elsif($in{'mode'} eq 'top3'){
	$top_html =$top3_html;
}elsif($in{'mode'} eq 'top4'){
	$top_html =$top4_html;
}else{
	$top_html =$top5_html;
}

$log_in_id =$hello_id;
if($id_pass_C ne '' || $id_pass2_C ne ''){$log_in_id =$id_name_C;}

$top_html =~ s/\$log_in_id/$log_in_id/g;
$top_html =~ s/\$log_in_name/$kanji_c/g;
$top_html =~ s/\$log_in_mess/$log_in_mess/g;

$top_html =~ s/\$url_goods_no/$url_goods_no/g;
$top_html =~ s/\$url_class/$url_class/g;
$top_html =~ s/\$url_keyword/$url_keyword/g;
$top_html =~ s/\$kensaku_form/$kensaku_form/g;
$top_html =~ s/\$into_cart_url/$into_cart_url/g;
$top_html =~ s/\$into_cart_form/$into_cart_form/g;
$top_html =~ s/\$url_top/$url_mode/g;
$top_html =~ s/\$url_mode/$url_mode/g;

$top_html =~ s/\$script/$script/g;
$top_html =~ s/\$order_encode/$order_encode/g;
$top_html =~ s/\$class_encode/$class_encode/g;
$top_html =~ s/\$keyword_encode/$keyword_encode/g;
$top_html =~ s/\$in{'pic_only'}/$in{'pic_only'}/g;
$top_html =~ s/\$in{'FF'}/$in{'FF'}/g;
$top_html =~ s/\$in{'price_sort'}/$in{'price_sort'}/g;
$top_html =~ s/\$pic_only/$in{'pic_only'}/g;
$top_html =~ s/\$page_no/$in{'FF'}/g;
$top_html =~ s/\$price_sort/$in{'price_sort'}/g;

print <<"EOF";
$top_html
EOF
	print "<br$xslash>$foot</body></html>" ;	

}
#===============インナーフレーム表示=======================================================
sub iframe_put{
&html_header();

$url =$in{'iframe'};

if($in{'height'}){
	$iframe_h =$in{'height'};
}
$iframe_w =$t_width;

print <<"EOF";

<center>
<table cellspacing='0' cellpadding='0' border='0' width="$iframe_w">
<tr><td align="center" bgcolor="" height="$iframe_h">

<iframe src="$url" height="100%"  width="100%"  border="0" frameborder="0" marginheight="0" marginwidth="0" name="sign" scrolling="auto" allowtransparency='true'>
この部分は iframe 対応のブラウザで見てください。
</iframe>
</td>
</tr>
</table>
</center>
EOF

	print "<p>$foot</body></html>" ;	

}
#=============================画像の拡大（詳細）===========================================
sub p_wide {
&keisan();
1 while $all_total01 =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
#====

($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$NEW[0]);

$aux2 =~ s/\r\n//g;
$aux2 =~ s/\r//g;
$aux2 =~ s/\n//g;
$aux5 =~ s/\r\n//g;
$aux5 =~ s/\r//g;
$aux5 =~ s/\n//g;

$sale_type_sett='';
if($sale_type){
	($kaitori,$lent)= split(/\//,$sale_type);
	if($aux6){
		$s_type =$lent;
	}else{
		$s_type =$kaitori;
	}
	$sale_type_sett ="<tr><td>[販売形態] $s_type</td></tr>";
	$sale_type_sett_w ="[販売形態] $s_type<br$xslash><br$xslash>";
}

$add1_basket ="$modoru_goods&amp;mode=look&amp;g_no=$goods_no&amp;amount=1";

#=========画像表示========
($pic1,$pic2,$pic3,$pici,$picj,$pic4,$pic5,$pic6,$pic7,$pic8,$pic9,$pic10) =split(/\|/,$picture);
if($pic1 eq ""){$pic1 ="$default_g";}

@image_name2 =('画像1','画像2','画像3','画像4','画像5','画像6','画像7','画像8','画像9','画像10');
@pic8 =("$pic1","$pic2","$pic3","$pic4","$pic5","$pic6","$pic7","$pic8","$pic9","$pic10");
if($popup_non){#=======ポップUPしない場合=======
	unless($in{'img'}){$in{'img'} =0;}
	$i =0;
	foreach(@image_name2){
		if($image_name[$i]){$_ =$image_name[$i];}
		if($pic8[$i] && $in{'img'} ne $i){
			$link_pop1 ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1&amp;img=$i";
			$pop1_set .='| '."<a href=$link_pop1>"."$_".'</a> ';
			$flag_link =1;
		}elsif($pic8[$i] && $in{'img'} == $i){
			$pop1_set .='| '."$_".' ';
			($pic1,$w_h_set1) =&pic_convert($imagesize_A,'',$pic8[$i],$convert_none_AB);
			$pic1_set ="<img src=\"$pic1\" border='0' alt=\"$name [$kigou]\" $w_h_set1$xslash>";
		}else{
#			$pop1_set .='| '."$_".' ';
		}
		$i ++;
	}
	unless($flag_link){$pop1_set =''}
	if($pop1_set){$pop1_set .='|';}

}else{#==========ポップUPする場合==========
($pic1,$w_h_set1) =&pic_convert($imagesize_A,'',$pic1,$convert_none_AB);
$pic1_set ="<img src=\"$pic1\" border='0' alt=\"$name [$kigou]\" $w_h_set1$xslash>";

$link_pop1 ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1&amp;popup=yes1";
$link_pop2 ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1&amp;popup=yes2";

if($pic2){
	$pop1_set =<<"EOF";
	<a href="\#$position" onclick=window.open("$link_pop1",'_blank','width=$popup_w,height=$popup_h,menubar=no,scrollbars=yes')><img src="$dir_m/B.gif" border='0' alt=''$xslash></a>\　\　
EOF
}
if($pic3){
	$pop2_set =<<"EOF";
	<a href="\#$position" onclick=window.open("$link_pop2",'_blank','width=$popup_w,height=$popup_h,menubar=no,scrollbars=yes')><img src="$dir_m/C.gif" border='0' alt=''$xslash></a>
EOF
}
}

#=================================ポップアップ=============================
if($in{'popup'} eq 'yes1' || $in{'popup'} eq 'yes2'){
if($in{'popup'} eq 'yes1'){$pic_pop =$pic2; }
if($in{'popup'} eq 'yes2'){$pic_pop =$pic3; }

($pic_pop,$w_h_set) =&pic_convert($imagesize_B,'',$pic_pop,$convert_none_AB);
$popup_set ="<img src=\"$pic_pop\" border='0' alt=\"$name [$kigou]\" $w_h_set$xslash>";

$header ='';$foot ='';

&html_header();

print <<"EOF";
<table cellspacing='0' cellpadding='15' width="100%" height='100%' border='0' bgcolor="#ffffff">
<tr><td align='center'>

<table cellspacing='0' cellpadding='0' width="100%" height='97%' style='border: 1px solid #cccccc;margin-bottom:3px' bgcolor="#ffffff">
<tr><td valign='middle' align='center'>$popup_set</td></tr>
</table>

<a href="javascript:window.close();"><font class='link_color'>CLOSE</font></a>

</td></tr>
</table>
$foot</body></html>
EOF

exit;
}
#==========================================================================
($a,$b)  =split(/\//,$class);
&class_name_get();

@option = split(/\:/,$option);
$i = 0;
$flag_zaiko_non=0;
$flag_non_option ='1';
$option_set = "";
$zaiko_new ='';
while($i < $option_no) {
	($op_k[$i],$op_m[$i],$op_su[$i],$op_pr[$i]) =split(/\,/,$option[$i]);
	if($op_k[$i] eq ''){ $i++; next;}
	$flag_non_option ='0';
	if($op_su[$i] eq ''){ $flag_zaiko_non=1; }
#	if($op_su[$i] eq '0'){$i++; next;}
	if($op_su[$i] > 0){$zaiko_new +=$op_su[$i];}
		$su_ex ='';
		if($op_su[$i] ne '' && $option_su_ex  == 1){ $su_ex ="/$op_su[$i]$option_su_tani";}
		$pr_ex ='';
		if($op_pr[$i] ne ''){$pr_ex ="[\\$op_pr[$i]]";}
		$option_set = $option_set."<option value='$op_k[$i]'>$op_m[$i]$pr_ex$su_ex</option>\n";
	$i++;
}
if($option_set ne ""){
    $option_set = "<select name='op1'>".$option_set."</select>";
}else{
	$option_set ="";
}

if($flag_non_option ne '1'){
	if($zaiko_new eq ''){
		$zaiko =0;
	}else{
		$zaiko =$zaiko_new;
	}
}

@option2 = split(/\:/,$option2);
$i = 0;
$option2_set = "";
while($i < $option2_no) {
	($op2_k[$i],$op2_m[$i],$op2_su[$i]) =split(/\,/,$option2[$i]);
	if($op2_k[$i] eq ""){ $i++; next;}
		$option2_set = $option2_set."<option value='$op2_k[$i]'>$op2_m[$i]</option>\n";
	$i++;
}
if($option2_set ne ""){
    $option2_set = "<select name='op2'>".$option2_set."</select>";
}else{
	$option2_set ="";
}

if($option_set){
	$option_set_w ="$option_set<br$xslash><br$xslash>";
}
if($option2_set){
	$option2_set_w ="$option2_set<br$xslash><br$xslash>";
}

($price,$tax_ch)= split(/\:/,$price);
if($tax_flag eq ''){
	if($tax_ch == 1){
		$tax_set ="$tax_komi";
	}else{
		$tax_set ="$tax_betu";
	}
}elsif($tax_flag eq '0'){
	$tax_set ="$tax_betu";
}elsif($tax_flag eq '1'){
	$tax_set ="$tax_komi";
}elsif($tax_flag eq '2'){
	$tax_set ='';
}
#===========================月次決済の時=========================
if($aux6){
	$tuki ='/月)';
	$tax_set =~ s/\)/$tuki/g;
}
if($sale_type){
	($kaitori,$lent)= split(/\//,$sale_type);
	if($aux6){
		$s_type =$lent;
	}else{
		$s_type =$kaitori;
	}
}
#================================================================

$price_set = $price;
1 while $price_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

if ($price =~ /[^0-9\.]/) {          # 文字列を含んでいたらか？全角数字も。
        $price_set = "<font color ='#ff0000'>$price_set</font>";
}

($setumei,$setumei2,$setumei3) =split(/\|\|/,$setumei);
#===========
if($data_pk_use){
	$setumei2 =&read_data_p($goods_no);
}
$setumei2 =~ s/&quot;/\"/g;
$setumei2 =~ s/\<n\>/\n/g;

$bikou_set =$bikou;
$setumei_set ="";
	if($bikou ne ""){
		if($bikou_flag == 1){
			$bikou_c = "※重量".$bikou.'(グラム)';
			$bikou = "<br$xslash>※重量".$bikou.'(グラム)';
		}else{
			$bikou_c = "※".$bikou;
			$bikou = "<br$xslash>※".$bikou;
		}
	}else{
			$bikou_c = '';
			$bikou = '';
	
	}
	$setumei_set =$setumei2. $bikou;

$zaiko_set ='';
if($zaiko_ex == 1){
if($zaiko eq ''){
	$zaiko_set ="";
    $zaiko = 100000;
}elsif($zaiko > 0){
	$zaiko_set ="在庫$zaiko$tani";
}elsif($zaiko <= 0){
	$zaiko =0;
	$zaiko_set ="在庫$zaiko$tani";
}
}else{
if($zaiko eq ''){
    $zaiko = 100000;
}elsif($zaiko <= 0){
	$zaiko =0;
}
}
if($flag_zaiko_non == 1){$zaiko = 100000; $zaiko_set ="";}

#======在庫僅少表示======
if($zaiko_few_n){
	if(0 < $zaiko && $zaiko < $zaiko_few_n){$zaiko_set .=$zaiko_few;}
}
#========================
($limit,$limit2) = split(/\:/,$limit);
if($limit ne ""){
	$tani_set ="$limit$taniまで";
}else{
    $tani_set =$tani;
    $limit =100000;
}
$limit_su =$limit;

$get_setting = "<input type='submit' value='購入' class='submit'$xslash>";
if($price == 0 && $free_soft){
		$get_setting = "$free_soft";
}elsif($zaiko_stop ne '' && $zaiko <= 0){
	if($limit2 eq '0' || $goods_yoyaku ne '1'){
		$get_setting = "$zaiko_stop";
	}else{
		$get_setting = "<input type='submit' value='予\約' class='submit'$xslash>";
		if($limit2 ne ""){
			$tani_set ="$limit2$taniまで";
		}else{
		    $tani_set =$tani;
		    $limit2 =100000;
		}
		$limit_su =$limit2;
}
}

$kosuu_setting = "";
foreach ( @kosuu_set ) {
	if($_ >$limit_su){
		last;
	}else{
		$kosuu_setting .= "<option value=\'$_\'>$_</option>";
	}
}
if($kosuu_setting eq ""){
	$kosuu_setting = "<select name='amount'><option value='0'>−</option></select>$tani_set";
}else{
	$kosuu_setting = "<select name='amount'>$kosuu_setting</select>$tani_set";
}

$word='タイムサービス';
$words='ﾀｲﾑｻｰﾋﾞｽ';
if (index($setumei,$word) >= 0 || index($bikou,$word) >= 0 || index($setumei,$words) >= 0 || index($bikou,$words) >= 0) {
    # タイムゾーンを日本時間に合わせる
	$ENV{'TZ'} = "JST-9";
	$times = time;
	($sec,$min,$hour,$day,$month,$year,$wday,$Days,$dmy) = localtime($times);
	if($service_time[0]  =~ /\//){
		$year = $year + 1900;
		$month = $month +1;
		$time =$year.'/'.$month.'/'.$day;
	}else{
		$time =$hour.':'.$min;
	}
	if(&suutika($time) < &suutika($service_time[0]) || &suutika($service_time[1]) < &suutika($time)){
		$get_setting ="[ｻｰﾋﾞｽﾀｲﾑ]".'<br$xslash>'."$service_time[0]-$service_time[1]";
	}
}

$aux1_set =$aux1;
if(($aux1_name eq '会員価格' || $aux1_name eq '特別会員') && $aux1 ne ''){
	if($mem_price_ex && !($id_pass_C ne '' || $id_pass2_C ne '')){
		$aux1_set ="$mem_price_ex";
	}else{
1 while $aux1_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
		$aux1_set = "<font color='#ff0000'>\\$aux1_set</font>$tax_set";
	}
}

$aux1_comma =$aux1;
1 while $aux1_comma =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

if($aux1 ne '' && $aux1_name){
	$aux1_setting ="<tr><td>[$aux1_name] $aux1_set</td></tr>";
	$aux1_setting_w ="$aux1_name  $aux1_set<br$xslash><br$xslash>";
	
}
if($aux2 && $aux2_name){
	$aux2_setting ="<tr><td>[$aux2_name] $aux2</td></tr>";
}
if($free1 && $free1_name){
	$free1_setting ="<tr><td>[$free1_name] $free1</td></tr>";
}
if($free2 && $free2_name){
	$free2_setting ="<tr><td>[$free2_name] $free2</td></tr>";
}
if($free3 && $free3_name){
	$free3_setting ="<tr><td>[$free3_name] $free3</td></tr>";
}

if($get_cago){
	$cago_back ="<input type='hidden' name='mode' value='look'$xslash>";
}

$get_setting2 =<<"EOF";
	$get_setting
	<input type='hidden' name='g_no' value="$goods_no"$xslash>
	<input type="hidden" name="class" value="$in{'class'}"$xslash>
	<input type="hidden" name="FF" value="$in{'FF'}"$xslash>
	<input type="hidden" name="order" value="$in{'order'}"$xslash>
	<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
	<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
	<input type="hidden" name="back" value="$in{'back'}"$xslash>
	$cago_back
EOF

#==============口コミ情報の件数及びその使用======
if($kutikomki_use){

# ログファイル
$kutikomi_logfile = "$dir_charm/charmlog.cgi";
$kutikomi_su =0;
open(IN,"$kutikomi_logfile") || &error("Open Error: $kutikomi_logfile");
@KUTIKOMI = <IN>;
close(IN);
foreach (@KUTIKOMI) {
	($no,$date,$nm,$msg,$col,$ico,$pw,$hos,$res,$col2,$ico2,$chk,$gno) = split(/<>/,$_);
	# チェック機能
	next if ($kutikomi_check && $chk eq '0');
	next if ($in{'id'} eq '' || $gno ne $in{'id'});
	$kutikomi_su ++;
}

	$kutikomi_link ="<a href=\"$script_charm?gno=$in{'id'}\"><font class='link_button'>$kutikomi_name（$kutikomi_su件）</font></a>";
	$kutikomi_link_c ="<a href=\"$script_charm?gno=$in{'id'}\"><font class='link_button'>$kutikomi_name（$kutikomi_su件）</font></a>";
	$kutikomi_link_w ="<br$xslash><a href=\"$script_charm?gno=$in{'id'}\"><font class='link_button'>$kutikomi_name（$kutikomi_su件）</font></a>";
	$bikou_hyouzi =$bikou_c;
}else{
	$kutikomi_link =$bikou_c;
	$bikou_hyouzi ='';
	$kutikomi_bk1 =$naka_color;
}

#==========================HTML出力===========================
#=====SEO====
$goods_seo_key =$name;
if($kigou){$goods_seo_key .="[$kigou]";}
#============

&html_header();

unless($kensaku_express){
print <<"EOF";
<table border='0' cellpadding='0' cellspacing='0' width="$t_width"  bgcolor="$bg_color" class='kensaku_table'><tr>
<td align="left">
<form method='post' action="$script"  style='margin: 0px;'>
<input type="text" size='20' name="keyword" value="$pas_word" class='kensaku'$xslash>
<input type='submit' value="商品検索" class='submit' class='submit'$xslash>
<input type="hidden" name="class" value="all"$xslash>
<input type="hidden" name="FF" value='0'$xslash>
<input type="hidden" name="superkey" value="1"$xslash>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
</form>
</td>
<td align="right">
<form method="post" action="$script" style='margin: 0px;'>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="class" value="$in{'class'}"$xslash>
<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
<input type="hidden" name="superkey" value="$in{'superkey'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
<input type="hidden" name="back" value="$in{'back'}"$xslash>
<input type="hidden" name="mode" value="look"$xslash>

<table cellspacing='0' cellpadding='0' border='0'><tr><td bgcolor="$color_d" class='total'><font class='total_text'>購入合計額：$all_total01円</font></td><td width='4'></td><td><input type='submit' value="ｶｰﾄを見る" class='submit'$xslash></form></td></tr>
</table>
</td></tr>
</table><br$xslash>
EOF
}elsif($kensaku_express eq '1'){
print <<"EOF";
<table border='0' cellpadding='0' cellspacing='0' width="$t_width"  bgcolor="$bg_color" class='kensaku_table'><tr>
<td align="right">
<table border='0' cellpadding='0' cellspacing='0'>
<tr><td class='total'><font class="total_text">購入合計額：$all_total01円</font></td>$name_in_cart<td width='4'></td>
<td>
<form method="post" action="$script" style='margin: 0px;'>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="class" value="$in{'class'}"$xslash>
<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
<input type="hidden" name="superkey" value="$in{'superkey'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
<input type="hidden" name="mode" value="look"$xslash>
<input type='submit' value="ｶｰﾄを見る" class='submit'$xslash>
</form>
</td></tr>
</table>
</td></tr></table><br$xslash>
EOF
}

print <<"EOF";
<table width="$t_width" id='detail_midasi_color'><tr><td><h2 id='detail_midasi_fontcolor'><strong>$name</strong></h2></td>
<td align="right"><a href="$referer_url"><font class='link_button' color="#ffffff">戻る</font></a></td></tr></table>
EOF

#=================================================
if($Wide_Fine eq 'C'){
($pic2,$w_h_set) =&pic_convert($imagesize_B,'',$pic2,$convert_none_AB);
unless($pic2){$pic2 ="$dir_p/space.gif";}
($pic3,$w_h_set) =&pic_convert($imagesize_B,'',$pic3,$convert_none_AB);
unless($pic3){$pic3 ="$dir_p/space.gif";}

$detail_tb =~ s/\<n\>/\n/g;

$detail_tb =~ s/\$goods_no/$goods_no/g;
$detail_tb =~ s/\$setumei_set/$setumei2/g;
$detail_tb =~ s/\$name/$name/g;
$detail_tb =~ s/\$kigou/$kigou/g;
$detail_tb =~ s/\$class_name/$class_name/g;
$detail_tb =~ s/\$bikou_set/$bikou_set/g;

$detail_tb =~ s/\$price_set/$price_set/g;

$detail_tb =~ s/\$option_set/$option_set/g;
$detail_tb =~ s/\$option2_set/$option2_set/g;

$detail_tb =~ s/\$link_pop/$link_pop/g;
$detail_tb =~ s/\$link_pw/$link_pw/g;

$detail_tb =~ s/\$tax_set/$tax_set/g;
$detail_tb =~ s/\$get_setting/$get_setting2/g;
$detail_tb =~ s/\$zaiko_set/$zaiko_set/g;
$detail_tb =~ s/\$kosuu_setting/$kosuu_setting/g;

$detail_tb =~ s/\$pica/$pic1/g;
$detail_tb =~ s/\$picb/$pic2/g;
$detail_tb =~ s/\$picc/$pic3/g;
$detail_tb =~ s/\$pop1_set/$pop1_set/g;
$detail_tb =~ s/\$pop2_set/$pop2_set/g;

$detail_tb =~ s/\$aux1_comma/$aux1_comma/g;
$detail_tb =~ s/\$aux1_set/$aux1_set/g;
$detail_tb =~ s/\$aux1/$aux1/g;
$detail_tb =~ s/\$aux2/$aux2/g;
$detail_tb =~ s/\$aux3/$aux3/g;
$detail_tb =~ s/\$aux4/$aux4/g;
$detail_tb =~ s/\$aux5/$aux5/g;
$detail_tb =~ s/\$aux6/$aux6/g;
$detail_tb =~ s/\$s_type/$s_type/g;
$detail_tb =~ s/\$aux7/$aux7/g;
$detail_tb =~ s/\$free1/$free1/g;
$detail_tb =~ s/\$free2/$free2/g;
$detail_tb =~ s/\$free3/$free3/g;
$detail_tb =~ s/\$free4/$free4/g;
$detail_tb =~ s/\$free5/$free5/g;

$detail_tb =~ s/\$kutikomi_link/$kutikomi_link_c/g;
$detail_tb =~ s/\$add1_basket/$add1_basket/g;

print <<"EOF";
$detail_tb
EOF

}elsif($Wide_Fine eq 'F'){

$wide_left =$t_width -200;

print <<"EOF";
<center>
<table bgcolor="$color_d" border='0' cellpadding="0" cellspacing="0">
<tr>
<td>
<table width="$t_width" cellpadding="5" cellspacing="1">
<tr>
<td bgcolor="#ffffff" rowspan="2" width="$wide_left" align='center'>
<img src="$pic1" border="0" alt="$name [$kigou]"$xslash><br$xslash><br$xslash>
$pop1_set$pop2_set
</td>
<td bgcolor="$naka_color" valign='top'>
<table width="200" cellpadding="3" cellspacing="1">
<tr>
<td>[名称] $name</td>
</tr>
<tr>
<td>[記号] $kigou</td>
</tr>
<tr>
<td>[分類] $class_name</td>
</tr>
$aux2_setting
$free1_setting
$free2_setting
$free3_setting
$aux1_setting
<tr>
<td>[価格] \\$price_set$tax_set</td>
</tr>
$sale_type_sett
</table>
<br$xslash>
<table bgcolor="$midasi_color" border='0' cellpadding="0" cellspacing="0"><tr><td>
EOF

print <<"EOF";
<table width="200" cellpadding="3" cellspacing="1" bgcolor="$midasi_color">
<tr>
<td>
<form action="$script" method="post">
<input type='hidden' name='g_no' value="$in{'id'}"$xslash>
<input type="hidden" name="class" value="$in{'class'}"$xslash>
<input type="hidden" name="FF" value="$in{'FF'}"$xslash>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="back" value="$in{'back'}"$xslash>
$cago_back
$option_set</td>
</tr>
<tr>
<td>$option2_set</td>
</tr>
<tr><td>$zaiko_set</td></tr>
<tr><td>$kosuu_setting</td></tr>
<tr><td>$get_setting
</td>
</tr>
</table>
</td></tr></table>
</form>
$bikou_hyouzi
</td></tr>
<tr><td bgcolor="$kutikomi_bk1" valign='top'>$kutikomi_link</td></tr>
<tr><td bgcolor="$naka_color" colspan="2" width="$t_width">
<font class='detail'>$setumei2</font>
</td></tr>
</table>
</td>
</tr>
</table>
</center>
EOF

}else{
#=================================Wタイプ=====================================
if($pic2){
	($pic2,$w_h_set2) =&pic_convert($imagesize_B,'',$pic2,$convert_none_AB);
	$pic2_setting ="<tr><td align='center'><img src=\"$pic2\" border=\"0\" alt=\"$name [$kigou]\" $w_h_set2$xslash></td></tr>";
}
if($pic3){
	($pic3,$w_h_set3) =&pic_convert($imagesize_B,'',$pic3,$convert_none_AB);
	$pic3_setting ="<tr><td align='center'><img src=\"$pic3\" border=\"0\" alt=\"$name [$kigou]\" $w_h_set3$xslash></td></tr>";
}
print <<"EOF";
<center>
<table cellspacing='0' cellpadding='0' width="$t_width" border='0' bgcolor="#ffffff">
<tr>
<td align='center'><br$xslash><img src="$pic1" border="0" alt="$name [$kigou]" $w_h_set1$xslash></td>
</tr>
$pic2_setting
$pic3_setting
<tr>
<td align='center'><br$xslash><font class='detail'>$setumei_set</font></td>
</tr>
<tr>
<td align='center'>$kutikomi_link_w</td>
</tr>
</table>
</center>
EOF

print <<"EOF";
<center>
<form action="$script" method="post">
<input type='hidden' name='g_no' value="$in{'id'}"$xslash>
<input type="hidden" name="class" value="$in{'class'}"$xslash>
<input type="hidden" name="FF" value="$in{'FF'}"$xslash>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="back" value="$in{'back'}"$xslash>
$cago_back
<br$xslash>
価格 \\$price_set$tax_set <br$xslash><br$xslash>$aux1_setting_w <br$xslash><br$xslash>$sale_type_sett_w
$option_set_w$option2_set_w注文数 $kosuu_setting \　 $get_setting
</form>

</center>
EOF

}

print <<"EOF";
<table width="$t_width" bgcolor="$bg_color"><tr><td align="right">
<a href="$referer_url"><font class='link_button'>戻る</font></a></td></tr>
</table>
EOF

#=============================関連＆お勧め商品================
$data_goods_no =$goods_no;
$data_class =$class;
&goods8_data();

#========================関連商品の表示======================
if($related_ok && @CHILD_DATA){

if($related_5_8goods){
$related_5_8_set =<<"EOF";
<tr valign='top' bgcolor='#ffffff'>
$table_related[4]
$table_related[5]
$table_related[6]
$table_related[7]
</tr>
EOF
}

print <<"EOF";
<br$xslash><br$xslash>
<table cellspacing='0' cellpadding='0' align='center' border='0'>
<tr><td align='center' bgcolor="$related_color">

<table cellspacing='0' cellpadding='3' align='center' border='0'>
<tr><td align='center' bgcolor="$related_color">
<font class='goods8_top'>$related_title</font>
</td></tr>
</table>

</td>
</tr>

<tr><td bgcolor="$related_color">
<table cellspacing='1' cellpadding='5' width="$t_width" border='0'>
<tr valign='top' bgcolor='#ffffff'>
$table_related[0]
$table_related[1]
$table_related[2]
$table_related[3]
</tr>
$related_5_8_set
</table>
</td></tr>
</table>
<br$xslash>
EOF
}

#=====================お勧め８商品の表示=============================
if($osusume_8 && $flag_4goods){

if($flag_5_8goods){
$goods5_8_set =<<"EOF";
<tr valign='top' bgcolor='#ffffff'>
$table_data[4]
$table_data[5]
$table_data[6]
$table_data[7]
</tr>
EOF
}

print <<"EOF";
<br$xslash><br$xslash>
<table cellspacing='0' cellpadding='0' align='center' border='0'>
<tr><td align='center' bgcolor="$goods8_top">

<table cellspacing='0' cellpadding='3' align='center' border='0'>
<tr><td align='center' bgcolor="$goods8_top">
<font class='goods8_top'>$goods8_title</font>
</td></tr>
</table>

</td>
</tr>

<tr><td bgcolor="$goods8_top">
<table cellspacing='1' cellpadding='5' width="$t_width" border='0'>
<tr valign='top' bgcolor='#ffffff'>
$table_data[0]
$table_data[1]
$table_data[2]
$table_data[3]
</tr>
$goods5_8_set
</table>
</td>
</tr>
</table>
<br$xslash>
EOF

}

print "$foot</body></html>" ;

}

#====================関連商品サブルーチン&お勧め８品サブルーチン====================
sub goods8_data{
if($related_ok && (-e $related_file)){
@child_no =();

open(IN,"$related_file") || &error("オープンエラー$related_file",'指定された書込みファイルが開けません。');
@RELATED = <IN>;
close(IN);

foreach(@RELATED){
	($mother_no,$child_data) = split(/\<\>/,$_);
	if ($data_goods_no eq $mother_no) {
		@child_no = split(/\,/,$child_data);
		last;
	}
}
}

$flag_4goods =0;
$flag_5_8goods =0;

$data_su1= 0;
$data_su2= 0;
$data_su3= 0;

foreach $data (@BASE) {

	$data2 = $data ;
	$data =~ s/\r\n//g;
	$data =~ s/\r//g;
	$data =~ s/\n//g;
		($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$data);
		
		if ($data_goods_no eq $goods_no) { next; }
		
		($limit_a,$limit_b) = split(/\:/,$limit);
		if($limit_a eq '0' && $goods_hide == 1){ next;}		#購入制限で=0のとき、商品非表示

		$exist_flag =0;
		foreach(@child_no){
			$_ =~ s/\r\n//g;
			$_ =~ s/\r//g;
			$_ =~ s/\n//g;
			if ($_ eq $goods_no) {
				push(@CHILD_DATA,$data2);
				$exist_flag =1;
			}
		}
		if ($exist_flag) { next; }

		($a1,$a2)  =split(/\//,$class);
		($b1,$b2)  =split(/\//,$data_class);
		
		if(($a1 eq $b1)&&($a2 eq $b2)){
			 push(@NEW1,$data2); 
			$data_su1++;
		}elsif($a1 eq $b1){
			 push(@NEW2,$data2); 
			$data_su2++;
		}else{
			 push(@NEW3,$data2); 
			$data_su3++;
		}

}

#=============関連商品==============
$t8_width = $t_width/4;

$i =0;
while($i < 8){
$table_related[$i] =<<"EOF";
<td  bgcolor="$bg_color"  width="$t8_width">\　</td>
EOF
$i ++;
}

$i =0;
foreach(@CHILD_DATA){
	($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$_);

($price,$tax_ch)= split(/\:/,$price);
if($tax_flag eq ''){
	if($tax_ch == 1){
		$tax_set ="$tax_komi";
	}else{
		$tax_set ="$tax_betu";
	}
}elsif($tax_flag eq '0'){
	$tax_set ="$tax_betu";
}elsif($tax_flag eq '1'){
	$tax_set ="$tax_komi";
}elsif($tax_flag eq '2'){
	$tax_set ='';
}

$price_set = $price;
1 while $price_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

$link_pw ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1&amp;back=$referer_url_encode";

($pic1,$pic2,$pic3,$pici,$picj) =split(/\|/,$picture);
if($pici eq ""){
	$pici ="$default_g";
}

($pici,$w_h_set) =&pic_convert($goods8_width,$goods8_height,$pici,$convert_none_8);
$pici_set ="<img alt=\"$name\" src=\"$pici\" border='0' $w_h_set$xslash>";

$h8_15 =$goods8_height +10;
$table_related[$i] =<<"EOF";
<td valign='bottom' align='center' width="$t8_width">
  <a href="$link_pw">$pici_set</a>
  <img height="$h8_15" src="$dir_p/space.gif" width="1" border="0" alt=''$xslash><br$xslash>
  <a href="$link_pw"><font class='goods8'>$name</font></a>
  <br$xslash><font class='goods8_price'>\\$price_set</font>$tax_set
  </td>
EOF

if($i == 4){
	$related_5_8goods =1;
}

$i ++;
}

#==============ランダム処理===========
if($osusume_8){

if($data_su1 >= 8){
	$j =$data_su1;
	$i =0;
	while($i < 8 && $j > 0){
		$r = int(rand($j));
		$DATA8[$i] = $NEW1[$r];
		splice(@NEW1, $r, 1);
		$j --;
		$i ++;
	}

}else{
	$husoku = 8-$data_su1;
	if($data_su2 > $husoku){
		$j =$data_su2;
		$i =0;
		while($i < $husoku && $j > 0){
			$r = int(rand($j));
			$HUSOKU[$i] = $NEW2[$r];
			splice(@NEW2, $r, 1);
			$j --;
			$i ++;
		}	
		@DATA8 =(@NEW1,@HUSOKU);

	}else{
		$husoku = 8-$data_su1-$data_su1;
		$j =$data_su3;
		$i =0;
		while($i < $husoku && $j > 0){
			$r = int(rand($j));
			$HUSOKU[$i] = $NEW3[$r];
			splice(@NEW3, $r, 1);
			$j --;
			$i ++;
		}	
		@DATA8 =(@NEW1,@NEW2,@HUSOKU);

	}
}

$i =0;
while($i < 8){
$table_data[$i] =<<"EOF";
<td  bgcolor="$bg_color"  width="$t8_width">\　</td>
EOF
$i ++;
}

}

$i =0;
foreach(@DATA8){
	($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$_);

($price,$tax_ch)= split(/\:/,$price);
if($tax_flag eq ''){
	if($tax_ch == 1){
		$tax_set ="$tax_komi";
	}else{
		$tax_set ="$tax_betu";
	}
}elsif($tax_flag eq '0'){
	$tax_set ="$tax_betu";
}elsif($tax_flag eq '1'){
	$tax_set ="$tax_komi";
}elsif($tax_flag eq '2'){
	$tax_set ='';
}

$price_set = $price;
1 while $price_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

$link_pw ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1&amp;back=$referer_url_encode";

($pic1,$pic2,$pic3,$pici,$picj) =split(/\|/,$picture);
if($pici eq ""){
	$pici ="$default_g";
}

($pici,$w_h_set) =&pic_convert($goods8_width,$goods8_height,$pici,$convert_none_8);
$pici_set ="<img alt=\"$name\" src=\"$pici\" border='0' $w_h_set$xslash>";

$h8_15 =$goods8_height +10;
$table_data[$i] =<<"EOF";
<td valign='bottom' align='center' width="$t8_width">
  <a href="$link_pw">$pici_set</a>
  <img height="$h8_15" src="$dir_p/space.gif" width="1" border="0" alt=''$xslash><br$xslash>
  <a href="$link_pw"><font class='goods8'>$name</font></a>
  <br$xslash><font class='goods8_price'>\\$price_set</font>$tax_set
  </td>
EOF

$flag_4goods =1;
if($i == 4){
	$flag_5_8goods =1;
}

$i ++;
}

}
#========詳細説明ファイルの読み=========
sub read_data_p{
	unless(-e $data_p_file){return;}
	$setumei_get ='';
	open (IN_P,"$data_p_file") || &error('オープンエラー1 data_p.cgi','指定された書込みファイルが開けません。');
	@DATA_P = <IN_P>;
	close (IN_P);
	foreach $data_p ( @DATA_P ) {
		($gds_no_p,$setumei_p) = split(/\<\>/,$data_p);
		if ( $gds_no_p eq $_[0] ) {$setumei_get = $setumei_p;last;}
	}
	return($setumei_get);
}

#===============代引き手数料===================
sub daibikikeisann{
if($daibiki_able eq 1){

$zyugen ='0';
foreach (@daibiki_tb) {
	($x,$y) = split(/:/,$_);
	if($x eq ''){
		$daibiki_add =$y;
		$zyugen ='1';
		last;
	}elsif($sougoukei <= $x){
		$daibiki_add =$y;
		$zyugen ='1';
		last;
	}
}

if($zyugen eq '0'){
	$daibiki_able =0;
}

}
}

#===============e-コレクト手数料===================
sub collectkeisann{
if($collect_able eq 1){

$zyugen ='0';
foreach (@collect_tb) {
	($x,$y) = split(/:/,$_);
	if($x eq ''){
		$collect_add =$y;
		$zyugen ='1';
		last;
	}elsif($sougoukei <= $x){
		$collect_add =$y;
		$zyugen ='1';
		last;
	}
}

if($zyugen eq '0'){
	$collect_able =0;
}

}
}

#===============クレジット手数料===================
sub creditkeisann{

if($sougoukei > $credit_epsilon_upper){
	$credit_able =0;
}

if($credit_able  eq 1 && $credit_add_yes eq 1){

foreach (@credit_tb) {
	($x,$y) = split(/:/,$_);
	if($x eq ''){
		$credit_add =$y;
		last;
	}elsif($sougoukei <= $x){
		$credit_add =$y;
		last;
	}
}

if($credit_add < 1){
		$credit_add =int($sougoukei*$credit_add);
}

}

}

#===============コンビニ決済手数料===================
sub convenikeisann{

if($sougoukei > $conveni_upper){
	$conveni_able =0;
}

if($conveni_able eq 1 && $conveni_add_yes eq 1){

foreach (@conveni_tb) {
	($x,$y) = split(/:/,$_);
	if($x eq ''){
		$conveni_add =$y;
		last;
	}elsif($sougoukei <= $x){
		$conveni_add =$y;
		last;
	}
}
if($conveni_add < 1){
		$conveni_add =int($sougoukei*$conveni_add);
}

}

}

#=================会員制===================
sub read_list{

&get_file_name();

if (-e $list_file) {

	if (!open(IN,"$list_file")) { &error("オープンエラー",'指定された書込みファイルが開けません。');}
	@LIST2 = <IN>;
	close(IN);

	$exist_flag = 0;
	foreach(@LIST2) {
	
		($entry_no,$identity,$password,$name,$fax,$keitai,$mail,$post,$addr,$tel,$date,$point,$mag,$kana,$born,$old,$sex,$kisyu) = split(/\<\>/,$_);
		($ken,$addr) = split(/\:/,$addr);
		($special,$tel_syu) = split(/\|/,$keitai);
    	if($in{'ID_NAME'} eq $identity){
			$exist_flag =1;
			if($in{'PASS'} eq $password){$exist_flag =2;}
			last;
    	}
	}
}else{ $read_error = 1; $exist_flag = 0;}

}

#=======================================
sub get_file_name{

$letter =substr($in{'ID_NAME'},0,1);
&letter_number();
$number1 =$number;

$letter =substr($in{'ID_NAME'},1,1);
&letter_number();
$number2 =$number;

$list_file =$dir_list.'/'.$number1.$number2.'.cgi';
$lock_file =$dir_lock.'/'.$number1.$number2.'.lock';

}
sub letter_number{

	if($letter =~ /[ab]+/){
		$number =0;
	}elsif($letter =~ /[cd]+/){
		$number =1;
	}elsif($letter =~ /[e-g]+/){
	    $number =2;
	}elsif($letter =~ /[h-l]+/){
	    $number =3;
	}elsif($letter =~ /[m-o]+/){
	    $number =4;
	}elsif($letter =~ /[p-r]+/){
	    $number =5;
	}elsif($letter =~ /[s]+/){
	    $number =6;
	}elsif($letter =~ /[t-z]+/){
	    $number =7;
	}elsif($letter =~ /[A-L]+/){
	    $number =8;
	}elsif($letter =~ /[M-Z]+/){
	    $number =9;
	}elsif($letter =~ /[0-9]+/){
		$number =$letter;
	}else{
	    $number =9;
	}
}

#=======================総額により送料計算=================================================
sub const_function{
if ($souryou_cst !~ /:/) {return;}

@cnst_table = split(/\,/,$souryou_cst);

foreach (@cnst_table) {
	($x,$y) = split(/:/,$_);
	if($y eq ''){$y =0;}
	if($x eq ''){
		$souryou_cst =$y;
		last;
	}elsif($all_total <= $x){
		$souryou_cst =$y;
		last;
	}
}

}
#======================================カートの中を見る======================================
sub look {
$order=$in{'order'};
&keisan();

&html_header();
$ajustw =$o_width -50;
$ajust =$o_width -370;
$ajust=int($ajust/4);
$w1 =112+$ajust;
$w2 =180+$ajust*3;
$w3 =158+$ajust*3;

if($bk_ground eq ''){
$zaiko_color =$bg_color;
}

if($zaiko_mess){
unless($goods_yoyaku){		#予\約機能なし
$zaiko_mess =<<"EOF";
<font color="#ff0000">ご注文商品の購入数が調整されています。</font>
<br$xslash><table><tr><td><ul class='list_style'>$zaiko_mess</ul></td></tr></table>
は、購入制限又は在庫不足のため、ご希望の数をご用意できません。<br$xslash>今回ご注文をお受けできる商品／数は下記の通りとなりますのでご確認下さい。<br$xslash>
EOF
}else{
$zaiko_mess =<<"EOF";
<font color="#ff0000">在庫のない商品はご予\約（取寄せ）になります。内容をご確認ください。</font>
EOF
}
$zaiko_color='#ffffcc';

}else{
$zaiko_mess =<<"EOF";
ご注文商品は下記の通りです。
<br$xslash>
EOF

}

	print <<"EOF";
<center>
<table cellpadding="3" width="$o_width">
    <tr>
      <td align="right" width="$o_width"><a href="$referer_url"><font class='link_button'>商品画面へ戻る</font></a></td>
    </tr>
</table>
</center>
<br$xslash>
<table cellpadding='7' cellspacing='0' width="$o_width"><tr><td align='left' bgcolor="$zaiko_color">$zaiko_mess</td></tr></table>
<br$xslash><center>
<table border="0" cellpadding='0' cellspacing='0' bgcolor="$color_kago" width="$o_width">
<tr>
<td align="center">
	<table width="$o_width"  border="0">
	<tr>
	<td></td>
	<td align="center"><b><font color="$color_d">現在のカートの中身</font></b></td>
	<td></td>
	</tr>
	<tr>
	<td></td>
	<td></td>
	<td></td>
	</tr>
	<tr>
	<td>\　</td>
	<td align="center">
	<table border="0" cellpadding="3" cellspacing='1' width="$ajustw" bgcolor="$color_d" bordercolor="$color_d">
	<tr>
	<td bgcolor="$color_d" align="center" width="$w1"><font color="#ffffff">商品画像</font></td>
	<td bgcolor="$color_d" align="center" width="$w2"><font color="#ffffff">商品名</font></td>
	<td bgcolor="$color_d" align="center" width="190"><font color="#ffffff">金額</font></td>
	<td bgcolor="$color_d" align="center" width="68"><font color="#ffffff">取消し</font></td>
	</tr>
EOF

@order_1 = split(/!/,$order);
foreach (@order_1) {
	($s_id,$t) = split(/:/,$_);
	($a,$b,$c) = split(/\,/,$s_id);
	($t,$book) = split(/\,/,$t);

$book_set = '';	
if($book eq 'b'){
	if($book_be ne 1){
		$book_set ="<tr><td align='center' colspan=4 bgcolor=$color_r>▼以下は在庫不足のため、ご予\約（取寄せ）商品となります▼</td></tr>";
	}
	$book_set2 ="<tr><td align='left'>【予\約商品】</td></tr>";
	$book_color ='#ffffcc';
	$book_be =1;
}else{
	$book_set ='';
	$book_color ='#ffffff';
	$zaiko_be =1;
}

@opt = split(/\:/,$k_option{"$s_id"});
$flag = 0;
$i = 0;
$option_set ="";
$zaiko_new ="";
if($b ne ""){
while($i < $option_no) {
	($op_k[$i],$op_m[$i],$op_su[$i]) =split(/\,/,$opt[$i]);
	if($op_k[$i] eq $b){$option_set = $op_m[$i];};
	if($op_k[$i] eq '' || $op_su[$i] eq '0'){ $i++; next;}
	if($op_k[$i] ne '' && $op_su[$i] ne ''){$zaiko_new +=$op_su[$i];}
	if($op_k[$i] ne ''){ $flag=1;}
	$i++;
}
}

if($flag == 1 ){$k_zaiko{"$s_id"} =$zaiko_new;}

@opt2 = split(/\:/,$k_option2{"$s_id"});
$i = 0;
$option2_set ="";
if($c ne ""){
while($i < $option2_no) {
	($op2_k[$i],$op2_m[$i]) =split(/\,/,$opt2[$i]);
	if($op2_k[$i] ne $c){ $i++; next;}
	$option2_set = $op2_m[$i];
	last;
}
}

($pic1,$pic2,$pic3,$pici,$picj) =split(/\|/,$k_picture{"$s_id"});

if($pici eq ""){
	$pici ="$default_g";
}

($pici,$w_h_set) =&pic_convert(65,'',$pici,$convert_none);
$pici_set ="<img src=\"$pici\" border='0' align='middle' $w_h_set alt=''$xslash>";

$kigou = $k_id{"$s_id"};
if($b ne ""){
$kigou .="-".$b;
}
if($c ne ""){
$kigou .="-".$c;
}

#if($bikou ne "\n"){
#	$bikou_set = "<tr><td width=$w3>※".$k_bikou{"$s_id"}."</td></tr>";
#}

if($k_zaiko{"$s_id"} eq ""){
    $k_zaiko{"$s_id"} = 100000;
}
if($k_limit{"$s_id"} eq ""){
    $k_limit{"$s_id"} =100000;
}

if($book eq 'b'){
	$kosuu_setting = "<input style='ime-mode:disabled;text-align:right;' size='3' name='re_suu' value=\'$k_amount_b{\"$s_id\"}\'$xslash>";
	$k_total_set =$k_total_b{"$s_id"};
}else{
	$kosuu_setting = "<input style='ime-mode:disabled;text-align:right;' size='3' name='re_suu' value=\'$k_amount{\"$s_id\"}\'$xslash>";
	$k_total_set =$k_total{"$s_id"};

}

1 while $k_price{"$s_id"} =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
1 while $k_total{"$s_id"} =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

print <<"EOF";
$book_set
	<tr bgcolor="$book_color">
	<td align="center" height="70" width="$w1">$pici_set<br$xslash>$kigou</td>
	<td align="center" height="70" width="$w2" valign='top'>
	<table style='margin-top:5px'>
	$book_set2
	<tr>
	<td align="left" width="$w3">$k_name{"$s_id"}</td>
	</tr>
	<tr>
	<td width="$w3">$option_set</td>
	</tr>
	<tr>
	<td width="$w3">$option2_set</td>
	</tr>
	$bikou_set
	</table>
	</td>
	<td align="right" height="70" width="190" valign='top'>
	
	<form name='F1' action="$script" method="post" style='margin-bottom:0px'>
	<table width="180" style='margin-top:5px'>
	<tr>
	<td align="right" width="100">単価$k_tax{"$s_id"}：</td>
	<td width="89" align="right">$k_price{"$s_id"}円</td>
	</tr>
	<tr>
	<td align="right" width="100">購入数：</td>
	<td width="89" align="right">
	$kosuu_setting$k_tani{"$s_id"}</td>
	</tr>
	<tr>
	<td align="right" width="100">小計：</td>
	<td width="89" align="right">$k_total{"$s_id"}円</td>
	</tr>
	</table>

	</td>
	<td align="center" height="70" width="68" valign='top'>
	<input type="hidden" name="mode" value="look"$xslash>
	<input type="hidden" name="recmp_no" value="$s_id"$xslash>
	<input type="hidden" name="class" value="$in{'class'}"$xslash>
	<input type="hidden" name="FF" value="$in{'FF'}"$xslash>
	<input type="hidden" name="book" value="$book"$xslash>
	<input type="hidden" name="order" value="$in{'order'}"$xslash>
	<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
	<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
	<input type="hidden" name="back" value="$in{'back'}"$xslash>
	<input type='submit' value="再計算" class='submit' style='margin-top:9px;margin-bottom:0px'$xslash>
	</form>
	<form name='F2' action="$script" method="post" style='margin-top:12px;margin-bottom:0px'>
	<input type="hidden" name="mode" value="look"$xslash>
	<input type="hidden" name="del_no" value="$s_id"$xslash>
	<input type="hidden" name="class" value="$in{'class'}"$xslash>
	<input type="hidden" name="FF" value="$in{'FF'}"$xslash>
	<input type="hidden" name="book" value="$book"$xslash>
	<input type="hidden" name="order" value="$in{'order'}"$xslash>
	<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
	<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
	<input type="hidden" name="back" value="$in{'back'}"$xslash>
	<input type='submit' value="取消" class='submit'$xslash>
	</form>
	</td>
	</tr>
EOF
}

if(!$order){
print <<"EOF";
	<tr>
	<td colspan="4" align="center" height="14" bgcolor="#ffffff"><br$xslash>カートの中は空です。<br$xslash><br$xslash></td>
	</tr>
EOF
}

$tax0 = int($all_total0 * $syouhi_tax);
$tax_total0 =$tax0 + $all_total0;
$all_total_set=$all_total1 + $tax_total0;
1 while $all_total1 =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
1 while $all_total0 =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
1 while $tax_total0 =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
1 while $tax0 =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
1 while $all_total_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

if($tax_flag eq '0'){
print <<"EOF";
	<tr>
	<td colspan="2" align="right" height="22" bgcolor="$color_r">合計</td>
	<td align="right" height="22" bgcolor="$color_r" width="190">$all_total0円</td>
	<td rowspan="4" valign="middle" align="center" width="68" bgcolor="$color_r">確認</td>
	</tr>
	<tr>
	<td colspan="2" align="right" height="22" bgcolor="$color_r">消費税</td>
	<td align="right" height="22" bgcolor="$color_r" width="190">$tax0円</td>
	</tr>
	<tr>
	<td colspan="2" align="right" height="22" bgcolor="$color_r">合計(消費税込み)</td>
	<td align="right" height="22" bgcolor="$color_r" width="190">$all_total_set円</td>
	</tr>
EOF

}elsif($tax_flag eq '1'){
print <<"EOF";
	<tr>
	<td colspan="2" align="right" height="14" bgcolor="$color_r">合計(消費税込み)</td>
	<td align="right" height="14" bgcolor="$color_r" width="190">$all_total1円</td>
	<td rowspan="4" valign="middle" align="center" width="68" bgcolor="$color_r">確認</td>
	</tr>
EOF

}elsif($tax_flag eq '2'){
print <<"EOF";
	<tr>
	<td colspan="2" align="right" height="14" bgcolor="$color_r">合計</td>
	<td align="right" height="14" bgcolor="$color_r" width="190">$all_total1円</td>
	<td rowspan="4" valign="middle" align="center" width="68" bgcolor="$color_r">確認</td>
	</tr>
EOF


}else{
print <<"EOF";
	<tr>
	<td colspan="2" align="right" height="14" bgcolor="$color_r">税込品目の合計</td>
	<td align="right" height="14" bgcolor="$color_r" width="190">$all_total1円</td>
	<td rowspan="4" valign="middle" align="center" width="68" bgcolor="$color_r">確認</td>
	</tr>
	<tr>
	<td colspan="2" align="right" height="22" bgcolor="$color_r">税別品目の合計</td>
	<td align="right" height="22" bgcolor="$color_r" width="190">$all_total0円</td>
	</tr>
	<tr>
	<td colspan="2" align="right" height="22" bgcolor="$color_r">税別品目の消費税</td>
	<td align="right" height="22" bgcolor="$color_r" width="190">$tax0円</td>
	</tr>
	<tr>
	<td colspan="2" align="right" height="22" bgcolor="$color_r">合計</td>
	<td align="right" height="22" bgcolor="$color_r" width="190">$all_total_set円</td>
	</tr>

EOF
}

print <<"EOF";
</table>
</td><td>\　</td></tr>
<tr><td></td>
<td>\　</td>
<td></td></tr>
</table>
</td></tr></table>
<br$xslash>
</center>
EOF


if($order ne "" && $all_total >= 0){

if($all_total < $free_price){

  if($souryou_cst eq ''){
  
   if(@souryou_tb <= 1){
  	$souryou_cst_set = $souryou_tb[0];
1 while $souryou_cst_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
	$soryo_set ="[送料は$souryou_cst_set円]";
	$souryou_hidden ="<input type='hidden' name='souryou' value=\'$souryou_tb[0]\'$xslash>";

   }else{
	$souryou_flag =1;
	$souryou_souhusaki ="-1".','."未選択";
	$soryo_set = "<option value=\"$souryou_souhusaki\">送付先を選択してください</option>\n";
	$i = 0;
	foreach (@souryou_tb) {
		$souryou_souhusaki ="$souryou_tb[$i]".','."$souhusaki[$i]";
		$soryo_set .= "<option value=\"$souryou_souhusaki\">$souhusaki[$i]</option>\n";
		$i++;
	}
	$soryo_set ="送り先：". "<select name='souryou'>".$soryo_set."</select>";
   }
   
  }else{
	&const_function();
  	$souryou_cst_set = $souryou_cst;
1 while $souryou_cst_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
	$soryo_set ="[送料は$souryou_cst_set円]";
	$souryou_hidden ="<input type='hidden' name='souryou' value=\'$souryou_cst\'$xslash>";
  }
}else{
	$soryo_set ="[送料は無料です]";
	$souryou_hidden ="<input type='hidden' name='souryou' value='0,0'$xslash>";
}

&present_inf();

print <<"EOF";
$present_mess_set
<center>
<br$xslash><a href="$referer_url"><font class='link_button'>さらに買物を続ける</font></a><br$xslash><br$xslash>
</center>
EOF

if($tyuui1){
print <<"EOF";
$tyuui1_table
EOF
}

print <<"EOF";
<center>
<br$xslash><br$xslash>
<table bgcolor="$color_d" border='0' width="$o_width" cellpadding="0" cellspacing='0'><tr><td>
<table cellpadding="3" cellspacing='1' width="$o_width" border="0" bgcolor="$color_d">
    <tr>
      <td width="$o_width" bgcolor="$color_d" align="center"><b><font color="#ffffff">送料又は送付先を確認して、購入手続きへ</font></b></td></tr>
	<tr><td width="$o_width" align="center" bgcolor="#ffffff" height='65' valign="middle">
	<form name='F7' action="$script_ssl" method="post" enctype="multipart/form-data" onsubmit="return kakunin()" >
	$soryo_set
	<input type="hidden" name="mode" value="order_form"$xslash>
    <input type="hidden" name="class" value="$in{'class'}"$xslash>
    <input type="hidden" name="FF" value="$in{'FF'}"$xslash>
    <input type="hidden" name="order" value="$in{'order'}"$xslash>
    <input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
    <input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
	$souryou_hidden
	\　\　<input type="submit" value="購入手続きへ" class='submit'$xslash>
	</form>
	</td></tr>
</table></td></tr></table>
</center><br$xslash>
EOF
}

if($tyuui2){
print <<"EOF";
$tyuui2_table
EOF
}

if($aff_recom_t && $affiliate_use){
print <<"EOF";
<br$xslash><br$xslash><center>
<table bgcolor="$color_d" border='0' width="$o_width" cellpadding="0" cellspacing='0'><tr><td>
<table cellpadding="3" cellspacing='1' width="$o_width" border="0" bgcolor="$aff_recom_c">
    <tr>
      <td width="$o_width" bgcolor="$aff_recom_c" align="center"><b><font color="#ffffff">$aff_recom_t</font></b></td></tr>
	<tr><td width="$o_width" bgcolor="#ffffff" valign="top">
$aff_recom_m<br$xslash>
</td></tr>
</table></td></tr></table>
</center>
EOF
}

#======送付先選択==================
if($souryou_flag ==1){
	$alert =<<"EOF";
	if (document.F7.souryou.selectedIndex == 0) {
		alert("送付先が選択されていません。");
		return(false);
	}
EOF
}
	print <<"EOF";
<script type="text/javascript">
function kakunin(){
	$alert
}
</script>
EOF
#==================================

	print "<br$xslash>$foot</body></html>" ;	

}

#=================================あといくらでプレゼント===================================
sub present_inf{
@present_p = split(/\,/,$present_price);
@present_mess =($present1,$present2,$present3,$present4,$present5);
$i =0;
foreach (@present_p) {
	if($_ eq ''){
		$present_mess_set ='';
		last;
	}elsif($all_total < $_){
		$atoikura = $_ - $all_total;
1 while $atoikura =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
		$present_mess_set = $present_mess[$i];
		$present_mess_set =~ s/\$atoikura/$atoikura/g;
		last;
	}
	$i ++;
}
	if($present_mess_set){
		$present_mess_set ="<div align='center'>$present_mess_set</div><br$xslash>";
	}
}

#==========================================================================================
sub class_name_get{
	($class_B,$k) = split(/\//,$class_tb[$a]);
	@class_tb2 =split(/:/,$k);
	if($b ne ''){
		$class_S =$class_tb2[$b];
		$class_name ="$class_B/$class_S";
	}else{
		$class_name ="$class_B";
	}
}

sub pic_convert{
	unless($_[2]){return(('',''));}

	if($_[0] && $convert_use && $_[3] ne 'none'){
		 $p ="$script_cnvrt?src=$_[2]&amp;w=$_[0]&amp;h=$_[1]&amp;type=";
	}else{$p =$_[2];}

	if($_[0] && $_[1]){$w_h ="width=\"$_[0]\" height=\"$_[1]\"";	
	}elsif($_[0]){$w_h ="width=\"$_[0]\"";
	}else{$w_h ="";}

	return(($p,$w_h));
}
#=======================================Shopping Form======================================
sub shop_form {
#===========著作権表示を無断で削除するとエラーになります。==========
if($right_free<49999 || $right_free>69999 || $right_free =~ /[^0-9]/){
	$http ='http://wb-i.net/';
	if($foot !~ /$http/){&error("error");}
}
#========================================================================

	&keisan();

&html_header();

1 while $all_total01 =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

if($pas_word ne ""){
	$condition =$pas_word;
}else{
	if($in{'class'} eq 'all' or $in{'class'} eq ''){
		$condition="$class_all";
	}else{
		($a,$b)  =split(/\//,$in{'class'});
		&class_name_get();
		$condition =$class_name;
	}
}

#=============================================================================
if($Super_Great eq 'S'){

$jump =$script.'?'."class=all&amp;keyword=&amp;superkey=1&amp;FF=0&amp;order=$order_encode&amp;pic_only=$in{'pic_only'}";

if($class_all){
	$category .="| <a href=$jump><font class='menu'>$class_all</font></a> | ";
}else{
	$category .="| ";
}

$ctgry_su =1;
$k =0;
$j =$orikaesi[$k];

foreach (@ctgry_tb) {
	$ct_encode =$_;
	$ct_encode  =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;    #ここでエンコード

	$jump =$script.'?'."class=all&amp;keyword=$ct_encode&amp;superkey=1&amp;FF=0&amp;order=$order_encode&amp;pic_only=$in{'pic_only'}";
	$category .=" <a href=$jump><font class='menu'>$_</font></a> |";
	$ctgry_su ++;
	if($ctgry_su eq $j){
			$category .="<br$xslash> |";
			$k ++;
			$j = $j + $orikaesi[$k];
	}
}

$i =0;
foreach (@class_tb) {
	($class_B,$k) = split(/\//,$_);
	$jump =$script.'?'."class=$i&amp;keyword=&amp;superkey=1&amp;FF=0&amp;order=$order_encode&amp;pic_only=$in{'pic_only'}";
	$category .=" <a href=$jump><font class='menu'>$class_B</font></a> |";
	$i ++;
	$ctgry_su ++;
	if($ctgry_su eq $j){
			$category .="<br$xslash> |";
			$k ++;
			$j = $j + $orikaesi[$k];
	}
}

print <<EOF;
<table width="$t_width" bgcolor="$menu_color_C" border='0' cellpadding='0' cellspacing='0'>
<tr><td align="center">
$category
<hr size='1'$xslash></td></tr>
</table>

EOF
}
#=============================================================================

unless($kensaku_express){
print <<"EOF";
<table border='0' cellpadding='0' cellspacing='0' width="$t_width"  bgcolor="$bg_color" class='kensaku_table'><tr>
<td align="left">
<form method='post' action="$script" style='margin: 0px;'>
<input type="text" size='20' name="keyword" value="$pas_word" class='kensaku'$xslash>
<input type='submit' value="商品検索" class='submit' class='submit'$xslash>
<input type="hidden" name="class" value="all"$xslash>
<input type="hidden" name="FF" value='0'$xslash>
<input type="hidden" name="superkey" value="1"$xslash>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
</form>
</td>
<td align="right">

<form method="post" action="$script" style='margin: 0px;'>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="class" value="$in{'class'}"$xslash>
<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
<input type="hidden" name="superkey" value="$in{'superkey'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
<input type="hidden" name="mode" value="look"$xslash>

<table border='0' cellpadding='0' cellspacing='0'><tr><td class='total'><font class="total_text">購入合計額：$all_total01円</font></td><td width='4'></td><td><input type='submit' value="ｶｰﾄを見る" class='submit'$xslash></td></tr>
</table>
</form>
</td></tr></table><br$xslash>
EOF
}elsif($kensaku_express eq '1'){
print <<"EOF";
<table border='0' cellpadding='0' cellspacing='0' width="$t_width"  bgcolor="$bg_color" class='kensaku_table'><tr>
<td align="right">
<table border='0' cellpadding='0' cellspacing='0'>
<tr><td class='total'><font class="total_text">購入合計額：$all_total01円</font></td>$name_in_cart<td width='4'></td>
<td>
<form method="post" action="$script" style='margin: 0px;'>
<input type="hidden" name="order" value="$in{'order'}"$xslash>
<input type="hidden" name="class" value="$in{'class'}"$xslash>
<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
<input type="hidden" name="superkey" value="$in{'superkey'}"$xslash>
<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
<input type="hidden" name="pic_only" value="$in{'pic_only'}"$xslash>
<input type="hidden" name="mode" value="look"$xslash>
<input type='submit' value="ｶｰﾄを見る" class='submit'$xslash>
</form>
</td></tr>
</table>
</td></tr></table><br$xslash>
EOF
}

($a,$b)  =split(/\//,$in{'class'});
&class_name_get();
#==============分類の表示（一覧上部）==============
($sctable_cols,$sctable_color,$sctable_bgcolor,$sctable_big_color,$sctable_selected) = split(/\//,$small_class_g);

if($sctable_cols &&  $in{'class'} ne '' && $in{'class'} ne 'all'){
	
unless(3 <= $sctable_cols && $sctable_cols <= 8){$sctable_cols =5;}
unless($sctable_color){$sctable_color ='#3f4073';}
unless($sctable_bgcolor){$sctable_bgcolor ='#ffffff';}
unless($sctable_big_color){$sctable_big_color ='#ffffff';}
unless($sctable_selected){$sctable_selected ='#3f4073';}

$i =0;
$j =0;
foreach (@class_tb) {
	if($a eq '' || $a eq 'all'){ last;}

	($class_b,$k) = split(/\//,$_);
	if($class_b ne $class_B){$i ++; next;}
	
	if($k eq ''){last;}
	$jump =$script.'?'."class=$i&amp;keyword=&amp;superkey=1&amp;FF=0&amp;order=$order_encode&amp;pic_only=$in{'pic_only'}";
	$class_big = "<a href=\"$jump\"><font color=\"$sctable_big_color\"><b>$class_b</b></font></a>";
	@class_S =split(/:/,$k);
	foreach (@class_S) {
		$jump =$script.'?'."class=$i%2F$j&amp;keyword=&amp;superkey=1&amp;FF=0&amp;order=$order_encode&amp;pic_only=$in{'pic_only'}";

		unless($j eq $b){
			$class_small[$j] = "<a href=\"$jump\">$class_S[$j]</a>";
		}else{
			$class_small[$j] = "<font color=\"$sctable_selected\"><b>$class_S[$j]</b></font>";}
		$j ++;
	}
	last;
}

$sct_cols_width =int(100/$sctable_cols);
$sct_cols_width ="width =\"$sct_cols_width%\"";

if($class_big){
$i =0;
while($i < $sctable_cols-1){
	unless($class_small[$i]){$class_small[$i] ='　';}
	$i ++;
}
print <<"EOF";
<table style="border: 1px solid $sctable_color;margin-bottom:10px" cellpadding='3' cellspacing='0' bgcolor="$sctable_bgcolor" width="$t_width">
<tr>
<td  $sct_cols_width height='20' align='center' bgcolor="$sctable_color">$class_big</td>
<td $sct_cols_width height='20' align='center'>$class_small[0]</td>
<td $sct_cols_width height='20' align='center'>$class_small[1]</td>
EOF
if($sctable_cols > 3){print "<td $sct_cols_width height='20' align='center'>$class_small[2]</td>";}
if($sctable_cols > 4){print "<td $sct_cols_width height='20' align='center'>$class_small[3]</td>";}
if($sctable_cols > 5){print "<td $sct_cols_width height='20' align='center'>$class_small[4]</td>";}
if($sctable_cols > 6){print "<td $sct_cols_width height='20' align='center'>$class_small[5]</td>";}
if($sctable_cols > 7){print "<td $sct_cols_width height='20' align='center'>$class_small[6]</td>";}
print "</tr>";
}

$e= $sctable_cols-1;
while($e < $j){
	
$i =$e;
$f =$e;
$e = $e +$sctable_cols;
if($class_big && $class_small[$f]){
while($i < $e){
	unless($class_small[$i]){$class_small[$i] ='　';}
	$i ++;
}
print <<"EOF";
<tr>
<td $sct_cols_width height='20' align='center'>$class_small[$f]</td>
<td $sct_cols_width height='20' align='center'>$class_small[$f+1]</td>
<td $sct_cols_width height='20' align='center'>$class_small[$f+2]</td>
EOF
if($sctable_cols > 3){print "<td $sct_cols_width height='20' align='center'>$class_small[$f+3]</td>";}
if($sctable_cols > 4){print "<td $sct_cols_width height='20' align='center'>$class_small[$f+4]</td>";}
if($sctable_cols > 5){print "<td $sct_cols_width height='20' align='center'>$class_small[$f+5]</td>";}
if($sctable_cols > 6){print "<td $sct_cols_width height='20' align='center'>$class_small[$f+6]</td>";}
if($sctable_cols > 7){print "<td $sct_cols_width height='20' align='center'>$class_small[$f+7]</td>";}
print "</tr>";
}

}
if($class_big){print "</table>";}

}
#==============分類の詳細説明==============
if($class_setumei == 1 && $a ne '' && $a ne 'all'){
	if($a < 10){
		if($b ne ''){
			$url ="$class_htm_dir/"."$a$b".".htm";
		}else{
			$url ="$class_htm_dir/"."$a".".htm";
		}
	}else{
		if($b ne ''){
			$url ="$class_htm_dir/"."$a".'_'."$b".".htm";
		}else{
			$url ="$class_htm_dir/"."$a".'_'.".htm";
		}
	}

@url_split  =split(/\//,$url);
$u1 =$#url_split - 1;
$u2 =$#url_split;
$url_test ="./"."$url_split[$u1]"."/"."$url_split[$u2]"; #相対アドレス。

if(-e $url_test){
print <<"EOF";
<table cellspacing='0' cellpadding='0' border='0' width="$class_width">
<tr><td align="center" bgcolor="" height="$class_height;">

<iframe src="$url" height="100%"  width="100%"  border="0" frameborder="0" marginheight="0" marginwidth="0" name="sign" scrolling="auto" allowtransparency='true'>
この部分は iframe 対応のブラウザで見てください。
</iframe>

</td></tr>
<tr><td align="center" bgcolor=""><hr size='1' width="$t_width"$xslash>
</td></tr>
</table>
EOF
}

}else{

	if($a < 10){
		if($b ne ''){
			$url ="./set_class_pl/"."$a$b".".pl";
		}else{
			$url ="./set_class_pl/"."$a".".pl";
		}
	}else{
		if($b ne ''){
			$url ="./set_class_pl/"."$a".'_'."$b".".pl";
		}else{
			$url ="./set_class_pl/"."$a".'_'.".pl";
		}
	}
if(-e $url){
require "$url";
print <<"EOF";
$class_html
EOF
}

}
#===================ソート==================
if(1 < $data_su && $data_su <= $sort_upper){	#ソートの条件

if($hatubaibi_sort == 1){
$hatubaibi_set ="<td align='center' style='padding-left: 3px;padding-right: 4px;'><a href=\"$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=0&amp;price_sort=2&amp;pic_only=$in{'pic_only'}\"><font class='link_button'>$aux2_name順</font></a></td>";
}elsif($hatubaibi_sort == 2){
$hatubaibi_set ="<td align='center' style='padding-left: 3px;padding-right: 4px;'><a href=\"$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=0&amp;price_sort=3&amp;pic_only=$in{'pic_only'}\"><font class='link_button'>$aux2_name順</font></a></td>";
}

if($aux5_popular){
$popular_set ="<td align='center' style='padding-left: 3px;padding-right: 0px;'><a href=\"$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=0&amp;price_sort=4&amp;pic_only=$in{'pic_only'}\"><font class='link_button'>人気順</font></a></td>";
}

$kakakuzyunn_set ="<td align='center' style='padding-left: 3px;padding-right: 4px;'><a href=\"$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=0&amp;price_sort=1&amp;pic_only=$in{'pic_only'}\"><font class='link_button'>価格順</font></a></td>";

}
#===========================================
if($in{'pic_only'}){
$only_set ="pic_only=0\"><font class='link_button'>通常表\示</font>";
}else{
$only_set ="pic_only=1\"><font class='link_button'>画像のみ</font>";
}
print <<"EOF";
<table cellspacing='0' cellpadding='0' border='0' width="$t_width" bgcolor="$bg_color" class='kensaku_table2' style="border-bottom:1px solid $color_d;margin-bottom:12px;"><tr>
<td>検索条件[$condition] [$data_su\件]</td>
<td align='right'>
<table cellspacing='0' cellpadding='0' border='0' bgcolor="$bg_color" class='kensaku_table'><tr>
<td align="center" style='padding-left: 3px;padding-right: 4px;'><a href=\"$script?order=$order_encode&amp;class=$class_encode&amp;keyword=$keyword_encode&amp;FF=0&amp;price_sort=$in{'price_sort'}&amp;$only_set</a></td>
$kakakuzyunn_set
$hatubaibi_set
$popular_set
</tr></table>

</td></tr></table>
EOF

	if (!@NEW) {
	print <<"EOF";
	<table border='0' cellspacing='0' cellpadding='5' width="$t_width">
	<tr><td bgcolor="$color_r" align='center'><center>★該当する商品はありません★</center></td></tr>
	</table>
EOF

	}else{
print <<"EOF";
<table cellpadding="0" cellspacing="0" bordercolordark="$naka_color" bordercolorlight="$naka_color" border="0" width="$t_width">
EOF
#========================================================================

		foreach ( @NEW ) {
			($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$_);
$_ =~ s/\r\n//g;

$sale_type_sett='';
if($sale_type){
	($kaitori,$lent)= split(/\//,$sale_type);
	if($aux6){
		$s_type =$lent;
	}else{
		$s_type =$kaitori;
	}
	$sale_type_sett ="<tr><td width=\"100%\" bgcolor=\"$naka_color\">[販売形態] $s_type</td></tr>";
}

@option = split(/\:/,$option);
$i = 0;
$flag_zaiko_non=0;
$flag_non_option ='1';
$option_set = "";
$zaiko_new ='';
while($i < $option_no) {
	($op_k[$i],$op_m[$i],$op_su[$i],$op_pr[$i]) =split(/\,/,$option[$i]);
	if($op_k[$i] eq ''){ $i++; next;}
	$flag_non_option ='0';
	if($op_su[$i] eq ''){ $flag_zaiko_non=1; }
#	if($op_su[$i] eq '0'){$i++; next;}
	if($op_su[$i] > 0){$zaiko_new +=$op_su[$i];}
		$su_ex ='';
		if($op_su[$i] ne '' && $option_su_ex  == 1){ $su_ex ="/$op_su[$i]$option_su_tani";}
		$pr_ex ='';
		if($op_pr[$i] ne ''){$pr_ex ="[\\$op_pr[$i]]";}
		$option_set = $option_set."<option value='$op_k[$i]'>$op_m[$i]$pr_ex$su_ex</option>\n";
	$i++;
}
if($option_set ne ""){
    $option_set = "<select name='op1'>".$option_set."</select>";
}else{
	$option_set ="";
}

if($flag_non_option ne '1'){
	if($zaiko_new eq ''){
		$zaiko =0;
	}else{
		$zaiko =$zaiko_new;
	}
}

@option2 = split(/\:/,$option2);
$i = 0;
$option2_set = "";
while($i < $option2_no) {
	($op2_k[$i],$op2_m[$i],$op2_su[$i]) =split(/\,/,$option2[$i]);
	if($op2_k[$i] eq ""){ $i++; next;}
		$option2_set = $option2_set."<option value='$op2_k[$i]'>$op2_m[$i]</option>\n";
	$i++;
}
if($option2_set ne ""){
    $option2_set = "<br$xslash><select name='op2'>".$option2_set."</select>";
}else{
	$option2_set ="\　";
}

($price,$tax_ch)= split(/\:/,$price);
if($tax_flag eq ''){
	if($tax_ch == 1){
		$tax_set ="$tax_komi";
	}else{
		$tax_set ="$tax_betu";
	}
}elsif($tax_flag eq '0'){
	$tax_set ="$tax_betu";
}elsif($tax_flag eq '1'){
	$tax_set ="$tax_komi";
}elsif($tax_flag eq '2'){
	$tax_set ='';
}
#===========================月次決済の時=========================
if($aux6){
	$tuki ='/月)';
	$tax_set =~ s/\)/$tuki/g;
}
#================================================================
$price_set = $price;
1 while $price_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

$price_set = "$price_set";

($setumei,$setumei2) =split(/\|\|/,$setumei);
$setumei =~ s/\<n\>/\n/g;

$setumei_set ="";
	if($bikou ne ""){
		if($bikou_flag == 1){
			$bikou_set = "<br$xslash>※重量".$bikou.'(グラム)';
		}else{
			$bikou_set = "<br$xslash>※".$bikou;
		}
	}
	$setumei_set ="<font color=\"$fcolor\">$setumei</font>". $bikou_set;

$zaiko_set ='';
if($zaiko_ex == 1){
if($zaiko eq ''){
	$zaiko_set ="";
    $zaiko = 100000;
}elsif($zaiko > 0){
	$zaiko_set ="在庫$zaiko$tani";
}elsif($zaiko <= 0){
	$zaiko =0;
	$zaiko_set ="在庫$zaiko$tani";
}

}else{
if($zaiko eq ''){
    $zaiko = 100000;
}elsif($zaiko <= 0){
	$zaiko =0;
}
}

if($flag_zaiko_non == 1){$zaiko = 100000; $zaiko_set ="";}

#======在庫僅少表示======
if($zaiko_few_n){
	if(0 < $zaiko && $zaiko < $zaiko_few_n){$zaiko_set .=$zaiko_few;}
}
#========================
($limit,$limit2) = split(/\:/,$limit);
if($limit ne ""){
	$tani_set =" $limit$taniまで";
}else{
    $tani_set =$tani;
    $limit =100000;
}
$limit_su =$limit;

$get_setting0 = "<input type='submit' value='購入' class='submit'$xslash>";
if($price == 0 && $free_soft){
		$get_setting0 = "$free_soft";
}elsif($zaiko_stop ne '' && $zaiko <= 0){
	if($limit2 eq '0' || $goods_yoyaku ne '1'){
		$get_setting0 = "$zaiko_stop";
	}else{
		$get_setting0 = "<input type='submit' value='予\約' class='submit'$xslash>";
		if($limit2 ne ""){
			$tani_set ="$limit2$taniまで";
		}else{
		    $tani_set =$tani;
		    $limit2 =100000;
		}
		$limit_su =$limit2;
	}
}

$kosuu_setting = "";
foreach ( @kosuu_set ) {
	if($_ >$limit_su){
		last;
	}else{
		$kosuu_setting .= "<option value=\'$_\'>$_</option>";
	}
}
if($kosuu_setting eq ""){
	$kosuu_setting = "<select name='amount'><option value='0'>−</option></select>$tani_set";
}else{
	$kosuu_setting = "<select name='amount'>$kosuu_setting</select>$tani_set";
}

$word='タイムサービス';
$words='ﾀｲﾑｻｰﾋﾞｽ';
if (index($setumei,$word) >= 0 || index($bikou,$word) >= 0 || index($setumei,$words) >= 0 || index($bikou,$words) >= 0) {
    # タイムゾーンを日本時間に合わせる
	$ENV{'TZ'} = "JST-9";
	$times = time;
	($sec,$min,$hour,$day,$month,$year,$wday,$Days,$dmy) = localtime($times);
	if($service_time[0]  =~ /\//){
		$year = $year + 1900;
		$month = $month +1;
		$time =$year.'/'.$month.'/'.$day;
	}else{
		$time =$hour.':'.$min;
	}
	if(&suutika($time) < &suutika($service_time[0]) || &suutika($service_time[1]) < &suutika($time)){
		$get_setting0 ="[ｻｰﾋﾞｽﾀｲﾑ]".'<br$xslash>'."$service_time[0]-$service_time[1]";
	}
}

($pic1,$pic2,$pic3,$pici,$picj) =split(/\|/,$picture);

if($pici eq ""){
	$pici ="$default_g";
}

$w_setum =$t_width-290;

($a,$b)  =split(/\//,$class);
&class_name_get();

$position ="no"."$goods_no";
$link_pw ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1";
$link_pop ="$modoru_goods&amp;mode=p_wide&amp;id=$goods_no&amp;superkey=1&amp;popup=yes";

$add1_basket ="$modoru_goods&amp;mode=look&amp;g_no=$goods_no&amp;amount=1";

$op_width = $t_width -$imagesize_w -300;

if($get_cago){
	$cago_back ="<input type='hidden' name='mode' value='look'$xslash>";
}

$get_setting =<<"EOF";
	$get_setting0
	<input type='hidden' name='g_no' value="$goods_no"$xslash>
	<input type="hidden" name="class" value="$in{'class'}"$xslash>
	<input type="hidden" name="FF" value="$in{'FF'}"$xslash>
	<input type="hidden" name="order" value="$in{'order'}"$xslash>
	<input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
	<input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
	$cago_back
EOF

#============================
	($pici,$w_h_set) =&pic_convert($imagesize_w,$imagesize_h,$pici,$convert_none);

	if($popup_yes){
		$popup_set ="<a href=\"$link_pw\"><img src=\"$pici\" border='0' align=\"middle\" alt=\"$name [$kigou]\" $w_h_set$xslash></a>";
	}else{
		$popup_set ="<img src=\"$pici\" border='0' align=\"middle\" alt=\"$name [$kigou]\" $w_h_set$xslash>";
	}

#============================

$aux1_set =$aux1;
if(($aux1_name eq '会員価格' || $aux1_name eq '特別会員') && $aux1 ne ''){
	if($mem_price_ex && !($id_pass_C ne '' || $id_pass2_C ne '')){
		$aux1_set ="$mem_price_ex";
	}else{
1 while $aux1_set =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理
		$aux1_set = "<font color='#ff0000'>\\$aux1_set</font>$tax_set";
	}
}

$aux1_comma =$aux1;
1 while $aux1_comma =~ s/(.*\d)(\d\d\d)/$1,$2/g; #桁カンマを入れる処理

$goods_tb =$goods_table;
$goods_tb =~ s/\<br\>//g;

$goods_tb =~ s/\$goods_no/$goods_no/g;
$goods_tb =~ s/\$setumei_set/$setumei_set/g;
$goods_tb =~ s/\$setumei/$setumei/g;
$goods_tb =~ s/\$bikou/$bikou/g;

$goods_tb =~ s/\$name/$name/g;
$goods_tb =~ s/\$kigou/$kigou/g;
$goods_tb =~ s/\$class_name/$class_name/g;
$goods_tb =~ s/\$price_set/$price_set/g;
$goods_tb =~ s/\$tax_set/$tax_set/g;

$goods_tb =~ s/\$option_set/$option_set/g;
$goods_tb =~ s/\$option2_set/$option2_set/g;

$goods_tb =~ s/\$pici/$pici/g;
$goods_tb =~ s/\$link_pop/$link_pop/g;
$goods_tb =~ s/\$link_pw/$link_pw/g;
$goods_tb =~ s/\$picture_set/$popup_set/g;

$goods_tb =~ s/\$get_setting/$get_setting/g;
$goods_tb =~ s/\$zaiko_set/$zaiko_set/g;
$goods_tb =~ s/\$kosuu_setting/$kosuu_setting/g;

$goods_tb =~ s/\$aux1_comma/$aux1_comma/g;
$goods_tb =~ s/\$aux1_set/$aux1_set/g;
$goods_tb =~ s/\$aux1/$aux1/g;
$goods_tb =~ s/\$aux2/$aux2/g;
$goods_tb =~ s/\$aux3/$aux3/g;
$goods_tb =~ s/\$aux4/$aux4/g;
$goods_tb =~ s/\$aux5/$aux5/g;
$goods_tb =~ s/\$aux6/$aux6/g;
$goods_tb =~ s/\$s_type/$s_type/g;
$goods_tb =~ s/\$aux7/$aux7/g;
$goods_tb =~ s/\$free1/$free1/g;
$goods_tb =~ s/\$free2/$free2/g;
$goods_tb =~ s/\$free3/$free3/g;
$goods_tb =~ s/\$free4/$free4/g;
$goods_tb =~ s/\$free5/$free5/g;

$goods_tb =~ s/\$add1_basket/$add1_basket/g;

$aux_sett ='';

if($regular_col >= 2){
	if($aux2 && $aux2_name){$aux_sett .="<tr><td width=\"100%\" bgcolor=\"$naka_color\">[$aux2_name] $aux2</td></tr>";}
	if($free1 && $free1_name){$aux_sett .="<tr><td width=\"100%\" bgcolor=\"$naka_color\">[$free1_name] $free1</td></tr>";}
	if($free2 && $free2_name){$aux_sett .="<tr><td width=\"100%\" bgcolor=\"$naka_color\">[$free2_name] $free2</td></tr>";}
	if($free3 && $free3_name){$aux_sett .="<tr><td width=\"100%\" bgcolor=\"$naka_color\">[$free3_name] $free3</td></tr>";}
	if($aux1 ne '' && $aux1_name){$aux_sett .="<tr><td width=\"100%\" bgcolor=\"$naka_color\">[$aux1_name] $aux1_set</td></tr>";}

}else{
$row_setting =5;

if($aux2 && $aux2_name){
$aux_sett =<<"EOF";
    <tr>
      <td align="center" height="10" bgcolor="$midasi_color"width="60" style="border:1px solid $waku_color;">分\　類</td>
      <td align="left" height="10" bgcolor="$naka_color" width="170" style="border:1px solid $waku_color;">$class_name</td>
      <td align="center" height="10" bgcolor="$midasi_color"width="60" style="border:1px solid $waku_color;">$aux2_name</td>
      <td align="left" height="10" bgcolor="$naka_color" width="110" style="border:1px solid $waku_color;">$aux2</td>
    </tr>
EOF

}else{
$aux_sett =<<"EOF";
    <tr>
      <td align="center" height="10" bgcolor="$midasi_color"width="60" style="border:1px solid $waku_color;">分\　類</td>
      <td colspan='3' align="left" height="10" bgcolor="$naka_color" width="340" style="border:1px solid $waku_color;">$class_name</td>
    </tr>
EOF

}

if($aux1 ne '' && $aux1_name){
$aux_sett .=<<"EOF";
    <tr>
      <td bgcolor="$midasi_color" width="60" height="10" valign="middle" align="center" style="border:1px solid $waku_color;">価\　格</td>
      <td bgcolor="$naka_color" width="170" height="10" align="left" valign="middle" style="border:1px solid $waku_color;">\\$price_set$tax_set</td>
      <td bgcolor="$midasi_color" width="60" height="10" valign="middle" align="center" style="border:1px solid $waku_color;">$aux1_name</td>
      <td bgcolor="$naka_color" width="110" height="10" align="left" valign="middle" style="border:1px solid $waku_color;">$aux1_set</td>
    </tr>
EOF

}else{
$aux_sett .=<<"EOF";
    <tr>
      <td bgcolor="$midasi_color" width="60" height="10" valign="middle" align="center" style="border:1px solid $waku_color;">価\　格</td>
      <td colspan='3' bgcolor="$naka_color" width="340" height="10" align="left" valign="middle" style="border:1px solid $waku_color;">\\$price_set$tax_set</td>
    </tr>
EOF
}

if($sale_type){
	($kaitori,$lent)= split(/\//,$sale_type);
	if($aux6){
		$s_type =$lent;
	}else{
		$s_type =$kaitori;
	}
$aux_sett .=<<"EOF";
    <tr>
      <td bgcolor="$midasi_color" width="60" height="10" valign="middle" align="center" style="border:1px solid $waku_color;">販売形態</td>
      <td colspan='3' bgcolor="$naka_color" width="340" height="10" align="left" valign="middle" style="border:1px solid $waku_color;">$s_type</td>
    </tr>
EOF
$row_setting =6;
}

}
#=======================================複数列表示==========================================
$Col_NO++;

if($in{'pic_only'}){
$row_data .=<<"EOF";
<td valign='bottom'>

<table cellpadding="2" cellspacing="1" border="0" width="$pic_col_width" style="margin-bottom:5px;">
    <tr><td align='center' valign='middle'>$popup_set</td></tr>
    <tr><td align='center'><h2><strong>$name</strong></h2></td></tr>
    <tr><td align='center'>\\$price_set$tax_set</td></tr>
</table>

</td>
EOF
}elsif($regular_col >= 2){

$row_data .="<td valign='top'>";

if($customize eq 1){
$row_data .=<<"EOF";
$goods_tb
EOF

}else{
$row_data .=<<"EOF";
<table cellpadding="3" cellspacing="0" width="$regular_col_width" style="border:1px solid $waku_color;margin-bottom:10px;border-collapse: collapse">
    <tr>
      <td width="100%" valign='top' align='center' bgcolor="$midasi_color" colspan='2'><div align="left"><h2><strong>$name [$kigou]</strong></h2></div>
      </td></tr>
    <tr>
      <td valign='top' align='center' bgcolor="$naka_color" width="40%"><br$xslash>$popup_set<br$xslash>
      </td><form action="$script" method="post">
      <td valign="top" bgcolor="$naka_color" width="60%">
      <table cellspacing='0' cellpadding='3' width="100%" border='0'>
        $aux_sett
          <tr>
            <td width="100%" bgcolor="$naka_color">[価格] \\$price_set$tax_set</td>
$sale_type_sett          
</tr></table>
	<input type='hidden' name='g_no' value="$goods_no"$xslash>
    <input type="hidden" name="class" value="$in{'class'}"$xslash>
    <input type="hidden" name="FF" value="$in{'FF'}"$xslash>
    <input type="hidden" name="order" value="$in{'order'}"$xslash>
    <input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
    <input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
$cago_back
         <table cellspacing='0' cellpadding='3' border='0' width="100%">
          <tr>
            <td valign='top' align="left" width="150">$option_set$option2_set</td></tr>
            <tr><td>$zaiko_set$kosuu_setting</td></tr><tr><td>$get_setting0</td>
          </tr><tr><td>$setumei_set<br$xslash></td></tr>
      </table>
      </td>
    </tr></form>
</table>
EOF
}
	$row_data .='</td>';
	
}else{
$row_data .="<td valign='top'>";

if($customize eq 1){

$row_data .=<<"EOF";
$goods_tb
EOF

}else{
$row_data .=<<"EOF";
<table cellpadding="3" cellspacing="0" width="$t_width" style="border:1px solid $waku_color;margin-bottom:10px;border-collapse: collapse">
    <tr>
      <td rowspan="$row_setting" bgcolor="$midasi_color" align="center"width="160" style="border:1px solid $waku_color;">$popup_set</td>
      <td bgcolor="$midasi_color" align="center" width="60" style="border:1px solid $waku_color;">名\　称</td>
      <td bgcolor="$naka_color" align="left" height="10" width="170" style="border:1px solid $waku_color;"><h2><strong>$name</strong></h2></td>
      <td bgcolor="$midasi_color" width="60" height="10" valign="middle" align="center" style="border:1px solid $waku_color;">記\　号</td>
      <td bgcolor="$naka_color" width="110" height="10" align="left" valign="middle" style="border:1px solid $waku_color;">$kigou</td>
    </tr>
$aux3_4_set
$aux_sett
    <tr>
      <td colspan="4" bgcolor="$naka_color" valign="top" height="40" style="border:1px solid $waku_color;">      <table border='0' cellpadding='0' cellspacing='0' align="right"><tr><td valign="top"><a href="$link_pw"><font class='link_color'>詳細説明</font></a></td></tr></table>
      $setumei_set
      </td>
    </tr>
    <tr>
      <td bgcolor="$midasi_color" colspan="4" align="left" valign="bottom" height="20">
      <table bgcolor="$midasi_color">
          <tr>
            <td valign="top" bgcolor="$midasi_color" width="$op_width">
            <form action="$script" method="post">$option_set\　 $option2_set
            </td>
            <td align="right" valign="bottom" width="270">
            $zaiko_set\　 $kosuu_setting\　 $get_setting0
$cago_back
	<input type='hidden' name='g_no' value="$goods_no"$xslash>
    <input type="hidden" name="class" value="$in{'class'}"$xslash>
    <input type="hidden" name="FF" value="$in{'FF'}"$xslash>
    <input type="hidden" name="order" value="$in{'order'}"$xslash>
    <input type="hidden" name="keyword" value="$in{'keyword'}"$xslash>
    <input type="hidden" name="price_sort" value="$in{'price_sort'}"$xslash>
            </td>
          </tr>
      </table>
      </td>
    </tr></form>
</table>
EOF
}
	$row_data .='</td>';
}

if($in{'pic_only'}){
	if($Col_NO< $pic_col){ next;}
}else{
	if($Col_NO< $regular_col){ next;}
}

print "<tr>$row_data</tr>";
$Col_NO=0;
$row_data ='';
}

}
if ( @NEW ) {

unless($Col_NO){print "</table>";}

while($Col_NO){
$Col_NO++;

if($in{'pic_only'}){
$row_data .=<<"EOF";
<td valign='top'>

<table cellpadding="2" cellspacing="0" border="0" width="$pic_col_width" style="margin-bottom:5px;">
    <tr><td valign='top' align='center'>\　</td></tr>
</table>

</td>
EOF
}else{


$row_data .=<<"EOF";
<td valign='top'>
<table cellpadding="3" cellspacing="0" border="0" width="$regular_col_width" style="margin-bottom:5px;">
    <tr>
      <td width="100%" valign='top' align='center' bgcolor="">\　<td valign='top' bgcolor=""></td>
    </tr>
</table>
</td>
EOF
}
if($in{'pic_only'}){
	if($Col_NO < $pic_col){  next;}
}else{
	if($Col_NO< $regular_col){  next;}
}
print "<tr>$row_data</tr></table>";
$Col_NO=0;

}

}

print <<"EOF";
<img height="1" src="$dir_p/line.gif" width="$t_width" border='0' style='margin-top:2px;margin-bottom:2px;' alt=''$xslash>
EOF

#====================================================================================

$buf ="class=".$class_encode;
$buf2 ="order=".$order_encode;
$buf3 ="keyword=".$keyword_encode."&amp;pic_only=$in{'pic_only'}";

#=============ページ数計算=======================
if($page_view){
if($data_su > $page){

	$j =$ff_no - $page*$page_view;
	if($j < 0){$j =0;}
	$i =int($j/$page) + 1;
	$k =$ff_no + $page*($page_view + 1);
	if($k >= $data_su){
		$k =$data_su;
	}else{
		$dotto ='.....';
	}

	while ($j < $k){
		if($j ne $ff_no ){
			$jump_set .="<a href=\"$script?$buf&amp;$buf2&amp;$buf3&amp;FF=$j&amp;price_sort=$in{'price_sort'}\"><span class='page'>$i</span></a>";
		}else{
			$jump_set .="<span class='page' style='text-decoration:none;font-weight:bold;'>$i</span>";
		}
		$i ++;
		$j = $j + $page; 
	}
	$jump_set .=$dotto;
}
}
#=================================================

        $nextlink = "";
		if ($next_num ne '') {
			$nextlink = "<a href=\"$script?$buf&amp;$buf2&amp;$buf3&amp;FF=$next_num&amp;price_sort=$in{'price_sort'}\"><span class='page'>次の$over_no件</span></a>";
		}
		
		$backlink = "";
		$back_num = $ff_no -$page;
		if($back_num >=0) {
			$backlink = "<a href=\"$script?$buf&amp;$buf2&amp;$buf3&amp;FF=$back_num&amp;price_sort=$in{'price_sort'}\"><span class='page'>前の$page件</span></a>";
		}

if($nextlink ne '' || $backlink ne ''){
if($page_view){
	   	print "<center><table width=\"$o_width\"><tr><td align='center'>$backlink\　 $jump_set\　 $nextlink</td></tr></table></center>\n";
}else{
	   	print "<center><table width=\"$o_width\"><tr><td align='center'>$backlink\　\　 $nextlink</td></tr></table></center>\n";
}
}

	print <<"EOF";
	<center><table border="0" width="$t_width"><tr>
	<td align="left" width="$t_width">※画像又は詳細説明をクリックすると拡大図及詳細説明を見ることができます。</td></tr>
	</table>
	</center>
EOF

	print "<br$xslash>$foot</body></html>" ;	
	
}

#=========================================================================================
sub keisan {
$data_no =0;
$all_total = 0;
$all_total0 =0;
$all_total1 =0;
@souryou_tb = ();
$size_A ='0';
$syuryou_total =0;

$tiikiNO=@souhusaki;
if($tiikiNO < 1){
	$tiikiNO =1;
}

@order_1 = split(/!/,$order);
foreach (@order_1) {
	($s,$t) = split(/:/,$_);
	($a,$b,$c) = split(/\,/,$s);
	($t,$book) = split(/\,/,$t);
    $flag =0;

	foreach ( @BASE ) {
		$_ =~ s/\n//g;

		($goods_no,$name,$kigou,$option,$option2,$class,$setumei,$fcolor,$price,$tani,$zaiko,$limit,$picture,$bikou,$aux1,$aux2,$aux3,$aux4,$aux5,$aux6,$aux7,$free1,$free2,$free3,$free4,$free5) = split(/\<\>/,$_);

		if($a == $goods_no){
			$flag=1;
			last;
		}
	}

#エラーチェック==================================================
if($flag  == 0){
	print &setCookie_0('ORDER', '');
	&error("NO.$aの商品情報が削除されています。",'商品画面で確認してください。');
}

if($t eq '' ){$t = 0;}

($price,$tax_ch)= split(/\:/,$price);
if($tax_flag eq ''){
	if($tax_ch == 1){
		$tax_set =$tax_komi;
	}else{
		$tax_set =$tax_betu;
	}
}elsif($tax_flag eq '0'){
	$tax_set =$tax_betu;
}elsif($tax_flag eq '1'){
	$tax_set =$tax_komi;
}elsif($tax_flag eq '2'){
	$tax_set ='';
}
#===========================月次決済の時=========================
if($aux6){
	$st_code2 =$st_code2_6;			#月時決済コード

	$order =$s.':'.'1';
	$in{'order'} =$s.':'.'1';
	$t =1;

	$data_no =0;
	$all_total = 0;
	$all_total0 =0;
	$all_total1 =0;
	@souryou_tb = ();
	$size_A ='0';
	$syuryou_total =0;

	$order_tyousei1 ='';
	$order_tyousei2 ='';
	
	$tuki ='/月)';
	$tax_set =~ s/\)/$tuki/g;
	
	$credit_able =1;	#イプシロンのクレジット決済でのみ有効
	$credit_epsilon =2;
	$bank_able =0;
	$e_bank_able =0;
	$hurikae_able =0;
	$daibiki_able =0;
	$collect_able =0;
	$kuroneko_able =0;
	$conveni_able =0;
}
#================================================================

@opt = split(/\:/,$option);
if($b eq ''){
	$i = 0;
	$flag=1;
	while($i < $option_no) {
		($op_k[$i],$op_m[$i],$op_su[$i]) =split(/\,/,$opt[$i]);
		if($op_k[$i] ne ''){$flag =0; last;}
		$i++;
	}
}else{
	$i = 0;
	$flag =0;
	while($i < $option_no) {
		($op_k[$i],$op_m[$i],$op_su[$i],$op_pr[$i]) =split(/\,/,$opt[$i]);
		if($op_k[$i] eq $b){$flag =2;last;}
		$i++;
	}
}


if($flag  == 0){
	print &setCookie_0('ORDER', '');
	&error("NO.$aの商品情報が変更されています。",'商品画面で確認してください。');
}


#=====================会員価格＆オプション価格===============
if(($member_system == 1 && $aux1_name eq '会員価格') && ($id_pass_C ne '' || $id_pass2_C ne '')){
	if($aux1){$price = $aux1;}
}elsif(($member_system == 1 && $aux1_name eq '特別会員') && ($special_member_C ne '' || $special_member2_C ne '')){
	if($aux1 ne ''){$price = $aux1;}
}

if($flag == 2){

	if($op_pr[$i] !~ /[^0-9]/ && $op_pr[$i] ne ''){$price =$op_pr[$i];}
	if($op_pr[$i] =~ /[+-]/){$price = $price + $op_pr[$i];}

}

#===========================================================
($limit,$limit2) = split(/\:/,$limit);

$t1 =0;
$t2 =0;
if($in{'mode'} eq 'look'){
if($book ne 'b'){
#=================
if($b ne ''){
	if($op_su[$i] ne '' && $t > $op_su[$i]){
		$t2 = $t - $op_su[$i];
		$t = $op_su[$i];
		$zaiko_mess .="<li>$name/$op_m[$i]（$kigou-$op_k[$i]）</li>";
	}
}elsif($zaiko ne '' && $t > $zaiko){
		$t2 = $t - $zaiko;
		$t = $zaiko;
		$zaiko_mess .="<li>$name ($kigou）</li>";
}
if($limit ne '' && $t > $limit){
	$t2 = $t - $limit;
	$t = $limit;
	$zaiko_mess .="<li>$name（$kigou）</li>";
}
#======
if($order_tyousei1 eq ''){
	if($t){
		$order_tyousei1 = "$a,$b,$c:$t";
	}
}else{
	if($t){
		$order_tyousei1 .= "!$a,$b,$c:$t";
	}
}

if($goods_yoyaku){		#予\約可能商品
	if($limit2 ne ''){
		if($t2 > $limit2){ $t2 = $limit2;}
	}
	if($order_tyousei2 eq ''){
		if($t2){
			$order_tyousei2 = "$a,$b,$c:$t2,b";
		}
	}else{
		if($t2){
				if($order_tyousei2 eq ''){
				$order_tyousei2 = "$a,$b,$c:$t2,b";
			}else{
				$order_tyousei2 .= "!$a,$b,$c:$t2,b";
			}
		}
	}
}else{
	$t2 =0;
}
#=========
}else{
	$t2 =$t;
	$t =0;
	if($limit2 ne ''){
		if($t2 > $limit2){ $t2 = $limit2;}
	}
	if($order_tyousei2 ne ''){

		$r = "$a,$b,$c";
		$k =0;
		@order_b = split(/!/,$order_tyousei2);
		foreach (@order_b) {
			($p,$q) = split(/:/,$_);
			($j,$book2) = split(/\,/,$q);
			if($book2 ne 'b'){next;}
			if($p eq $r){
				$t2 = $t2 + $j;
				
				if($limit2 ne ''){
					if($t2 > $limit2){ $t2 = $limit2;}
				}
				
				if($order_3 eq ""){
					$order_3 =$p.":"."$t2,$book2";
				}else{
			    	$order_3 .="!".$p.":"."$t2,$book2";
			    }
			    $k =1;
			}else{
				if($order_3 eq ""){
					$order_3 =$_;
				}else{
			    	$order_3 .="!".$_;
				}
			}
		}

		if($k ne 1){
			$order_tyousei2 .= "!$a,$b,$c:$t2,b";
		}else{
			$order_tyousei2 =$order_3;
	   	}
	}else{
		$order_tyousei2 = "$a,$b,$c:$t2,b";
	}
}
}else{
if($book eq 'b'){
	$t2 =$t;
	$t =0;
}
}
#======

@opt = split(/\:/,$option2);
if($c eq ''){
	$i = 0;
	$flag=1;
	while($i < $option2_no) {
		($op_k[$i],$op_m[$i]) =split(/\,/,$opt[$i]);
		if($op_k[$i] ne ''){$flag =0; last;}
		$i++;
	}
}else{
	$i = 0;
	$flag =0;
	while($i < $option2_no) {
		($op_k[$i],$op_m[$i]) =split(/\,/,$opt[$i]);
		if($op_k[$i] eq $c){$flag=1;last;}
		$i++;
	}
}

if($flag  == 0){
	print &setCookie_0('ORDER', '');
	&error("NO.$aの商品情報が変更されています。",'商品画面で確認してください。');
}

#============送料計算
$t_t2 = $t + $t2;			#購入と予約の合計数で送料を計算する。

if($bikou_flag ne 1){		#送料サイズ

$sizeno = 1;		#サイズＡはスキップ
$size_flag = '0';
while ($sizeno < @size_tb) {

	if(index($bikou,$size_tb[$sizeno]) >= 0){
		$tiiki =0;
		@s_tb = split(/:/,$souryou[$sizeno]);
		while ($tiiki < $tiikiNO) {
			$souryou_tb[$tiiki] =$souryou_tb[$tiiki] + $s_tb[$tiiki] * $t_t2;
            $tiiki ++;
        }
        $size_flag = '1';
		last;
	}
    $sizeno ++;
}
if($size_flag eq '0'){
	$size_A = '1';
}

}elsif($bikou_flag == 1){
	$syuryou_total =$syuryou_total + $bikou * $t_t2;
}

	$k_aux3{"$s"} = $aux3;
	$k_aux4{"$s"} = $aux4;
	
	$k_zaiko{"$s"} = $zaiko;
	$k_limit{"$s"} = $limit;

	$k_no{"$s"} = $a;
	$k_id{"$s"} = $kigou;
	$k_name{"$s"} = $name;
	$k_option{"$s"} = $option;
	$k_option2{"$s"} = $option2;
	$k_bikou{"$s"} = $bikou;
	$k_price{"$s"} = $price;
	$k_price_set{"$s"} = $price;
	$k_tax{"$s"} = $tax_set;

	$k_tani{"$s"} = $tani;
	$k_picture{"$s"} = $picture;

#=============カートの中=============
	$name_in_cart .="<td class='total'>$name($t_t2)</td>";
#====================================

if($t){
	$k_amount{"$s"} = $t;
	$k_total{"$s"} = $t*$price;
if($tax_flag eq '' && $tax_ch == 1 || $tax_flag eq '1' || $tax_flag eq '2'){
	$all_total1 = $k_total{"$s"} + $all_total1;
}else{
	$all_total0 = $k_total{"$s"} + $all_total0;
}
	$all_no = $data_no;
	$data_no++;

}
if($t2){	
	$k_amount_b{"$s"} = $t2;
	$k_total_b{"$s"} = $t2*$price;
if($tax_flag eq '' && $tax_ch == 1 || $tax_flag eq '1' || $tax_flag eq '2'){
	$all_total1 = $k_total_b{"$s"} + $all_total1;
}else{
	$all_total0 = $k_total_b{"$s"} + $all_total0;
}
	$all_no = $data_no;
	$data_no++;
}
#=======

if($aux6){last;}		#月次決済

}	#ループ終了

$tax0 = int($all_total0 * $syouhi_tax);
$tax_total0 =$tax0 + $all_total0;
$all_total01 =$all_total0 +$all_total1;
$all_total =$tax_total0 +$all_total1;

#===========送料==============
if($bikou_flag ne 1){
	$tiiki =0;
	if($size_A eq '1'){
		@s_tb = split(/:/,$souryou[0]);
		while ($tiiki < $tiikiNO) {
			$souryou_tb[$tiiki] =$souryou_tb[$tiiki] + $s_tb[$tiiki];
			$tiiki ++;
		}
	}

}elsif($bikou_flag == 1){
	$i =0;
	foreach( @size_tb_g ){
		if($syuryou_total < $_){ last; }
	    $i ++;
	}
	@souryou_tb = split(/:/,$souryou[$i]);
}

#========
if($in{'mode'} eq 'look'){
	if($order_tyousei1 ne '' && $order_tyousei2 ne ''){
		$order =$order_tyousei1.'!'.$order_tyousei2;
	}elsif($order_tyousei1){
		$order =$order_tyousei1;
	}else{
		$order =$order_tyousei2;
	}
	
#	unless($goods_yoyaku){$order =$order_tyousei1;}		#予\約機能なし
	
	$in{'order'} =$order;

	$order_encode =$in{'order'};
	$order_encode =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;    #ここでエンコード


}
#========
	#クッキーの設定
	print &setCookie_0("ORDER", $order);

}

# =======================================================================================
sub adm1 {

if($adm_pass eq "1234"){
	$dis_closure = "<br$xslash>[パスワード = 1234]<br$xslash>";
}

&html_header();

print <<"EOF";
<table width="$o_width" align='center' cellpadding='0' border='0'>
<tr><td>
<div align="right"><a href="$modoru_goods"><font class='link_button'>戻る</font></a></div><hr width="$o_width" size='1'$xslash>
<br$xslash><br$xslash></td></tr></table>
<table bgcolor="$color_adm_r" width='65%' align='center' cellpadding='10' border='1' bordercolor="$color_adm_d">
<tr><td><center>
<form method='post' action="$script">
<input type='hidden' name='class' value="all"$xslash>
<input type='hidden' name='FF' value='0'$xslash>
<input type='hidden' name="keyword" value=""$xslash>
<input type="hidden" name="superkey" value="1"$xslash><br$xslash>
管理者用パスワードを入力してください。<br$xslash><br$xslash>
<input type='password' name='pass'$xslash>
<input type='hidden' name="mode" value="adm_menu"$xslash>
<input type='submit' value='認証' class='submit'$xslash>$dis_closure<br$xslash>
</form></center></td></tr></table>
<br$xslash>
<hr width="$o_width" size='1'$xslash>
$foot
</body></html>
EOF

}

# =======================================================================================
sub adm_menu {
if($in{'pass'} eq ''){
#	$in{'pass'} = $COOKIE{'PASS'};
}

if ( $in{'pass'} ne $adm_pass ) { print "Location: $script?mode=adm1\n\n"; exit; }

#print &setCookie_0('PASS', $adm_pass);

&html_header();

print <<"EOF";
<table width="$o_width" align='center' cellpadding='0' border='0'>
<tr><td>
<div align="right"><a href="$modoru_goods"><font class='link_button'>戻る</font></a></div><hr width="$o_width" size='1'$xslash>
<br$xslash><br$xslash></td></tr></table>
<table bgcolor="$color_adm_r" width='75%' align='center' cellpadding='10' border='1' bordercolor="$color_adm_d">
<tr><td align='center'><br$xslash>
<b>◆管理メニュー◆</b><br$xslash>
<br$xslash>
<table cellpadding='10'>
<tr><td bgcolor="#ffff88" align='left'><a href="./setup.cgi?mode=contents&amp;pass=$in{'pass'}"><font class='link_color'>■システム設定\　 Set-Up Manager</font></a><br$xslash>
      <ul>
        <li><a href="$script_u?mode=title&amp;pass=$in{'pass'}"><font class='link_color'>タイトル画像のＵＰロード(PC用Xタイプ)</font></a></li>
  <li><a href="$script_u?mode=title_G&amp;pass=$in{'pass'}"><font class='link_color'>タイトル背景画像のＵＰロード(PC用G/Cタイプ)</font></a></li>
  <li><a href="$script_u?mode=mainpic&amp;pass=$in{'pass'}"><font class='link_color'>メイン画像のＵＰロード(PC用)</font></a></li>
        <li><a href="$script_u?mode=ktitle&amp;pass=$in{'pass'}"><font class='link_color'>タイトル画像のＵＰロード(携帯gif)</font></a></li>
        <li><a href="$script_u?mode=jtitle&amp;pass=$in{'pass'}"><font class='link_color'>タイトル画像のＵＰロード(携帯png)</font></a></li>
        <li><a href="$script_u?mode=movie&amp;pass=$in{'pass'}"><font class='link_color'>ＴＯＰ動画のＵＰロード(携帯3gp,3g2,amc,jpg)</font></a></li>
        <li><a href="$script_u?mode=class&amp;pass=$in{'pass'}"><font class='link_color'>分類説明HTMLのＵＰロード</font></a></li>
      </ul></td></tr>
EOF

if($member_system ne 0){
print <<"EOF";
<tr><td bgcolor="#cef0ff" align='left'><a href="$script_m?pass=$in{'pass'}"><font class='link_color'>■会員管理\　 Members Manager</font></a><br$xslash>
      <ul>
        <li><a href="$script_m?mode=mail&amp;pass=$in{'pass'}"><font class='link_color'>メールマガジン一括送信(PC用)</font></a></li>
        <li><a href="$script_m?mode=mail_k&amp;pass=$in{'pass'}"><font class='link_color'>メールマガジン一括送信(携帯用)</font></a></li>
      </ul></td></tr>
EOF
}
print <<"EOF";
 <tr><td bgcolor="#ffebdf" align='left'><a href="$script_s?&amp;pass=$in{'pass'}&amp;check0=on&amp;check1=on&amp;check2=on&amp;check3=on&amp;check4=on"><font class='link_color'>■販売管理\　 Sale Manager</font></a><br$xslash><br$xslash>
       <ul>
        <li><a href="$script_pay?pass=$in{'pass'}"><font class='link_color'>イプシロン決済管理\　 Payment Manager</font></a></li>
      <li><a href="$epsilon3_cgi_url" target='_blank'><font class='link_color'>入金状況のお問合せ</font></a></li>
      </ul></td></tr>
      <tr><td bgcolor="#ffccff" align='left'><font class='link_color'>■商品管理\　 Goods Manager</font><br$xslash>
      <ul>
        <li><a href="$script_g?mode=adm3&amp;pass=$in{'pass'}"><font class='link_color'>更新/削除</font></a></li>
        <li><a href="$script_g?mode=adm2&amp;pass=$in{'pass'}"><font class='link_color'>商品追加</font></a></li>
        <li><a href="$script_g?mode=adm5&amp;pass=$in{'pass'}"><font class='link_color'>CSVデータから商品データファイルを新規作成</font></a></li>
        <li><a href="$script_g?mode=adm5a&amp;pass=$in{'pass'}"><font class='link_color'>CSVデータから商品データファイルにデータ追加</font></a></li>
        <li><a href="$script_g?mode=adm8&amp;pass=$in{'pass'}"><font class='link_color'>商品データファイルからCSVファイルを作成</font></a></li>
      </ul>
      <ul>
        <li><a href="$script_u?mode=csv&amp;pass=$in{'pass'}"><font class='link_color'>商品ＣＳＶファイルのＵＰロード</font></a></li>
      </ul>
</td></tr>
EOF

if(-e './ror_sitemap.cgi'){
print <<"EOF";
<tr><td bgcolor="#99ff99" align='left'>
■ユーティリティー
<ul>
<li><a href="./ror_sitemap.cgi?mode=make_ok&amp;pass=$in{'pass'}"><font class='link_color'>RORサイトマップ生成</font></a></li>
</ul>
</td></tr>
EOF
}

if(-e './html_maker.cgi'){
print <<"EOF";
<tr><td bgcolor="#99ff99" align='left'>
<ul>
<li><a href="./html_maker.cgi?mode=make_ok&amp;pass=$in{'pass'}"><font class='link_color'>HTML生成\　 HTML_MAKER</font></a></li>
</ul>
</td></tr>
EOF
}

if($affiliate_use){
print <<"EOF";
<tr><td bgcolor="#ffcf6a" align='left'><a href="./affiliate/aff_adm.cgi?pass=$in{'pass'}"><font class='link_color'>■アフィリエイトプログラムの管理</font></a><br$xslash>
      <ul>
        <li><a href="./affiliate/aff_adm.cgi?mode=mail&amp;pass=$in{'pass'}"><font class='link_color'>メールマガジン一括送信(PC用)</font></a></li>
      </ul>
</td></tr>
EOF
}

print <<"EOF";
</table><br$xslash>
</td></tr>
</table>
<br$xslash>
<hr width="$o_width" size='1'$xslash>
$foot
</body></html>
EOF

}
#===============================問合せ=================================
sub ask_put{

&html_header();

print <<"EOF";
<center>
<table width="$o_width" cellspacing='1' cellpadding='0' border='0' bgcolor="$color_adm_d">
<tr><td width="$o_width">

<table cellspacing="0" cellpadding="4" width="$o_width" bgcolor="$color_adm_d" border="0">
<tr><td align="left" bgcolor="$color_adm_d" width="$o_width"><font color='#ffffff'><b>お問合せ方法</b></font>
</td></tr>
</table>

<table cellspacing='0' cellpadding='0' border='0'>
<tr><td align="left" width="$o_width">
<table width="$o_width" cellpadding='7' bgcolor='#ffffff'>
<tr><td width="$o_width">
<div align="left">$ask_mess
<ul class='list_style'>
<li style='margin-bottom:7px;'>メール ： <a href="mailto:$ask_mail?subject=お問合せ"><font class='link_color'>$ask_mail</font></a>
<li>会員の方はこちらからどうぞ ⇒ <a href="./entry.cgi?mode=info0&order=$order_encode" target="_parent"><font class='link_color'>会員窓口</font></a>
</ul>
</div>
</td></tr>
</table>
</td></tr>
</table>

</td></tr>
</table>
</center>
EOF

print "$foot</body></html>" ;	

}
#===============================特定商取引法による表示===================
sub law_put{

$i =0;
while($i <= 27){
unless($law[$i]){$i++;$i++;next;}

$law_express .=<<"EOF";
<tr>
<td width="23%" bgcolor="$color_adm_r" align='center'>
$law[$i]
</td>
<td valign='top' width="77%" bgcolor='#ffffff'>
$law[$i+1]
</td>
</tr>
EOF

$i++;
$i++;
}

&html_header();

print <<"EOF";
<center>
<table cellspacing='0' cellpadding='0' width="$o_width" border='0'>
<tr>
<td colspan='2'>
<table cellspacing='0' cellpadding='5' border='0'>
<tr>
<td align="left" width="$o_width" bgcolor="$color_adm_d"><b><font color='#ffffff'>ご購入方法</font></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br$xslash>
<table cellspacing='0' cellpadding='0' bgcolor='#ffffff' border='0'>
<tr>
<td>
<table cellspacing='1' cellpadding='5' width="$o_width" bgcolor="$color_adm_d">

$law_express

</table>
</td>
</tr>
</table>
</center>
EOF

$i =38;
while($i <= 40){
unless($law[$i]){$i++;$i++;next;}

$privacy_express .=<<"EOF";
<tr>
<td width="23%" bgcolor="$color_adm_r" align='center'>
$law[$i]
</td>
<td valign='top' width='77%' bgcolor='#ffffff'>
$law[$i+1]
</td>
</tr>
EOF

$i++;
$i++;
}
print <<"EOF";
<br$xslash><br$xslash><center>
<table cellspacing='0' cellpadding='0' width="$o_width" border='0'>
<tr>
<td colspan='2'>
<table cellspacing='0' cellpadding='5' border='0'>
<tr>
<td align="left" width="$o_width" bgcolor="$color_adm_d"><b><font color='#ffffff'>個人情報保護法に基づく表\示</font></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br$xslash>
<table cellspacing='0' cellpadding='0' bgcolor='#ffffff' border='0'>
<tr>
<td>
<table cellspacing='1' cellpadding='5' width="$o_width" bgcolor="$color_adm_d">

$privacy_express

</table>
</td>
</tr>
</table>
</center>
EOF

print "$foot</body></html>" ;	

}
#===============================購入方法===================
sub howto_put{

$i =28;
while($i <= 37){
unless($law[$i]){$i++;$i++;next;}

$howto_express .=<<"EOF";
<tr>
<td width="117" bgcolor="$color_adm_r" align='center'>
$law[$i]
</td>
<td valign='top' width='438' bgcolor='#ffffff'>
$law[$i+1]
</td>
</tr>
EOF

$i++;
$i++;
}

&html_header();

print <<"EOF";
<center>
<table cellspacing='0' cellpadding='0' width="$o_width" border='0'>
<tr>
<td colspan='2'>
<table cellspacing='0' cellpadding='5' border='0'>
<tr>
<td align="left" width="$o_width" bgcolor="$color_adm_d"><b><font color='#ffffff'>会社概要</font></b></td>
</tr>
</table>
</td>
</tr>
</table>
<br$xslash>
<table cellspacing='0' cellpadding='0' bgcolor='#ffffff' border='0'>
<tr>
<td>
<table cellspacing='1' cellpadding='5' width="$o_width" bgcolor="$color_adm_d">

$howto_express

</table>
</td>
</tr>
</table>
</center>
EOF

print "$foot</body></html>" ;	

}
#======================================================================
# Cookieに値を書き込むためのSet-Cookie:ヘッダを生成する
#
sub setCookie{
    local($tmp, $val);
    $val = $_[1];
    $val =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;
    $tmp = "Set-Cookie: ";
    $tmp .= "$_[0]=$val; ";
    $tmp .= "expires=Thu, 1-Jan-2050 00:00:00 GMT;\n";
    return($tmp);
}
sub setCookie_0{
    local($tmp, $val);
    $val = $_[1];
    $val =~ s/(\W)/sprintf("%%%02X", unpack("C", $1))/eg;
    $tmp = "Set-Cookie: ";
    $tmp .= "$_[0]=$val; ";
    $tmp .= ";\n";
    return($tmp);
}
#
# Cookieの値を読み出す
#
sub getCookie{
    local($xx, $name, $value);
    for $xx (split(/; */, $ENV{'HTTP_COOKIE'})) {
        ($name, $value) = split(/=/, $xx);
        $value =~ s/%([0-9A-Fa-f][0-9A-Fa-f])/pack("C", hex($1))/eg;
        $COOKIE{$name} = $value;
    }
}

sub html_header{
	if($shop_key_add){
		$shop_title_add ="$shop_key_add";
		$shop_descrip_add ="$shop_key_add";$shop_descrip_add =~ s/\// /g;
		$shop_key_add =~ s/\//,/g;$shop_key_add .=',';
	}
	if($goods_seo_key){
		$main_title ="$goods_seo_key";
		$shop_descrip_add ="$goods_seo_key";
		$shop_key_add =$goods_seo_key;$shop_key_add .=',';
		$shop_title_add ='';
	}
	if($shop_title_add){
		$shop_title_add =~ s/\//-/g;
		$shop_title_add .='/';
	}
	
	print "Content-type: text/html\n\n";

if($xhtml_use){
	if($xhtml_use ne 2){print "<?xml version='1.0' encoding='Shift_JIS'?>\n";}
	print "<!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>\n";
	print "<html xmlns='http://www.w3.org/1999/xhtml' xml:lang='ja' lang='ja'>\n";
}else{
	print "<!DOCTYPE html PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n";
	print "<html lang='ja'>\n";
}

	print "<head>\n";
	print "<meta content=\"text/html; charset=Shift_JIS\" http-equiv='Content-Type'$xslash>\n";
	print "<title>$shop_title_add$main_title</title>\n";
	print "<meta name=\"keywords\" content=\"$shop_key_add$shop_keywords\"$xslash>\n";
	print "<meta name=\"description\" content=\"$shop_description$shop_descrip_add\"$xslash>\n";
	print "<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\"$xslash>\n";
	print "<meta content=\"text/css\" http-equiv='Content-Style-Type'$xslash>\n";

	print "$style";
	
	print "</head>$body$header\n";

}

#=================ロック処理========================== 
sub lock_log {
	local($retry)=5;
	# symlink関数式ロック
	if ($lockkey == 1) {
		while (!symlink(".", $loglock)) {
			if (--$retry <= 0) { &error("Log is lock."); }
			sleep(1);
		}
	# mkdir関数式ロック
	} elsif ($lockkey == 2) {
		while (!mkdir($loglock, 0755)) {
			if (--$retry <= 0) { &error("Log is lock."); }
			sleep(1);
		}
	}
	$lockflag=1;
}
sub lock_list {
	local($retry)=5;
	# symlink関数式ロック
	if ($lockkey == 1) {
		while (!symlink(".", $lock_file)) {
			if (--$retry <= 0) { &error("List is lock."); }
			sleep(1);
		}
	# mkdir関数式ロック
	} elsif ($lockkey == 2) {
		while (!mkdir($lock_file, 0755)) {
			if (--$retry <= 0) { &error("List is lock."); }
			sleep(1);
		}
	}
	$lockflag=1;
}
sub lock_aff {
	local($retry)=5;
	# symlink関数式ロック
	if ($lockkey == 1) {
		while (!symlink(".", $aff_lock_file)) {
			if (--$retry <= 0) { &error("affiliate is lock."); }
			sleep(1);
		}
	# mkdir関数式ロック
	} elsif ($lockkey == 2) {
		while (!mkdir($aff_lock_file, 0755)) {
			if (--$retry <= 0) { &error("affiliate is lock."); }
			sleep(1);
		}
	}
	$lockflag=1;
}
#=====================ロック解除======================
sub unlock_log {
	if ($lockkey == 1) { unlink($loglock); }
	elsif ($lockkey == 2) { rmdir($loglock); }
	$lockflag=0;
}
sub unlock_list {
	if ($lockkey == 1) { unlink($lock_file); }
	elsif ($lockkey == 2) { rmdir($lock_file); }
	$lockflag=0;
}
sub unlock_aff {
	if ($lockkey == 1) { unlink($aff_lock_file); }
	elsif ($lockkey == 2) { rmdir($aff_lock_file); }
	$lockflag=0;
}

#===============================================================
sub error {
# ファイルロック解除
if (-e $lock_file) { &unlock_list(); }
if (-e $loglock) { &unlock_log(); }
if (-e $aff_lock_file) { &unlock_aff(); }

&html_header();
	
unless($kensaku_express){
print <<"EOF";
<center>
<table cellpadding="3" width="$o_width">
	<tr>
	<td align="right" width="$o_width"><a href="$save_data&amp;order=$empty"><font class='link_button'>商品画面</font></a></td>
	</tr>
</table>
</center>
EOF
}
	print "<br$xslash><center>$_[0]</center>\n";
	print "<center>$_[1]</center>\n";

	print "<br$xslash><hr size='1' width=\"$o_width\"$xslash><br$xslash>$foot</body></html>";
	exit;
}

