var Dom=YAHOO.util.Dom;var Event=YAHOO.util.Event;var DDM=YAHOO.util.DragDropMgr;YAHOO.example.DDApp={init:function(){var b=Dom.get("orderlist");var a=YAHOO.util.Dom.getElementsBy(function(c){return true},"li",b);for(i=0;i<a.length;i++){new YAHOO.example.DDList(a[i].id)}new YAHOO.util.DDTarget(b);this.initialOrder="";this.arrInitialOrder=new Array();this.saveInitialOrder();this.saveOrder()},saveInitialOrder:function(c){var b=Dom.get("orderlist");this.initialOrder=b.innerHTML;var a=YAHOO.util.Dom.getElementsBy(function(d){return true},"li",b);for(i=0;i<a.length;i++){this.arrInitialOrder.push(a[i].id)}},saveOrder:function(d){var c="";var b=Dom.get("orderresult");var a=Dom.get("orderlist");listitems=YAHOO.util.Dom.getElementsBy(function(e){return true},"li",a);for(i=0;i<listitems.length;i++){c+=listitems[i].id;if(i<listitems.length-1){c+=":"}}b.value=c},restoreOrder:function(){var a=Dom.get("orderlist");a.innerHTML=this.initialOrder;this.init()}};YAHOO.example.DDList=function(d,a,b){YAHOO.example.DDList.superclass.constructor.call(this,d,a,b);var c=this.getDragEl();Dom.setStyle(c,"opacity",0.67);Dom.addClass(c,"proxy");c.resizeFrame=false;this.goingUp=false;this.lastY=0};YAHOO.extend(YAHOO.example.DDList,YAHOO.util.DDProxy,{startDrag:function(b,d){var a=this.getDragEl();var c=this.getEl();Dom.setStyle(c,"visibility","hidden");a.innerHTML=c.innerHTML},endDrag:function(g){var d=this.getEl();var f=this.getDragEl();Dom.setStyle(f,"visibility","");var b=new YAHOO.util.Motion(f,{points:{to:Dom.getXY(d)}},0.2,YAHOO.util.Easing.easeOut);var c=f.id;var h=this.id;b.onComplete.subscribe(function(){Dom.setStyle(c,"visibility","hidden");Dom.setStyle(h,"visibility","")});b.animate();YAHOO.example.DDApp.saveOrder()},onDragDrop:function(c,d){if(DDM.interactionInfo.drop.length===1){var b=DDM.interactionInfo.point;var a=DDM.interactionInfo.sourceRegion}},onDrag:function(a){var b=Event.getPageY(a);if(b<this.lastY){this.goingUp=true}else{if(b>this.lastY){this.goingUp=false}}this.lastY=b},onDragOver:function(f,g){var c=this.getEl();var b=Dom.get(g);if(b.nodeName.toLowerCase()=="li"){var a=c.parentNode;var d=b.parentNode;if(this.goingUp){d.insertBefore(c,b)}else{d.insertBefore(c,b.nextSibling)}DDM.refreshCache()}}});Event.onDOMReady(YAHOO.example.DDApp.init,YAHOO.example.DDApp,true);