define(["browser","dom","layoutManager","css!./viewcontainer-lite"],function(browser,dom,layoutManager){"use strict";function enableAnimation(){return!browser.tv&&browser.supportsCssAnimation()}function findLastView(parent,className){for(var nodes=parent.childNodes,i=nodes.length-1;i>=0;i--){var node=nodes[i],classList=node.classList;if(classList&&classList.contains(className))return node}}function findViewBefore(elem,className){for(var node=elem.previousSibling;node;){var classList=node.classList;if(classList&&classList.contains(className))return node;node=node.previousSibling}}function loadView(options){if(!options.cancel){cancelActiveAnimations();var selected=selectedPageIndex,previousAnimatable=selected===-1?null:allPages[selected],pageIndex=selected+1;pageIndex>=pageContainerCount&&(pageIndex=0);var viewHtml=options.view,properties=[];options.fullscreen&&properties.push("fullscreen");var view,currentPage=allPages[pageIndex];return currentPage?(triggerDestroy(currentPage),currentPage.insertAdjacentHTML("beforebegin",viewHtml),view=findViewBefore(currentPage,"view"),mainAnimatedPages.removeChild(currentPage)):(mainAnimatedPages.insertAdjacentHTML("beforeend",viewHtml),view=findLastView(mainAnimatedPages,"view")),view.classList.add("mainAnimatedPage"),properties.length&&view.setAttribute("data-properties",properties.join(",")),options.type&&view.setAttribute("data-type",options.type),allPages[pageIndex]=view,onBeforeChange&&onBeforeChange(view,!1,options),beforeAnimate(allPages,pageIndex,selected),animate(view,previousAnimatable,options.transition,options.isBack).then(function(){return selectedPageIndex=pageIndex,currentUrls[pageIndex]=options.url,!options.cancel&&previousAnimatable&&afterAnimate(allPages,pageIndex),view})}}function beforeAnimate(allPages,newPageIndex,oldPageIndex){for(var i=0,length=allPages.length;i