<?php
	require("../__common__/__define_common.php");
	if ($_COOKIE['translate_language_original']) {
		$original = $_COOKIE['translate_language_original'];
	} else {
		$original = 'en';
	}
	if ($_COOKIE['translate_language_target']) {
		$target = $_COOKIE['translate_language_target'];
	} else {
		$target = 'ja';
	}
	if (isset($_GET['url'])) {
		$url = $_GET['url'];
	}
	$original_tbl = array();
	$original_tbl[] = array('en', '英語');
	$original_tbl[] = array('ja', '日本語');
	$original_tbl[] = array('fr', 'フランス語');
	$original_tbl[] = array('de', 'ドイツ語');
	$original_tbl[] = array('it', 'イタリア語');
	$original_tbl[] = array('es', 'スペイン語');
	$original_tbl[] = array('pt', 'ポルトガル語');
	$original_tbl[] = array('ko', '韓国語');
	$original_tbl[] = array('zh', '中国語');
	$target_tbl = array();
	$target_tbl[] = array('ja', '日本語');
	$target_tbl[] = array('en', '英語');
	$target_tbl[] = array('fr', 'フランス語');
	$target_tbl[] = array('de', 'ドイツ語');
	$target_tbl[] = array('it', 'イタリア語');
	$target_tbl[] = array('es', 'スペイン語');
	$target_tbl[] = array('pt', 'ポルトガル語');
	$target_tbl[] = array('ko', '韓国語');
	$target_tbl[] = array('zh', '中国語');
?><!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="utf-8">
<meta name="author" content="ok.2nd">
<style>
a.return_index { font-size: 12px; text-decoration: none; font-weight: normal;}
a.return_index:link { color: #e0e0e0; }
a.return_index:visited { color: #e0e0e0; }
a.return_index:hover { color: #ffc080; }
a.return_index:active { color: #ffc080; }
</style>
<title>Yahoo ホームページ対訳</title>
<script src="../scripts/jquery.js"></script>
<script src="../scripts/jquery.cookie.js"></script>
<script>
function viewPage(url){
	source.location.href = url;
	translateView(url);
}
function translateView(url) {
	original = $("#original").val();
	target = $("#target").val();
	translate.location.href = "http://honyaku.yahoofs.jp/url_result?ieid="+original+"&oeid="+target+"&both=F&url="+url;
}
function originalChange() {
	original = $("#original").val();
	$.cookie('translate_language_original',original,{path:'<?= MY_SESSION_PATH ?>', expires:365});
	if (original != 'ja') {
		target = 'ja';
		$("select[name='target']").val(target);
		$.cookie('translate_language_target',target,{path:'<?= MY_SESSION_PATH ?>', expires:365});
	}
}
function targetChange() {
	target = $("#target").val();
	$.cookie('translate_language_target',target,{path:'<?= MY_SESSION_PATH ?>', expires:365});
	if (target != 'ja') {
		original = 'ja';
		$("select[name='original']").val(original);
		$.cookie('translate_language_original',original,{path:'<?= MY_SESSION_PATH ?>', expires:365});
	}
}
function clearInput(){
	$("#url").val('');
	$.cookie('translate_source_url','',{path:'<?= MY_SESSION_PATH ?>'});
}
$(function(){
	$("#left").css("height",window.innerHeight-30);
	$("#right").css("height",window.innerHeight-30);
	var right = $("#right");
	var left = $("#left");
	right.scroll(function(){
		left.scrollTop(right.scrollTop())
		left.scrollLeft(right.scrollLeft())
	});
});
</script>
</head>
<body style="margin:0;">
<div>
<form><a href="../tools/" class="return_index">■</a><span style="font-size:12px;">URL:</span><input id="url" class="text" type="text" style="width:500px;" name="url" value="<?= $url ?>">
<select id="original" name="original" onchange="originalChange()">
<?php
	foreach ($original_tbl as $ori) {
?>
		<option value="<?= $ori[0] ?>"<?= $ori[0] == $original ? ' selected' : '' ?>><?= $ori[1] ?></option>
<?php
		}
?>
	</select>
<select id="target" name="target" onchange="targetChange()">
<?php
	foreach ($target_tbl as $tar) {
?>
		<option value="<?= $tar[0] ?>"<?= $tar[0] == $target ? ' selected' : '' ?>><?= $tar[1] ?></option>
<?php
		}
?>
	</select>
<button onclick="viewPage(form.url.value);return false;">翻訳</button><button onclick="clearInput();return false;">クリア</button>
</form>
</div>
<div id="left" style="width:49.5%;overflow:hidden;float:left;border:1px solid #888;">
	<iframe id="source" scrolling="no" name="source" style="width:1024px;height:20000px;border-style:none;" src="<?= $url ?>"></iframe>
</div>
<div id="right" style="width:49.5%;overflow:auto;float:left;border:1px solid #888;">
	<iframe id="translate" scrolling="no" name="translate" style="width:1024px;height:20000px;border-style:none;position:relative;top:-100px;" src="<?= $translate ?>"></iframe>
</div>
<div style="clear:both"></div>
</body>
</html>
