/*
   ┏━━━━━━━━━━━━━━━━━━━┓
   ┃     KajiNavi JavaScript File         ┃
   ┃                                      ┃
   ┃     Author : Naoya Ogawa             ┃
   ┃     Version: 1.0 ( 15 Dec 2004 )     ┃
   ┗━━━━━━━━━━━━━━━━━━━┛
*/






// ########## Delete Error Message
// ########## 2003.08.09
function HideError(){
	return true;
}
//window.onerror = HideError;





// ########## OS,Browser Info
// ########## 2003.08.09
var ua  = navigator.userAgent.toLowerCase();
var mie = (navigator.appName.indexOf('Micr') != -1);
var ns4 = (document.layers);
var opr = (navigator.userAgent.indexOf("Opera") != -1);
var gck = (navigator.userAgent.indexOf("Gecko") != -1);
var mac = (ua.indexOf('mac') != -1);
var win = (ua.indexOf('win') != -1);





// ########## Netscape 4.x Reload Bug Patch
// ########## 2003.08.09
function N4_Reload(init) {
	if (init==true) with (navigator) {
		if (ns4) {
			document.N4_pgW = innerWidth;
			document.N4_pgH = innerHeight;
			onresize = N4_Reload;
		}
	} else if (innerWidth != document.N4_pgW || innerHeight != document.N4_pgH) location.reload();
}
N4_Reload(true);





// ########## images PreLoad
// ########## 2003.08.09
function PreLoad() {
	var d = document;
	if(d.images){
		if(!d.My_IMG) d.My_IMG = new Array();
		var i , j = d.My_IMG.length , a = PreLoad.arguments;
		for(i=0; i<a.length; i++) if (a[i].indexOf("#")!=0){
			d.My_IMG[j] = new Image;
			d.My_IMG[j++].src = a[i];
		}
	}
}





// ########## Get Object
// ########## 2003.08.09
function GetObj(n, d) {
	var p,i,x;
	if(!d) d = document;
	if((p=n.indexOf("?"))>0&&parent.frames.length) {
		d = parent.frames[n.substring(p+1)].document;
		n = n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x = d.all[n];
	for(i=0; !x&&i<d.forms.length; i++) x = d.forms[i][n];
	for(i=0; !x&&d.layers&&i<d.layers.length; i++) x = GetObj(n,d.layers[i].document);
	if(!x && document.getElementById) x = document.getElementById(n);
	return x;
}





// ########## Swap image
// ########## 2003.08.09
function ChgIMG() {
	var i , j = 0 , x , a = ChgIMG.arguments;
	document.My_sr = new Array;
	for(i=0; i<(a.length-2); i+=3) if ((x=GetObj(a[i]))!=null){
		document.My_sr[j++] = x;
		if(!x.oSrc) x.oSrc = x.src;
		x.src = a[i+2];
	}
}





// ########## Reset image
// ########## 2003.08.09
function ResetIMG() {
	var i , x , a = document.My_sr;
	for(i=0; a&&i<a.length&&(x=a[i])&&x.oSrc; i++) x.src = x.oSrc;
}





// ########## PullDown Menu Link
// ########## 2003.08.09
function JumpMenu(targ,selObj,restore){
	JumpLink = selObj.options[selObj.selectedIndex].value;
	if(JumpLink != "-"){
		if((JumpLink.indexOf('http:')== 0)||(JumpLink.indexOf('https:')== 0)){
			window.open(JumpLink,'_blank');
		}else{
			eval(targ + ".location='" + JumpLink + "'");
		}
	}
	if (restore) selObj.selectedIndex = 0;
}





// ########## Sub Window Open
// ########## 2003.08.09
function WinOpen(URL,WN,F) {
	if(sbwin_closed(window.WN)){
		newwin = window.open(URL,WN,F);
		newwin.focus();
	}else{
		newwin.location.href = URL;
		newwin.focus();
	}
}
function sbwin_closed(winVar) {
	var ua = navigator.userAgent;
	if( !!winVar ){
		if( gck || ( ua.indexOf('MSIE 4')!=-1 && ua.indexOf('Win')!=-1 ) ) return winVar.closed;
		else return typeof winVar.document != 'object';
	}else return true;
}






// ########## Switch Layer
// ########## 2003.08.09
function SHLayer() {
	var i,p,v,obj,args = SHLayer.arguments;
	for (i=0; i<(args.length-2); i+=3) if ((obj=GetObj(args[i]))!=null) {
		v = args[i+2];
		if (obj.style) {
			obj = obj.style;
			v = (v=='show')?'visible':(v=='hide')?'hidden':v;
		}
		obj.visibility=v;
	}
}



// ########## Page Top Scroll
// ########## 2003.08.09
function getScroll(){
	var x, y;
	if(mie){
		x = document.body.scrollLeft;
		y = document.body.scrollTop;
	}else if(document.layers !== void 0 || (navigator.userAgent.indexOf("Opera") !== -1 || window.opera !== void 0)){
		x = window.pageXOffset;
		y = window.pageYOffset;
	}else if(navigator.userAgent.indexOf("Gecko") != -1){
		x = window.scrollX;
		y = window.scrollY;
	}else{
		x = y = 0;
	}
	return {x: x, y: y};
}
var SCROLL ;
var divCountScroller = 50 ;
function scroller( x, y, edging, count ){
	if( count === void 0 ){
		count = 0 ;
		SCROLL = getScroll();
	}
	if( count++ < divCountScroller ){
		var c = count/divCountScroller ;
		var nx = SCROLL.x+( x-SCROLL.x )*( c+edging/(100*Math.PI)*Math.sin( Math.PI*c ) );
		var ny = SCROLL.y+( y-SCROLL.y )*( c+edging/(100*Math.PI)*Math.sin( Math.PI*c ) );
		window.scrollTo( nx, ny );
		setTimeout( "scroller("+x+","+y+","+edging+","+count+");", 1 );
	}
}



// E N D

