/*-------------------------
Rollover
-------------------------*/
conf = {
       className : 'rollover',
       postfix : '_sw'
};
function setMouseOverImages() {
       $A(document.getElementsByClassName(conf.className)).each(function (node){
               node.onmouseout = changeSrcFunction(node.src);
               node.onmouseover =
			    changeSrcFunction(node.src.replace(/(\.gif|\.jpg|\.png)/, conf.postfix+"$1"));
       });
}
function changeSrcFunction(data){
       return function(){ this.src = data; }
}
Event.observe(window, 'load', setMouseOverImages, false);





/*-------------------------
windowscroll
-------------------------*/
/* 画面の読み込み速度が低下するため、コメントアウトする。
Event.observe(window, 'load', function() {
  $$('a[href^=#]:not([href=#])').each(function(element) {
    element.observe('click', function(event) {
      new Effect.ScrollTo(this.hash.substr(1));
      Event.stop(event);
    }.bindAsEventListener(element))
  })
})
*/

/*-------------------------
DropDown menu class
-------------------------*/
/* エラーになるのでコメントアウトする（他に使われている形跡もないため）
topHover = function() {
	var sfEls = document.getElementById("glList").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" tophover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" tophover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", topHover);
*/


/*-------------------------
menu_1
-------------------------*/

var menu_1 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menu_1').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menu_1', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menu_1').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menu_1', {duration:.3, fps:40})},300);
  }
 }
}
/*-------------------------
menu_2
-------------------------*/
var menu_2 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menu_2').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menu_2', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menu_2').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menu_2', {duration:.3, fps:40})},300);
  }
 }
}

/*-------------------------
menu_3
-------------------------*/
var menu_3 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menu_3').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menu_3', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menu_3').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menu_3', {duration:.3, fps:40})},300);
  }
 }
}

/*-------------------------
menu_4
-------------------------*/
var menu_4 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menu_4').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menu_4', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menu_4').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menu_4', {duration:.3, fps:40})},300);
  }
 }
}

/*-------------------------
menu_5
-------------------------*/
var menu_5 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menu_5').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menu_5', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menu_5').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menu_5', {duration:.3, fps:40})},300);
  }
 }
}

/*-------------------------
menu_6
-------------------------*/
var menu_6 = {
 timeout : null,
 showPopup : function(){
  clearTimeout(this.timeout);
  if($('menu_6').style.display == 'none'){
   this.timeout = setTimeout(function(){new Effect.BlindDown('menu_6', {duration:.3, fps:40})},400);
  }
 },
 hidePopup : function(){
  if($('menu_6').style.display == 'none'){
   clearTimeout(this.timeout);
  }else{
   this.timeout = setTimeout(function(){new Effect.BlindUp('menu_6', {duration:.3, fps:40})},300);
  }
 }
}


/*-------------------------
Cart Layer
-------------------------*/

// Browser Checker
function browserCheck(){ 
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	//alert(this.ver);
	this.dom=document.getElementById?1:0
	this.opera6=((this.agent.indexOf("Opera 6")>-1) && this.dom)?1:0;
	this.ie5=((this.ver.indexOf("MSIE 5")>-1) && this.dom && !this.opera6)?1:0; 
	this.ie6r=(((this.ver.indexOf("MSIE 6") != -1) || (this.ver.indexOf('MSIE 7.',0) != -1)) && this.dom && (document.compatMode == "BackCompat"))?1:0;
	this.ie6s=(((this.ver.indexOf("MSIE 6") != -1) || (this.ver.indexOf('MSIE 7.',0) != -1))&& this.dom && (document.compatMode == "CSS1Compat"))?1:0;
	//this.ie7=((this.ver.indexOf("MSIE 7")>-1) && this.dom && (document.compatMode == "CSS1Compat"))?1:0;
	
	
	//alert(this.ie7);
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie=(this.ie4||this.ie5||this.ie6r||this.ie6s)?1:0;
	this.mac=(this.agent.indexOf("Mac")>-1)?1:0;
	this.ns6=(this.dom && (parseInt(this.ver) >= 5)) ?1:0; 
	this.ns4=(document.layers && !this.dom)?1:0;
	this.ns=(this.ns4||this.ns6)?1:0;
	this.bw5=(this.ie5||this.ie6r)?1:0;
	this.bw6=(this.ie6s||this.ns6)?1:0;
	this.bw=(this.ie6r||this.ie6s||this.ie5||this.ns6||this.opera6||this.ie7)?1:0;
	return this;
}

//---------------------------------------
var cartMarginTop, cartMarginBottom, cartTop;
var cartDivName, cartObject, cartCurrentY;
//---------------------------------------

function cartInit()
{
	var id = 'cart';
	var mt = 0;
	var mb = 0;
	var tp = 0;
	
	//
	bw=new browserCheck;
	//alert(bw.bw+"  :  "+bw.bw5+"  :  "+bw.bw6);
	if (bw.bw) {
		cartDivName = bw.bw5 ? document.all(id) : bw.bw6 ? document.getElementById(id) : 0;
		cartObject = cartDivName.style;
		cartObject.position = 'absolute';
		cartMarginTop = mt ? mt : -221;
		cartMarginBottom = mb ? mb : 0;
		cartCurrentY = cartTop = tp ? tp : cartDivName.offsetTop;
		moveLay();
	} 
}

function moveLay()
{
	var winh = bw.ie6s ? document.documentElement.clientHeight : (bw.ns6||bw.opera6) ? innerHeight : bw.bw5 ? document.body.clientHeight : 0 ;
	var yt = bw.ie6s ? document.documentElement.scrollTop : bw.bw5 ? document.body.scrollTop : (bw.ns6||bw.opera6) ? window.pageYOffset : 0;
	
	var divh = cartDivName.offsetHeight;

	if (winh >= cartMarginTop + divh + cartMarginBottom) {
		yt = Math.max(yt + cartMarginTop, cartTop);
	} else {
		var yt1 = Math.max(yt + cartMarginTop, cartTop);
		var f1 = (yt1 > cartCurrentY) ? 1 : 0;
		var yt2 = yt - (divh + cartMarginBottom - winh);
		yt2 = Math.max(yt2, cartTop);
		var f2 = (yt2 < cartCurrentY) ? 1 : 0;
		if (f1 && f2) yt = cartCurrentY;
		else yt = f2 ? Math.max(yt1, yt2) : Math.min(yt1, yt2);
	}
	//alert(yt);
	if (yt != cartCurrentY) {
		/*
		var vy = yt;
		cartCurrentY += Math.round(vy);
		cartObject.top = cartCurrentY + 'px';
		*/
		var vy = (yt - cartCurrentY) * 0.35;
		if (Math.abs(vy) < 1) vy = (vy > 0) ? 1 : (vy < 0) ? -1 : 0;
		cartCurrentY += Math.round(vy);
		cartObject.top = cartCurrentY + 'px';
		//alert(cartObject.top);
	}
	setTimeout('moveLay()', 10);
}

//window.onload = cartInit;
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
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_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}
function MM_nbGroup(event, grpName) { //v6.0
  var i,img,nbArr,args=MM_nbGroup.arguments;
  if (event == "init" && args.length > 2) {
    if ((img = MM_findObj(args[2])) != null && !img.MM_init) {
      img.MM_init = true; img.MM_up = args[3]; img.MM_dn = img.src;
      if ((nbArr = document[grpName]) == null) nbArr = document[grpName] = new Array();
      nbArr[nbArr.length] = img;
      for (i=4; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
        if (!img.MM_up) img.MM_up = img.src;
        img.src = img.MM_dn = args[i+1];
        nbArr[nbArr.length] = img;
    } }
  } else if (event == "over") {
    document.MM_nbOver = nbArr = new Array();
    for (i=1; i < args.length-1; i+=3) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = (img.MM_dn && args[i+2]) ? args[i+2] : ((args[i+1])? args[i+1] : img.MM_up);
      nbArr[nbArr.length] = img;
    }
  } else if (event == "out" ) {
    for (i=0; i < document.MM_nbOver.length; i++) {
      img = document.MM_nbOver[i]; img.src = (img.MM_dn) ? img.MM_dn : img.MM_up; }
  } else if (event == "down") {
    nbArr = document[grpName];
    if (nbArr)
      for (i=0; i < nbArr.length; i++) { img=nbArr[i]; img.src = img.MM_up; img.MM_dn = 0; }
    document[grpName] = nbArr = new Array();
    for (i=2; i < args.length-1; i+=2) if ((img = MM_findObj(args[i])) != null) {
      if (!img.MM_up) img.MM_up = img.src;
      img.src = img.MM_dn = (args[i+1])? args[i+1] : img.MM_up;
      nbArr[nbArr.length] = img;
  } }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,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; }
}