#===============================表示HTMLドキュメントを生成===========================
sub html {
	open(PRE,"$junle_file") || &error('FILE OPEN ERROR - junle');
	@junles = <PRE>;
	close(PRE);
	if($QUERY{'junle'} eq ""){
		# カウンタアップ
			if($tno_ck == 2){
				$cookie_namew = $cookie_name .'cnt';
				&get_cookie($cookie_namew);
				if($COOKIE{'cnt'} eq ""){
					# ロック開始
						if ($lockkey == 1) { &lock1; }
						elsif ($lockkey == 2) { &lock2; }
					open(TNO,"$tno_file") || &error('ファイルオープンに失敗しました - no');
					$tno = <TNO>;
					close(TNO);
					$tno =~ s/\n//g;
					$tno ++;
					open(TNO,">$tno_file") || &error('FILE OPEN ERROR - no');
					print TNO $tno;
					close(TNO);
					&unlock; # ロック解除
					&set_count($cookie_namew,$tno);
				}
			}
		($jlcode,$jw) = split(/<>/,@junles[0]); $QUERY{'junle'} = $jlcode;
	}
	open(PRE,"$design_file") || &error('FILE OPEN ERROR - design');
	@htmls = <PRE>;
	close(PRE);
	$html = "";
	foreach (@htmls) { $html .= $_; }
	($headw,$junlew,$footw) = split(/<!--junle-->/,$html);
	if($mojicode eq "s"){ &jcode'convert(*junlew,'euc'); }
	$junle = "";
	foreach (@junles) {
		($jlcode,$jlw) = split(/<>/,$_);
		if($QUERY{'junle'} eq $jlcode){ $jwordw = "$jlw"; }
		else{ $jwordw = "<a href=\"$form_cgi?mode=list&junle=$jlcode\">$jlw</a>"; }
		$jw = $junlew;
		$jw =~ s/<!--jword-->/$jwordw/g;
		$junle .= $jw;
	}
	if($mojicode eq "s"){ &jcode'convert(*junle,'sjis'); }
	$html = $headw .$junle .$footw;
	($headw,$prew,$footw) = split(/<!--form-->/,$html);
	if($mojicode eq "s"){ &jcode'convert(*prew,'euc'); }
	open(LOG,"$data_file") || &error('FILE OPEN ERROR - data');
	@logs = <LOG>;
	close(LOG);
	open(JNL,"$jokyo_file") || &error('FILE OPEN ERROR - jokyo');
	@jokyos = <JNL>;
	close(JNL);
	$i = 0; $prev = "";
	foreach $logwk (@logs) {
		($hdate,$seq,$title,$junle,$image,$yen,$gram,$page,$size,$set_code,$com,$hf,$himg,$samnale,$busu,$mm) = split(/<>/, $logwk);
		if($QUERY{'junle'} eq $junle){
			$hdate = substr($hdate,0,4) .'/' .substr($hdate,4,2) .'/' .substr($hdate,6,2);
			$su = &su_make($seq);
			$hrefw = ""; $sample = "";
			if($image ne ""){ $image = "<img src=\"$up_dir$image\" align=\"absmiddle\" border=0>"; }else{ $image = ""; }
			if($samnale ne ""){
				@kcss = split(/\./,$samnale);
				$kcs = pop(@kcss);
				if($kcs eq "html" || $kcs eq "htm" || $kcs eq "txt" || $kcs eq "shtml"){ $surl_f = 1; $hrefw = $samnale; }
				else{ $hrefw = "$form_cgi?mode=view&img=$samnale"; }
				if($pop_ck == 1){ $hrefw = "javaScript:newopen(\'$hrefw\');"; }
				else{ $hrefw .= "\" target=\"_blank"; }
				if($image ne ""){ $image = "<a href=\"$hrefw\">$image</a>"; }
				$sample = "<a href=\"$hrefw\"><img src=\"$sam_img\" align=\"absmiddle\" border=0></a>";
			}else{ $sample = ""; }
			$prevw = $prew;
			if($hf == 9){ ($headpw,$orderw,$footpw) = split(/<!--order-->/,$prevw); $prevw = $headpw .$footpw; }
			foreach $jwk (@jokyos){ # 販売イメージ参照
				($jokyo,$jpic) = split(/<>/,$jwk);
				if($jokyo eq $himg){
					if($jpic ne ""){ $himg = '<img src="' .$joukyo_dir .$jpic .'" align="absmiddle">'; }
					last;
				}
			}
			$prevw =~ s/<!--title-->/$title/g;
			$prevw =~ s/<!--su-->/$su/g;
			$prevw =~ s/<!--image-->/$image/g;
			$prevw =~ s/<!--sample-->/$sample/g;
			$prevw =~ s/<!--yen-->/$yen/g;
			$prevw =~ s/<!--gram-->/$gram/g;
			$prevw =~ s/<!--mm-->/$mm/g;
			$prevw =~ s/<!--page-->/$page/g;
			$prevw =~ s/<!--size-->/$size/g;
			$prevw =~ s/<!--set_code-->/$set_code/g;
			$prevw =~ s/<!--com-->/$com/g;
			$prevw =~ s/<!--date-->/$hdate/g;
			$prevw =~ s/<!--hf-->/$himg/g;
			$prevw =~ s/<!--busu-->/$busu/g;
			$prev .= $prevw;
			$i++;
		}
	}
	if($i == 0){ $prev = 'データがありません。'; }
	if($mojicode eq "s"){ &jcode'convert(*prev,'sjis'); }
	$html = $headw .$prev .$footw;
	if($frame_ck != 1){ $html =~ s/ target="order"//g; }
	$html =~ s/<!--form_cgi-->/$form_cgi/g;
	$html =~ s/<!--admin_cgi-->/$admin_cgi/g;
	$html =~ s/<!--form-->/$prev/g;
	$html =~ s/<!--system-->/$systeminfo/g;
	print "Content-Type: text/html\n\n";
	print $html;
	exit;

}

#===============================イメージプレビュー===========================
sub view {
	open(PRE,"$sample_file") || &error('FILE OPEN ERROR - design');
	@htmls = <PRE>;
	close(PRE);
	$html = "";
	foreach (@htmls) { $html .= $_; }
	$image = '<img src="' .$up_dir .$QUERY{'img'} .'">';
	$html =~ s/<!--image-->/$image/g;
	$html =~ s/<!--system-->/$systeminfo/g;
	print "Content-Type: text/html\n\n";
	print $html;
	exit;
}

#===============================注文冊数作成===========================
sub su_make {
	my $sqw = $_[0];
	if($busu_ck >= 0 && $busu - $busu_ck <= $busu_max){ $busu_maxw = $busu - $busu_ck; }else{ $busu_maxw = $busu_max; }
	my $i = 1;
	my $su = "<select name=\"$sqw\">";
	if($design_file ne "design2.html"){ $su .= "<option value=\"\">0\n"; }
	while($i <= $busu_maxw){
	$su .= "<option value=\"$i\">$i\n";
		$i++;
	}
	$su .= "</select>";
	return $su;
}


return 1;
