
function openTab( num ){
  for(i=0; i<20; i++){
    if(document.getElementById('ccblocktitle'+i)!=undefined){
      document.getElementById('ccblocktitle'+i).style.backgroundColor='#ffd449';
    }
    if(document.getElementById('ccblockcontent'+i)!=undefined){
      document.getElementById('ccblockcontent'+i).style.display='none';
    }
  }
  var no = ( num==null ) ? 0 : num ;
  if(document.getElementById('ccblockcontent'+no)!=undefined){
    document.getElementById( 'ccblockcontent'+no ).style.display='block';
  }
  if(document.getElementById('ccblocktitle'+no)!=undefined){
    document.getElementById( 'ccblocktitle'+no ).style.backgroundColor='#fff6d5';
    var a_title = document.getElementById( 'ccblocktitle'+no ) ;
    var b_title = a_title.childNodes.item(1).innerHTML ;
    if( num!=null ){
      akikotabSetCookie( 'AKIKOTAB_USER' , b_title , 7 ) ;
    }
  }
}


function initOpenTitleContents(){
  var cookie = akikotabGetCookie('AKIKOTAB_USER') ;
  if( document.getElementById('BlockTitleWrap')!=undefined ){
    document.getElementById('BlockTitleWrap').style.display='block';
  }
  var tabno = null ;
  for(i=0; i<20; i++){
    var a_title = document.getElementById( 'ccblocktitle'+i ) ;
    if( a_title!=undefined ){
      var b_title = a_title.childNodes.item(1).innerHTML ;
      if( b_title == cookie ){
        tabno = i ;
        break ;
      }
    }
  }
  openTab( tabno ) ;
}

/*        クッキーに登録する汎用関数              */
/* 書式 : mySetCookie(クッキー名,値,有効期限日数) */
/* 戻り値 : なし(void)                            */
function akikotabSetCookie(myCookie,myValue,myDay){
   myExp = new Date();
   myExp.setTime(myExp.getTime()+(myDay*24*60*60*1000));
   myItem = "@" + myCookie + "=" + escape(myValue) + ";";
   myExpires = "expires="+myExp.toGMTString()+ ";" ;
   myPath = "path=/;" ;
   document.cookie =  myItem + myExpires + myPath;
}

/*        クッキーを取り込む汎用関数              */
/* 書式 : myGetCookie(クッキー名)                 */
/* 戻り値 : 値(string)  null:該当なし             */
function akikotabGetCookie(myCookie){
   myCookie = "@" + myCookie + "=";
   myValue = null ;
   myStr = document.cookie + ";" ;
   myOfst = myStr.indexOf(myCookie);
   if (myOfst != -1){
      myStart = myOfst + myCookie.length;
      myEnd   = myStr.indexOf(";" , myStart);
      myValue = unescape(myStr.substring(myStart,myEnd));
   }
   return myValue;
}


setTimeout('initOpenTitleContents()', 2000 );