if (typeof window.Hp == "undefined") window.Hp = {}; if (typeof window.Hp.FlyPage == "undefined") window.Hp.FlyPage = { isInitialized: false, flyDiv: null, dotPage: null, pageCount: 0, flyWidth: 0, pageIndex: 0, beginx: 0, stopx: 0, delay: 0, processAnimating: function() { this.dotPage.find('div').removeClass('hover current').eq(this.pageIndex).addClass('current'); this.flyDiv.animate({left : -(this.flyWidth*this.pageIndex)+'px'}, this.delay); }, createDotPage: function() { var d = []; for(var i=1; i <= this.pageCount; i++) { d[d.length] = '<div title="' + i +'"class=""><img src="/s/i_bg/sprite.png" alt="' + i + '"></div>'; } this.dotPage.append(d.join('')); this.dotPage.find('div:first').addClass('current').end().find('div').click(function(){ var e = Hp.FlyPage; e.pageIndex = $(this).index(); e.processAnimating(); }).hover(function(){$(this).not('.current').addClass('hover');},function(){$(this).not('.current').removeClass('hover');}); }, init: function() { var e = Hp.FlyPage; if (e.isInitialized) return; e.isInitialized = true; e.flyDiv = $(".hpFP .hpFP_content"); e.dotPage = $(".hpFP_dot .hpFP_dotPaging"); e.pageCount = $(".hpFP_box .hpFP_slide").length; e.flyWidth = $(".hpFP .hpFP_box").width(); e.flyDiv.css("width", e.pageCount* e.flyWidth); e.pageIndex = 0; e.beginx=0; e.stopx=0; e.delay = 500; e.createDotPage(); e.flyDiv.draggable ({ axis:'x', handle:'div', start:function(event,ui){ var e = Hp.FlyPage; e.beginx=this.offsetLeft; e.stopx=0; }, stop:function(event,ui){ var e = Hp.FlyPage; e.stopx=this.offsetLeft; var s=e.beginx-e.stopx; var d = s>0?-1:1; if((e.pageIndex - d) < e.pageCount && (e.pageIndex - d) >= 0){ e.pageIndex -= d; } e.processAnimating(); } }); } };