var items=7; var pages=2*items; var stopit = 0; var x = 5; var clearright=0; var clearleft=0; var container=""; var dostop = function() { stopit=1; } var clearstop = function() { stopit=0; } var movetoleft = function() { var temp=parseInt(container.style.left)-770; var temp2=parseInt(container2.style.left)-2240; container.style.left=temp+'px'; container2.style.left=temp2+'px'; x=x+items; clearleft=0; clearstop; } var movetoright = function() { var temp=parseInt(container.style.left)+770; var temp2=parseInt(container2.style.left)+2240; container.style.left=temp+'px'; container2.style.left=temp2+'px'; x=x-items; clearright=0; clearstop; } var movetostart = function() { container.style.left='0px'; container2.style.left='-960px'; x=1; clearright=0; clearstop; } var movetoend = function() { container.style.left='-770px'; container2.style.left='-3200px'; x=items+1; clearleft=0; clearstop; } YAHOO.slider = function() { var $D = YAHOO.util.Dom; var $E = YAHOO.util.Event; var $A = YAHOO.util.Anim; var $M = YAHOO.util.Motion; var $DD = YAHOO.util.DD; var $ = $D.get; return { init : function() { $E.on(['move-left','move-right'], 'click', this.move); container=document.getElementById('slider-cont'); container2=document.getElementById('slider2-cont'); container.style.left='0px'; container2.style.left='0px'; var attributes = { points : { by : [-440, 0] } }; var anim = new $M('slider-cont', attributes, 0.5, YAHOO.util.Easing.easeOut); anim.animate(); var attributes2 = { points : { by : [-2240, 0] } }; var anim2 = new $M('slider2-cont', attributes2, 0.5, YAHOO.util.Easing.easeOut); anim2.animate(); }, moveto : function(pos) { if (stopit==0) { if (posx) { // alert(pos); if (pos>items+1) clearright=1; } var y=x-pos; var dist=y*110; x=pos; var dist2=y*320; var attributes = { points : { by : [dist, 0] } }; var attributes2 = { points : { by : [dist2, 0] } }; var anim = new $M('slider-cont', attributes, 0.5, YAHOO.util.Easing.easeOut); if (clearright==1) anim.onStart.subscribe(movetoright); else anim.onStart.subscribe(dostop); if (clearleft==1) anim.onStart.subscribe(movetoleft); else anim.onStart.subscribe(dostop); anim.onComplete.subscribe(clearstop); anim.animate(); var anim2 = new $M('slider2-cont', attributes2, 0.5, YAHOO.util.Easing.easeOut); anim2.animate(); } }, move : function(e) { if (stopit==0) { $E.stopEvent(e); switch(this.id) { case 'move-left': if ( x === 1 ) { var temp=(pages-1)*110; var temp2=(pages-1)*320; var attributes = { points : { by : [-temp, 0] } }; var attributes2 = { points : { by : [-temp2, 0] } }; x=pages; } else { var attributes = { points : { by : [110, 0] } }; var attributes2 = { points : { by : [320, 0] } }; x--; if (x==1) clearleft=1; } break; case 'move-right': if ( x === pages ) { var temp=(pages-1)*110; var temp2=(pages-1)*320; var attributes = { points : { by : [temp, 0] } }; var attributes2 = { points : { by : [temp2, 0] } }; x=1; } else { var attributes = { points : { by : [-110, 0] } }; var attributes2 = { points : { by : [-320, 0] } }; x++; if (x==items+1) clearright=1; } break; }; var anim = new $M('slider-cont', attributes, 0.5, YAHOO.util.Easing.easeOut); anim.onStart.subscribe(dostop); if (clearright==1) anim.onComplete.subscribe(movetostart); else anim.onComplete.subscribe(clearstop); if (clearleft==1) anim.onComplete.subscribe(movetoend); else anim.onComplete.subscribe(clearstop); anim.animate(); var anim2 = new $M('slider2-cont', attributes2, 0.5, YAHOO.util.Easing.easeOut); anim2.animate(); } } }; }(); YAHOO.util.Event.onAvailable('slider-topcontainer',YAHOO.slider.init, YAHOO.slider, true);