jslous.noConflict();
var js = jslous;
js(function(){
 
 var list_items = {
  'j_navi_001':'j_navi_002',
  'j_navi_002':'j_navi_001',
  'j_navi_003':'j_navi_004',
  'j_navi_004':'j_navi_003',  
  'e_navi_001':'e_navi_002',
  'e_navi_002':'e_navi_001',
  'e_navi_003':'e_navi_004',
  'e_navi_004':'e_navi_003'
 };
 
 var motion = false;
 var tt = 0;
 var ll = 0;
 var hscroll = function(f,t){
  jslous.func.motion.Listener({},{
   time:0.25,
   effect:'quartinout',
   x:{from:f,to:t,uint:''},
   upd:function(){
    var arg = parseInt(this.target['x']);
    window.scrollTo(arg,tt);
   },
   comp:function(){
    motion = false;
    window.scrollTo(t,tt);
   }
  });
 }
 
 var show_regexp  = /(j_navi_002|j_navi_004|e_navi_002|e_navi_004)/;
 var hide_regexp  = /(j_navi_001|j_navi_003|e_navi_001|e_navi_003)/;

 js('li.trigger').each(function(){
  var elm = this;
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'li'){
   //elm.setAttribute('height',jslous.css.height(elm));
   elm.style['overflow'] = 'hidden';
   if(elm['className'].match(hide_regexp)){
    elm.style['height'] = 30+'px';
   }else{
    elm.style['height'] = 'auto';
   }
  }
 }).query('a.trigger_off').push('img.trigger_off').toggle(function(trg){
  if(trg && trg.tagName && (trg.tagName.toLowerCase() == 'a' || trg.tagName.toLowerCase() == 'img')){
   trg = trg.parentNode;
  }
  if(trg && trg.tagName && trg.tagName.toLowerCase() == 'li'){
   if(trg['className'].match(/root/)){
    trg.style['overflow'] = 'hidden';
    trg.style['height'] = 'auto';
   }
   var t = jslous.css.height(trg);
   jslous.func.motion.Listener(trg.style,{
    time:0.25,
    effect:'quartinout',
    height:{from:t,to:30,uint:'px'},
    comp:function(){
     trg.style['height'] = 30+'px';
     var c = trg['className'].match(show_regexp)[1];
     trg['className'] = trg['className'].replace(c,list_items[c]);
    }
   });
  }
 },function(elm){
  if(elm && elm.tagName && (elm.tagName.toLowerCase() == 'a' || elm.tagName.toLowerCase() == 'img')){
   elm = elm.parentNode;
  }
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'li'){
   elm.style['height'] = 'auto';
   var t = jslous.css.height(elm);
   if(elm.parentNode.parentNode['className'].match(/trigger/)){
    elm.parentNode.parentNode.style['overflow'] = 'hidden';
    elm.parentNode.parentNode.style['height'] = 'auto';
   }
   elm.style['height'] = 30+'px';
   jslous.func.motion.Listener(elm.style,{
    time:0.25,
    effect:'quartinout',
    height:{from:30,to:t,uint:'px'},
    comp:function(){
     elm.style['height'] = 'auto';
     var c = elm['className'].match(hide_regexp)[1];
     elm['className'] = elm['className'].replace(c,list_items[c]);
    }
   });
  }
 }).query('a.trigger_on').push('img.trigger_on').toggle(function(elm){
  if(elm && elm.tagName && (elm.tagName.toLowerCase() == 'a' || elm.tagName.toLowerCase() == 'img')){
   elm = elm.parentNode;
  }
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'li'){
   elm.style['height'] = 'auto';
   var t = jslous.css.height(elm);
   if(elm.parentNode.parentNode['className'].match(/trigger/)){
    elm.parentNode.parentNode.style['overflow'] = 'hidden';
    elm.parentNode.parentNode.style['height'] = 'auto';
   }
   elm.style['height'] = 30+'px';
   jslous.func.motion.Listener(elm.style,{
    time:0.25,
    effect:'quartinout',
    height:{from:30,to:t,uint:'px'},
    comp:function(){
     elm.style['height'] = 'auto';
     var c = elm['className'].match(hide_regexp)[1];
     elm['className'] = elm['className'].replace(c,list_items[c]);
    }
   });
  }
 },function(trg){
  if(trg && trg.tagName && (trg.tagName.toLowerCase() == 'a' || trg.tagName.toLowerCase() == 'img')){
   trg = trg.parentNode;
  }
  if(trg && trg.tagName && trg.tagName.toLowerCase() == 'li'){
   if(trg['className'].match(/root/)){
    trg.style['overflow'] = 'hidden';
    trg.style['height'] = 'auto';
   }
   var t = jslous.css.height(trg);
   jslous.func.motion.Listener(trg.style,{
    time:0.25,
    effect:'quartinout',
    height:{from:t,to:30,uint:'px'},
    comp:function(){
     trg.style['height'] = 30+'px';
     var c = trg['className'].match(show_regexp)[1];
     trg['className'] = trg['className'].replace(c,list_items[c]);
    }
   });
  }
 }).query('img.totop').click(function(evt){
  ll = jslous.size.scrollLeft();
  var f = jslous.size.scrollTop();
  if(f > 0 && motion == false){
   motion = true;
   jslous.func.motion.Listener({},{
    time:0.25,
    effect:'quartinout',
    y:{from:f,to:0,uint:''},
    upd:function(){
     var arg = parseInt(this.target['y']);
     window.scrollTo(ll,arg);
    },
    comp:function(){
     motion = false;
     window.scrollTo(ll,0);
    }
   });
  }
 }).query('img#toenglish').push('img#toenglish2').click(function(evt){
  var gg = document.getElementById('tojapanese');
  if(gg){
   tt = jslous.size.scrollTop();
   var ww = parseInt(jslous.size.clientWidth());
   var from = jslous.size.scrollLeft();
   var to = (jslous.elmPos.left(gg)+56)-ww;
   if(to > 0 && motion == false){
    motion = true;
    hscroll(from,to);
   }
  }
 }).query('img#tojapanese').click(function(evt){
  var to = 0;
  tt = jslous.size.scrollTop();
  var from = jslous.size.scrollLeft();
  if(from > 0 && motion == false){
   motion = true;
   hscroll(from,to);
  }
 });
});
