#!/usr/bin/perl
$|=1;

#携帯端末シミュレータ(sample store)のフレーム表示
#

require '/home/storenavi/public_html/master/index.pl';
require '/home/snich/public_html/lib/analog_system.pl';
require '/home/snich/public_html/lib/jcode.pl';
require '/home/snich/public_html/lib/cgi-lib.pl';
&decode;
$uid = $FORM{'uid'} || 'sample';

print <<"EOF";
content-type:text/html

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="ja">

	<head>
		<meta http-equiv="content-type" content="text/html;charset=EUC-JP">
		<title>【ストアナビ】携帯端末表示サンプル</title>
<SCRIPT type="text/javascript" language="javascript">
<!--
function sup() {mobilescreen.scrollBy(0,90);}
function sdn() {mobilescreen.scrollBy(0,-90);}
function userwin() {
	uidval = window.opener.form1.uid.value;
	if (uidval != '') {
		mobilescreen.location.href = "mobile_sample.a?uid="+uidval;
	} else {
		mobilescreen.location.href = "mobile_sample.a?uid=sample";
	}
}
//-->
</SCRIPT>
	</head>

	<body bgcolor="#ffffff" onLoad="userwin()">
		<div align="center">
			<table border="0" cellspacing="1" cellpadding="0">
				<tr>
					<td>
						<table width="200" border="0" cellspacing="1" cellpadding="3">
							<tr>
								<td bgcolor="#696969"><font size="2" color="white"><b>携帯端末簡易シミュレータ</b></font></td>
							</tr>
							<tr>
								<td><font size="2" color="#212121">携帯端末よりSample Shopにアクセスした場合をシミュレートしています。</font>
									<p><font size="2" color="#212121">本体画像のボタンにより、上下スクロール・履歴の移動ができます。</font></p>
									<p><font size="2" color="#212121">リンク先へのジャンプやフォームへの記入は直接マウスクリックでお試し下さい。</font></p>
								</td>
							</tr>
							<tr>
								<td><font size="2" color="#696969">※インラインフレーム及びJavascriptを利用してページを表示しております。お使いのブラウザの対応状況により、正しく動作しないことがあります。<br>
									</font><font size="2" color="#696969"> ※一般的な携帯端末での表示状態を表しています。<br>
										携帯機種や設定により一行に表示できる文字数は異なるため、実際の携帯画面とは折り返し位置が異なる場合があります。<br>
									</font><font size="2" color="#696969">※携帯独自の機能や表記（電話をかける、絵文字など）には対応しておりません。</font></td>
							</tr>
						</table>
					</td>
					<td>
						<table border="0" cellspacing="0" cellpadding="0">
							<tr height="83">
								<td width="40" height="83"><img src="../images/mobile02_01.gif" alt="" width="40" height="83" border="0"></td>
								<td width="132" height="83"><img src="../images/mobile02_02.gif" alt="" width="132" height="83" border="0"></td>
								<td width="41" height="83"><img src="../images/mobile02_03.gif" alt="" width="41" height="83" border="0"></td>
							</tr>
							<tr height="180">
								<td width="40" height="180"><img src="../images/mobile02_04.gif" alt="" width="40" height="180" border="0"></td>
								<td width="132" height="180"><IFRAME name="mobilescreen" src="mobile_sample.a?uid=$uid" width="132" height="180" frameborder="0" scrolling="NO"></IFRAME></td>
								<td width="41" height="180"><img src="../images/mobile02_06.gif" alt="" width="41" height="180" border="0"></td>
							</tr>
							<tr height="473">
								<td width="40" height="473"><img src="../images/mobile02_07.gif" alt="" width="40" height="473" border="0"></td>
								<td width="132" height="473"><img src="../images/mobile02_08.gif" alt="" height="473" width="132" usemap="#buttons" border="0"></td>
								<td width="41" height="473"><img src="../images/mobile02_09.gif" alt="" width="41" height="473" border="0"></td></tr>
						</table>
						<map name="buttons"><area shape="rect" coords="83,180,107,219" href="#" alt="" onClick="javascript:history.forward();"><area shape="rect" coords="25,180,49,219" href="#" alt="" onClick="javascript:history.back();"><area shape="rect" coords="48,210,82,234" href="#" alt="" onClick="sup()"><area shape="rect" coords="48,162,82,186" href="#" alt="" onClick="sdn()"></map>
					</td>
				</tr>
			</table>
		</div>
	</body>

</html>
EOF

exit(0);

sub decode{
	%FORM = '';
	if ($ENV{'REQUEST_METHOD'} eq "POST") {
		read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	} else { $buffer = $ENV{'QUERY_STRING'}; }
	@pairs = split(/&/,$buffer);
	foreach $pair (@pairs) {
		($name, $value) = split(/=/, $pair);
		$value =~ tr/+/ /;
		$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

		# タグ変換（タグを表示用特殊文字へ変換）
		$value =~ s/</&lt;/g;
		$value =~ s/>/&gt;/g;
		# カンマ変換（半角カンマを全角カンマへ変換）
		$value =~ s/\,/，/g;
		# jcode.plを利用して文字コード変換
		&jcode'convert(*value,'euc');

		$FORM{$name} = $value;
	}
return %FORM;
}
