//----------------------------------
// javascript
// by s.noguchi
// 2003-2009 ver 1.12
//----------------------------------

function init(value) {
//	window.onselectstart = function() { return false; }
//	window.onContextMenu = function() { return false; }
	var cookie = getCookie("fontSize");
	ChgFontSize( ( cookie != "" ) ? cookie : "s" );
	if(value) { document.getElementById(value).className = "page"; }
	if(document.getElementById("vsp")) {
		document.getElementById("vsp").style.height =
			document.body.clientHeight -
			document.getElementById("vsp").offsetTop -
			135 + "px";
	}
	return;
}

function ChgFontSize(val) {
	var element = document.getElementsByTagName("div");
	for (j = 0 ; element.length > j; j++) {
		if( element[j].id.indexOf("fontsize") == 0 ) {
			if( element[j].id == "fontsize-" + val ) {
				document.getElementById(element[j].id).className="valid";
			} else {
				document.getElementById(element[j].id).className="invalid";
			}
		}
	}
	var element = document.getElementsByTagName("link");
	for (j = 0 ; element.length > j ; j++) {
		if( element[j].className == "ChgFont" ) {
			if( element[j].id.indexOf(val) ) {
				element[j].disabled = true;
			} else {
				element[j].disabled = false;
			}
		}
	}
	setCookie("fontSize", val, getExpDate(60, 0, 0), "/");
	return;
}

var w = window;
function OpenHTML(sorce) {
	if ((w == window) || w.closed) {
	var str = new String ("toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,top=0,left=0,width=450,height=450");
	w = open ( sorce , "", str );
	} else {
		w.focus();
	}
}

function OpenerURL(sorce) {
	window.opener.location.href = sorce;
	window.self.close();
}

function getExpDate(days, hours, minutes) {
	var expDate = new Date();
	if(typeof days == "number" && typeof hours == "number" && typeof hours == "number") {
		expDate.setDate(expDate.getDate() + parseInt(days));
		expDate.setHours(expDate.getHours() + parseInt(hours));
		expDate.setMinutes(expDate.getMinutes() + parseInt(minutes));
		return expDate.toGMTString();
	}
}

function getCookieVal(offset) {
	var endstr = document.cookie.indexOf (";", offset);
	if(endstr == -1) { endstr = document.cookie.length; }
	return unescape(document.cookie.substring(offset, endstr));
}

function getCookie(name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) { return getCookieVal(j); }
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	}
	return "";
}

function setCookie(name, value, expires, path, domain, secure) {
	document.cookie = name + "=" + escape(value) +
		((expires) ? "; expires=" + expires : "") +
		((path) ? "; path=" + path : "") +
		((domain) ? "; domain=" + domain : "") +
		((secure) ? "; secure=" + secure : "");
}

function deleteCookie(name, path, domain) {
	if (getCookie(name)) {
		document.cookie = name + "=" +
			((path) ? "; path=" + path : "") +
			((domain) ? "; domain=" + domain : "") +
			"; expires=Thu, 01-Jan-70 00:00:01 GMT";
	}
}

function Focus(obj){
	if(obj.value==obj.defaultValue){
		obj.value=""; obj.style.color="#000";
	}
}
function Blur(obj){
	if(obj.value==""){
		obj.value=obj.defaultValue; obj.style.color="#888";
	}
}

function suffix(formname, filename) {
	var n = document.forms[formname].elements[filename].value;
	var s = n.substring(n.lastIndexOf(".") + 1, n.length);
	s = s.toLowerCase();
	if ( s != "pdf" ) {
		alert("File Type Error!!");
		history.back();
	}
}
