
var Mac = navigator.appVersion.indexOf('Mac',0) != -1;
var Win = navigator.appVersion.indexOf('Win',0) != -1;
var IE  = navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1;
var NN  = navigator.appName.indexOf("Netscape",0) != -1;
var Moz = navigator.userAgent.indexOf("Gecko") != -1;
var Vmajor = parseInt(navigator.appVersion);
var Vminor = parseFloat(navigator.appVersion);

var MacIE4 = ((Mac && navigator.appVersion.indexOf('MSIE 4.',0) != -1));
var MacIE3 = ((Mac && navigator.appVersion.indexOf('MSIE 3.',0) != -1));


function setObj(id) {
	if (document.all) {
		return document.all(id);
	} else if (document.getElementById) {
		return document.getElementById(id);
	} else if (document.layers) {
		return document.layers[id];
	}
	return false;
}

function gtScL01() {
	if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {
		return document.body.scrollLeft;
	} else if (window.pageXOffset) {
		return window.pageXOffset;
	} else {
		return 0;
	}
}

function gtScT01() {
	if ((navigator.appName.indexOf("Microsoft Internet Explorer",0) != -1)) {
		return document.body.scrollTop;
	} else if (window.pageYOffset) {
		return window.pageYOffset;
	} else {
		return 0;
	}
}


// to page top
var pgScTim01;
function pgSc01(toX,toY,frms,cuX,cuY) {
	if (pgScTim01) clearTimeout(pgScTim01);
	if (!toX || toX < 0) toX = 0;
	if (!toY || toY < 0) toY = 0;
	if (!cuX) cuX = 0 + gtScL01();
	if (!cuY) cuY = 0 + gtScT01();
	if (!frms) frms = 6;

	if (toY > cuY && toY > (gtAncPo01('end','enddiv').y) - gtInSz01().height)
		toY = (gtAncPo01('end','enddiv').y - gtInSz01().height) + 1;
		cuX += (toX - gtScL01()) / frms; if (cuX < 0) cuX = 0;
		cuY += (toY - gtScT01()) / frms;  if (cuY < 0) cuY = 0;
		var posX = Math.floor(cuX);
		var posY = Math.floor(cuY);
		window.scrollTo(posX, posY);

	if (posX != toX || posY != toY) {
		pgScTim01 = setTimeout("pgSc01("+toX+","+toY+","+frms+","+cuX+","+cuY+")",16);
	}
}

function pgTopScl01() {
	pgSc01(0,0,5);
}

function gtInSz01() {
	var obj = new Object();
	if (document.all || (document.getElementById && IE)) {
		obj.width = document.body.clientWidth;
		obj.height = document.body.clientHeight;
	} else if (document.layers || (document.getElementById && Moz)) {
		obj.width = window.innerWidth;
		obj.height = window.innerHeight;
	}
	return obj;
}

function gtAncPo01(elementname, elementid) {
 var obj = setObj(elementname);
 var objnew = new Object();
 var objtmp;

 if (document.getElementById && IE) {
  objtmp = obj;
  objnew.x = objtmp.offsetLeft;
  objnew.y = objtmp.offsetTop;
  while ((objtmp = objtmp.offsetParent) != null) {
   objnew.x += objtmp.offsetLeft;
   objnew.y += objtmp.offsetTop;
  }
 } else if (document.getElementById && Moz) {
//  objnew.x = document.getElementsByTagName("A").namedItem(elementname).offsetLeft;
//  objnew.y = document.getElementsByTagName("A").namedItem(elementname).offsetTop;
  objnew.x = document.getElementsByTagName("DIV").namedItem(elementid).offsetLeft;
  objnew.y = document.getElementsByTagName("DIV").namedItem(elementid).offsetTop;
 } else if (document.all) {
  objtmp = obj;
  objnew.x = objtmp.offsetLeft;
  objnew.y = objtmp.offsetTop;
  while ((objtmp = objtmp.offsetParent) != null) {
   objnew.x += objtmp.offsetLeft;
   objnew.y += objtmp.offsetTop;
  }
 } else if (document.layers) {
  objnew.x = document.anchors[elementname].x;
  objnew.y = document.anchors[elementname].y;
 } else {
  objnew.x = 0;
  objnew.y = 0;
 }
 return objnew;
}


// flash plug-in checker
var actX = searchActiveX("ShockwaveFlash.ShockwaveFlash.7");
var plug = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 7",2);

/* Netscape style plugin */
function searchPluginsNN(mineType,strSearch,searchType){
var enabled = false;
var result = false;
var strPlg;
var spObj;
	if(!(navigator.plugins && navigator.mimeTypes && navigator.mimeTypes[mineType])) return result;
	if(window.opera && !document.plugins){
	// Enabled Plugin Non supported (Opera 6 Under ...)
		enabled = true;
	}else if(navigator.mimeTypes[mineType].enabledPlugin){
		enabled = true;
	}
	if(strSearch != '' && enabled){
		if(searchType == 3) strSearch = strSearch.toLowerCase();
		for(i=0;i<navigator.plugins.length;i++){
			spObj = navigator.plugins[i];
			strPlg = ((searchType == 3) ? spObj.filename.toLowerCase() : ((searchType == 2) ? spObj.description : ((searchType == 1) ? spObj.name : "")));
			if(strPlg.indexOf(strSearch) != -1){
				//document.write('<strong>'+strPlg+' ['+mineType+']<\/strong><br />');
				result = true; break;
			//}else{
				//document.write(spObj.name+'('+strPlg+')<br />');
			}
	 	}
	}else if(strSearch == '' && enabled){
		result = true;
	}
	return result;
}

/* MSIE ActveX plugin search */
function searchActiveX(ActiveXName){
var result = false;
	if (!window.opera && document.all) {
		/*@cc_on @*/
		/*@if ((@_jscript_version >= 3) && (@_win32 || @_win64))
			document.open();
			document.write('<scr'+'ipt language="VBScript"\>\nOn Error Resume Next\nDim ax\nax=False\nax=(IsObject(CreateObject("'+ActiveXName+'")))\n<\/scr'+'ipt\>\n');
			document.close();
			result = (ax) ? true : false;
			//alert("Now JScript version 3++ ( " + @_jscript_version + " )\nax ? = " + ax);
		@else @*/
			//alert("This browser is not Internet Explorer for Win32 or Win64 system");
		/*@end @*/
	}
	return result;
}

function chkpiFls01(nf_url01){
	if ( /* actX09 == 0 && plug09 == 0 && actX08 == 0 && plug08 == 0 && */ actX07 == 0 && plug07 == 0 && actX06 == 0 && plug06 == 0 && actX05 == 0 && actX05 == 0 && actX04 == 0 && actX04 == 0) {
		location.href = nf_url01 ;
	}
}

// var actX09 = searchActiveX("ShockwaveFlash.ShockwaveFlash.9");
// var plug09 = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 9",2);
// var actX08 = searchActiveX("ShockwaveFlash.ShockwaveFlash.8");
// var plug08 = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 8",2);
var actX07 = searchActiveX("ShockwaveFlash.ShockwaveFlash.7");
var plug07 = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 7",2);
var actX06 = searchActiveX("ShockwaveFlash.ShockwaveFlash.6");
var plug06 = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 6",2);
var actX05 = searchActiveX("ShockwaveFlash.ShockwaveFlash.5");
var plug05 = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 5",2);
var actX04 = searchActiveX("ShockwaveFlash.ShockwaveFlash.4");
var plug04 = searchPluginsNN("application\/x-shockwave-flash","Shockwave Flash 4",2);


var newWin;

// sub window
function pWin (wUrl,wName,wProp) {
	newWin = window.open (wUrl,wName,wProp);
	newWin.focus();
}
function pWinGen (wUrl,wName,wScl,wRsz,wWdt,wHgt) {
	newWin = window.open (wUrl,wName,'toolbar=0,location=0,directories=0,status=0,menubar=1,scrollbars=' + wScl + ',resizable=' + wRsz + ',width=' + wWdt + ',height=' + wHgt);
	newWin.focus();
}
function pWinTv (wUrl,wName,wScl,wRsz,wWdt,wHgt) {
	newWin = window.open (wUrl,wName,'toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=' + wScl + ',resizable=' + wRsz + ',width=' + wWdt + ',height=' + wHgt);
	newWin.focus();
}

function OpenWindowYume(file) {
	var w_size = 900;
	var h_size = 650;

	var l_position=Number((window.screen.width-w_size)/2);
	var t_position=Number((window.screen.height-h_size)/2);
	var options="";
	options = "toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=no,width="+w_size+",height="+h_size+",left="+l_position+",top="+t_position;

	window.open(file,"yume",options);
}

function pWinLg90(wUrl) {
	var options="";
	options="toolbar=0,location=0,status=0,menubar=0,scrollbars=0, width="+screen.width+", height="+screen.height;
	lsg90=window.open(wUrl,"lossguard90",options);
	lsg90.moveTo(0, 0);
}

function lossguard90_open() {
	var options="";
	options="toolbar=0,location=0,status=0,menubar=0,scrollbars=0, width="+screen.width+", height="+screen.height;
	lsg90=window.open("/news/lossguard/index.html","lossguard90",options);
	lsg90.moveTo(0, 0);
}

function icube_open(wUrl) {
	var options="";
	options="toolbar=0,location=0,status=0,menubar=0,scrollbars=1,resizable=1, width="+screen.width+", height="+screen.height;
	icube=window.open(wUrl,"icube",options);
	icube.moveTo(0, 0);
}


// rollover
function chImg(name,num){
	if (document.images) document.images[name].src = imgTo[num].src;
}


// pulldown link
function plLnk(lngFm,lngLnk){
	elm = document.lngFm.lngLnk;
	lnkUrl = elm.options[elm.options.selectedIndex].value;
	location.href = lnkUrl;
}

function plLnk2(elm){
	with (document.forms[0])
	{
		lnkUrl = elm.options[elm.options.selectedIndex].value;
		document.body.focus();
		if (lnkUrl.length>0)
			location.href = lnkUrl
		else
			elm.options.selectedIndex = 0;
	}
}


// top page random image
var l = 3;
var displayImg = Math.floor(Math.random() * l);

function randomImg(){
	document.write('<img src="' + bgImgs[displayImg] + '" alt="Style for the 21st century" width="27" height="201">');
}

function randomImg2(){
	document.write('<img src="' + bgImgs[displayImg + 3] + '" alt="Style for the 21st century" width="597" height="201">');
}


// css bg rollover
function chnStl01 (name,num) {
	if ( document.all ) {
		document.all(name).style.backgroundImage='url(' + imgTo[num].src + ')';
	} else if ( document.getElementById ) {
		document.getElementById(name).style.backgroundImage='url(' + imgTo[num].src + ')';
	}
}

function openDir(form) {
	var newIndex = form.fieldname.selectedIndex;
	if ( newIndex == 0 ) {
//		alert( "Please select a location!" );
	} else {
		cururl = form.fieldname.options[ newIndex ].value;
		window.location.assign(cururl);
	}
}


// naming parent window
function nWin01(){
	window.name = "win_master01";
}

function nWin02(){
	window.name = "win_topic02";
}

// naming parent window with any name
function nWin_cus(wName){
	window.name = wName;
}



// layer control
function chnLyr01(layNam,html){
	if(document.getElementById){
		document.getElementById(layNam).innerHTML=html;
	} else if(document.all){
		document.all(layNam).innerHTML=html;
	} else if(document.layers) {
		with(document.layers[layNam].document){
			open();
			write(html);
			close();
		}
	}
}

// search
function SearchQuery() {
	var Input = document.getElementById('search_ipt');
	if ( Input.value == '') { alert("検索内容を入力してください"); }
	else{	
		document.f1.submit();
	}
}

