/* ******************************************************************************
  ▼▼▼カタログ用写真切り替えJavaScript
****************************************************************************** */
// ▼画像を閉じる
function WindowClose(){
(window.open('', '_self').opener = window).close();
}

// ▼画像入替えAjax 1
$(document).ready( function() {
    $(".thumbnail img").click( function() {
        var changeSrc = this.src;
        $("#target").fadeOut(
            "slow",
            function() {
                $(this).attr("src", changeSrc);
                $(this).fadeIn();
            }
        );
    });
});

// ▼画像入替えAjax 2
$(document).ready( function() {
    $(".thumbnail a").click( function() {
        var changeSrc = $(this).attr("href");
        $("#target").fadeOut(
            "slow",
            function() {
                $(this).attr("src", changeSrc);
                $(this).fadeIn();
            }
        );
        return false;
    });
});



/* ******************************************************************************
  ▼▼▼smooth scroll
****************************************************************************** */
function toPageTop() {
	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 / 1.4), Math.floor(y / 1.4));
	if (x > 0 || y > 0) {
		window.setTimeout("toPageTop()", 30);
	}
}

/* ******************************************************************************
  ▼▼▼画像入れ替えスクリプト http://jsajax.com/ImageRolloverArticle737.aspx
	◎HTML側の表示
	<img src="images_hp/on.gif" class="domroll images_hp/off.gif" alt="" />

  DOM Image Rollover v3(hover) Demo: http://chrispoole.com/scripts/dom_image_rollover_hover
  licensed under the MIT License http://opensource.org/licenses/mit-license.php
****************************************************************************** */
function domRollover() {   
    if (navigator.userAgent.match(/Opera (\S+)/)) {   
        var operaVersion = parseInt(navigator.userAgent.match(/Opera (\S+)/)[1]);   
    }   
    if (!document.getElementById||operaVersion <7) return;   
  
    var imgarr=document.getElementsByTagName('img');   
    var imgPreload=new Array();   
    var imgSrc=new Array();   
    var imgClass=new Array();   
       
    for (i=0;i<imgarr.length;i++){   
        if (imgarr[i].className.indexOf('domroll')!=-1){   
            imgSrc[i]=imgarr[i].getAttribute('src');   
            imgClass[i]=imgarr[i].className;   
            imgPreload[i]=new Image();   
            if (imgClass[i].match(/domroll (\S+)/)) {   
                imgPreload[i].src = imgClass[i].match(/domroll (\S+)/)[1]   
            }   
            imgarr[i].setAttribute('xsrc', imgSrc[i]);   
            imgarr[i].onmouseover=function(){   
                this.setAttribute('src',this.className.match(/domroll (\S+)/)[1])   
            }   
            imgarr[i].onmouseout=function(){   
                this.setAttribute('src',this.getAttribute('xsrc'))   
            }   
        }   
    }   
}   
window.onload = domRollover;


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_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];}
}

/* ******************************************************************************
 ▼▼▼コンテンツを折りたたむ
 http://jsajax.com/AnimatedCollapsibleDivArticle620.aspx
	◎HTML側の表示
	<a href="javascript:collapse.slidedown()">開く</a>　
	<a href="javascript:collapse.slideup()">閉じる</a>　
	<a href="javascript:collapse.slideit()">開閉</a>　
	<div id="Kobetuni_Henkou_No01">
	    ここに展開/折りたたみするコンテンツを記述します。<BR>
	    ここに展開/折りたたみするコンテンツを記述します。<BR>
	</div>
	<script type="text/javascript">
	var collapse = new animatedcollapse("Kobetuni_Henkou_No01", 1000, false);	//閉じた状態からスタート
	//var collapse = new animatedcollapse("Kobetuni_Henkou_No01", 1000, true);	//開いた状態からスタート
	//var collapse = new animatedcollapse("Kobetuni_Henkou_No01", 1000, true,"block");	//継承？状態からスタート
	</script>
****************************************************************************** */
var uniquepageid=window.location.href.replace("http://"+window.location.hostname, "").replace(/^\//, "");

function animatedcollapse(divId, animatetime, persistexpand, initstate){
	this.divId=divId;
	this.divObj=document.getElementById(divId);
	this.divObj.style.overflow="hidden";
	this.timelength=animatetime;
	this.initstate=(typeof initstate!="undefined" && initstate=="block")? "block" : "contract";
	this.isExpanded=animatedcollapse.getCookie(uniquepageid+"-"+divId);
	this.contentheight=parseInt(this.divObj.style.height);
	var thisobj=this;
	if (isNaN(this.contentheight)){ 
		animatedcollapse.dotask(window, function(){thisobj._getheight(persistexpand)}, "load");
		if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="") 
			this.divObj.style.visibility="hidden";
	}
	else if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes" && this.isExpanded!="")
		this.divObj.style.height=0;
	if (persistexpand)
		animatedcollapse.dotask(window, function(){animatedcollapse.setCookie(uniquepageid+"-"+thisobj.divId, thisobj.isExpanded)}, "unload");
}
animatedcollapse.prototype._getheight=function(persistexpand){
	this.contentheight=this.divObj.offsetHeight;
	if (!persistexpand && this.initstate=="contract" || persistexpand && this.isExpanded!="yes"){
		this.divObj.style.height=0;
		this.divObj.style.visibility="visible";
	}
	else 	
		this.divObj.style.height=this.contentheight+"px";
}
animatedcollapse.prototype._slideengine=function(direction){
	var elapsed=new Date().getTime()-this.startTime;
	var thisobj=this;
	if (elapsed<this.timelength){
		var distancepercent=(direction=="down")? animatedcollapse.curveincrement(elapsed/this.timelength) : 1-animatedcollapse.curveincrement(elapsed/this.timelength);
	  this.divObj.style.height=distancepercent * this.contentheight +"px";
	  this.runtimer=setTimeout(function(){thisobj._slideengine(direction)}, 10);
	}
	else{
		this.divObj.style.height=(direction=="down")? this.contentheight+"px" : 0;
		this.isExpanded=(direction=="down")? "yes" : "no";
		this.runtimer=null;
	}
}
animatedcollapse.prototype.slidedown=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){
		if (isNaN(this.contentheight))
			alert("Please wait until document has fully loaded then click again");
		else if (parseInt(this.divObj.style.height)==0){
			this.startTime=new Date().getTime();
			this._slideengine("down");
		}
	}
}
animatedcollapse.prototype.slideup=function(){
	if (typeof this.runtimer=="undefined" || this.runtimer==null){
		if (isNaN(this.contentheight))
			alert("Please wait until document has fully loaded then click again");
		else if (parseInt(this.divObj.style.height)==this.contentheight){
			this.startTime=new Date().getTime();
			this._slideengine("up");
		}
	}
}
animatedcollapse.prototype.slideit=function(){
	if (isNaN(this.contentheight))
		alert("Please wait until document has fully loaded then click again");
	else if (parseInt(this.divObj.style.height)==0)
		this.slidedown();
	else if (parseInt(this.divObj.style.height)==this.contentheight)
		this.slideup();
}
animatedcollapse.curveincrement=function(percent){
	return (1-Math.cos(percent*Math.PI)) / 2;
}
animatedcollapse.dotask=function(target, functionref, tasktype){ 
	var tasktype=(window.addEventListener)? tasktype : "on"+tasktype;
	if (target.addEventListener)
		target.addEventListener(tasktype, functionref, false);
	else if (target.attachEvent)
		target.attachEvent(tasktype, functionref);
}
animatedcollapse.getCookie=function(Name){ 
	var re=new RegExp(Name+"=[^;]+", "i");
	if (document.cookie.match(re))
		return document.cookie.match(re)[0].split("=")[1];
	return "";
}
animatedcollapse.setCookie=function(name, value){
  document.cookie = name+"="+value;
}


/* ******************************************************************************
  ▼▼▼クリック表示非表示（トラバセンターより引用）
****************************************************************************** */
function showMore(varA1, varB1){ 
var123 = ('TBXYZ_' + (varA1)); 
varABC = ('TB_' + (varA1)); 
if( document.getElementById ) { 
if( document.getElementById(var123).style.display ) { 
if( varB1 != 0 ) { 
document.getElementById(var123).style.display = "block"; 
document.getElementById(varABC).style.display = "none"; 
} else { document.getElementById(var123).style.display = "none"; 
document.getElementById(varABC).style.display = "block"; } 
} else { location.href = varB1; 
return true; } 
} else { location.href = varB1; 
return true; } 
} 


// ** ▼▼▼テスト▼▼▼ ********************************************************************

/* 水平メニュー */
/*
$(function() {
  $("#menu li").click(function() {
    $("#menu li").removeClass("current");
    $(this).addClass("current");
    $("#h2left").html($(this).children("a").html());
  });    
});
*/

/* 垂直メニュー */
/*
$(function() {
  $("#flyout li").click(function() {
    $("#flyout li a").removeClass("current");
    $(this).children("a").addClass("current");
    var oval = $("#h2left").html().replace("<B>", "").replace("</B>", "").replace("<!-->", "");
    var nval = $(this).children("a").html().replace("<B>", "").replace("</B>", "").replace("<!-->", "");
    if (oval.indexOf(nval) == -1) {
      $("#h2left").html($(this).children("a").html());
    }
  });
});
*/


/* =====================================================================
  ■クリックで解答が開くFAQ 1
  http://www.shoeisha.com/book/hp/dhtml/
  http://www.imztry.net/dhtml/042/042.html
===================================================================== */
/* 
function showHideAnswer()
{
	var numericID = this.id.replace(/[^\d]/g,'');
	var obj = document.getElementById('a' + numericID);
	if(obj.style.display=='block'){
		obj.style.display='none';
	}else{
		obj.style.display='block';
	}
}
function initShowHideContent()
{
	var divs = document.getElementsByTagName('DIV');
	for(var no=0;no<divs.length;no++){
		if(divs[no].className=='question'){
			divs[no].onclick = showHideAnswer;
		}
	
	}
}
window.onload = initShowHideContent;
 */











