var CSlideBox = Class.create(); CSlideBox.prototype = { initialize: function(el,slide_el,term_width,ainfo,is_biglayer) { this.el = el; this.slide_el = el.select('.'+slide_el); this.scrollbody_el = el.select('.scrollbody')[0]; this.term_width = term_width; if(ainfo) this.ainfo = ainfo; this.nowpos = 0; //파이어폭스에서 퍼포먼스 문제가 있어, 큰 레이어는 에니메이션 적용 안함 if(is_biglayer) this.is_biglayer = is_biglayer; else this.is_biglayer = false; this.ani_timer = false; }, nomore: function() { no_el = this.el.select('.nopage')[0]; if(no_el) { Effect.Appear(no_el, {duration:0.3,beforeFinish:(function(){ setTimeout((function(){ new Effect.Fade(no_el,{duration:0.5}); }).bind(this),1000); }).bind(this)}); } else { alert('다른 페이지가 없습니다.'); } }, next:function() { if(this.slide_el.length<=1) { this.nomore(); return; } //if(this.ani_timer) return; //this.ani_timer = true; this.nowpos++; if(this.nowpos>this.slide_el.length-1) this.nowpos = 0; gotopos = this.term_width*this.nowpos; this.moving(gotopos); }, prev:function() { if(this.slide_el.length<=1) { this.nomore(); return; } if(this.slide_el.length<=1) { alert('다른 페이지가 없습니다.'); return; } //if(this.ani_timer) return; //this.ani_timer = true; this.nowpos--; if(this.nowpos<0) this.nowpos = this.slide_el.length-1; gotopos = this.term_width*this.nowpos; this.moving(gotopos); }, moving:function(gotopos) { if(this.is_biglayer && navigator.userAgent.indexOf('Firefox') > -1) dr = 0; else dr = 0.3; new Effect.Move(this.scrollbody_el, { x: gotopos*-1, y: 0, mode: 'absolute', duration:dr, beforeFinish:(function(){ this.ani_timer = false; this.finish(); }).bind(this)}); }, reset:function() { new Effect.Move(this.scrollbody_el, { x: 0, y: 0, mode: 'absolute', duration:0, beforeFinish:(function(){}).bind(this)}); }, finish:function() { }, shuffle:function() { var rnum = Math.floor(Math.random() * (this.slide_el.length-1)) + 1; this.nowpos = rnum; gotopos = this.term_width*this.nowpos; new Effect.Move(this.scrollbody_el, { x: gotopos*-1, y: 0, mode: 'absolute', duration:0, beforeFinish:(function(){ this.finish() }).bind(this)}); this.scrollbody_el.show(); } }; var CMixupBestBox = Class.create(); CMixupBestBox.prototype = { initialize: function(tarel,total_cnt) { this.tarel = tarel; this.now_tab_id = 1; this.total_cnt = total_cnt; this.over_timer = null this.now_tab_id = 1; this.slide = new CSlideBox(this.tarel.getElementsByClassName('tab_i'+this.now_tab_id)[0],'contents',348,null,true); this.tab_list = Array('','day','yesterday','week','month'); }, tabchange:function(tab_id) { if(this.now_tab_id==tab_id) return; if(this.over_timer) return; this.over_timer = setTimeout((function(){ this.tabreset(tab_id); }).bind(this),200); }, tabreset:function(tab_id) { this.tarel.getElementsByClassName('tab_i'+this.now_tab_id)[0].hide(); tabi_el = this.tarel.getElementsByClassName('tab_i'+tab_id)[0]; this.slide = new CSlideBox(tabi_el,'contents',348,null,true); this.slide.reset(); tabi_el.show(); this.tarel.getElementsByClassName('tab_m'+this.now_tab_id)[0].getElementsByClassName('tab_link')[0].removeClassName('selected'); this.tarel.getElementsByClassName('tab_m'+tab_id)[0].getElementsByClassName('tab_link')[0].addClassName('selected'); this.now_tab_id = tab_id; //커버 타이머삭제 if(this.over_timer) this.tabchange_cancle(); }, tabchange_cancle:function() { clearTimeout(this.over_timer); this.over_timer = null; }, next: function() { this.slide.next(); }, prev: function() { this.slide.prev(); }, more: function() { location.href='/rank/contents/?type='+this.tab_list[this.now_tab_id]; } }; var CIssueBox = Class.create(); CIssueBox.prototype = { initialize: function(tar_el,tabinfo) { this.tar_el = tar_el; this.tabinfo = tabinfo; this.now_tag_pos = 0; this.now_tag_uid = tabinfo[this.now_tag_pos]['tag_uid']; this.over_timer = null; this.ani_timer = null; $(this.tar_el).getElementsByClassName('tab_m'+this.now_tag_uid)[0].getElementsByClassName('tab_link')[0].addClassName('selected'); }, show:function(tag_uid,pos) { if(this.now_tag_uid==tag_uid) return; if(this.over_timer) return; this.over_timer = setTimeout((function(){ this.now_tag_pos = pos; this.draw(tag_uid); this.reposition_tab('over'); }).bind(this),200); }, cancle:function() { clearTimeout(this.over_timer); this.over_timer = null; }, draw:function(tag_uid) { $(this.tar_el).getElementsByClassName('tab_i'+this.now_tag_uid)[0].hide(); $(this.tar_el).getElementsByClassName('tab_i'+tag_uid)[0].show(); //탭 변경 $(this.tar_el).getElementsByClassName('tab_m'+this.now_tag_uid)[0].getElementsByClassName('tab_link')[0].removeClassName('selected'); $(this.tar_el).getElementsByClassName('tab_m'+tag_uid)[0].getElementsByClassName('tab_link')[0].addClassName('selected'); clearTimeout(this.over_timer); this.over_timer = null; this.now_tag_uid = tag_uid; }, next: function() { //if(this.ani_timer) return; this.now_tag_pos++; if(this.now_tag_pos>this.tabinfo.length-1) this.now_tag_pos = 0; this.draw(this.tabinfo[this.now_tag_pos]['tag_uid']); this.reposition_tab('but'); }, prev: function() { //if(this.ani_timer) return; this.now_tag_pos--; if(this.now_tag_pos<0) this.now_tag_pos = this.tabinfo.length-1; this.draw(this.tabinfo[this.now_tag_pos]['tag_uid']); this.reposition_tab('but'); }, more: function() { location.href='/post/list/issue.html?tar_tag='+encodeURI(this.tabinfo[this.now_tag_pos]['tag']); }, reposition_tab: function(type) { var gotopos = -1; if(type=='but') { if(this.now_tag_pos>1) { if(this.now_tag_pos>this.tabinfo.length-3) { gotopos = ((this.tabinfo.length-2)*95)-157; } else { gotopos = (this.now_tag_pos*95)-135; } } } else if(type=='over') { el = $(this.tar_el).getElementsByClassName('tab_m'+this.tabinfo[this.now_tag_pos]['tag_uid'])[0]; if($(this.tar_el).viewportOffset()[0]>el.viewportOffset()[0]) { gotopos = (this.now_tag_pos*95); } if($(this.tar_el).viewportOffset()[0]+$(this.tar_el).getWidth()