astrStyle  = new Array();
astrStyle[0] = 'default#default';
astrStyle[1] = 'monotone#monotone';
astrStyle[2] = 'yuki#snow';

var gstrName, gintExp, gstrDomain, gstrPath, gstrMyself, gstrStyle;
gstrName   = 'watalab';
gintExp    = 90;
gstrDomain = location.hostname;
gstrPath   = '/';
gstrMyself = getThisfilename();


function htmlSelectstyle() {
	document.write('<FORM action="' + gstrMyself + '" method="POST">');
	document.write('<LABEL for="cboStyle">StyleF');
	document.write('<SELECT id="cboStyle" class="auto" onchange="(selectStyle(this))">');
	for (i = 0; i < astrStyle.length; i++) {
		tmp = astrStyle[i].split('#', 2);
		if (gstrStyle == tmp[0]) {
			document.write('<OPTION value="' + tmp[0] + '" selected>' + tmp[1] + '</OPTION>');
		} else {
			document.write('<OPTION value="' + tmp[0] + '">' + tmp[1] + '</OPTION>');
		}
	}
	document.write('</SELECT>');
	document.write('</LABEL>');
	document.write('</FORM>');
}

function htmlLanglink(blnExist) {
	if (blnExist) {
		document.write('<SPAN class="lang">');
		document.write('[ <A href="./' + gstrMyself.substring(0, gstrMyself.length - 5) + '-j.html">Japanese</A> ]');
		document.write('</SPAN>');
	}
/*
		document.write('<SPAN class="lang">');
		document.write('[ <A href="http://www.me.titech.ac.jp/~wata_lab/index-j.html">Japanese</A> ]');
		document.write('</SPAN>');
*/
}

function htmlLastupdate() {
	document.write('<DIV id="lastupdate">');
	document.write('LastUpdate : '+document.lastModified);
	document.write('</DIV>');
}

function setStyle(strBasepath) {
	gstrStyle = getCookie(gstrName);
	if (gstrStyle == null) gstrStyle = 'default';
	document.write('<LINK rel="stylesheet" type="text/css" href="' + strBasepath + 'css/' + gstrStyle + '.css">');
}

function selectStyle(cboStyle) {
	dtmExp = new Date();
	dtmExp.setTime(dtmExp.getTime() + ( gintExp * 24 * 3600 * 1000 ));
	setCookie(gstrName, dtmExp.toGMTString(), gstrDomain, gstrPath, cboStyle.value);
	cboStyle.form.submit();
	//location.reload(true);
}

function getThisfilename() {
	var strPath;
	strPath = location.pathname;
	if (strPath.lastIndexOf('/') == strPath.length - 1) {
		return 'index.html';
	} else {
	return strPath.substring(strPath.lastIndexOf('/')+1,strPath.length);
	}
}

function setCookie(strName, dtmExp, strDomain, strPath, strValue) {
	var strCookie;
	strCookie  = strName + '=' + escape(strValue) + '; ';
	strCookie += 'expires=' + dtmExp + '; ';
	strCookie += 'domain=' + strDomain + '; ';
	strCookie += 'path=' + strPath + '; ';
	document.cookie = strCookie;
}

function getCookie(strName){
	var strSearch = strName + '=';
	var offset, end;
	if (document.cookie.length > 0) {
	offset = document.cookie.indexOf(strSearch);
	if (offset != -1){
		offset += strSearch.length;
		end     = document.cookie.indexOf(';',offset);
		if(end == -1) {
			end = document.cookie.length;
		}
		return unescape(document.cookie.substring(offset,end));
		}
	}
	return null;
}

