var iPhone=!1,iPad=!1;rm={htmlbody:$("html, body"),init:function(){navigator.userAgent.toLowerCase().indexOf("ipad")!=-1&&$("body").addClass("ipad"),$(document).ready(function(){var t,i,r,n,u;$(".ie8").length&&(t=window.location.hash,t.length&&(ccoords=$(t).offset().top+-20,rm.htmlbody.scrollTop(ccoords))),$(".scLoadingIndication").length?(i="fade",r=!1):(i="slide",r=!0),$(".flexslider").length&&$(".flexslider").flexslider({animation:i,prevText:"&lsaquo;",nextText:"&rsaquo;",slideshowSpeed:5e3,slideshow:r,start:function(){$(".flex-direction-nav").first().appendTo(".carousel");var t=$(".flex-control-paging li"),n=t.length*t.outerWidth(!0)/2;$(".carousel .flex-control-paging").css({marginLeft:-n}),$("head").append('<style type="text/css">@media only screen and (max-width: 767px) {.carousel > .flex-direction-nav a.flex-prev { margin-left: '+(-n-20)+"px; }.carousel > .flex-direction-nav a.flex-next { margin-left: "+(n+8)+"px; }}<\/style>")}}),rm.setScrollLinks(),$("#storeMap").length&&rm.mapData(),$.extend($.easing,{easeInBack:function(n,t,i,r,u,f){return f==undefined&&(f=1.70158),r*(t/=u)*t*((f+1)*t-f)+i},easeOutBack:function(n,t,i,r,u,f){return f==undefined&&(f=1.70158),r*((t=t/u-1)*t*((f+1)*t+f)+1)+i}}),typeof gigya!="undefined"&&(n=new gigya.socialize.UserAction,n.setUserMessage("This is the user message"),n.setTitle(document.title),n.setSubtitle("Subtitle"),n.setLinkBack($(location).attr("href")),n.setDescription($("meta[name=description]").attr("content")),n.addMediaItem({type:"image",src:"http://www.coles.com.au/assets/coles/images/elements/gigya-logo.png"}),u={containerID:"share-button",shareButtons:[{provider:"Share",iconImgUp:"http://www.coles.com.au/assets/coles/images/btn_share-button.png"}],iconsOnly:"true",showCounts:"none",showEmailButton:!0,userAction:n},gigya.socialize.showShareBarUI(u))})},setScrollLinks:function(){var n=rm.htmlbody.find("[data-scroll='true']");n.on("touchstart click",function(n){n.preventDefault(),coords=$(this).data("state")!=null?$(".states").find("h2."+$(this).data("state")).offset().top+-20:0,rm.htmlbody.animate({scrollTop:coords},"slow")})},sectionShow:function(){$(".in-this-section .button-secondary").on("touchstart click",function(n){$(".module-content").slideToggle(),$(this).text($(this).text()=="Show"?"Collapse":"Show"),$(this).parents(".in-this-section").toggleClass("closed"),n.preventDefault()})},headerElementShow:function(){$("header .search-popup a").on("touchstart click",function(n){n.preventDefault(),$(".search").slideToggle(),$(this).parents(".search-popup").toggleClass("open")})},mobileNav:function(){$(".nav-popup").on("touchstart click",function(n){n.preventDefault(),$("nav.mega-nav").toggleClass("open")})},equalHeights:function(){$(".products-listing.requires-equal-heights").imagesLoaded(function(){$(".requires-equal-heights").each(function(){var n=0;$(".height-content",this).each(function(){$(this).height()>n&&(n=$(this).height())}),$(".height-content",this).height(n+10)})})},accordionInit:function(){var i=$(".accordion-item").length,t,n=$(".accordion-control-all");$(".accordion-item").each(function(){var r=$(this),f=r.find(".button-secondary"),u=r.find(".accordion-content");($(".default-open").length<1&&r.index(".accordion-item")!==0||$(".default-open").length>=1&&!r.hasClass("default-open"))&&(f.text("+").attr("title","Expand"),r.addClass("closed"),u.height(0));r.find(".accordion-trigger").on("touchstart click",function(e){r.hasClass("closed")?(f.text("-").attr("title","Collapse"),r.removeClass("closed"),u.stop().animate({height:r.find(".accordion-content-inner").outerHeight(!0)},250,function(){u.css({height:"auto"})})):(f.text("+").attr("title","Expand"),r.addClass("closed"),u.stop().animate({height:0},150)),t=$(".accordion-item.closed").length,t===0?n.text("Collapse All").attr("title","Collapse All"):t===i&&n.text("Expand All").attr("title","Expand All"),e.preventDefault()})});n.on("touchstart click",function(t){$(this).text().toLowerCase().indexOf("expand all")!=-1?(n.text("Collapse All").attr("title","Collapse All"),$(".accordion-item.closed").find(".accordion-trigger").trigger("click")):(n.text("Expand All").attr("title","Expand All"),$(".accordion-item").not(".closed").find(".accordion-trigger").trigger("click")),t.preventDefault()})},adjustMegaMenuBorders:function(){var i={".catalogue-specials":[1,2],".location-hours":[1],".shop-online":[2],".our-range":[1,2],".hag":[1,2,3]},e=55,o='<div class="menu-section-border"><\/div>',u,f,t,n,r;for(t in i)if(i.hasOwnProperty(t))for(n=$(t),n.addClass("cbp-hropen-temp"),u=n.find(".cbp-hrsub").outerHeight(!0),f=n.find(".column").first().outerHeight(!0)||0,n.removeClass("cbp-hropen-temp"),r=0;r<i[t].length;r++)n.find(".columns").eq(i[t][r]).append(o).height(u-f-e)},googleMapsInit:function(n){function r(){var i=n[0],f={zoom:zoomLevel,center:new google.maps.LatLng(i.Latitude,i.Longitude),mapTypeId:google.maps.MapTypeId.ROADMAP},e=document.getElementById("storeMap"),r=new google.maps.Map(e,f);google.maps.event.addListener(r,"click",function(){t.close()}),u(r,n)}function u(n,t){for(var r,i=0;i<t.length;i++)r=t[i],f(n,r,i)}function f(n,r,u){for(var h=new google.maps.LatLng(r.Latitude,r.Longitude),f="<div class='row gmarker'><div class='small-12 large-12'><h3>"+r.Title+"<\/h3><p><strong>Address: <\/strong>"+r.Address+"<\/p><p><strong>Phone: <\/strong>"+r.Phone+"<\/p><ul>",o,s,e=0;e<r.Hours.length;e++)f+="<li>"+r.Hours[e]+"<\/li>";f+="<\/ul>",markerImage=u==0?"/assets/coles/images/elements/marker.png":r.BrandId==6?"/assets/coles/images/elements/marker-bilo.png":"/assets/coles/images/elements/marker-grey.png",o=new google.maps.Marker({map:n,title:r.Title,position:h,animation:google.maps.Animation.DROP,shadow:"/assets/coles/images/elements/marker-shadow.png",icon:markerImage}),google.maps.event.addListener(o,"click",function(){$.ajax({type:"POST",url:"/services/admin/storelocator.asmx/GetMapOpeninghoursExceptions",contentType:"application/json; charset=utf-8",data:"{ storeID: '"+r.Id+"' }",timeout:1e4,dataType:"json",success:function(i){var u,e;if(i.d.length>0)for(f+="<p><strong>Season trading hours<\/strong><\/p>",u=0;u<i.d.length;u++)f+="<table><thead><tr><th colspan='3'>"+i.d[u].Reason+"<\/th><\/tr><\/thead><tbody><tr>",i.d[u].Day!=""&&(f+="<td><strong>"+i.d[u].Day+"<\/strong><\/td>"),i.d[u].Date!=""&&(f+="<td>"+i.d[u].Date+"<\/td>"),i.d[u].Details!=""&&(f+="<td>"+i.d[u].Details+"<\/td>"),f+="<\/tr><\/tbody><\/table>";for(f+="<p><a href='"+r.StoreLink+"' class='button-secondary'>More information<\/a><\/p>",f+="<\/div><\/div>",t.setContent(f),t.open(n,o),f="<div class='row gmarker'><div class='small-12 large-12'><h3>"+r.Title+"<\/h3><p><strong>Address: <\/strong>"+r.Address+"<\/p><p><strong>Phone: <\/strong>"+r.Phone+"<\/p><ul>",e=0;e<r.Hours.length;e++)f+="<li>"+r.Hours[e]+"<\/li>";f+="<\/ul>"},error:function(){}})}),s=new google.maps.LatLng(r.Latitude,r.Longitude),i.extend(s)}var e=n.length,i=new google.maps.LatLngBounds,t=new google.maps.InfoWindow({});Modernizr.touch&&$(document.activeElement).blur(),r()},mapData:function(){rm.googleMapsInit(storeMapInfoList)}},$.rmPlaceHolders=function(){"placeholder"in document.createElement("input")||$("input[placeholder]").each(function(){var n=$(this),t=n.attr("placeholder");n.val(t).addClass("rmPrompt");n.on("focus",function(){$(this).val()==t&&$(this).val("").removeClass("rmPrompt")});n.on("blur",function(){$(this).val()==""&&$(this).val(t).addClass("rmPrompt")})})},$(function(){rm.init(),$.rmPlaceHolders(),cbpHorizontalMenu.init(),rm.accordionInit(),rm.sectionShow(),rm.headerElementShow(),rm.mobileNav(),rm.adjustMegaMenuBorders(),rm.equalHeights()})