// -*- coding: UTF-8 -*-
// jtools.js - JavaScript
// Copyright 2005 Sofrosune. All rights reserved.
// Author: Sofrosune; www.sofrosune.net
// No part of this program may be reproduced or transmitted in any form or 
// by any means without permission from the author, Sofrosune.
//
// Date: June 18, 2005.
// Version: 1.00; June 18, 2005.
// Version: 1.10; March 8, 2007.
// Version: 1.20; October 26, 2008. (adapted to jquery library)
// Version: 2.00; May 10, 2009. (first release)
// Version: 2.01; May 20, 2009. (added popimg function)
// Version: 2.02; June 2, 2009. (added item to Pref)
// Version: 2.03; June 22, 2009. (separate pase functions from Pref)
// Version: 2.04; July 24, 2010. (added detecting Acrobat web capture)
// Version: 2.05; September 18, 2010. (workaround for jt_get_timestamp)

// Usage:
/**
<head>
	<script type="text/javascript" src="../scripts/jquery.js"></script>
	<script type="text/javascript" src="../scripts/jtools.js"></script>
	<script type="text/javascript" src="../scripts/TEMP.js"></script>
	<script type="text/javascript" src="../scripts/TEMP_data.js"></script>
</head>
*/

// Constants:

// search engine
var kJT_QUERY_FORM = '\
<form method="get" action="http://www.google.co.jp/search" target="viewSearch">\
<input type="hidden" name="ie" value="UTF-8" />\
<input type="hidden" name="oe" value="UTF-8" />\
<input type="hidden" name="hl" value="ja" />\
<input type="hidden" name="domains" value="$$$domain$$$" />\
<input type="hidden" name="sitesearch" value="$$$domain$$$" />\
<input type="text" name="q" size="8" maxlength="255" style="vertical-align:middle; width:120px; height:14px; font-size:12px; color:#000000; background-color:#fffff7; border:1px solid darkgray; padding:1px;" value="" /> \
<input type="submit" name="btnG" style="vertical-align:middle; height:18px; font-size:10px; color:#0000FF; background-color:#e6e6fa; border:1px solid darkgray; padding:1px;" title="$$$search$$$" value="$$$search$$$" />\
</form>\
';

var kJT_QUERY_FORM_BUTTON = '<input type="image" style="vertical-align:middle;" name="btnG" border="0" width="40" height="18" src="$$$rootdir$$$/images/buttons/button-search-40x18.png" />';

var kJT_QUERY_DOMAIN = "TEMP.co.jp";
var kJT_QUERY_LABEL = "Search";

// copyright
var kJT_COPYRIGHT = '<span class="serif">Copyright &copy; $$$year$$$ $$$owner$$$. All Rights Reserved.</span>';

// Variables:

// popup window
var kJT_POPUP_TARGET_DEFAULT = "note";
var kJT_POPUP_WIDTH_DEFAULT = 640; // in pixel

// load initial data
var gJT_INITIAL_DATA = { };

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// common functions
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_z2h
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var str_hankaku = jt_z2h(str_zenkaku);
//	var str_hankaku = str_zenkaku.z2h();

// translation (encoding is UTF-8)
var kJT_Z2H_ALPHANUMERIC = "　０-９Ａ-Ｚ＠ａ-ｚ＿．－";
var kJT_Z2H_ALPHANUMERIC_PATTERN = new RegExp("["+kJT_Z2H_ALPHANUMERIC+"]","g");
var kJT_Z2H_OFFSET = "！".charCodeAt(0) - "!".charCodeAt(0);

function jt_z2h(text) {
	return text.replace(kJT_Z2H_ALPHANUMERIC_PATTERN,
		function ($0) {
			return String.fromCharCode($0.charCodeAt(0) - kJT_Z2H_OFFSET);
		});
}

String.prototype.z2h = function() {
	return jt_z2h(this.valueOf()); // or use this.toString()
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_quote
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var str_quoted = jt_quote(str);
//	var str_quoted = str.Quote();
//
//	var str = jt_unquote(str_quoted);
//	var str = str_quoted.Unquote();

function jt_quote(text) {
	return text.replace(/(['"])/g,"\\$1");
}

function jt_unquote(text) {
	return text.replace(/\\(['"])/g,"$1");
}

String.prototype.Quote = function() {
	return jt_quote(this.valueOf()); // or use this.toString()
}

String.prototype.Unquote = function() {
	return jt_unquote(this.valueOf()); // or use this.toString()
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_replace_key
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	replaces /\$\$\$key\$\$\$/g with value
//
//	var text = jt_replace_key(text,"key",value);
//	var text = jt_replace_key(text,[["key1",value1],["key2",value2],...]); // Array type
//	var text = jt_replace_key(text,{key1:value1,key2:value2,...}); // Object type
//
//	var text = text.replaceKey("key",value);
//	var text = text.replaceKey([["key1",value1],["key2",value2],...]); // Array type
//	var text = text.replaceKey({key1:value1,key2:value2,...}); // Object type

function jt_replace_key(text,param1,param2) {

	var preamble = "\\$\\$\\$";
	var search_regex = "";

	if (param2 != undefined) {
		search_regex = new RegExp(preamble+param1+preamble,"g");
		text = text.replace(search_regex,param2);

	} else if (param1 instanceof Array) {
		// replaces each items in the predefined order
		for (var idx in param1) {
			search_regex = new RegExp(preamble+param1[idx][0]+preamble,"g");
			text = text.replace(search_regex,param1[idx][1]);
		}

	} else if (param1 instanceof Object) {
		// replaces each items in a random order
		for (var key in param1) {
			search_regex = new RegExp(preamble+key+preamble,"g");
			text = text.replace(search_regex,param1[key]);
		}
	}

	return text;
}

String.prototype.replaceKey = function(param1,param2) {
	return jt_replace_key(this.valueOf(),param1,param2); // or use this.toString()
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_replace_rootdir
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var msg = jt_replace_rootdir(msg [,key = "rootdir"]);
//	var msg = msg.replaceRootdir();

function jt_replace_rootdir(msg,key) {
	if (key == undefined) { key = "rootdir"; }
	var rootdir = jt_get_rootdir();
	return jt_replace_key(msg,key,rootdir);
}

String.prototype.replaceRootdir = function(key) {
	return jt_replace_rootdir(this.valueOf(),key); // or use this.toString()
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_is_acrobat
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var isAcrobatWebCapture_or_not = jt_is_acrobat();

var kJT_BROWSER_ACROBAT = /AppleWebKit\/523.15/i; // for Acrobat 9.3

function jt_is_acrobat() {
	return (navigator.userAgent.search(kJT_BROWSER_ACROBAT) != -1);
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_cPref
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var aPref = new jt_cPref();
//	aPref.parse();
//	var key = aPref.key;
//	var track = aPref.meta.track or aPref.meta["track"];
//	var offset = aPref.param.PARAM_OFFSET or aPref.param["PARAM_OFFSET"];
//
// About rootdir:
//	(1) rootdir is the position to "pages" directory, or home directory (/).
//	(2) if "pages" exists, "$$$rootdir$$$/info/index.html" stands for "..../pages/info/index.html".
//	(3) if no "pages" exists", "$$$rootdir$$$/info/index.html" stands for "/info/index.html".

var kJT_PREF_ROOT_PATTERN = /^(?:[e]?pages|web-content)(?:-\d+)?/;
var kJT_PREF_CHAP_PATTERN = /((?:book|chap|contact|corp|home|info|misc|news|note|prof|prod|recruit|tech|topics|)\S*)/;
var kJT_PREF_SECT_PATTERN = /(sect\S*)/;
var kJT_PREF_PAGE_PATTERN = /(page\S*)/;
var kJT_PREF_ITEM_PATTERN = /(item\S*)/;

var gJT_Pref = new jt_cPref();
gJT_Pref.parse();

function jt_cPref() {
	this.meta = { }; // { name1:value1, ... }
	this.param = { }; // { "PARAM_OFFSET":0, ... }
	this.rootdir = ""; // Ex. "../.." for the path "/pages-123/abc/xyz/doc.html"
	this.path = ""; // window.location.pathname; Ex. "/pages-123/abc/xyz/doc.html"
	this.nodes = new Array(); // ["xyz","abc","pages-123"]
	this.self = ""; // "doc.html"
	this.track = [ ] ; // Ex. ["CORP01","SECT04","*"]  for this.meta.track = "CORP01:SECT04:*"
	this.section = { }; // Ex. {chap:"corp01",sect:"sect04",page:"page03",item:"item01"} for "corp01 sect04 page03 item01"
	this.title = ""; // document.title
	this.type = "none"; // option
	this.offset = 0; // option
	this.comet = ""; // option

	// parse
	this.parse = function () {
		// title
		this.title = document.title; // e3/N2

		// parth path
		this.path = window.location.pathname.replace(/\\/g,"/");
		this.nodes = this.path.split("/"); // ["pages-123","abc","xyz","doc.html"]
		this.self = this.nodes.pop(); // "doc.html"
		this.nodes.reverse(); // ["xyz","abc","pages-123"]
		this.rootdir = "";
		for (var k = 0; k < this.nodes.length; k++) {
			if (this.nodes[k].search(kJT_PREF_ROOT_PATTERN) != -1) { break; }
			if (this.rootdir != "") { this.rootdir += "/"; }
			this.rootdir += "..";
		}
		if (this.rootdir == "") { this.rootdir = "."; }
	//	window.alert(this.rootdir); // "../.."

		// parse query string
		this.param = jt_parse_query();

		// set param default
		if (this.param["PARAM_TYPE"] == undefined) { this.param["PARAM_TYPE"]  = "none"; }
		if (this.param["PARAM_OFFSET"] == undefined) { this.param["PARAM_OFFSET"]  = 0; }
		else { this.param["PARAM_OFFSET"] = parseInt(this.param["PARAM_OFFSET"]); }

		// parse meta
		this.meta = jt_parse_meta();

		// parse mata.comet
		var comet = this.meta["comet"];
		if ((comet != undefined) && (comet != null)) {
			this.comet = comet.replace(/^\s+/,"").replace(/\s+$/,"");
		//	window.alert("comet = "+this.comet);
		}

		// parse mata.track
		// Ex. ["CORP01","SECT04",${TITLE}]  for this.meta.track = "CORP01:SECT04:*"
		var meta_track = this.meta["track"];
		if ((meta_track != undefined) && (meta_track != null)) {
			meta_track = meta_track.replace(/^\s+/,"").replace(/\s+$/,"").replace(/\s*:\s*/g,":");
			this.track = meta_track.split(":");
			if ((this.track.length > 0) && (this.track[this.track.length - 1] == "*")) {
				// if the last item is "*" then replace it with title
				this.track[this.track.length - 1] = document.title;
			}
		//	window.alert("track=" + this.track.join("#"));
		}

		// parse mata.section
		// Ex. {chap:"corp01",sect:"sect04",page:"page03",item:"Item01"} for "corp01 sect04 page03 item01"
		var section = this.meta.section;
		if ((section != undefined) && (section != null)) {
			if (section.search(kJT_PREF_CHAP_PATTERN) != -1) { this.section.chap = RegExp.$1; }
			if (section.search(kJT_PREF_SECT_PATTERN) != -1) { this.section.sect = RegExp.$1; }
			if (section.search(kJT_PREF_PAGE_PATTERN) != -1) { this.section.page = RegExp.$1; }
			if (section.search(kJT_PREF_ITEM_PATTERN) != -1) { this.section.item = RegExp.$1; }
		}
	//	var _str = ""; for (var key in this.section) { _str += key+":\""+this.section[key]+"\", "; } window.alert(_str);
	}
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_parse_meta
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	<meta name="key1" content="value1" />
//
//	var meta = jt_parse_meta();
//	var val1 = meta["key1"];

function jt_parse_meta() {

	var meta = {};

	var elems = document.getElementsByTagName("meta");
	for (var k = 0; k < elems.length; k++) {
		var elem = elems.item(k);
		var key_ = elem.getAttribute("name");
		if ((key_ != "") && (key_ != null)) {
			var value_ = elem.getAttribute("content");
			key_ = key_.toLowerCase();
			meta[key_] = value_;
		//	window.alert("meta["+key_+"\]=["+value_+"]");
		}
	}

	return meta;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_parse_query
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	index.html?key1=value1&key2=value2
//	var params = jt_parse_query();
//	var val1 = params["key1"];

function jt_parse_query() {

	var params = {};

	var query_str = window.location.search.replace(/^\?/,"");
	query_str = unescape(query_str);
//	window.alert(query_str);
	if (query_str != "") {
		var queries = query_str.split("&");
		for (var k = 0; k < queries.length; k++) {
			var tuple = queries[k].split("=");
			var key_ = tuple[0];
			var value_ = tuple[1];
			params[key_] = value_;
		//	window.alert("query["+key_+"\]=["+value_+"]");
		}
	}

	return params;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_pref
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var tracks = jt_get_pref("track");

function jt_get_pref(key) {
	var val = gJT_Pref[key];
	if ((val == undefined) || (val == null)) { val = ""; }
	return val;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_rootdir, jt_get_self, jt_get_param, jt_get_meta
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var rootdir = jt_get_rootdir();
//	var self = jt_get_self();
//	var offset = jt_get_param("PARAM_OFFSET");
//	var author = jt_get_meta('author");

function jt_get_rootdir() {
	return gJT_Pref.rootdir;
}

function jt_get_self() {
	return gJT_Pref.self;
}

function jt_get_param(key) {
	var val = gJT_Pref.param[key];
	if ((val == undefined) || (val == null)) { val = ""; }
	return val;
}

function jt_get_meta(key) {
	var val = gJT_Pref.meta[key];
	if ((val == undefined) || (val == null)) { val = ""; }
	return val;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_title
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var msg = jt_get_maintitle();
//	var msg = jt_get_subtitle();

function jt_get_maintitle() {
	var msg = gJT_Pref.title;
	if (gJT_Pref.track.length > 0) { msg = gJT_Pref.track[gJT_Pref.track.length - 1]; }
	return msg;
}

function jt_get_subtitle() {
	var msg = gJT_Pref.title;
	if (gJT_Pref.track.length > 1) { msg = gJT_Pref.track[gJT_Pref.track.length - 2]; }
	return msg;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_option
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	option = jt_get_option(obj,option);
//	var href = option.href;
//	var path = option.path;
//	var target = option.target;
//	var help = option.help;
//	var width = option.width;
//	var height = option.height;
//
//	<a onclick="func(this,{type:'image',width:128,height:96,help:'msg'});">

function jt_get_option(obj,option) {
	if (option == undefined) { option = { }; }

	option.href = (option.href != undefined) ? option.href : ((obj.getAttribute("href") != undefined) ? obj.getAttribute("href"): "");

	option.path = (option.path != undefined) ? option.path : ((obj.getAttribute("path") != undefined) ? obj.getAttribute("path"): "");

	option.target = (option.target != undefined) ? option.target : ((obj.getAttribute("target") != undefined) ? obj.getAttribute("target"): "");

	option.help = (option.help != undefined) ? option.help : ((obj.getAttribute("help") != undefined) ? obj.getAttribute("help"): "");
	if (option.help == "") { option.help = obj.title; }

	option.width = (option.width != undefined) ? option.width : ((obj.getAttribute("width") != undefined) ? obj.getAttribute("width"): "0");
	option.width = parseInt(option.width);

	option.height = (option.height != undefined) ? option.height : ((obj.getAttribute("height") != undefined) ? obj.getAttribute("height"): "0");
	option.height = parseInt(option.height);

	var url = (option.path != "" ? option.path : option.href );
	if (url.search(/(\d+)x(\d+)\.(jpg|png|gif|swf|html)$/i) != -1) {
		option.width = parseInt(RegExp.$1);
		option.height = parseInt(RegExp.$2);
	}

	return option;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_query
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var msg = jt_get_query();
//	var msg = jt_get_query("TEMP.co.jp",kJT_QUERY_FORM_BUTTON);

function jt_get_query(domain,submit) {
	if (domain == undefined) { domain = kJT_QUERY_DOMAIN; }
	if (submit == undefined) { submit = ""; }

	var msg = kJT_QUERY_FORM;
	if (submit != "") {
		submit = submit.replaceRootdir();
		msg = msg.replace(/<input\s+type="submit".*?\/>/,submit);
	}
	msg = msg.replaceRootdir();
	msg = msg.replaceKey({domain:domain,search:kJT_QUERY_LABEL});
	return msg;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_footer
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var msg = jt_get_footer();

function jt_get_footer() {
	var msg = kJT_FOOTER;
	msg = msg.replaceRootdir();
	return msg;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_copyright
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var msg = jt_get_copyright("TEMP Company");
//	var msg = jt_get_copyright("TEMP Company",1996);

function jt_get_copyright(owner,establishedYear) {
	var year1 = (establishedYear == undefined ? "" : establishedYear); // Ex. 1996
	var year2 = (new Date()).getYear();
	if (year2 < 2000) { year2 += 1900; }
	var year = (year1 == "" ? year2 : year1+" - "+year2);

	var msg = kJT_COPYRIGHT;
	msg = msg.replaceKey({owner:owner,year:year});
	return msg;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_get_timestamp
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	var msg = jt_get_timestamp();

function jt_get_timestamp() {
	var lastModified = document.lastModified;
	if (! lastModified) { lastModified = (new Date()).toDateString(); } // added on 2010-09-18
	var modDate = new Date(lastModified);
	var y = modDate.getYear(); if (y < 1900) { y += 1900; }
	var m = 1 + modDate.getMonth();
	var d = modDate.getDate();
	var th = modDate.getHours();
	var tm = modDate.getMinutes();
	var ts = modDate.getSeconds();

	var sm = "00" + m; sm = sm.substr(sm.length-2);
	var sd = "00" + d; sd = sd.substr(sd.length-2);
	var sth = "00" + th; sth = sth.substr(sth.length-2);
	var stm = "00" + tm; stm = stm.substr(stm.length-2);
	var sts = "00" + ts; sts = sts.substr(sts.length-2);

//	var ymd = y + "/" + m + "/" + d;
//	var ymd = y + "." + sm + "." + sd;
	var ymd = y + "-" + sm + "-" + sd;
	var hms = sth + ":" + stm ;

//	var msg = ymd + " " + hms;
	var msg = ymd;

	return msg;
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_popup
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	<a href="url" onclick="jt_popup(this); return false;">[CLICK]</a>
//	<a href="url" onclick="jt_popup(this,{target:"note",width:704}); return false;">[CLICK]</a>
//	<a href="url" onclick="jt_popup(this,{target:"news",width:544}); return false;">[CLICK]</a>

function jt_popup(obj,option) {
	option = jt_get_option(obj,option);

	var screenw = window.screen.width;
	var screenh = window.screen.height;
	if (screenh > 640) { screenh -= 200; }

	var url = option.href;
	var target = (option.target != "") ? option.target : kJT_POPUP_TARGET_DEFAULT;
	var width = (option.width != 0) ? option.width : (kJT_POPUP_WIDTH_DEFAULT + 64);
	var height = (option.height != 0) ? option.height : screenh;

	// nudge
	if (document.all) {
		// for MSIE
		width += 16;
	} else {
		// W3C standard browser
	//	height += 20;
	}

	var feature = "toolbar=no,location=no,status=yes,menubar=yes,scrollbars=yes,resizable=yes,width="+width+",height="+height;
	var win = window.open(url,target,feature);
	win.focus();
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_initial_data
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// [REQUIRES] jquery.js
// load initial data
// Usage:
//	<script type="text/javascript">
//	gJT_INITIAL_DATA = { "PARAM_GENDER":"FEMAIL","PARAM_OPT[size]":"5" };
//	</script>

function jt_initial_data() {

	if (gJT_INITIAL_DATA == undefined) { return; }

	for (var key in gJT_INITIAL_DATA) {
		var value = gJT_INITIAL_DATA[key];
		if (value == null) { continue; }
		var 	fields = $('input[name="'+jt_quote(key)+'"]');
	//	window.alert(key+" = "+fields.length);
		if (fields.length > 0) {
			fields.val([value]);
		}
	}
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_popimg_init
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	<img class="popimg" src="images/photo-384x288.jpg" alt="" border="0" width="192" height="144" />
//	<img class="popimg" src="images/photo-384x288.jpg" path="images/photo-640x480.jpg" alt="" border="0" width="192" height="144" />

function jt_popimg_init(zoomIcon) {
	if (zoomIcon == undefined) { zoomIcon = true; }

	// set popimg
	$('<a class="popimg" title="" href="#" onclick="openNewImageWindowNoscroll(this);return false;"></a>').appendTo(document.body);
	$('img.popimg').addClass('flashd');
	$('img.popimg').wrap($('a.popimg'));
	var a_popimgs = $('a.popimg');
	for (var k = 0; k < a_popimgs.length; k++) {
		var a_popimg = a_popimgs[k];
		var imgs = a_popimg.getElementsByTagName('img');
		if (imgs.length > 0) {
			var img =  imgs[0];
			// pop src
			var path = img.getAttribute("path");
			var src = img.src;
		//	src = src.replace(/^.+\/(images\/.+)$/,"$1");
		//	window.alert(src);
			a_popimg.href = (path != undefined ? path : src);
			a_popimg.title = img.alt;
			// zoom icon
			if (zoomIcon) {
			//	var w = img.getAttribute("width");
			//	var h = img.getAttribute("height");
			//	var popzoom = '<div class="popzoom" style="width:'+w+'px; height:'+h+'px;"></div>';
				var popzoom = '<div class="popzoom"></div>';
				$(popzoom).prependTo(a_popimg);
			//	window.alert(popzoom);
			}
		}
	}

}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// jt_init
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// Usage:
//	option.enable_popimg: true(false) or false // added on 2010-07-24
//	option.popimg_zoomIcon: true(default) or false
//	option.disable_popimg_on_acrobat: true(default) or false // added on 2010-07-24
//
//	<body onload="jt_init();">
//	window.onload = jt_init;

function jt_init(option) {

	if (option == undefined) { option = { }; }
	option.enable_popimg = (option.enable_popimg != undefined) ? option.enable_popimg : true;
	option.popimg_zoomIcon = (option.popimg_zoomIcon != undefined) ? option.popimg_zoomIcon : true;
	option.disable_popimg_on_acrobat = (option.disable_popimg_on_acrobat != undefined) ? option.disable_popimg_on_acrobat : true;

	// load initial data
	jt_initial_data();

	if (typeof(jt_popimg_init) == "function") {
		if (option.enable_popimg) {
			if ((! jt_is_acrobat()) || (! disable_popimg_on_acrobat)) {
				jt_popimg_init(option.popimg_zoomIcon);
			}
		}
	}

//	if (typeof(an_ancestor_init) == "function") {
//		an_ancestor_init();
//	}
}

// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
// main functions:
// -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-

//if (typeof(jQuery) == "function") {
//	$(document).ready(jt_init);
//} else {
//	window.onload = jt_init;
//}

// end of javascript

