jslous.noConflict();
var js = jslous;
js(function(){
 /* URLRequest Root_Path */
 var doc_root = 'http://'+location.host+'/';
 var php_root = 'http://'+location.host+'/req/';
 var dir_req = 'http://'+location.host+'/xml/';
 var sys_req = 'http://'+location.host+'/system/xml/';
 
 /* sliderContents activate Props */
 var slideWidth = 227;
 var activeWidth = 227;
 var desabledWidth = 0;
 var activethumb = 0;
 var prvthumb = 0;
 
 /* sliderContents moving Props */
 var currentPoint = 16;
 var togglePoint = 0;
 var mintoggle = 0;
 var maxtoggle = 762;
 var maxleft = (372+(128*31))-896-8;
 var minleft = 16;
 var moverange = maxleft-minleft+128;
 var minusboxmarge = 167;
 var minusmarge = (jslous.size.clientWidth()-(785+(jslous.Agents.ie ? -38:(jslous.Agents.firefox ? -38:32*2))))/2;
 var mouseflg = false;
 /* eventSchedules Props */
 var activeplace = 'events';
 var prvplace = 'events';
 var eventsmax = 142;
 
 /* tooltip Prop */
 var propwrap = document.getElementById('contents');
 var tip = document.getElementById('tooltip');
 if(tip != null && typeof tip != 'undefined' && jslous.Agents.ie6){
  tip.style['filter'] = 'progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'img/black_arrow_big02.png\',sizingMethod=scale)';
  tip.style['backgroundImage'] = 'none';
 }
// var activetip = null;
// var prvtip = null;
 
 var anc = location.hash;
 
 /* page Intirized Methods */
 js('div#flashcontent').each(function(){
  var elm = this;
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'div'){
   /*var so = new SWFObject("top.swf", "同志社カルチャー", "100%", "360", "7", "#000");
   so.addVariable("flashVarText", "this is passed in via FlashVars for example only");
   so.addParam("scale", "noscale");
   so.write("flashcontent");*/
  }
 }).query('div#naviBs').each(function(){
  var elm = this;
  var triger = [];
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'div'){
   jslous.ajax(dir_req+'footers.xml','GET','',function(res){
    var blocks = jslous.node.list2array(res.getElementsByTagName('block'));
    for(var i = 0,len = blocks.length;i < len;i++){
     var parentul = document.createElement('ul');
     parentul['id'] = 'navigation';
     parentul['className'] = 'vertical';
     var parentli = document.createElement('li');
     var parenta = document.createElement('a');
     parenta.setAttribute('href','javascript://');
     parenta.setAttribute('index',i);
     parenta.innerHTML = blocks[i].getAttribute('blockname');
     var blockname = blocks[i].getAttribute('blockname');
     triger.push(parenta);
     parentli.appendChild(parenta);
     parentul.appendChild(parentli);
     clubs = jslous.node.list2array(blocks[i].getElementsByTagName('club'));
     if(clubs.length > 0){
      var boxul = document.createElement('ul');
      boxul['className'] = 'bouncebox';
      for(var j = 0,l = clubs.length;j < l;j++){
       var boxli = document.createElement('li');
       boxli['className'] = 'bounce';
       var boxa = document.createElement('a');
       var prop = clubs[j].getAttribute('clubname');
       boxa.innerHTML = prop.replace('&','&amp;');
       boxa.setAttribute('href',doc_root+'contents/club/club_name.php?club='+encodeURIComponent(prop)+'&block='+encodeURIComponent(blockname));
       boxli.appendChild(boxa);
       boxul.appendChild(boxli);
      }
      parentli.appendChild(boxul);
     }
     elm.appendChild(parentul);
    }
    var active = null;
    var prv = 0;
    var flg = false;
    js(triger).click(function(evt){
     var btn = jslous.Event.target(evt);
     prv = active;
     active = btn.getAttribute('index');
     while(btn.tagName.toLowerCase() != 'a'){ btn = btn.parentNode; }
     var trg = btn.parentNode;
     while(trg['className'] != 'vertical'){ trg = trg.parentNode; }
     var box = jslous.node.list2array(jslous.html.query('ul.bouncebox',trg));
     var list = jslous.node.list2array(jslous.html.query('li.bounce',trg));
     var targets = jslous.merge(box,list);
     var ptargets = null;
     if(active != prv && flg == true){
      var prvtrg = triger[prv].parentNode;
      while(prvtrg['className'] != 'vertical'){ prvtrg = prvtrg.parentNode; }
      var pbox = jslous.node.list2array(jslous.html.query('ul.bouncebox',prvtrg));
      var plist = jslous.node.list2array(jslous.html.query('li.bounce',prvtrg));
      ptargets = jslous.merge(pbox,plist);
     }
     if(active == prv && flg == true){
      ptargets = targets;
      targets = null;
     }
     var tmp = {};
     jslous.func.motion.Listener(tmp,{
      time:0.5,
      effect:'quintin',
      w:{from:0,to:195,unit:'px'},b:{from:0,to:1,unit:'px'},pw:{from:195,to:0,unit:'px'},pb:{from:1,to:0,unit:'px'},o:{from:0,to:100,unit:''},po:{from:100,to:0,unit:''},
      go:function(){
       if(ptargets){
        jslous.each(function(){
         var elm = this;
         if(elm.tagName.toLowerCase() == 'li'){ elm.style['overflow'] = 'hidden'; }
        });
       }
      },
      upd:function(){
       var wid = parseInt(this.target.w),bid = parseInt(this.target.b),pwid = parseInt(this.target.pw),pbid = parseInt(this.target.pb),op = parseInt(this.target.o),pop = parseInt(this.target.po);
       if(targets){
        jslous.each(targets,function(){
         var target = this; target.style['width'] = wid+'px';
         jslous.css.opacity(target,op);
         if(target.tagName.toLowerCase() == 'li'){ target.style['borderWidth'] = bid+'px'; }
        });
       }
       if(ptargets){
        jslous.each(ptargets,function(){
         var target = this; target.style['width'] = pwid+'px';
         jslous.css.opacity(target,pop);
         if(target.tagName.toLowerCase() == 'li'){ target.style['borderWidth'] = pbid+'px'; }
        });
       }
      },
      comp:function(){
       if(targets){
        jslous.each(targets,function(){
         var target = this; target.style['width'] = 195+'px';
         if(target.tagName.toLowerCase() == 'li'){
          target.style['borderWidth'] = 1+'px';
          target.style['overflow'] = 'visible';
         }
        });
       }
       if(ptargets){
        jslous.each(ptargets,function(){
         var target = this; target.style['width'] = 0+'px';
         if(target.tagName.toLowerCase() == 'li'){
          target.style['borderWidth'] = 0+'px';
          target.style['overflow'] = 'hidden';
         }
        });
       }
       flg = true;
       if(active == prv && flg == true){
        prv = 0;
        active = null;
        flg = false;
       }
      }
     });
    });
   },'xml');
  }
 }).query('div.event_contents').each(function(){
  var elm = this;
  if(elm.getAttribute('index') != activethumb){
   jslous.css.setstyles(elm,{'width':0+'px','overflow':'hidden'});
   jslous.css.opacity(elm,0);
  }
 }).query('img.event_thumb').click(function(evt){
  var slide_contents = jslous.html.query('div.event_contents');
  var elm = jslous.Event.target(evt);
  prvthumb = activethumb;
  activethumb = elm.getAttribute('index'); 
  (function(){
   if(activethumb == prvthumb){ return false; }
   var tmp = {};
   slide_contents[prvthumb].style['overflow'] = 'hidden';
   jslous.func.motion.Listener(tmp,{
    time:0.1,effect:'liner',da:{from:100,to:0,unit:''},
    upd:function(){
     var dalpha = parseInt(this.target.da);
     jslous.css.opacity(slide_contents[prvthumb],dalpha);
    },
    comp:function(){
     jslous.css.opacity(slide_contents[prvthumb],0);
     var obj = {};
     jslous.func.motion.Listener(obj,{
      time:0.1,effect:'liner',aw:{from:0,to:227,unit:''},dw:{from:0,to:0,unit:''},
      go:function(){ jslous.css.setstyles(slide_contents[activethumb],{'width':0+'px','overflow':'hidden','display':''}); },
      upd:function(){
       var awidth = parseInt(this.target.aw);
       var dwidth = parseInt(this.target.dw);
       slide_contents[activethumb].style['width'] = awidth+'px';
       slide_contents[prvthumb].style['width'] = dwidth+'px';
      },
      comp:function(){
       jslous.css.setstyles(slide_contents[activethumb],{'width':227+'px','overflow':'visible'});
       jslous.css.setstyles(slide_contents[prvthumb],{'width':0+'px','display':'none'});
       var obj2 = {};
       jslous.func.motion.Listener(obj2,{
        time:0.1,effect:'liner',aa:{from:0,to:100,unit:''},
        upd:function(){
         var aalpha = parseInt(this.target.aa);
         jslous.css.opacity(slide_contents[activethumb],aalpha);
        },
        comp:function(){ jslous.css.opacity(slide_contents[activethumb],100); }
       });
      }
     });
    }
   });
  })();
 }).query('div#requestclublist').each(function(){
  var elm = this;
  var left_box = document.getElementById('clubBt_l');
  var right_box = document.getElementById('clubBt_r');
  if(left_box && right_box){
   var left_ul = document.createElement('ul');
   left_box.appendChild(left_ul);
   var right_ul = document.createElement('ul');
   right_box.appendChild(right_ul);
  }
  if(elm && elm.tagName.toLowerCase() == 'div'){
   jslous.ajax(dir_req+'footers.xml','GET','',function(res){
    var blocks = jslous.node.list2array(res.getElementsByTagName('block'));
    for(var i = 0,len = blocks.length;i < len;i++){
     if(left_box && right_box){
      var boxli = document.createElement('li');
      var boxa = document.createElement('a');
      boxa.innerHTML = blocks[i].getAttribute('blockname') == '学生マルチメディア運営局' ? 'マルチメディア':blocks[i].getAttribute('blockname');
      boxa.setAttribute('href',doc_root+'contents/club/#'+encodeURIComponent(blocks[i].getAttribute('blockname')));      
      boxli.appendChild(boxa);
      if(i%2 == 0){
       left_ul.appendChild(boxli);
      }else{
       right_ul.appendChild(boxli);
      }
     }
     if(i%3 == 0 && i != len-2){
      if(box){ elm.appendChild(box); }
      var box = document.createElement('div');
      box['className'] = 'box';
     }else if(box && i == len-2){ elm.appendChild(box); }
     if(box){
      var block = document.createElement('div');
      block['className'] = 'block';
      var blockname = document.createElement('div');
      blockname['className'] = 'title';
      blockname.innerHTML = blocks[i].getAttribute('blockname');
      block.appendChild(blockname);
      var clubbox = document.createElement('div');
      var clubul = document.createElement('ul');
      var clubs = jslous.node.list2array(blocks[i].getElementsByTagName('club'));
      if(clubs){
       for(var j = 0,leng = clubs.length;j < leng;j++){
        var li = document.createElement('li');
        var a = document.createElement('a');
 //       a.setAttribute('href',doc_root+'contents/club/#'+encodeURIComponent(clubs[j].getAttribute('clubname')));
 a.setAttribute('href',doc_root+'contents/club/club_name.php?club='+encodeURIComponent(clubs[j].getAttribute('clubname'))+'&block='+encodeURIComponent(blocks[i].getAttribute('blockname')));        
        a.innerHTML = clubs[j].getAttribute('clubname').replace('&','&amp;');
     //   alert(clubs[j].getAttribute('clubname'));
        li.appendChild(a);
        clubul.appendChild(li);
       }
      }
      clubbox.appendChild(clubul);
      block.appendChild(clubbox);
      box.appendChild(block);
     }
    }
   },'xml');
  }
 }).query('div#clubList').each(function(){
  var elm = this;
  if(elm && elm.tagName && elm.tagName.toLowerCase() == 'div'){
   jslous.ajax(dir_req+'introductions.php','GET','',function(res){
    var blocks = jslous.node.list2array(res.getElementsByTagName('block'));
    var cnt = 0;
    for(var i = 0,len = blocks.length;i < len;i++){
     cnt++;
     var blockbox = document.createElement('div');
     blockbox['id'] = cnt == 3 ? 'block02':'block';
     var blockname = blocks[i].getAttribute('blockname');
     var block = document.createElement('div');
     block['id'] = 'md_block';
     var blockanc = document.createElement('a');
     block.innerHTML = '<a name='+encodeURIComponent(blockname)+'></a>'+blockname;
     blockbox.appendChild(block);
     var clubs = jslous.node.list2array(blocks[i].getElementsByTagName('club'));
     if(clubs.length > 0){
      var clubbox = document.createElement('div');
      clubbox['id'] = 'blockBt';
      var clubul = document.createElement('ul');
      clubbox.appendChild(clubul);
      for(var k = 0,j = clubs.length;k < j;k++){
       var clubname = clubs[k].getAttribute('clubname');
       var publish_flag = clubs[k].getAttribute('publish');
       if(publish_flag === '1'){
        var href = 'club_name.php?club='+encodeURIComponent(clubname)+'&block='+encodeURIComponent(blockname);       
       }else{
        var href = 'javascript://';       
       }
       var clubli = document.createElement('li');
       var cluba = document.createElement('a');
       cluba.setAttribute('query','club='+encodeURIComponent(clubname)+'&block='+encodeURIComponent(blockname));
       if(publish_flag === '1'){
        jslous.Event.Listener(cluba,'mouseover',function(evt){
         var trg = jslous.Event.target(evt);
         while(trg.tagName.toLowerCase() != 'a'){ trg = trg.parentNode; }
         var over = arguments.callee;
         var activetip = tip;
         jslous.ajax(php_root+'tip_thumb.php?'+trg.getAttribute('query'),'GET','',function(res){
          if(res && res.length > 0){
           var result = res.split('::');
           activetip.getElementsByTagName('img')[0].src = result[0];
           document.getElementById('popstring').innerHTML = result[1];
           jslous.css.setstyles(activetip,{display:'block',left:jslous.elmPos.left(trg)-(155/2)+'px',top:jslous.elmPos.top(trg)-162+'px'});
           jslous.Event.removeListener(trg,'mouseover',over);
           jslous.Event.Listener(trg,'mouseout',function(evt){
            var trg = jslous.Event.target(evt);
            while(trg.tagName.toLowerCase() != 'a'){ trg = trg.parentNode; }
            var out = arguments.callee;
            activetip.style.display = 'none';
            jslous.Event.Listener(trg,'mouseover',over);
            jslous.Event.removeListener(trg,'mouseover',out);
           });
          }
         },'txt');
        });
       }
       cluba.style['fontSize'] = 10+'px';
       cluba.innerHTML = clubname.replace('&','&amp;');
       cluba.setAttribute('href',href);
       clubli.appendChild(cluba); 
       clubul.appendChild(clubli); 
      }
      blockbox.appendChild(clubbox);
     }
     elm.appendChild(blockbox);
     if(cnt%3 == 0){
      var clear = document.createElement('div');
      clear['className'] = 'clear';
      elm.appendChild(clear);
      cnt = 0;
     }
    }
    var clear = document.createElement('div');
    clear['className'] = 'clear';
    elm.appendChild(clear);
    if(!jslous.Agents.firefox){ location.hash = ''; }
    for(var l = 0,alen = document.anchors.length;l < alen;l++){
     if(decodeURIComponent(anc) == '#'+decodeURIComponent(document.anchors[l].name)){
      location.hash = document.anchors[l].name;
     }
    }
   },'xml');
  }
 }).query('tt#toggle').down(function(evt){
  var toggle = jslous.Event.target(evt);
  var trg = document.getElementById('club_list');
  var moving = function(evt){
   if(mouseflg == true){
    var pt = parseInt(jslous.Event.clientX(evt))-minusmarge;
    pt = jslous.Agents.webkit ? pt-30:jslous.Agents.ie6 ? pt+45:jslous.Agents.ie ? pt+45:pt+45;
    if(minleft <= pt && 777 >= pt){
     toggle.style['left'] = (pt-16)+'px';
     var percent = ((pt-16)/777);
     trg.style['left'] = -(moverange*percent)+16+'px';
     currentPoint = -(moverange*percent);
     togglePoint = pt-15;
    }
    jslous.Event.preventDefault(evt);
   }
  }
  var callee = arguments.callee;
  if(mouseflg == false){
   mouseflg = true;
   jslous.Event.Listener(document,'mousemove',moving);
   jslous.Event.Listener(document,'mouseup',function(evt){
    mouseflg = false;
    jslous.Event.removeListener(document,'mouseup',arguments.callee);
    jslous.Event.removeListener(document,'mousemove',moving);
   });
  }
 }).query('a#left_toggle').click(function(){
  var toggle = document.getElementById('toggle');
  var trg = document.getElementById('club_list');
  jslous.func.motion.Listener(trg.style,{
   time:0.75,
   effect:'backin',
   left:{from:currentPoint,to:minleft,unit:'px'},
   togglep:{from:togglePoint,to:mintoggle,unit:'px'},
   upd:function(){
    currentPoint = parseInt(this.target.left);
    var tp = parseInt(this.target.togglep);
    if(tp > 0 && tp < maxtoggle){
     toggle.style['left'] = tp+'px';
     togglePoint = tp;
    }
   },
   comp:function(){
    var tp = parseInt(this.target.togglep);
    toggle.style['left'] = tp+'px';
    togglePoint = tp;
    trg.style['left'] = minleft+'px';
    currentPoint = minleft;
   }
  });
 }).query('a#right_toggle').click(function(){
  var toggle = document.getElementById('toggle');
  var trg = document.getElementById('club_list');
  jslous.func.motion.Listener(trg.style,{
   time:0.75,
   effect:'backin',
   left:{from:currentPoint,to:-maxleft,unit:'px'},
   togglep:{from:togglePoint,to:maxtoggle,unit:'px'},
   upd:function(){
    currentPoint = parseInt(this.target.left);
    var tp = parseInt(this.target.togglep);
    if(tp > 0 && tp < maxtoggle){
     toggle.style['left'] = tp+'px';
     togglePoint = tp;
    }
   },
   comp:function(){
    var tp = parseInt(this.target.togglep);
    toggle.style['left'] = tp+'px';
    togglePoint = tp;
    trg.style['left'] = -maxleft+'px';
    currentPoint = -maxleft;
   }
  });
 }).query('div#naviBt').each(function(){
  var target = this;
  if(target['className'] == 'none'){ return false; }
  jslous.ajax(php_root+'updator.php','GET','',function(res){
   if(res.length > 0){
    target.innerHTML = res;
   }
  },'txt');
  
 }).query('select#placeswitcher').each(function(){
  var src = document.getElementById('placeswitcher');
  if(src && src.tagName.toLowerCase() == 'select'){
   var active = jslous.node.getSelect(src).value;
   if(document.getElementById('openactive')){
    active = document.getElementById('openactive').value;
   }
   var categories = [];
   categories.push({val:'events',txt:'全会場を表示する '});
   jslous.ajax(sys_req+'places.xml?get='+Math.floor(Math.random()*100),'GET','',function(res){
    $('place',res).each(function(){
     var self = this,value = self.getAttribute('anc'),text = self.getAttribute('at');
     if((active.length > 0 && value == active) || (self.getAttribute('index') && self.getAttribute('index') == 1)){ current = self; }
     categories.push({val:value,txt:text});
    }); 
    categories = jslous.node.createSelect(categories,active);
    categories['name'] = src['name'];
    src.parentNode.replaceChild(categories,src);
    categories['id'] = 'placeswitcher';
    jslous.Event.Listener(categories,'change',function(evt){
     var trg = jslous.Event.target(evt);
     if(trg.tagName.toLowerCase() == 'select'){
      prvplace = activeplace;
      activeplace = jslous.node.getSelect(trg).value;
      if(prvplace == activeplace){ return false; }
      var actives = jslous.html.query('div.'+activeplace);
      var prvs = jslous.html.query('div.'+prvplace);
      var disable = {};
      jslous.func.motion.Listener(disable,{
       time:0.1,
       effect:'expoin',
       alp:{from:100,to:0,unit:''},
       go:function(){ jslous.each(prvs,function(){ var elm = this; elm.style['ovarflow'] = 'hidden'; }); },
       upd:function(){
        var alpha = parseInt(this.target.alp);
        jslous.each(prvs,function(){ var elm = this; jslous.css.opacity(elm,alpha); });
       },
       comp:function(){
        jslous.each(prvs,function(){ var elm = this; jslous.css.opacity(elm,0); });
        var dis = {};
        jslous.func.motion.Listener(dis,{
         time:0.2,
         effect:'backin',
         hei:{from:142,to:0,unit:''},
         upd:function(){
          var height = parseInt(this.target.hei);
          jslous.each(prvs,function(){ var elm = this; elm.style['height'] = height+'px'; });
         },
         comp:function(){
          jslous.each(prvs,function(){ var elm = this; elm.style['height'] = 0+'px';});
          var activetor = {};
          jslous.func.motion.Listener(activetor,{
           time:0.2,
           effect:'backout',
           hei:{from:0,to:142,unit:''},
           upd:function(){
            var height = parseInt(this.target.hei);
            jslous.each(actives,function(){ var elm = this; elm.style['height'] = height+'px'; });
           },
           comp:function(){
            jslous.each(actives,function(){ var elm = this; elm.style['height'] = 142+'px';});
            var finish = {};
            jslous.func.motion.Listener(finish,{
             time:0.1,
             effect:'expoin',
             alp:{from:0,to:100,unit:''},
             upd:function(){
              var alpha = parseInt(this.target.alp);
              jslous.each(actives,function(){ var elm = this; jslous.css.opacity(elm,alpha); });
             },
             comp:function(){
              jslous.each(actives,function(){
               var elm = this; jslous.css.opacity(elm,100);
               elm.style['ovarflow'] = 'visible';
              });
             }
            });
           }           
          });
         }
        });
       }
      });
     }
    });
   },'xml');
  } 
 });

});
