/* ===============================================
	ID存在チェック
=============================================== */
	function checkLayerId(id){
		if(document.all || document.getElementById){
			if(document.all){
				if( document.all(id) != null ){
					return true;
				}
			} else if(document.getElementById){
				if( document.getElementById(id) != null ){
					return true;
				}
			}
		}
		return null;
	}

/* ===============================================
	ID存在数チェック
=============================================== */
	function getLayerNum(id){
		var num = 0;
		var idN = id + '1';
		for( i=1 ; checkLayerId(idN) != null ; i++ ){
			idN = id + i;
			num++;
		}
		num--;
		return num;
	}

/* ===============================================
	レイヤーの表示形式を変更
=============================================== */
	function changeLayerDisplay(id,dis){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).style.display = dis;
			} else if(document.getElementById){
				document.getElementById(id).style.display = dis;
			}
		}
	}
	function LayerDisplay(id){
		if(document.all || document.getElementById){
			if(document.all){
				if(document.all(id).style.display == "none"){
					document.all(id).style.display = "block";
				} else {
					document.all(id).style.display = "none";
				}
			} else if(document.getElementById){
				if(document.getElementById(id).style.display == "none"){
					document.getElementById(id).style.display = "block";
				} else {
					document.getElementById(id).style.display = "none";
				}
			}
		}
	}
	function LayerDisplayInForm(id){
		if(document.all || document.getElementById){
			if(document.all){
				if(document.all(id).style.display == "none"){
					document.all(id).style.display = "block";
					if( ie6Check() == "true" ) setSelectDis("none");
				} else {
					document.all(id).style.display = "none";
					if( ie6Check() == "true" ) setSelectDis("inline");
				}
			} else if(document.getElementById){
				if(document.getElementById(id).style.display == "none"){
					document.getElementById(id).style.display = "block";
					if( ie6Check() == "true" ) setSelectDis("none");
				} else {
					document.getElementById(id).style.display = "none";
					if( ie6Check() == "true" ) setSelectDis("inline");
				}
			}
		}
	}
	function setSelectDis(dis){
		var elems = document.getElementsByTagName("select");
		for (i = 0; i < elems.length; i++) {
			elems[i].style.display = dis;
		}
	}

/* ===============================================
	レイヤーの表示形式取得
=============================================== */
	function getLayerDisplay(id){
		if(document.all || document.getElementById){
			if(document.all){
				return document.all(id).style.display;
			} else if(document.getElementById){
				return document.getElementById(id).style.display;
			}
		}
	}

/* ===============================================
	レイヤーの背景色変更
=============================================== */
	function setLayerBackgroundColor(id,c){
		if(document.all || document.getElementById){
			if(document.all){
				document.getElementById(id).style.backgroundColor = c;
			} else if(document.getElementById){
				return document.getElementById(id).style.backgroundColor = c;
			}
		}
	}

//=============================================
// SmartRollOver()
//=============================================
function initRollovers() {
	if (!document.getElementById) return

	var aPreLoad = new Array();
	var sTempSrc;
	var aImages = document.getElementsByTagName('img');

	for (var i = 0; i < aImages.length; i++) {
		if (aImages[i].className == 'ov') {
			var src = aImages[i].getAttribute('src');
			var ftype = src.substring(src.lastIndexOf('.'), src.length);
			var hsrc = src.replace(ftype, '_on'+ftype);

			aImages[i].setAttribute('hsrc', hsrc);

			aPreLoad[i] = new Image();
			aPreLoad[i].src = hsrc;

			aImages[i].onmouseover = function() {
				sTempSrc = this.getAttribute('src');
				this.setAttribute('src', this.getAttribute('hsrc'));
			}	

			aImages[i].onmouseout = function() {
				if (!sTempSrc) sTempSrc = this.getAttribute('src').replace('_on'+ftype, ftype);
				this.setAttribute('src', sTempSrc);
			}
		}
	}
}

//=============================================
// form elements onfocus bgColor
//=============================================
var initFormelEments = {
	setColor : {
		focusColor : "#FFFBBF",
		blurColor  : "#FFFFFF"
	},
	setCName : {
		cName : "ontxt"
	},

	main : function (){
		var i;
		var input    = document.getElementsByTagName("input");
		var textarea = document.getElementsByTagName("textarea");
		var select   = document.getElementsByTagName("select");

		for( i=0 ; i < input.length ; i++ ){
			try {
				input[i].addEventListener('focus', initFormelEments.changeBGFocus, false);
				input[i].addEventListener('blur', initFormelEments.changeBGBlur, false);
			} catch (e) {
				input[i].attachEvent('onfocus', (function(el){return function(){initFormelEments.changeBGFocus.call(el);};})(input[i])); 
				input[i].attachEvent('onblur', (function(el){return function(){initFormelEments.changeBGBlur.call(el);};})(input[i])); 
			}
		}

		for( i=0 ; i < textarea.length ; i++ ){
			try {
				textarea[i].addEventListener('focus', initFormelEments.changeBGFocus, false);
				textarea[i].addEventListener('blur', initFormelEments.changeBGBlur, false);
			} catch (e) {
				textarea[i].attachEvent('onfocus', (function(el){return function(){initFormelEments.changeBGFocus.call(el);};})(textarea[i])); 
				textarea[i].attachEvent('onblur', (function(el){return function(){initFormelEments.changeBGBlur.call(el);};})(textarea[i])); 
			}
		}

		for( i=0 ; i < select.length ; i++ ){
			try {
				select[i].addEventListener('focus', initFormelEments.changeBGFocus, false);
				select[i].addEventListener('blur', initFormelEments.changeBGBlur, false);
			} catch (e) {
				select[i].attachEvent('onfocus', (function(el){return function(){initFormelEments.changeBGFocus.call(el);};})(select[i])); 
				select[i].attachEvent('onblur', (function(el){return function(){initFormelEments.changeBGBlur.call(el);};})(select[i])); 
			}
		}
	},

	changeBGFocus : function(){
		if ( this.className.indexOf(initFormelEments.setCName.cName)  != -1 ) {
			this.style.backgroundColor = initFormelEments.setColor.focusColor;
		}
	},
	changeBGBlur : function(){
		var bColor = "#ffffff";
		if ( this.className.indexOf(initFormelEments.setCName.cName)  != -1 ) {
			this.style.backgroundColor =  initFormelEments.setColor.blurColor;
		}
	},

	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}
initFormelEments.addEvent();

/* ===============================================
	画像差し替え
=============================================== */
	function changeImage(fileName, imageName){
		document.images[imageName].src = fileName;
	}

/* ===============================================
	レイヤーの高さ取得
=============================================== */
	function getLayerHeight(id){
		if(document.all || document.getElementById){
			if(document.all){
				return document.all(id).offsetHeight;
			} else if(document.getElementById){
				return document.getElementById(id).offsetHeight;
			}
		}
	}

/* ===============================================
	レイヤーの高さ設定
=============================================== */
	function setLayerHeight(id,h){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).style.height = h + "px";
			} else if(document.getElementById){
				document.getElementById(id).style.height = h + "px";
			}
		}
	}

/* ===============================================
	レイヤーの座標設定
=============================================== */
	function setLayerPosition(id,x,y){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).style.top  = y + "px";
				document.all(id).style.left = x + "px";
			} else if(document.getElementById){
				document.getElementById(id).style.top  = y + "px";
				document.getElementById(id).style.left = x + "px";
			}
		}
	}

/* ===============================================
	指定された ID領域に記述
=============================================== */
	function writeIdArea(id,writeData){
		if(document.all || document.getElementById){
			if(document.all){
				document.all(id).innerHTML = writeData;
			} else if(document.getElementById){
				document.getElementById(id).innerHTML = writeData;
			}
		}
	}

/* ===============================================
	指定された ID領域 高さ統一
=============================================== */
	function setAllLayArrangeH(id){
		var num = 0;
		var h = 0;
		var idN = id + '1';
		if( checkLayerId(idN) != null ){
			num = getLayerNum(id);

			if( num > 1 ){
				for( i=1 ; num >= i ; i++ ){
					idN = id + i;
					h = ( h > getLayerHeight(idN) ) ? h : getLayerHeight(idN);
				}
				for( i=1 ; num >= i ; i++ ){
					idN = id + i;
					setLayerHeight(idN,h);
				}
			}
		}
	}

/* ===============================================
	指定された ID領域 display:none
=============================================== */
	function allLayDisNone(id){
		var num = 0;
		var idN = id + '1';
		if( checkLayerId(idN) != null ){
			num = getLayerNum(id);

			if( num > 1 ){
				for( i=1 ; num >= i ; i++ ){
					idN = id + i;
					changeLayerDisplay(idN,'none');
				}
			}
		}
	}


/* ===============================================
	change text and fadein out
=============================================== */
var changeTxtFadeInOut = {
	temp : {
		timmer    : 10,
		timmerTxt : 1000,
		timmerOut : 5000,
		opacnt    : 2,
		opa       : 0,
		id        : null,
		idNum     : 0,
		txt       : null,
		txtNum    : 0,
		txtCnt    : 0
	},

	main : function (){
		if ( ( setChangeTxtFadeInOut.temp.id != null ) && ( setChangeTxtFadeInOut.temp.txt != null ) ){
			changeTxtFadeInOut.temp.id  = setChangeTxtFadeInOut.temp.id;
			changeTxtFadeInOut.temp.txt = setChangeTxtFadeInOut.temp.txt;

			changeTxtFadeInOut.temp.idNum  = getLayerNum(changeTxtFadeInOut.temp.id);
			changeTxtFadeInOut.temp.txtNum = changeTxtFadeInOut.temp.txt.length;

			if( changeTxtFadeInOut.temp.idNum != -1 ){
				changeTxtFadeInOut.fadeOut(100);
			}
		}
	},


	fadeOut : function(opa){
		opa = opa - changeTxtFadeInOut.temp.opacnt;

		for( i=1 ; changeTxtFadeInOut.temp.idNum >= i ; i++ ){
			var id = changeTxtFadeInOut.temp.id + i;
			document.getElementById(id).style.filter = "alpha(opacity:"+opa+")";  //ver IE
			document.getElementById(id).style.opacity = opa/100;                  //ver Mozilla
		}

		if( opa < 0 ){
			changeTxtFadeInOut.changeTxt();
		}else{
			setTimeout(function (){
				changeTxtFadeInOut.fadeOut(opa);
			},changeTxtFadeInOut.temp.timmer);
		}
	},


	changeTxt : function(){
		if( changeTxtFadeInOut.temp.txtCnt >= changeTxtFadeInOut.temp.txtNum ) changeTxtFadeInOut.temp.txtCnt = 0;

		var i = changeTxtFadeInOut.temp.txtCnt;
		var writeData = changeTxtFadeInOut.temp.txt[i];

		for( i=1 ; changeTxtFadeInOut.temp.idNum >= i ; i++ ){
			var id = changeTxtFadeInOut.temp.id + i;
			writeIdArea(id,writeData);
		}
		changeTxtFadeInOut.temp.txtCnt++;

		setTimeout(function (){
			changeTxtFadeInOut.fadeIn(0);
		},changeTxtFadeInOut.temp.timmerTxt);
	},


	fadeIn : function(opa){
		opa = opa + changeTxtFadeInOut.temp.opacnt;

		for( i=1 ; changeTxtFadeInOut.temp.idNum >= i ; i++ ){
			var id = changeTxtFadeInOut.temp.id + i;
			document.getElementById(id).style.filter = "alpha(opacity:"+opa+")";  //ver IE
			document.getElementById(id).style.opacity = opa/100;                  //ver Mozilla
		}

		if( opa >= 100 ){
			setTimeout(function (){
				changeTxtFadeInOut.fadeOut(100);
			},changeTxtFadeInOut.temp.timmerOut);
		}else{
			setTimeout(function (){
				changeTxtFadeInOut.fadeIn(opa);
			},changeTxtFadeInOut.temp.timmer);
		}
	},


	addEvent : function(){
		try {
			window.addEventListener('load', this.main, false);
		} catch (e) {
			window.attachEvent('onload', this.main);
		}
	}
}


/* ===============================================
	window open
=============================================== */
var openWinDefault = {
	temp : {
		toolbar     : "no",
		location    : "yes",
		directories : "no",
		status      : "no",
		menubar     : "no",
		scrollbars  : "yes",
		resizable   : "yes",
		width       : "650",
		height      : "500",
		winName     : "sse"
	},

	main : function (url) {
		var winSet = null;
		winSet =  'toolbar='     + openWinDefault.temp.toolbar     + ',';
		winSet += 'location='    + openWinDefault.temp.location    + ',';
		winSet += 'directories=' + openWinDefault.temp.directories + ',';
		winSet += 'status='      + openWinDefault.temp.status      + ',';
		winSet += 'menubar='     + openWinDefault.temp.menubar     + ',';
		winSet += 'scrollbars='  + openWinDefault.temp.scrollbars  + ',';
		winSet += 'resizable='   + openWinDefault.temp.resizable   + ',';
		winSet += 'width='       + openWinDefault.temp.width       + ',';
		winSet += 'height='      + openWinDefault.temp.height;

		openWindow = window.open(url,openWinDefault.temp.winName,winSet);
		openWindow.focus();
	}
}


/* ===============================================
	読み込み処理
=============================================== */
var onloadFlug = "false";
var loadFuncCommon = {
	addEvent : function(){
		try {
			window.addEventListener('load', function(){
				initRollovers();
				onloadFlug = "true";
				setAllLayArrangeH('setTLRH');
			}, false);
		} catch (e) {
			window.attachEvent('onload', function(){
				initRollovers();
				onloadFlug = "true";
				setAllLayArrangeH('setTLRH');
			});
		}
	}
}
loadFuncCommon.addEvent();


/* ===============================================
	印刷処理
=============================================== */
function PrintPage(){
	if(document.getElementById || document.layers){
		window.print();		//印刷をします
	}
}
/* スクロール制御JS */

function backToTop() {
    var x1 = x2 = x3 = 0;
    var y1 = y2 = y3 = 0;

    if (document.documentElement) {
        x1 = document.documentElement.scrollLeft || 0;
        y1 = document.documentElement.scrollTop || 0;
    }

    if (document.body) {
        x2 = document.body.scrollLeft || 0;
        y2 = document.body.scrollTop || 0;
    }

    x3 = window.scrollX || 0;
    y3 = window.scrollY || 0;

    var x = Math.max(x1, Math.max(x2, x3));
    var y = Math.max(y1, Math.max(y2, y3));

    window.scrollTo(Math.floor(x / 2), Math.floor(y / 2));

    if (x > 0 || y > 0) {
        window.setTimeout("backToTop()", 25);
    }
}


/* Macromedia JS */

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_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_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];}
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function close_win(){
	var nvua = navigator.userAgent;
		if(nvua.indexOf('MSIE') >= 0){
			if(nvua.indexOf('MSIE 5.0') == -1) {
				top.opener = '';
			}
		}
		else if(nvua.indexOf('Gecko') >= 0){
			top.name = 'CLOSE_WINDOW';
			wid = window.open('','CLOSE_WINDOW');
		}
	top.close();
}