﻿/*
##################################################
#This javascript was made on January 31, 2003.
#It is responsible for a MEDAL Co,Ltd.
#Responsibility is not taken although use is free.
##################################################
#nn4 reload & window resize bugfix
#reloads the window if Netscape4x resized.
#copyright macromedia.Co, Ltd.
##################################################
*/

function MM_reloadPage(init){
	if( init==true ){
		with( navigator ){
			if(( appName.charAt(0)=="N" )&&( parseInt(appVersion)<=4 )){
				document.MM_pgW=innerWidth;
				document.MM_pgH=innerHeight;
				window.onresize = MM_reloadPage; 
			}
		}
	}else if((innerWidth!=document.MM_pgW)||(innerHeight!=document.MM_pgH)) location.reload();
}

MM_reloadPage(true);


function MM_showHideLayers(){ //v6.0
	var i, p, v, obj;
	var args = MM_showHideLayers.arguments;

	for (i=0; i<(args.length-2); i+=3){
		if(( obj = MM_findObj(args[i])) != null){
			v = args[i+2];
			if( obj.style ){
				obj = obj.style;
				v = (v == 'show')?'visible':(v == 'hide')?'hidden':v;
			}
			obj.visibility = v;
		}
	}

}

function MM_findObj( n, d ){ //v4.01
	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){ //ie4 lower or ie5up
		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 = MM_findObj( n, d.layers[i].document ); //ns4 lower
	}

	if(!x && d.getElementById) x=d.getElementById(n); //ie5up or ns6up

	return x;
}


/*
###################################
#menu pushbutton script
###################################
*/
function newImage(arg) {
	if (document.images) {
		rslt = new Image();
		rslt.src = arg;

		return rslt;
	}
}

function changeImages() {
	if (document.images && (preloadFlag == true)) {
		for (var i=0; i<changeImages.arguments.length; i+=2) {
			document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
			//alert(changeImages.arguments[i+1]);
		}
	}
}

var preloadFlag = false;

function preloadImages( imgpath ) {
	var imageList = new Array();

	if (document.images) {
		//preload images
		imageList[0] = "";
		
		//home-item
		imageList[imageList.length++] = newImage(imgpath+"");

		preloadFlag = true;
	}
}


/*
###################################################################
#open window method
#The value of the argument of windowSize is 'width=***,height=***'
#features is  [ true | false | Array ]
###################################################################
*/
function WindowFeaturesItem( foption ){ //features option.
	var wf = "";
	wf = "toolbar=" + (foption[0] ? "yes" : "no");
	wf += ",location=" + (foption[1] ? "yes" : "no");
	wf += ",directories=" + (foption[2] ? "yes" : "no");
	wf += ",status=" + (foption[3] ? "yes" : "no");
	wf += ",menubar=" + (foption[4] ? "yes" : "no");
	wf += ",scrollbars=" + (foption[5] ? "yes" : "no");
	wf += ",resizable=" + (foption[6] ? "yes" : "no");

	return wf;
}


function openWin( theUrl, windowName, features, windowSize, x, y ){
	var is = new Is_env();

	// windowhight is adjusted at the time of Mac ie4.5.
	if( is.MAC && is.IE && is.IE45 ) var adjusth = 2;
	else var adjusth = 0;
	
	var H = parseInt( windowSize.substring(17,20)) + adjusth;
	var winSize = new String( windowSize.substring(0,17) + H ); //String constructor is set up.
	
	if((features==true)||(features==false)){
		var f = new Array();
		for(i=0; i<7; i++){
			f[i] = features;
		}
		var wfeatures = WindowFeaturesItem(f);
	}else{
		var wfeatures = WindowFeaturesItem( features ); //window features setting.
		//alert( wfeatures );
	}

	// It arranges it at the center.
	//var x = parseInt((screen.width - parseInt( windowSize.substring(6,9) )) / 2);
	var y = parseInt((screen.height - H) / 2);

	var windowPosition = ( ",top=" + x + ",left=" + y );
	wfeatures += ( "," + winSize + windowPosition );
	//alert( wfeatures );

	new_window = window.open( theUrl, windowName, wfeatures ); //window open method.
	new_window.focus();
	//new_window.moveTo( x, y );
}

function openResizeWin(w,h,x,y) {
	window.resizeTo(w,h);
	window.moveTo(x,y);
}

function ShowLargeImgWin( path, imgName, imgW, imgH, features, x, y, altTitle ){
	if((features==true)||(features==false)){
		var f = new Array();
		for(i=0; i<7; i++){
			f[i] = features;
		}
		var wfeatures = WindowFeaturesItem(f);
	}else{
		var wfeatures = WindowFeaturesItem( features ); //window features setting.
		//alert( wfeatures );
	}

	//var x = parseInt((screen.width - imgW) / 2);
	var y = parseInt(( screen.height - imgH ) / 2);
	var windowPosition = ( ",top=" + x + ",left=" + y );
	var newfeatures = '"'+ wfeatures +',width='+ imgW +',height='+ imgH + windowPosition +'"';
	//alert(newfeatures);

	//var windowSize = 'width='+imgW+',height='+imgH;
	//newWindow = openWin( "", "newSubWindow", false, windowSize, 0, 0 );

	newSubWindow = window.open( "", "SUB_WIN", newfeatures );
	newSubWindow.document.open("text/html");
	newSubWindow.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">\n');
	newSubWindow.document.write('<html lang="ja" dir="ltr">\n');
	newSubWindow.document.write('<head>\n');
	newSubWindow.document.write('<meta http-equiv="Content-Language" content="ja" />\n');
	newSubWindow.document.write('<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />\n');
	newSubWindow.document.write('<meta http-equiv="Content-Style-Type" content="text/css" />\n');
	newSubWindow.document.write('<meta http-equiv="Content-Script-Type" content="text/javascript" />\n');
	newSubWindow.document.write('<meta http-equiv="imagetoolbar" content="no" />\n');
	newSubWindow.document.write('<title>'+ altTitle +'</title>\n');
	newSubWindow.document.write('<script language="JavaScript" type="text/javascript" src="'+ path +'js/default.js"></script>\n');
	newSubWindow.document.write('<script language="JavaScript" type="text/javascript" src="'+ path +'js/base.js"></script>\n');
	newSubWindow.document.write('</head>\n');
	newSubWindow.document.write('<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginheight="0" marginwidth="0" onBlur="self.closeWin();" onClick="self.closeWin(); return false;">\n');
	newSubWindow.document.write('<div id="Largeimage">\n');
	newSubWindow.document.write('<img src="'+ path + imgName +'" width="'+ imgW +'" height="'+ imgH +'" alt="'+ altTitle +'" title="'+ altTitle +'" />\n');
	newSubWindow.document.write('</div>\n');
	newSubWindow.document.write('</body>\n');
	newSubWindow.document.write('</html>');
	newSubWindow.document.close();
	newSubWindow.focus();
}



/*
#################################
#closed window method
#################################
*/
function onErrMacWinClose(){
	closeWin();
	return true;
}

function closeWin(){
	var is = new Is_env();

	if( is.MAC && is.IE4X ) window.onerror = onErrMacWinClose;
	if( !this.closed ) this.close();
}

/*
##################################################
#The size of the parents window is acquired and
#it reflects it in the child window.
##################################################
*/
/* GET WINDOW SIZE METHOD */
function getWindowWidth(){
	if(window.innerWidth){
		return window.innerWidth;
	}else if(document.documentElement && document.documentElement.clientWidth){
		return document.documentElement.clientWidth;
	}else if ( document.body && document.body.clientWidth){
		return document.body.clientWidth;
	}
}

function getWindowHeight(){
	if(window.innerHeight){
		return window.innerHeight;
	}else if(document.documentElement && document.documentElement.clientHeight){
		return document.documentElement.clientHeight;
	}else if ( document.body && document.body.clientHeight){
		return document.body.clientHeight;
	}
}

/* RESIZE WINDOW METHOD */
function checkWindowSize(pram, w, h) {
	var sizeObj = new Object();
	if(pram=="WH"){
		sizeObj.width = getWindowWidth();
		sizeObj.height = getWindowHeight();
	}else if(pram=="W"){
		sizeObj.width = w;
		sizeObj.height = getWindowHeight();
	}else if(pram=="H"){
		sizeObj.width = getWindowWidth();
		sizeObj.height = h;
	}
	//alert(sizeObj);

	return sizeObj;
}

function focusWin(theUrl, windowName, pram, w, h, features) {
	if((w == null) || (w == "undefined") || (w == '')) w = 640;
	if((h == null) || (h == "undefined") || (h == '')) h = 480;
	var size = checkWindowSize(pram, w, h);
	openWin( theUrl, windowName, features, 'width='+size.width+',height='+size.height, 0, 0 );
}

/*
##################################################
#The main window is operated. method
##################################################
*/
function dispWin(theUrl, windowName, features, w, h){
	if(window.opener || !window.opener.closed){
		window.opener.location.href = theUrl;
	}else{
		openWin( theUrl, windowName, features, 'width='+w+',height='+h, 0, 0 );
	}
}


/*
##################################################
#The script for branching Windows IE..
#In this case, the file of VBScript.
##################################################
*/

function check_vbscript( path ){
	var is = new Is_env();
	document.open("text/html");
	if(is.WIN && document.all && !is.OPERA){
		document.write('<script language="VBScript" type="text/VBScript" src="'+path+'js/flashCheck.vbs"></scr'+'ipt>');
	}
	document.close();
}


function load_lightWindow( path ) {
	document.open("text/html");
	document.write('<script type="text/javascript" src="'+path+'js/prototype.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/scriptaculous.js?load=effects"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/effects.js"></script>');
	document.write('<script type="text/javascript" src="'+path+'js/lightwindow.js"></script>');
	document.close();
}

/*
#########################################################################
#scroll potion method.
#ex.JavaScript:doPageScroll('up', -100) or doPageScroll('down', 500)
#########################################################################
*/
function doScroller( action, pram ){
	if (action == 'up'){ //scroll up action
		if (pram == screen.availHeight) var y = 0;
		else var y = 1000;

		y = y +(pram - y)*.1;
		while(y != pram){
			window.scroll(0, y);
			y = y + (pram - y)*.1;
			//window.status = "pram is : " +pram+ ", Y is : " +y;
			if (((pram - y) <= .5)&&((pram - y) >= -.5)) y = pram;
		}
	}else if (action == 'down'){ //scroll down action1
		y = 1;
		boundary = pram*.5;

		while(y <= boundary){
			window.scroll(0, y);
			y = y +(y*.3);
			if (((boundary - y) <= .5)&&((boundary - y) >= -.5)) y = boundary;
		}

		while(y != pram){
			window.scroll(0, y);
			y = y +(pram - y)*.1;
			if (((pram - y) <= .5)&&((pram - y) >= -.5)) y = pram;
		}
	}else{ //scroll down action2
		y = 0;
		y = y +(pram - y)*.1;

		while(y != pram){
			window.scroll(0, y);
			y = y +(pram-y)*.1;
			if (((pram - y) <= .5)&&((pram - y) >= -.5)) y = pram;
		}
	}
}

/*
######################################################################
#Side Scroll Page method
#<a href="javascript: slidePageTo(500)"></a>
#<a href="javascript: slidePageBy(300)"></a>
#<a href="javascript: slidePageBy(-300)"></a>
######################################################################
*/
var moveID = false;
var pos = 0;

function slideMe_left(n) {
	pos += Math.ceil((n-pos)*0.07);
	self.scroll(pos,0);
	if ((n-pos) <= 1) {
		pos = n;
		self.scroll(n,0);
		clearTimeout(moveID);
		moveID = false;
		return;
	}
	moveID = setTimeout("slideMe_left(" + n + ")",0);
}

function slideMe_right(n) {
	pos -= Math.ceil((pos-n)*0.07);
	self.scroll(pos,0);
	if (Math.abs(n-pos) <= 1) {
		pos = n;
		self.scroll(n,0);
		clearTimeout(moveID);
		moveID = false;
		return;
	}
	moveID = setTimeout("slideMe_right(" + n + ")",0);
}

function slidePageTo(n) {
	if(!moveID) {
		var d = (n>pos)? "left" : "right";
		var f ="slideMe_"+ d +"(" + n + ")";
		moveID = setTimeout(f,0);
	}
}

function slidePageBy(n) {
	if(!moveID) {
		var d = (n>0)? "left" : "right";
		var f ="slideMe_"+ d +"(" + (pos+n) + ")";
		moveID = setTimeout(f,0);
	}
}
