// JavaScript Document


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//     Sub Window
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//Sub Window
//window.name="sub";
window.focus();
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//     Sub Window New Style
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

function subWin(page1){

	str = navigator.userAgent.toUpperCase();
	str2  = navigator.appName.toUpperCase();
	if (str.indexOf("MAC") >= 0 && str2.indexOf("MICROSOFT") >= 0) {
		WinW=700;
	} 
	else {
		WinW=716;
	}
	sub1=window.open(page1,"sub","resizable=yes,menubar=yes,directories=no,scrollbars=yes,status=no,location=no,width="+WinW+",height=500");
	window.sub1.focus();
}

function mainWin(page2){

	main1=window.open(page2,"hoshinoya","");
	window.main1.focus();
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//     Roll Over
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

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) 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);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
//     Page Scroll
//
//+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

//For Page Top
function scroller(ps){
		scroller_up(ps,500);
}
	
function scroller_up(ps,y){
	y = y + (ps - y)*.1;
	window.scroll(0,y);
	if (((ps - y) <= .5)&&((ps - y) >= -.5))
	{					
		y = ps;
	}else{
		setTimeout("scroller_up("+ps+","+y+")",1);
	}
}

//For Ancor Link of Page
var eventTimer;	//Timer variant number
var restScroll=0;	//Rest amount of Scroll

function Scroll(base,move){

	//
	var obj_base  = getElemPosition(base);

	//
	var elem_move = document.getElementById(move);
	var obj_move  = getElemPosition(elem_move);

	restScroll = obj_move.y-obj_base.y;
	eventTimer = setInterval(setScrollPosition,10);
}
//Process for Scroll
function setScrollPosition() {

	var moveValue=0;

	//
	//
	if(Math.abs(restScroll)>80){
		moveValue = (restScroll>0)?20:-20;
	}else{
		moveValue = Math.round(restScroll/4);
	}
	//
	parent.scrollBy(0,moveValue);

	//
	restScroll = (restScroll>0)?restScroll-moveValue:restScroll-moveValue;

	if(moveValue==0){
		clearInterval(eventTimer);
		restScroll=0;
	}
}

//
function getElemPosition(elem) {
	var obj = new Object();
	obj.x = elem.offsetLeft;
	obj.y = elem.offsetTop;

	//
	while(elem.offsetParent) {
		elem = elem.offsetParent;
		obj.x += elem.offsetLeft;
		obj.y += elem.offsetTop;
	}
	return obj;
}