var slide = 0;
var duration= 350;
var currentAnimation;
function doAnimation(nodeId, size, direction) {
console.log("doAnimation: [ID: " + nodeId + "],[Size: " + size + "],[Direction: " + direction + "]");
  switch(size) {
    case 'L':
      slide = 150-80;
      break;
    case 'L2':
      slide = 97-50;
      break;
    case 'M': 
      slide = 97-50;        
      break;
    case 'S': 
      slide = 71-40;        
      break;
    case 'XS': 
      slide = 50-35;        
      break;
  }
  switch(direction) {
    case 'top':
      currentAnimation = dojo.animateProperty( {
        node: nodeId ,duration: duration, properties: {
          marginTop: {end: 1}
        }
      });
      break;
    case 'down': 
      currentAnimation = dojo.animateProperty( {
        node: nodeId ,duration: duration, properties: {
          marginTop: {end: slide}
        }
      });
      break;
  }
  if (currentAnimation) {
    //Play the animation. Without this call, it will not run.
    dojo.connect(currentAnimation, "onEnd", function() {
      currentAnimation = null;
    });
  currentAnimation.play();
  }
}