if (!window.adf) {
  window.adf = {};
}
adf.shared = adf.shared || {};
adf.shared.impl = adf.shared.impl || {};
adf.shared.impl.animationUtils = new Object;
adf.shared.impl.animationUtils._browserSpecificNames = {};
adf.shared.impl.animationUtils.transition = function(transitionType, currentElement, newElement, properties) {
  var dimensionsFromParent = properties["dimensionsFromParent"];
  var finishedFunction = properties["finishedFunction"];
  var callbackParams = properties["callbackParams"];
  var animationEnabled = properties["animationEnabled"];
  var isRtl = properties["isRtl"];
  var fineLogger = properties["fineLogger"];
  var hasCurrent = currentElement != null;
  var hasNew = newElement != null;
  var animationUtils = adf.shared.impl.animationUtils;
  var animationContext = new animationUtils.AnimationContext(finishedFunction, callbackParams);
  var cancelFunction = function() {
  };
  animationUtils._isRtl = isRtl;
  animationUtils._fineLogger = fineLogger;
  if (animationUtils._agentTypeAndVersion == null) {
    animationUtils._agentTypeAndVersion = animationUtils._getAgentTypeAndVersion(navigator.userAgent);
  }
  try {
    var nothingToAnimate = false;
    if (!hasCurrent && !hasNew) {
      nothingToAnimate = true;
    } else {
      if (hasCurrent && hasNew && currentElement.parentNode != newElement.parentNode) {
        nothingToAnimate = true;
        animationUtils._fineLogger("AdfAnimationUtils: transition common parent prerequisite was violated");
      }
    }
    if (hasCurrent && currentElement.style.display == "none") {
      nothingToAnimate = true;
      animationUtils._fineLogger("AdfAnimationUtils: transition currentElement display !\x3d none prerequisite was violated");
    }
    if (hasNew && newElement.style.display == "none") {
      nothingToAnimate = true;
      animationUtils._fineLogger("AdfAnimationUtils: transition newElement display !\x3d none prerequisite was violated");
    }
    if (nothingToAnimate) {
      if (finishedFunction != null) {
        adf.shared.impl.animationUtils._requestAnimationFrame(animationUtils.getProxyFunction(animationContext, animationContext._performFinish));
      }
      return cancelFunction;
    }
    if (!animationEnabled) {
      transitionType = "none";
    }
    var transitionFunction = null;
    var direction = null;
    if (transitionType != null) {
      var agentType = animationUtils._agentTypeAndVersion[0];
      var agentVersion = animationUtils._agentTypeAndVersion[1];
      if (transitionType.indexOf("slide") == 0 && animationUtils._isMinimumAgentMet(agentType, agentVersion, "gecko", 16, "trident", 6, "webkit", 533.1)) {
        direction = transitionType.substring(5).toLowerCase();
        transitionFunction = animationUtils._slide;
      } else {
        if (transitionType.indexOf("flip") == 0 && animationUtils._isMinimumAgentMet(agentType, agentVersion, "gecko", 19, "trident", 6, "webkit", 533.1)) {
          direction = transitionType.substring(4).toLowerCase();
          transitionFunction = animationUtils._flip;
        } else {
          if (transitionType == "fade" && animationUtils._isMinimumAgentMet(agentType, agentVersion, "gecko", 16, "trident", 6, "webkit", 533.1)) {
            transitionFunction = animationUtils._fade;
          }
        }
      }
    }
    if (direction == "") {
      direction = "start";
    }
    if (transitionFunction == null || (hasCurrent && !currentElement.addEventListener || hasNew && !newElement.addEventListener)) {
      animationUtils._restoreStyles(currentElement);
      animationUtils._restoreStyles(newElement);
      if (hasCurrent) {
        currentElement.style.display = "none";
      }
      adf.shared.impl.animationUtils._requestAnimationFrame(animationUtils.getProxyFunction(animationContext, animationContext._performFinish));
    } else {
      if (hasCurrent && hasNew && !dimensionsFromParent) {
        var currentElementStyle = currentElement.style;
        var currentWidth = currentElement.offsetWidth;
        var currentHeight = currentElement.offsetHeight;
        currentElementStyle.position = "absolute";
        currentElementStyle.top = "0px";
        currentElementStyle.width = currentWidth + "px";
        currentElementStyle.height = currentHeight + "px";
      }
      cancelFunction = transitionFunction(animationContext, currentElement, newElement, properties, dimensionsFromParent, direction);
    }
  } catch (problem) {
    animationUtils._fineLogger("AdfAnimationUtils: unable to perform transition due to problem:");
    animationUtils._fineLogger(problem);
  }
  return cancelFunction;
};
adf.shared.impl.animationUtils.getProxyFunction = function(owner, func) {
  var proxyFunction = function anonymous() {
    var f = arguments.callee;
    return f._func.apply(f._owner, arguments);
  };
  proxyFunction["_owner"] = owner;
  proxyFunction["_func"] = func;
  return proxyFunction;
};
adf.shared.impl.animationUtils._fade = function(animationContext, currentElement, newElement, properties, dimensionsFromParent, direction) {
  var animationUtils = adf.shared.impl.animationUtils;
  var hasCurrent = currentElement != null;
  var hasNew = newElement != null;
  if (hasCurrent) {
    animationUtils._setOpacity(currentElement, "1");
  }
  if (hasNew) {
    animationUtils._saveStyles(newElement);
    animationUtils._setOpacity(newElement, "0");
    newElement.style.zIndex = "1";
    adf.shared.impl.animationUtils._ensureAppliedStyle(newElement, "opacity", 1);
  }
  adf.shared.impl.animationUtils._requestAnimationFrame(function() {
    if (hasCurrent) {
      animationUtils._setTransition(currentElement, "all .2s ease-in-out");
    }
    if (hasNew) {
      animationUtils._setTransition(newElement, "all .2s ease-in-out");
    }
    if (hasCurrent) {
      animationContext.addTransitionEndA(currentElement, function() {
        currentElement.style.display = "none";
      });
    }
    if (hasNew) {
      animationContext.addTransitionEndB(newElement, function() {
        animationUtils._restoreStyles(newElement);
      });
    }
    if (hasCurrent) {
      animationUtils._setOpacity(currentElement, "0");
    }
    if (hasNew) {
      animationUtils._setOpacity(newElement, "1");
    }
  });
  return animationUtils.getProxyFunction(animationContext, animationContext.cancelFunction);
};
adf.shared.impl.animationUtils._slide = function(animationContext, currentElement, newElement, properties, dimensionsFromParent, direction) {
  var animationUtils = adf.shared.impl.animationUtils;
  var hasCurrent = currentElement != null;
  var hasNew = newElement != null;
  var parentElement = null;
  if (hasCurrent) {
    parentElement = currentElement.parentNode;
  } else {
    if (hasNew) {
      parentElement = newElement.parentNode;
    }
  }
  if (hasNew) {
    animationUtils._saveStyles(newElement);
  }
  var vertical = false;
  var back = false;
  if (direction == "up" || direction == "down") {
    vertical = true;
  }
  if (direction == "right" || direction == "down") {
    back = true;
  }
  if (animationUtils._isRtl) {
    if (direction == "start") {
      back = true;
    }
  } else {
    if (direction == "end") {
      back = true;
    }
  }
  var fadeCurrent = !dimensionsFromParent;
  if (hasCurrent && fadeCurrent) {
    animationUtils._setOpacity(currentElement, "1");
  }
  var translateDistance, size, offsetShift;
  var offsetProperty = vertical ? "offsetHeight" : "offsetWidth";
  if (back) {
    if (hasNew) {
      size = newElement[offsetProperty];
    } else {
      size = currentElement[offsetProperty];
    }
  } else {
    if (hasCurrent) {
      size = currentElement[offsetProperty];
    } else {
      size = newElement[offsetProperty];
    }
  }
  offsetShift = back ? -1 * size : size;
  translateDistance = offsetShift * -1;
  if (hasNew) {
    if (vertical) {
      animationUtils._setTransformTranslate(newElement, "0," + offsetShift + "px");
    } else {
      animationUtils._setTransformTranslate(newElement, offsetShift + "px,0");
    }
    var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
    adf.shared.impl.animationUtils._ensureAppliedStyle(newElement, transformProperty, "none");
  }
  adf.shared.impl.animationUtils._requestAnimationFrame(function() {
    if (hasCurrent) {
      animationUtils._setTransition(currentElement, "all 125ms ease-in-out");
    }
    if (hasNew) {
      animationUtils._setTransition(newElement, "all 125ms ease-in-out");
    }
    if (hasCurrent) {
      animationContext.addTransitionEndA(currentElement, function() {
        currentElement.style.display = "none";
      });
    }
    if (hasNew) {
      animationContext.addTransitionEndB(newElement, function() {
        animationUtils._restoreStyles(newElement);
      });
    }
    if (vertical) {
      if (hasCurrent) {
        animationUtils._setTransformTranslate(currentElement, "0," + translateDistance + "px");
      }
      if (hasNew) {
        animationUtils._setTransformTranslate(newElement, "0,0");
      }
    } else {
      if (hasCurrent) {
        animationUtils._setTransformTranslate(currentElement, translateDistance + "px,0");
      }
      if (hasNew) {
        animationUtils._setTransformTranslate(newElement, "0,0");
      }
    }
    if (hasCurrent && fadeCurrent) {
      animationUtils._setOpacity(currentElement, "0");
    }
  });
  return animationUtils.getProxyFunction(animationContext, animationContext.cancelFunction);
};
adf.shared.impl.animationUtils._flip = function(animationContext, currentElement, newElement, properties, dimensionsFromParent, direction) {
  var animationUtils = adf.shared.impl.animationUtils;
  var hasCurrent = currentElement != null;
  var hasNew = newElement != null;
  var parentElement = null;
  if (hasCurrent) {
    parentElement = currentElement.parentNode;
  } else {
    if (hasNew) {
      parentElement = newElement.parentNode;
    }
  }
  if (hasCurrent) {
    animationUtils._saveStyles(currentElement);
  }
  if (hasNew) {
    animationUtils._saveStyles(newElement);
  }
  animationUtils._saveStyles(parentElement);
  var vertical = false;
  var back = false;
  if (direction == "up" || direction == "down") {
    vertical = true;
  }
  if (direction == "right" || direction == "up") {
    back = true;
  }
  if (animationUtils._isRtl) {
    if (direction == "start") {
      back = true;
    }
  } else {
    if (direction == "end") {
      back = true;
    }
  }
  var agentType = animationUtils._agentTypeAndVersion[0];
  var doInsetFlip = true == properties["parentFlipAllowed"] && "trident" != agentType;
  if ("webkit" == agentType && 534.3 > animationUtils._agentTypeAndVersion[1]) {
    doInsetFlip = false;
  }
  if (doInsetFlip) {
    animationUtils._flipInset(animationContext, animationUtils, currentElement, hasCurrent, newElement, hasNew, parentElement, vertical, back, dimensionsFromParent);
  } else {
    animationUtils._flipOnPageLayer(animationContext, animationUtils, currentElement, hasCurrent, newElement, hasNew, parentElement, vertical, back);
  }
  return animationUtils.getProxyFunction(animationContext, animationContext.cancelFunction);
};
adf.shared.impl.animationUtils._flipOnPageLayer = function(animationContext, animationUtils, currentElement, hasCurrent, newElement, hasNew, parentElement, vertical, back) {
  var offsetWidth = 0;
  var offsetHeight = 0;
  if (hasNew) {
    offsetWidth = newElement.offsetWidth;
    offsetHeight = newElement.offsetHeight;
  }
  if (hasCurrent) {
    offsetWidth = Math.max(offsetWidth, currentElement.offsetWidth);
    offsetHeight = Math.max(offsetHeight, currentElement.offsetHeight);
  }
  if (hasNew) {
    animationUtils._setBackfaceVisibility(newElement, "hidden");
    animationUtils._setTransformStyle(newElement, "preserve-3d");
    newElement.style.width = offsetWidth + "px";
    newElement.style.height = offsetHeight + "px";
    if (vertical) {
      animationUtils._setTransformRotateX(newElement, back ? "-180deg" : "180deg");
    } else {
      animationUtils._setTransformRotateY(newElement, back ? "-180deg" : "180deg");
    }
    var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
    adf.shared.impl.animationUtils._ensureAppliedStyle(newElement, transformProperty, "none");
  }
  if (hasCurrent) {
    animationUtils._setBackfaceVisibility(currentElement, "hidden");
    animationUtils._setTransformStyle(currentElement, "preserve-3d");
    currentElement.style.width = offsetWidth + "px";
    currentElement.style.height = offsetHeight + "px";
    if (vertical) {
      animationUtils._setTransformRotateX(currentElement, "0deg");
    } else {
      animationUtils._setTransformRotateY(currentElement, "0deg");
    }
  }
  var agentType = adf.shared.impl.animationUtils._agentTypeAndVersion[0];
  var agentVersion = adf.shared.impl.animationUtils._agentTypeAndVersion[1];
  if ("webkit" == agentType) {
    if ("webkit" == agentType && 534.3 <= agentVersion) {
      var perspectiveProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("perspective");
      parentElement.style[perspectiveProperty] = "2000px";
    }
  } else {
    if ("trident" != agentType) {
      parentElement.style.perspective = "2000px";
    }
  }
  adf.shared.impl.animationUtils._requestAnimationFrame(function() {
    if (hasCurrent) {
      animationUtils._setTransition(currentElement, "all .2s ease-in-out");
    }
    if (hasNew) {
      animationUtils._setTransition(newElement, "all .2s ease-in-out");
    }
    if (hasCurrent) {
      animationContext.addTransitionEndA(currentElement, function() {
        currentElement.style.display = "none";
        animationUtils._restoreStyles(currentElement);
        animationUtils._restoreStyles(parentElement);
      });
    }
    if (hasNew) {
      animationContext.addTransitionEndB(newElement, function() {
        animationUtils._restoreStyles(newElement);
        animationUtils._restoreStyles(parentElement);
      });
    }
    if (vertical) {
      if (hasCurrent) {
        animationUtils._setTransformRotateX(currentElement, back ? "180deg" : "-180deg");
      }
      if (hasNew) {
        animationUtils._setTransformRotateX(newElement, "0deg");
      }
    } else {
      if (hasCurrent) {
        animationUtils._setTransformRotateY(currentElement, back ? "180deg" : "-180deg");
      }
      if (hasNew) {
        animationUtils._setTransformRotateY(newElement, "0deg");
      }
    }
  });
};
adf.shared.impl.animationUtils._flipInset = function(animationContext, animationUtils, currentElement, hasCurrent, newElement, hasNew, parentElement, vertical, back, dimensionsFromParent) {
  var grandparentElement = parentElement.parentNode;
  animationContext.addExtraCancelFunction(function() {
    animationUtils._flipInsetExtraCancel(currentElement, hasCurrent, newElement, hasNew, parentElement, grandparentElement);
  });
  animationUtils._saveStyles(grandparentElement);
  var perspectiveProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("perspective");
  grandparentElement.style[perspectiveProperty] = "2000px";
  animationUtils._setTransformStyle(parentElement, "preserve-3d");
  var offsetWidth = 0;
  var offsetHeight = 0;
  if (hasNew) {
    offsetWidth = newElement.offsetWidth;
    offsetHeight = newElement.offsetHeight;
  }
  if (hasCurrent) {
    offsetWidth = Math.max(offsetWidth, currentElement.offsetWidth);
    offsetHeight = Math.max(offsetHeight, currentElement.offsetHeight);
  }
  if (hasNew) {
    animationUtils._setBackfaceVisibility(newElement, "hidden");
    newElement.style.width = offsetWidth + "px";
    newElement.style.height = offsetHeight + "px";
    if (vertical) {
      animationUtils._setTransformValue(newElement, "perspective(2000px) rotateX(" + (back ? "180deg" : "-180deg") + ")");
    } else {
      animationUtils._setTransformValue(newElement, "perspective(2000px) rotateY(" + (back ? "-180deg" : "180deg") + ")");
    }
    var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
    adf.shared.impl.animationUtils._ensureAppliedStyle(newElement, transformProperty, "none");
  }
  if (hasCurrent) {
    animationUtils._setBackfaceVisibility(currentElement, "hidden");
    currentElement.style.width = offsetWidth + "px";
    currentElement.style.height = offsetHeight + "px";
    if (vertical) {
      animationUtils._setTransformValue(currentElement, "perspective(2000px) rotateX(0deg)");
    } else {
      animationUtils._setTransformValue(currentElement, "perspective(2000px) rotateY(0deg)");
    }
  }
  if (vertical) {
    animationUtils._setTransformOrigin(parentElement, back ? "center bottom" : "center top");
  } else {
    animationUtils._setTransformOrigin(parentElement, back ? "left center" : "right center");
  }
  adf.shared.impl.animationUtils._requestAnimationFrame(function() {
    animationUtils._setTransition(parentElement, "all .2s ease-in-out");
    animationContext.addTransitionEndA(parentElement, function() {
      if (hasCurrent) {
        animationUtils._restoreStyles(currentElement);
        currentElement.style.display = "none";
      }
      if (hasNew) {
        animationUtils._restoreStyles(newElement);
      }
      animationUtils._flipInsetExtraCancel(currentElement, hasCurrent, newElement, hasNew, parentElement, grandparentElement);
    });
    if (vertical) {
      animationUtils._setTransformValue(parentElement, "perspective(2000px) " + (back ? "translateY(-100%) rotateX(180deg)" : "translateY(100%) rotateX(-180deg)"));
    } else {
      animationUtils._setTransformValue(parentElement, "perspective(2000px) " + (back ? "translateX(100%) rotateY(180deg)" : "translateX(-100%) rotateY(-180deg)"));
    }
  });
};
adf.shared.impl.animationUtils._flipInsetExtraCancel = function(currentElement, hasCurrent, newElement, hasNew, parentElement, grandparentElement) {
  var animationUtils = adf.shared.impl.animationUtils;
  animationUtils._restoreStyles(parentElement);
  animationUtils._restoreStyles(grandparentElement);
};
adf.shared.impl.animationUtils._ensureAppliedStyle = function(element, propertyName, valueItShouldNotBe) {
  if (element.ownerDocument.defaultView.getComputedStyle != null) {
    var actualValue = element.ownerDocument.defaultView.getComputedStyle(element)[propertyName];
    if (actualValue == valueItShouldNotBe) {
      adf.shared.impl.animationUtils._fineLogger("AdfAnimationUtils: computed style had unexpected value: " + actualValue);
    }
  }
};
adf.shared.impl.animationUtils._getTransitionEndEventName = function() {
  if (adf.shared.impl.animationUtils._transitionEndEventName == null) {
    var eventName = "transitionend";
    var element = document.createElement("div");
    var possibleEventNames = {"WebkitTransition":"webkitTransitionEnd", "transition":"transitionend", "OTransition":"oTransitionEnd", "MozTransition":"transitionend"};
    for (var stylePropertyName in possibleEventNames) {
      if (element.style[stylePropertyName] !== undefined) {
        eventName = possibleEventNames[stylePropertyName];
        break;
      }
    }
    adf.shared.impl.animationUtils._transitionEndEventName = eventName;
  }
  return adf.shared.impl.animationUtils._transitionEndEventName;
};
adf.shared.impl.animationUtils._getBrowserSpecificName = function(baseName) {
  if (adf.shared.impl.animationUtils._browserSpecificNames[baseName] == null) {
    var name = baseName;
    var capitalizedName = baseName.charAt(0).toUpperCase() + baseName.substring(1);
    var element = document.createElement("div");
    var possibleNames = {};
    possibleNames["Webkit" + capitalizedName] = "webkit" + capitalizedName;
    possibleNames[name] = name;
    possibleNames["O" + capitalizedName] = "o" + capitalizedName;
    possibleNames["Moz" + capitalizedName] = "moz" + capitalizedName;
    for (var stylePropertyName in possibleNames) {
      if (element.style[stylePropertyName] !== undefined) {
        name = stylePropertyName;
        break;
      }
    }
    adf.shared.impl.animationUtils._browserSpecificNames[baseName] = name;
  }
  return adf.shared.impl.animationUtils._browserSpecificNames[baseName];
};
adf.shared.impl.animationUtils._requestAnimationFrame = function(callback) {
  var lastTime = 0;
  var vendors = ["webkit", "ms", "moz", "o"];
  for (var x = 0;x < vendors.length && !window.requestAnimationFrame;++x) {
    window.requestAnimationFrame = window[vendors[x] + "RequestAnimationFrame"];
    window.cancelAnimationFrame = window[vendors[x] + "CancelAnimationFrame"] || window[vendors[x] + "CancelRequestAnimationFrame"];
  }
  if (!window.requestAnimationFrame) {
    window.requestAnimationFrame = function(callback) {
      var currTime = (new Date).getTime();
      var timeToCall = Math.max(0, 16 - (currTime - lastTime));
      var id = window.setTimeout(function() {
        callback(currTime + timeToCall);
      }, timeToCall);
      lastTime = currTime + timeToCall;
      return id;
    };
  }
  if (!window.cancelAnimationFrame) {
    window.cancelAnimationFrame = function(id) {
      clearTimeout(id);
    };
  }
  window.requestAnimationFrame(callback);
};
adf.shared.impl.animationUtils._isMinimumAgentMet = function(actualAgentType, actualAgentVersion) {
  var argCount = arguments.length;
  if (argCount % 2 == 1) {
    adf.shared.impl.animationUtils._fineLogger("AdfAnimationUtils: invalid number of minimum agent requirement arguments: " + argCount);
    return false;
  }
  for (var i = 2;i <= argCount - 2;i += 2) {
    var requriementType = arguments[i];
    if (actualAgentType == requriementType) {
      var requirementVersion = arguments[1 + i];
      if (actualAgentVersion >= requirementVersion) {
        return true;
      } else {
        return false;
      }
    }
  }
  return false;
};
adf.shared.impl.animationUtils._getAgentTypeAndVersion = function(givenUserAgentString) {
  var versionParser = adf.shared.impl.animationUtils._parseFloatVersion;
  var agentType = null;
  var agentVersion = -1;
  var userAgent = givenUserAgentString.toLowerCase();
  if (userAgent.indexOf("msie") != -1 || userAgent.indexOf("trident") != -1) {
    agentType = "trident";
    var possibleVersion = versionParser(userAgent, /trident\/(\d+[.]\d+)/);
    if (possibleVersion != -1) {
      agentVersion = possibleVersion;
    } else {
      possibleVersion = versionParser(userAgent, /msie (\d+\.\d+);/);
      if (possibleVersion == -1) {
        possibleVersion = versionParser(userAgent, /msie (\d+\.\d+)b;/);
      }
      agentVersion = possibleVersion - 4;
    }
    if (document.documentMode != null) {
      agentVersion = Math.min(agentVersion, document.documentMode - 4);
    }
  } else {
    if (userAgent.indexOf("applewebkit") != -1) {
      agentType = "webkit";
      agentVersion = versionParser(userAgent, /applewebkit\/(\d+([.]\d+)*)/);
    } else {
      if (userAgent.indexOf("gecko/") != -1) {
        agentType = "gecko";
        agentVersion = versionParser(userAgent, /rv:(\d+[.]\d+)/);
      }
    }
  }
  return [agentType, agentVersion];
};
adf.shared.impl.animationUtils._parseFloatVersion = function(userAgent, versionNumberPattern) {
  var matches = userAgent.match(versionNumberPattern);
  if (matches) {
    var versionString = matches[1];
    if (versionString) {
      return parseFloat(versionString);
    }
  }
  return -1;
};
adf.shared.impl.animationUtils._saveStyles = function(element) {
  if (element != null && element.getAttribute && element.setAttribute) {
    var styles = element.getAttribute("data-adf-original-style");
    if (styles != null) {
      adf.shared.impl.animationUtils._fineLogger("AdfAnimationUtils: save while pending restore");
      adf.shared.impl.animationUtils._restoreStyles(element);
    }
    styles = element.getAttribute("style");
    if (styles == null) {
      styles = "";
    }
    element.setAttribute("data-adf-original-style", styles);
  }
};
adf.shared.impl.animationUtils._restoreStyles = function(element) {
  if (element != null && element.getAttribute && element.setAttribute) {
    var styles = element.getAttribute("data-adf-original-style");
    if (styles != null) {
      element.setAttribute("style", styles);
      if (element.removeAttribute) {
        element.removeAttribute("data-adf-original-style");
      }
    }
  }
};
adf.shared.impl.animationUtils._setOpacity = function(element, opacityValue) {
  element.style.opacity = opacityValue;
};
adf.shared.impl.animationUtils._setTransition = function(element, transitionValue) {
  var transitionProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transition");
  element.style[transitionProperty] = transitionValue;
};
adf.shared.impl.animationUtils._setTransformValue = function(element, transformValue) {
  var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
  element.style[transformProperty] = transformValue;
};
adf.shared.impl.animationUtils._setTransformTranslate = function(element, translateValues) {
  var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
  element.style[transformProperty] = "translate(" + translateValues + ")";
};
adf.shared.impl.animationUtils._setTransformRotateX = function(element, rotateXValues) {
  var agentType = adf.shared.impl.animationUtils._agentTypeAndVersion[0];
  if ("trident" == agentType) {
    element.style.transform = "perspective(2000px) rotateX(" + rotateXValues + ")";
  } else {
    var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
    element.style[transformProperty] = "rotateX(" + rotateXValues + ")";
  }
};
adf.shared.impl.animationUtils._setTransformRotateY = function(element, rotateYValues) {
  var agentType = adf.shared.impl.animationUtils._agentTypeAndVersion[0];
  if ("trident" == agentType) {
    element.style.transform = "perspective(2000px) rotateY(" + rotateYValues + ")";
  } else {
    var transformProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transform");
    element.style[transformProperty] = "rotateY(" + rotateYValues + ")";
  }
};
adf.shared.impl.animationUtils._setBackfaceVisibility = function(element, backfaceVisibility) {
  var backfaceVisibilityProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("backfaceVisibility");
  element.style[backfaceVisibilityProperty] = backfaceVisibility;
};
adf.shared.impl.animationUtils._setTransformStyle = function(element, transformStyle) {
  var transformStyleProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transformStyle");
  element.style[transformStyleProperty] = transformStyle;
};
adf.shared.impl.animationUtils._setTransformOrigin = function(element, transformOrigin) {
  var transformOriginProperty = adf.shared.impl.animationUtils._getBrowserSpecificName("transformOrigin");
  element.style[transformOriginProperty] = transformOrigin;
};
adf.shared.impl.animationUtils.AnimationContext = function(finishedFunction, callbackParams) {
  this.Init(finishedFunction, callbackParams);
};
adf.shared.impl.animationUtils.AnimationContext.prototype = new Object;
if (window.AdfObject != null) {
  adf.shared.impl.animationUtils.AnimationContext.prototype.constructor = window.AdfObject;
}
adf.shared.impl.animationUtils.AnimationContext.prototype.Init = function(finishedFunction, callbackParams) {
  this._finishedFunction = finishedFunction;
  this._callbackParams = callbackParams;
  this._handledA = true;
  this._handledB = true;
};
adf.shared.impl.animationUtils.AnimationContext.prototype.cancelFunction = function() {
  this._finishedFunction = null;
  var callbackParams = this._callbackParams;
  this._callbackParams = null;
  var animationUtils = adf.shared.impl.animationUtils;
  animationUtils._restoreStyles(this._elementA);
  animationUtils._restoreStyles(this._elementB);
  var parentElement;
  if (this._elementA != null) {
    parentElement = this._elementA.parentNode;
    animationUtils._restoreStyles(parentElement);
    if (parentElement != null) {
      animationUtils._restoreStyles(parentElement.parentNode);
    }
  } else {
    if (this._elementB != null) {
      parentElement = this._elementB.parentNode;
      animationUtils._restoreStyles(parentElement);
      if (parentElement != null) {
        animationUtils._restoreStyles(parentElement.parentNode);
      }
    }
  }
  this._removeTransitionEndA();
  this._removeTransitionEndB();
  if (this._extraCancelFunction) {
    try {
      this._extraCancelFunction();
    } catch (problem) {
      animationUtils._fineLogger("AdfAnimationUtils: unable to complete extra cancel function due to problem:");
      animationUtils._fineLogger(problem);
    }
    this._extraCancelFunction = null;
  }
  return callbackParams;
};
adf.shared.impl.animationUtils.AnimationContext.prototype._performFinish = function() {
  var finishedFunction = this._finishedFunction;
  var callbackParams = this._callbackParams;
  this._finishedFunction = null;
  this._extraCancelFunction = null;
  this._callbackParams = null;
  if (finishedFunction != null) {
    finishedFunction(callbackParams);
  }
};
adf.shared.impl.animationUtils.AnimationContext.prototype.addExtraCancelFunction = function(extraCancelFunction) {
  this._extraCancelFunction = extraCancelFunction;
};
adf.shared.impl.animationUtils.AnimationContext.prototype.addTransitionEndA = function(element, extraHandler) {
  this._elementA = element;
  this._handleProxyA = adf.shared.impl.animationUtils.getProxyFunction(this, this._handleTransitionEndA);
  this._handledA = false;
  var transitionEndEventName = adf.shared.impl.animationUtils._getTransitionEndEventName();
  if (extraHandler != null) {
    this._extraHandlerA = extraHandler;
    element.addEventListener(transitionEndEventName, extraHandler, true);
  }
  element.addEventListener(transitionEndEventName, this._handleProxyA, true);
};
adf.shared.impl.animationUtils.AnimationContext.prototype._removeTransitionEndA = function() {
  var element = this._elementA;
  if (element != null) {
    var transitionEndEventName = adf.shared.impl.animationUtils._getTransitionEndEventName();
    if (this._extraHandlerA != null) {
      element.removeEventListener(transitionEndEventName, this._extraHandlerA, true);
      this._extraHandlerA = null;
    }
    element.removeEventListener(transitionEndEventName, this._handleProxyA, true);
    this._elementA = null;
  }
  this._handleProxyA = null;
};
adf.shared.impl.animationUtils.AnimationContext.prototype._handleTransitionEndA = function() {
  if (!this._handledA) {
    this._handledA = true;
    this._removeTransitionEndA();
    if (this._handledB) {
      this._performFinish();
    }
  }
};
adf.shared.impl.animationUtils.AnimationContext.prototype.addTransitionEndB = function(element, extraHandler) {
  this._elementB = element;
  this._handleProxyB = adf.shared.impl.animationUtils.getProxyFunction(this, this._handleTransitionEndB);
  this._handledB = false;
  var transitionEndEventName = adf.shared.impl.animationUtils._getTransitionEndEventName();
  if (extraHandler != null) {
    this._extraHandlerB = extraHandler;
    element.addEventListener(transitionEndEventName, extraHandler, true);
  }
  element.addEventListener(transitionEndEventName, this._handleProxyB, true);
};
adf.shared.impl.animationUtils.AnimationContext.prototype._removeTransitionEndB = function() {
  var element = this._elementB;
  if (element != null) {
    var transitionEndEventName = adf.shared.impl.animationUtils._getTransitionEndEventName();
    if (this._extraHandlerB != null) {
      element.removeEventListener(transitionEndEventName, this._extraHandlerB, true);
      this._extraHandlerB = null;
    }
    element.removeEventListener(transitionEndEventName, this._handleProxyB, true);
    this._elementB = null;
  }
  this._handleProxyB = null;
};
adf.shared.impl.animationUtils.AnimationContext.prototype._handleTransitionEndB = function() {
  if (!this._handledB) {
    this._handledB = true;
    this._removeTransitionEndB();
    if (this._handledA) {
      this._performFinish();
    }
  }
};
