define(["lazyLoader","layoutManager","browser","appSettings","require"],function(lazyLoader,layoutManager,browser,appSettings,require){"use strict";var supportsNativeLazyLoading="loading"in HTMLImageElement.prototype;supportsNativeLazyLoading||require(["css!./style"]);var self={};function fillImage(elem,source){if(source||!supportsNativeLazyLoading){if("IMG"===elem.tagName)return elem.setAttribute("src",source||elem.getAttribute("data-src")),void elem.removeAttribute("data-src");source&&(elem.style.backgroundImage="url('"+source+"')"),elem.classList.remove("lazy")}}return self.fillImages=function(elems){if(!supportsNativeLazyLoading)for(var i=0,length=elems.length;i<length;i++){fillImage(elems[0])}},self.lazyImage=fillImage,self.lazyChildren=function(elem){supportsNativeLazyLoading||lazyLoader.lazyChildren(elem,fillImage)},self.getPrimaryImageAspectRatio=function(items,options){for(var values=[],i=0,length=items.length;i<length;i++){var item=items[i],ratio=(options&&options.showCurrentProgramImage?item.CurrentProgram||item:item.ProgramInfo||item).PrimaryImageAspectRatio||0;ratio&&(values[values.length]=ratio)}if(!values.length)return null;values.sort(function(a,b){return a-b});var result,half=Math.floor(values.length/2);return result=values.length%2?values[half]:(values[half-1]+values[half])/2,Math.abs(2/3-result)<=.1666667?2/3:Math.abs(16/9-result)<=.222222?16/9:Math.abs(4/3-result)<=.2?4/3:Math.abs(1-result)<=.1666667?1:result},self});