﻿/*@cc_on _d=document;eval('var document=_d')@*/

//-----------------------------------------------------
//固定変数
//-----------------------------------------------------
var DDSPEED = 6
var DDTIMER = 15;
//メニューの高さ
var DDHEIGHT = 48;

//-----------------------------------------------------
//初期表示状態
//-----------------------------------------------------
function ddDefault(){
  var c = document.getElementById('def-ddcontent');  
  var s = document.getElementById('ddspace');	
  
  //ブロック
  c.style.display = 'block';
  //高さ自動
  c.style.height = 'auto';      
  //高さ
  c.style.height = "48px";
  //透明度
  //c.style.filter = 'alpha(opacity=95)';
  //透明度
  //c.style.opacity = 0.5;
  //余白の高さ
  s.style.height = "0px";
  
}

//-----------------------------------------------------
//メニューを表示する
//-----------------------------------------------------
function ddMenu(id,d){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');  
  var s = document.getElementById('ddspace');
  
  //デフォルト削除
  var def = document.getElementById('def-ddcontent');
    
  //要素がない時はスルー i/2009.01.20
  if(def != null){
	  //デフォルトが出ていた場合
	  if(def.style.height  != "0px"){
		  def.style.height  = "0px";
		  def.style.display = "none";
		  s.style.height    = "48px";
	  }
  }
  
  clearInterval(c.timer);
  
  if(d == 1){
  
    //全て閉じる
    ddClose();
  
    clearTimeout(h.timer);
    
    if(c.maxh && c.maxh <= c.offsetHeight){
    	return
    	
    //設定されてない場合
    }else if(!c.maxh){
      //ブロック
      c.style.display = 'block';
      //高さ自動
      c.style.height = 'auto';      
	  //IEでずれることもあったので高さを固定
      c.maxh = DDHEIGHT;
      //初期メニュー高さ
      c.style.height = '0px';
    }
    
	if(s.offsetHeight >= 0){
    	c.timer = setInterval(function(){ddSlide(c,1,s)},DDTIMER);
    }
    
  }else{
  
  	c.style.height = '0px';
  	s.style.height = '48px';
    //h.timer = setTimeout(function(){ddCollapse(c,s)},DDTIMER);
    
  }
  
}

//-----------------------------------------------------
// collapse the menu 
//-----------------------------------------------------
function ddCollapse(c,s){
	c.timer = setInterval(function(){ddSlide(c,-1,s)},DDTIMER);
}

//-----------------------------------------------------
//表示状態
//-----------------------------------------------------
function cancelHide(id){
  var h = document.getElementById(id + '-ddheader');
  var c = document.getElementById(id + '-ddcontent');
  var s = document.getElementById('ddspace');
  
  //タイマーもクリアしないとコンマ何秒で1pxずれたりする。 1/30
  clearInterval(c.timer);
  c.style.height = '48px';
  s.style.height = '0px';
  
}
//-----------------------------------------------------
//メニューを表示スクリプト
//param=c オブジェクト(この場合dlタグ)
//param=d (d=1)の開く、(d=-1)閉じる
//-----------------------------------------------------
function ddSlide(c,d,s){
  
  //(予想)オブジェクトの高さ
  var currh = c.offsetHeight;
  
  //(予想)伸縮度合
  var dist;
  
  // d == 1 これは開くとき
  if(d == 1){
    dist = (Math.round((c.maxh - currh) / DDSPEED));
  
  // d != 1 こちらは閉じる時
  }else{
  	
  	//現在の高さ / 伸縮のスピードを四捨五入(残りを埋める形式)
    dist = (Math.round(currh / 1));
    
  }
  

  if(dist <= 1 && d == 1){
    dist = 1;
  }
  
  //高さを伸縮
  c.style.height = currh + (dist * d) + 'px';
  
  //余白を伸縮
  s.style.height = (DDHEIGHT - (currh + (dist * d))) + 'px';
  
  //透明度
  //c.style.opacity = 0.3;
  
  //透明度
  //c.style.filter = 'alpha(opacity=' + (currh * 100 / c.maxh) + ')';
  
  //伸びる制限
  if((currh < 2 && d != 1) || (currh > (c.maxh - 2) && d == 1)){
    clearInterval(c.timer);
  }
	
  //alert(c.style.height);
	
  //用途不明
  if(d != 1 && c.style.height == '5px'){c.style.height=0;}
    
}
//-----------------------------------------------------
//全てを閉じる関数
//-----------------------------------------------------
function ddClose(){

	var s     = document.getElementById('ddspace');
	var one   = document.getElementById('one-ddcontent');
	var two   = document.getElementById('two-ddcontent');
	var three = document.getElementById('three-ddcontent');
	var four  = document.getElementById('four-ddcontent');
	var five  = document.getElementById('five-ddcontent');
	var six   = document.getElementById('six-ddcontent');
	

	var one_h   = document.getElementById('one-ddheader');
	var two_h   = document.getElementById('two-ddheader');
	var three_h = document.getElementById('three-ddheader');
	var four_h  = document.getElementById('four-ddheader');
	var five_h  = document.getElementById('five-ddheader');
	var six_h   = document.getElementById('six-ddheader');
	
	
	//全て閉じる
	one.style.height   = '0px';
	two.style.height   = '0px';
	three.style.height = '0px';
	four.style.height  = '0px';
	five.style.height  = '0px';
	six.style.height   = '0px';
	
	//描写時間クリア(描写状態をなしにする)
	clearInterval(one.timer);
	clearInterval(two.timer);
	clearInterval(three.timer);
	clearInterval(four.timer);
	clearInterval(five.timer);
	clearInterval(six.timer);
	
	
	
  	//余白
  	s.style.height = '48px';
	
}
