<?php
	require("../index/__include-common.php");
	require("../account/__logincheck.php");
	if (!defined('pane2_text_FONT_SIZE_SELECT')) {
		define('pane2_text_FONT_SIZE_SELECT', '10,11,12,13,14,15,16,18,20,24,28,30,36,48');
		define('pane2_text_FONT_SIZE_DEFAULT', '14');
	}
	if (!defined('pane2_text_FONT_FAMILY_SELECT')) {
		define('pane2_text_FONT_FAMILY_SELECT', 'ＭＳ Ｐゴシック,ＭＳ ゴシック,ＭＳ Ｐ明朝,ＭＳ 明朝,MS UI Gothic,メイリオ');
		define('pane2_text_FONT_FAMILY_DEFAULT', 'ＭＳ Ｐゴシック');
	}
	if ($_COOKIE['pane2_text_fontSize'].'' <> '') {
		$fontSize = $_COOKIE['pane2_text_fontSize'];
	} else {
		$fontSize = pane2_text_FONT_SIZE_DEFAULT;
	}
	if ($_COOKIE['pane2_text_fontFamily'].'' <> '') {
		$fontFamily = $_COOKIE['pane2_text_fontFamily'];
	} else {
		$fontFamily = pane2_text_FONT_FAMILY_DEFAULT;
	}
	$con = my_mysql_connect(_DB_SCHEMA);
	$sql = "select * from m_pane2 where id_account = ".$_SESSION['login_id']."";
	$rs = my_mysql_query($sql);
	if (mysql_num_rows($rs) > 0) {
		$rec = mysql_fetch_array($rs);
		$text1 = my_htmlspecialchars($rec['c_text1']);
		$text2 = my_htmlspecialchars($rec['c_text2']);
	} else {
		$text1 = '';
		$text2 = '';
	}
?>
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="author" content="ok.2nd">
<meta name="description" content="Pane2">
<meta name="keywords" content="2pane,column">
<style>
body {
	font-family: "MS PGothic",Osaka,Arial,sans-serif;
	font-size: 12px;
	background: #e8e8e8;
	margin: 5px 0 0 0;

}
form#form {
	width: 100%;
	margin: 0;
}
.frame {
	float: left;
	width: 49%;
}
.expanding {
	margin: 3px 0 3px 5px;
	min-height: 40em;
	width: 98%;
	font-size: <?= $fontSize ?>px;
	font-family: "ＭＳ Ｐゴシック","Osaka",sans-serif;
	padding: 5px;
}
#icon {
	border: 0;
	margin: 0 5px 0 10px;
	vertical-align: middle;
}
a.return_index { font-size: 12px; text-decoration: none; font-weight: normal; }
a.return_index:link { color: #808080; }
a.return_index:visited { color: #808080; }
a.return_index:hover { color: #ffc080; }
a.return_index:active { color: #ffc080; }
</style>
<script src="../scripts/jquery.js"></script>
<script src="../scripts/jquery.cookie.js"></script>
<script src="../scripts/jquery.textarea.js"></script>
<script src="../scripts/ExpandingTextareas/expanding.js"></script>
<script>
function saveText() {
	var text1 = $('#text1').val();
	var text2 = $('#text2').val();
	var data = {c_text1:text1, c_text2:text2};
	$.ajax({
		type: "POST",
		url: "pane2-update.php",
		data: data,
		async: false
	});
}
function clearText(){
	cleartext = '';
	var data = {c_text1:cleartext, c_text2:cleartext};
	$.ajax({
		type: "POST",
		url: "pane2-update.php",
		data: data,
		async: false
	});
	$(".expanding").val('');
}
function fontSizeChange() {
	var fontSize = $("#fontSize").val();
	$(".expanding").css("font-size", fontSize+"px");
	$.cookie("pane2_text_fontSize",fontSize,{path:'<?= MY_SESSION_PATH ?>', expires:365});
}
function fontFamilyChange() {
	var fontFamily = $("#fontFamily").val();
	$(".expanding").css("font-family", fontFamily+',Osaka,sans-serif');
	$.cookie("pane2_text_fontFamily",fontFamily,{path:'<?= MY_SESSION_PATH ?>', expires:365});
}
</script>
<script>
$(function() {
	$('textarea.expanding').tabby();
});
</script>
<title>横2段 テキストエリア</title>
</head>
<body onload="document.form0.text1.focus()">
<form name="form0" id="form">
<a href="../tools/"><img id="icon" src="../icon/text_columns.png"></a>
<button onclick="saveText();return false;">保存</button style="margin-left:10px;">
<button onclick="clearText();return false;" style="margin-right:10px;">クリア</button>
フォントサイズ：<select id="fontSize" onchange="fontSizeChange()" style="margin-right:10px;">
<?php
	$keyary = explode(",", pane2_text_FONT_SIZE_SELECT);
	foreach ($keyary as $keytmp) {
?>
	<option value="<?= $keytmp ?>"<?= $fontSize == $keytmp ? " selected" : "" ?>><?= $keytmp ?>ポイント
<?php
	}
?>
	</select>
フォント種類：<select id="fontFamily" onchange="fontFamilyChange()" style="margin-right:10px;">
<?php
	$keyary = explode(",", pane2_text_FONT_FAMILY_SELECT);
	foreach ($keyary as $keytmp) {
?>
	<option value="<?= $keytmp ?>"<?= $fontFamily == $keytmp ? " selected" : "" ?>><?= $keytmp ?>
<?php
	}
?>
	</select>
<div>
	<div class="frame">
		<textarea id="text1" class="expanding" wrap="soft"><?= $text1 ?></textarea>
	</div>
	<div class="frame" style="margin-left:3px;">
		<textarea id="text2" class="expanding" wrap="soft"><?= $text2 ?></textarea>
	</div>
</div>
</form>
</body>
</html>
