// JavaScript Document

//site Framework
var cpText = "Copyright &copy; 1998 - 2008 EIKOH INC. All Rights Reserved.";

var ip = "/common/imgs/gn/";
var cp = new Object();
var selectedGn;

var strPn = window.location.pathname;
var pathKey = "/";
var crumb = strPn.split("/");

var popupArray = new Array();

//------------------

var subCategorys = new Object();


// subCategory path
var subCategorysWork = {
"workContents01": "/work/contents01/",
"workContents02": "/work/contents02/",
"workContents03": "/work/contents03/",
"workCats": "/work/cats/"
};

var subCategorysReason = {
"reasonContents01": "/reason/contents01/",
"reasonContents02": "/reason/contents02/",
"reasonContents03": "/reason/contents03/"
};

var subCategorysEntry = {
"entryContents01": "/entry/contents01/",
"entryContents02": "/entry/contents02/",
"entryContents03": "/entry/contents03/"
};

var subCategorysSupport = {
"supportContents01": "/support/contents01/",
"supportContents02": "/support/contents02/",
"supportContents03": "/support/contents03/"
};

//-- functions --
function drowCopyright() {
	document.write(cpText);
}

function addCp(_key,_path){
	cp[_key] = _path;
};

function setSubCategory(_cName){
	switch(_cName){
		case "work": subCategorys = subCategorysWork;
		break;
		case "reason": subCategorys = subCategorysReason;
		break;
		case "entry": subCategorys = subCategorysEntry;
		break;
		case "support": subCategorys = subCategorysSupport;
		break;
	}

	for(cName in subCategorys){
		addCp(cName,subCategorys[cName]);
	}
};

function checkCategory() {
	for (i = 1; i < crumb.length; i++) {
		pathKey += crumb[i] + "/";
		for(pName in cp){
			if(cp[pName] == pathKey){
				var preCategory = pName;
				i = crumb.length;
				break;
			}
		}
	}
	//alert("preCategory in checkCategory" + preCategory);
	setNaviFrip('subNavi',preCategory);
}

function setNaviFrip(_cName,_tId){
var objPos = '0px -92px';
if(_cName == 'subNavi') objPos = '0px -34px';
var noteObj = document.getElementsByClassName(_cName);

for(var nl=0; nl < noteObj.length; nl++){
	var objId = String(noteObj[nl].parentNode.id);
	if(objId == _tId) {
		noteObj[nl].style.backgroundPosition = objPos;
	}
}

/*
noteObj.each(function(obj){
	if(obj.parentNode.id == _tId) {
		obj.style.backgroundPosition = objPos;
		if(_cName == 'subNavi') 
		obj.style.color = '#FFFFFF';
		obj.style.textDecoration = 'none';
		//obj.style.fontWeight = 'bold';
	}
});

*/
}

function setFontL(){
var mailObj = document.getElementById('contentContainer');
mailObj.style.fontSize = '140%';
document.getElementById('setFontS').firstChild.style.backgroundPosition = '0px 0px';
document.getElementById('setFontM').firstChild.style.backgroundPosition = '0px 0px';
document.getElementById('setFontL').firstChild.style.backgroundPosition = '0px -18px';
}

function setFontM(){
var mailObj = document.getElementById('contentContainer');
mailObj.style.fontSize = '120%';
document.getElementById('setFontS').firstChild.style.backgroundPosition = '0px 0px';
document.getElementById('setFontM').firstChild.style.backgroundPosition = '0px -18px';
document.getElementById('setFontL').firstChild.style.backgroundPosition = '0px 0px';
}

function setFontS(){
var mailObj = document.getElementById('contentContainer');
mailObj.style.fontSize = '100%';
document.getElementById('setFontS').firstChild.style.backgroundPosition = '0px -18px';
document.getElementById('setFontM').firstChild.style.backgroundPosition = '0px 0px';
document.getElementById('setFontL').firstChild.style.backgroundPosition = '0px 0px';
}


/* popup series */
/*
popupArray.push({"cName":"pop1", "w":100, "h":200, "scrollbars":0, "resizable":1});
popupArray.push({"cName":"pop2", "w":"fs", "h":"fs", "scrollbars":0, "resizable":1});
*/

function initPopup() {
	for(n=0; n < popupArray.length; n++){
		var cName = popupArray[n].cName;
		var popObj = document.getElementsByClassName(cName);
		popObj.each(function(obj){
			obj.popupProp = popupArray[n];
			obj.onclick = function(){
				return winOpen(obj.href,this.popupProp);
			}
		});
	}
};

function winOpen(_src,_popupProp){
	var ww = _popupProp.w;
	var wh = _popupProp.h;
	if(ww == "fs") ww = screen.width;
	if(wh == "fs") wh = screen.height;
	var popupOption = "width="+ww+",height="+wh+",scrollbars="+_popupProp.scrollbars+",resizable="+_popupProp.resizable;
	var nw = window.open(_src,_popupProp.cName,popupOption);
	x = (screen.width / 2) - (ww / 2);
	y = (screen.height / 2) - (wh / 2);
	nw.moveTo(x,y);

	return false;
}
/* popup series */


//page initialize
function init() {
	setNaviFrip('headerGn',selectedGn);
	setSubCategory(selectedGn);
	checkCategory();
	initPopup();
	setFontS();
}
