//オープンウィンドウ
var Newwin=null;
function op_win(wi,he,s_data) {
Newwin = window.open(s_data, "sub_win", "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,width="+wi+",height="+he);
}
var Newwin=null;
function op_win2(wi,he,s_data) {
Newwin = window.open(s_data, "sub_win", "toolbar=1,location=0,directories=0,status=0,menubar=1,scrollbars=1,resizable=1,width="+wi+",height="+he);
}

/*htmlへのリンクの張り方

1.記述形式　<a href="javascript:op_win('630','500','○○.html');">○○○○</a>
　・op_winは上記のfunctionで定義した名前。任意
　・630および500はウィンドウサイズ（メニューバーやスクロールなど全て含んだサイズ）。任意。
　・○○.htmlはウィンドウ内に呼び出すhtmlのアドレス。任意
*/


//スワップ
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];}
}


// スクロール
var bAgent = navigator.userAgent;
var bName = navigator.appName;
var bPlugins = navigator.plugins;
var d = document;
	
function sniffer(){
	/*OS*/
	this.Win = bAgent.indexOf("Win",0) != -1 ? 1 :0;
	this.Mac = bAgent.indexOf("Mac",0) != -1 ? 1 :0;
	this.MacOSX = ((bAgent.indexOf("Mozilla") != -1) && (bAgent.indexOf("Mac OS X") != -1)) ? 1 :0;
	if(bPlugins){for(i=0;i<bPlugins.length;i++){if(this.Mac && (bPlugins[i].filename.indexOf("QuickTime Plugin.plugin")!=-1)){this.MacOSX=true;}}}
	/*Browser*/
	this.IE = ((bAgent.indexOf("MSIE") != -1) && (bAgent.indexOf("Opera") == -1)) ? 1 :0;
	this.NS = ((bName == "Netscape") && (bAgent.indexOf("Opera") == -1)) ? 1 :0;
	this.NC = ((bName == "Netscape") && (bAgent.indexOf("Gecko") == -1) && (bAgent.indexOf("Opera") == -1)) ? 1 :0;
	this.Moz = ((bAgent.indexOf("Gecko") != -1) && (bAgent.indexOf("Safari",0) == -1)) ? 1 :0;
	this.OPERA = bAgent.indexOf("Opera",0) != -1 ? 1 :0;
	this.SAFARI = bAgent.indexOf("Safari",0) != -1 ? 1 :0;
	this.ICAB = bAgent.indexOf("iCab",0) != -1 ? 1 :0;
	this.IE3 = (bAgent.indexOf('MSIE 3.',0) != -1);
	this.MacIE4 = (this.Mac && (bAgent.indexOf('MSIE 4.',0) != -1));
	this.MacIE45 = (this.Mac && (bAgent.indexOf('MSIE 4.5',0) != -1));
	this.MacIE5 = (this.Mac && (bAgent.indexOf('MSIE 5.',0) != -1));
	this.NS60 = (bAgent.indexOf("Netscape6/6.0") != -1);
	this.NS6 = (bAgent.indexOf("Netscape6/") != -1);
	this.NS7 = (bAgent.indexOf("Netscape/7") != -1);
	
	/*Object*/
	/*NS4 = 1, IE4 = 2, IE5+,OPERA5,7 = 3, NS6+,SAFARI,OPERA6 = 4, others = 0*/
	this.checkObj = d.all?(d.getElementById?3:2):(d.getElementById?4:(d.layers?1:0));
	this.allObj = ((this.checkObj == 1) || (this.checkObj == 2) || (this.checkObj == 3) || (this.checkObj == 4));
	this.checkObj4 = (d.getElementById && !d.all) ? 1 :0;
	this.checkObj3 = (d.getElementById && d.all) ? 1 :0;
	this.checkObj2 = (d.all && !d.getElementById) ? 1 :0;
	this.checkObj1 = d.layers ? 1 :0;
		
	/*Compat Mode*/
	this.modeStandard = d.compatMode == "CSS1Compat" ? 1 : 0;
	this.modeQuirks = d.compatMode == "BackCompat" ? 1 : 0;
	this.WinIE6s = (this.Win && this.IE && this.modeStandard && (bAgent.indexOf('MSIE 6.',0) != -1));
	this.WinIE6q = (this.Win && this.IE &&this. modeQuirks && (bAgent.indexOf('MSIE 6.',0) != -1));
		
	return this;
}
var usr = new sniffer;

function getWindowWidth(){
	if(usr.WinIE6s){
		return d.documentElement.clientWidth;
	}else if(usr.Mac && (usr.checkObj == 1 || usr.OPERA)){
		return window.innerWidth;
	}else if(usr.Win && usr.checkObj == 1){
		return window.innerWidth - 16;
	}else if(usr.checkObj == 4){
		return window.innerWidth - 15;
	}else if(usr.OPERA || usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.clientWidth;
	}
}

function getWindowHeight(){
	if(usr.WinIE6s){
		return d.documentElement.clientHeight;
	}else if(usr.Mac && (usr.checkObj == 1 || usr.OPERA)){
		return window.innerHeight;
	}else if(usr.Win && usr.checkObj == 1){
		return window.innerHeight - 16;
	}else if(usr.checkObj == 4){
		return window.innerHeight - 15;
	}else if(usr.OPERA || usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.clientHeight;
	}
}

function getWindowXOffset(){
	if(usr.WinIE6s || usr.modeStandard){
		return d.body.parentNode.scrollLeft;
	}else if(usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.scrollLeft;
	}else if(usr.checkObj == 1 || usr.checkObj == 4){
		return window.pageXOffset;
	}
}

function getWindowYOffset(){
	if(usr.WinIE6s || usr.modeStandard){
		return d.body.parentNode.scrollTop;
	}else if(usr.checkObj == 2 || usr.checkObj == 3){
		return d.body.scrollTop;
	}else if(usr.checkObj == 1 || usr.checkObj == 4){
		return window.pageYOffset;
	}
}

function getDocWidth(){
	if(usr.allObj){
		return getTagLeft('end') + 1;
	}
}

function getDocHeight(){
	if(usr.allObj){
		return getTagTop('end') + 1;
	}
}

function getDistanceMaxX(){
	if(usr.allObj){
		return (getDocWidth() - getWindowWidth());
	}
}

function getDistanceMaxY(){
	if(usr.allObj){
		return (getDocHeight() - getWindowHeight());
	}
}

function setObj(idName){
	return d.all ? d.all(idName) : d.getElementById ? d.getElementById(idName) : d.layers[idName];
}

function getTagLeft(idName) {
	var obj = setObj(idName);
	var tagCoords = new Object();
	if((usr.checkObj == 2) || (usr.checkObj == 3) || (usr.checkObj == 4)) {
		tagCoords.x = obj.offsetLeft;
		while ((obj = obj.offsetParent) != null) {
			tagCoords.x += obj.offsetLeft;
		}
	} else if(usr.checkObj == 1) {
		tagCoords.x = d.anchors[idName].x;
	}if((tagCoords.x*0)==0){
		return tagCoords.x;
	}else{
		return idName;
	}
}

function getTagTop(idName) {
	var obj = setObj(idName);
	var tagCoords = new Object();
	if((usr.checkObj == 2) || (usr.checkObj == 3) || (usr.checkObj == 4)) {
		tagCoords.y = obj.offsetTop;
		while ((obj = obj.offsetParent) != null) {
			tagCoords.y += obj.offsetTop;
		}
	} else if(usr.checkObj == 1) {
		tagCoords.y = d.anchors[idName].y;
	}if((tagCoords.y*0) == 0){
		if(usr.Mac && usr.Moz){
			return (tagCoords.y - 12);
		}else if((usr.Win && usr.Moz) || (usr.Mac && usr.SAFARI)){
			return (tagCoords.y - 9);
		}else{
			return (tagCoords.y);
		}
	}else{
		return idName;
	}
}

/*PageScroller*/
var pageScrollTimer;
function pageScroll(toX,toY,frms,frX,frY) {
	if(pageScrollTimer) clearTimeout(pageScrollTimer);
	var spd = usr.Moz?2:usr.Mac ? 14 :16;
	var actX = getWindowXOffset();
	var actY = getWindowYOffset();
	if(!toX || toX < 0) toX = 0;
	if(!toY || toY < 0) toY = 0;
	if(!frms) frms = (usr.Mac&&(usr.OPERA||usr.NS6))?3:usr.NS6?4:usr.NS?10:5;
	if(!frX) frX = 0 + actX;
	if(!frY) frY = 0 + actY;
	frX += (toX - actX) / frms;
	if (frX < 0) frX = 0;
	frY += (toY - actY) / frms;
	if (frY < 0) frY = 0;
	var posX = Math.ceil(frX);
	var posY = Math.ceil(frY);
	window.scrollTo(posX, posY);
	if((Math.floor(Math.abs(actX - toX)) < 1) && (Math.floor(Math.abs(actY - toY)) < 1)){
		clearTimeout(pageScrollTimer);
		window.scroll(toX,toY);
	}else if(posX != toX || posY != toY){
		pageScrollTimer = setTimeout("pageScroll("+toX+","+toY+","+frms+","+frX+","+frY+")",spd);
	}else{
		clearTimeout(pageScrollTimer);
	}
}

function toAnchor(idName,longitudinalAdj,traverser) {
	if(usr.allObj){
		if(!!idName){
			var anchorX = traverser ? getTagLeft(idName) : 0;
			var anchorY = longitudinalAdj? getTagTop(idName)-longitudinalAdj : getTagTop(idName)-20;
			var dMaxX = getDistanceMaxX();
			var dMaxY = getDistanceMaxY();
			if(((anchorX*0) == 0)||((anchorY*0) == 0)){
				var setX = (anchorX<1)?0:(anchorX>dMaxX)?dMaxX:anchorX;
				var setY = (anchorY<1)?0:(anchorY>dMaxY)?dMaxY:anchorY;
				pageScroll(setX,setY);
			}else{
				location.hash = idName;
			}
		}else{
			pageScroll(0,0);
		}
	}else{
		!!idName ? location.hash = idName : location.hash = "top";
	}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}