Cwo.RegisterNamespace("Cwo.PropertyDetails");Cwo.RegisterNamespace("Cwo.PropertyDetails.MainImage");Cwo.RegisterNamespace("Cwo.PropertyDetails.NavigationImage");Cwo.RegisterNamespace("Cwo.PropertyDetails.Tabs.Click");Cwo.RegisterNamespace("Cwo.PropertyDetails.EPC");Cwo.RegisterNamespace("Cwo.PropertyDetails.EPC.Click");Cwo.RegisterNamespace("Cwo.PropertyDetails.PointsOfInterestOptionsDropDown.OptionChange");Cwo.RegisterNamespace("Cwo.PropertyDetails.PointsOfInterestOptionRemove");Cwo.RegisterNamespace("Cwo.PropertyDetails.MapView");Cwo.PropertyDetails.Photos=new Cwo.Collection();Cwo.PropertyDetails.MapViewMap=null;Cwo.PropertyDetails.Constants=function(){};Cwo.PropertyDetails.Constants.AERIALVIEW_DEFAULT_ZOOMLEVEL=20;Cwo.PropertyDetails.Constants.MAPVIEW_DEFAULT_ZOOMLEVEL=14;Cwo.CollisionDetect=function(a,b,c){var e=$(c),d=e.offset();if((a>d.left)&&(a<+(d.left+e.width()))&&(b>+d.top)&&(b<+(d.top+e.height()))){return true}return false};Cwo.PropertyDetails.TraverseImage=function(c){var d=(c==="prev")?-1:1,e=Cwo.PropertyDetails.MainImage.Element.attr("src"),b;$("#DetailsThumbnailsContainer ul li img").each(function(){if($(this).parent().attr("class")==="Selected"){b=$(this).attr("id").split("_")[1]}});if(!b){b="0"}var a=parseInt(b,10)+parseInt(d,10);a=(a>Cwo.PropertyDetails.Photos.Count()-1)?0:a;a=(a<0)?Cwo.PropertyDetails.Photos.Count()-1:a;e=Cwo.PropertyDetails.Photos.Item(a);Cwo.PropertyDetails.MainImage.ShowImage(e,a)};Cwo.PropertyDetails.MainImage.ShowImage=function(b,c){var a="PropertyPicture_"+c;$("#DetailsThumbnailsContainer ul li").removeClass("Selected");$("#DetailsThumbnailsContainer ul li img").each(function(){var d=$(this).attr("id");(d.toString()===a.toString())?$(this).parent().addClass("Selected"):$(this).parent().removeClass("Selected")});Cwo.PropertyDetails.MainImage.Element.attr("src",b)};Cwo.PropertyDetails.MainImage.ShowButtons=function(a){if(Cwo.PropertyDetails.Photos.Count()>1){$("#DetailsLargeImageContainer img.NavigationButton").css("display","block")}};Cwo.PropertyDetails.MainImage.HideButtons=function(a){if(!Cwo.CollisionDetect(a.pageX,a.pageY,"#DetailsLargeImageContainer img.MainPhoto")){$("#DetailsLargeImageContainer img.NavigationButton").css("display","none")}};Cwo.PropertyDetails.NavigationImage.Click=function(a){var d=a.target;var b;var c;if(d){c=$(d).attr("id").split("_")[1];b=Cwo.PropertyDetails.Photos.Item(c);Cwo.PropertyDetails.MainImage.ShowImage(b,c)}};Cwo.PropertyDetails.Tabs.Click=function(){var g=$("#GlobalContainer");var d=$(this).attr("id");var e=$("#pointsOfInterestOptionsContainer");var f=$("#nearbyPointsOfInterestContainer");var b=$("#estateAgentsDetails");var c=$("#mortgageCalculatorContainer");e.hide();f.hide();b.hide();c.hide();if(d==="TabPropertyDetails"){g.removeClass().addClass("PropertyDetails");f.show();b.show();c.show()}else{if(d==="TabAerialView"){g.removeClass().addClass("AerialView");var a={propertyInstructionID:Cwo.PropertyDetails.GetPropertyInstructionID()};new Cwo.AjaxCall("/webservices/PropertyDetailsSearch.asmx/GetMapPoint",JSON.stringify(a),function(h){Cwo.PropertyDetails.ShowAerialView(h)},null,null)}else{if(d==="TabMapView"){g.removeClass().addClass("MapView");e.show();Cwo.PropertyDetails.MapViewMap=new Cwo.PropertyDetails.MapView("MapView",latitude,longitude,Cwo.PropertyDetails.Constants.MAPVIEW_DEFAULT_ZOOMLEVEL,true,$("[id$='_bingMapKey']").val())}}}};Cwo.PropertyDetails.GetPropertyInstructionID=function(){return $("[id$='_propertyInstructionIDHiddenField']").attr("value")};Cwo.PropertyDetails.ShowAerialView=function(b){var a=b.d.ContentContainer.MapPoints[0];$("#AerialViewMapPointAccuracy").attr("innerText",a.AccuracyStatement);new Cwo.Maps.Single("AerialViewMap",a.Latitude,a.Longitude,Cwo.PropertyDetails.Constants.AERIALVIEW_DEFAULT_ZOOMLEVEL,true,false,true,$("[id$='_bingMapKey']").val())};Cwo.PropertyDetails.EPC=function(a){$(document).ready(function(){Cwo.PropertyDetails.OnLoad=function(){$(".EnergyPerformanceCertificateThumbnail").bind("click",function(c){Cwo.PropertyDetails.EPC.Click(a);c.preventDefault()})};if(navigator.userAgent.indexOf("MSIE")>-1){Cwo.PropertyDetails.OnLoad();return}try{Cwo.PropertyDetails.OnLoad()}catch(b){Cwo.Error.TrackError(b)}})};Cwo.PropertyDetails.EPC.Click=function(a){new Cwo.Popup(a)};Cwo.PropertyDetails.FloorplanDetails=new Hashtable();Cwo.PropertyDetails.AddFloorplanDetail=function(a,b){Cwo.PropertyDetails.FloorplanDetails.Add(a,b)};Cwo.PropertyDetails.BindFloorplanClicks=function(){$(".DetailsFloorplan").bind("click",function(a){var b=$(this).attr("id").replace(/DetailsFloorplan/,"");new Cwo.Popup(Cwo.PropertyDetails.FloorplanDetails.GetItem(b))})};Cwo.PropertyDetails.AddPointsOfInterestOptionsListItem=function(a,g,e,c){var h=Cwo.PropertyDetails.GetSelectedPointsOfInterestList();var f="<img src='"+e+"'/img>";var b="<a onclick='Cwo.PropertyDetails.PointsOfInterestOptionRemove.Click(this);' onmouseover='Cwo.PropertyDetails.PointOfInterestRemoveOnMouseOver(this);'>  <img src='/images/modal/close-icon.png' class='Remove'/>  <label class='Remove'>Remove</label>  </a>";var d="<li classificationNumber='"+a+"'visibleOnMap='"+c+"' optionIconPath='"+e+"' optionDescription='"+g+"' >"+f+"<span>"+g+"</span>";if(c==="true"){d+=b}d+=" </li>";h.append(d);Cwo.PropertyDetails.SortItemsByText(h,"li","[visibleOnMap=true]");Cwo.PropertyDetails.SortItemsByText(h,"li","[visibleOnMap=false]")};Cwo.PropertyDetails.PointOfInterestRemoveOnMouseOver=function(a){var d=$(a);var c=d.parent();var f=c.attr("optionDescription");var b="Remove '"+f+"' from map";d.attr("title",b)};Cwo.PropertyDetails.SortItemsByText=function(c,a,b){var d;if(!b){d=c.children(a).get()}else{d=$(c).find(b)}d.sort(function(g,e){var f=$(g).text();var h=$(e).text();if(f<h){return -1}else{if(f>h){return 1}else{return 0}}});$.each(d,function(f,e){c.append(e)})};Cwo.PropertyDetails.GetPointsOfInterestOptionsDropDown=function(){return $("#pointsOfInterestOptionsContainer select[id$='pointsOfInterestOptionsDropDown']")};Cwo.PropertyDetails.GetSelectedPointsOfInterestList=function(){return $("#pointsOfInterestOptionsContainer ul[id$='selectedPointsOfInterestList']")};Cwo.PropertyDetails.PointsOfInterestOptionRemove.Click=function(g){var f=$(g).parent();var a=f.attr("classificationNumber"),b=f.attr("optionIconPath"),i=f.attr("optionDescription"),d=f.attr("visibleonmap");f.remove();if(Cwo.PropertyDetails.MapViewMap!==null){Cwo.PropertyDetails.MapViewMap.OnMapChangeView()}var h=$("<option></option>");h.val(a);h.text(i);h.attr("optionIconPath",b);h.attr("isvisibleonmap",d);var c=Cwo.PropertyDetails.GetPointsOfInterestOptionsDropDown();c.append(h);Cwo.PropertyDetails.SortItemsByText(c,"option:not(:first-child)")};Cwo.PropertyDetails.PointsOfInterestOptionsDropDown.OptionChange=function(){var b=Cwo.PropertyDetails.GetPointsOfInterestOptionsDropDown().find("option:selected");var e=b.attr("index");if(e>0){var a=b.val();var f=b.text();var d=b.attr("optionIconPath");var c=b.attr("isvisibleonmap");Cwo.PropertyDetails.AddPointsOfInterestOptionsListItem(a,f,d,c);if(Cwo.PropertyDetails.MapViewMap!==null){Cwo.PropertyDetails.MapViewMap.OnMapChangeView()}b.remove()}};Cwo.PropertyDetails.ToggleSocialNetworking=function(){var c="Open";var a="Closed";var b=$("#AddThis");if(b.hasClass(c)){b.removeClass(c);b.addClass(a)}else{if(b.hasClass(a)){b.removeClass(a);b.addClass(c)}}};Cwo.PropertyDetails.HideSocialNetworking=function(){var c="Open";var a="Closed";var b=$("#AddThis");if(b.hasClass(c)){b.removeClass(c);b.addClass(a)}};Cwo.PropertyDetails.ClickMapTab=function(){window.scrollTo(0,0);$("#GlobalListingTabsContainer li[id$='TabMapView']").click()};Cwo.PropertyDetails.MapView=function(k,l,a,j,n,o){var q=k;var h=l;var i=a;var f=j;var b=n;var e=false;var c=null;var g=this;function m(t){var u=t.d.ContentContainer.MapPoints[0],s="/images/map/singleprop-large.png";$("#MapViewMapPointAccuracy").attr("innerText",u.AccuracyStatement);c.AddMarker(u.Latitude,u.Longitude,{icon:s,width:32,height:33,typeName:"MapPointLarge"})}function d(y){var s=y.d.ContentContainer.PointsOfInterest;var t=s.length;for(var x=0;x<t;x++){var w=s[x];var v="/images/icons/PointsOfInterest/"+w.IconName;var u=w.Name;if(w.Address.length>0){u+=", ";u+=w.Address}c.AddMarker(w.Latitude,w.Longitude,{icon:v,width:16,height:16,toolTip:true,toolTiptext:u,typeName:"MapPointOfInterest"})}}function r(){var s=Cwo.PropertyDetails.GetPointsOfInterestOptionsDropDown();if(s.find("option").length===1){s.hide()}else{s.show()}}function p(s){c.DeleteAllShapeLayers();d(s);m(s);r()}this.MapLoaded=function(){g.OnMapChangeView()};this.OnMapChangeView=function(){var t=c.GetTopLeft(),s=c.GetBottomRight(),u=new Cwo.Collection();Cwo.PropertyDetails.GetSelectedPointsOfInterestList().find("li").each(function(x){var w=$(this).attr("classificationNumber");u.Add(w)});var v={propertyInstructionID:Cwo.PropertyDetails.GetPropertyInstructionID(),zoomLevel:c.GetZoom(),topLeftVisible:t,bottomRightVisible:s,selectedClassificationNumbers:JSON.stringify(u.Items)};new Cwo.AjaxCall("/webservices/PropertyDetailsSearch.asmx/GetMapPoints",JSON.stringify(v),function(w){p(w)},null,null)};this.LoadMap=function(){var s=new Cwo.MapProvider(o);c=s.RenderMap(document.getElementById(q),{centerLat:h,centerLong:i,zoom:f});c.AttachEvent("viewchangeend",g.OnMapChangeView);g.MapLoaded();if(Cwo.Common.GetCookie("PropertyWideMapToken")!==""){c.SetClientToken(Cwo.Common.GetCookie("PropertyWideMapToken"))}};if(!Cwo.Maps.IsScriptLoaded()){Cwo.Page.EventController.Subscribe("Maps.BingScriptLoaded",g.LoadMap)}else{this.LoadMap()}};$(document).ready(function(){Cwo.PropertyDetails.OnStart=function(){Cwo.PropertyDetails.BindFloorplanClicks();Cwo.PropertyDetails.MainImage.Element=$("#DetailsLargeImageContainer img.MainPhoto");Cwo.PropertyDetails.MainImage.Element.bind("mouseover",function(c){Cwo.PropertyDetails.MainImage.ShowButtons(c)});$("#DetailsLargeImageContainer img").bind("mouseout",function(c){Cwo.PropertyDetails.MainImage.HideButtons(c)});$("#DetailsThumbnailsContainer ul li img").bind("click",function(c){Cwo.PropertyDetails.NavigationImage.Click(c)});$("#DetailsLargeImageContainer img.Next").bind("click",function(c){Cwo.PropertyDetails.TraverseImage("next")});$("#DetailsLargeImageContainer img.Prev").bind("click",function(c){Cwo.PropertyDetails.TraverseImage("prev")});$("#GlobalListingTabsContainer li").bind("click",Cwo.PropertyDetails.Tabs.Click);$("#DetailsPriceAndContactContainer a[id$='ContactAgent']").bind("click",Cwo.PropertyDetails.HideSocialNetworking);$("#DetailsBodyPriceAndContactContainer a[id$='ContactAgentBody']").bind("click",Cwo.PropertyDetails.HideSocialNetworking);$("#estateAgentsDetails a[id$='ContactAgentLink']").bind("click",Cwo.PropertyDetails.HideSocialNetworking);$("#DetailsContentContainer a[id$='EnergyPerformanceCertificateThumbnail']").bind("click",Cwo.PropertyDetails.HideSocialNetworking);Cwo.PropertyDetails.GetPointsOfInterestOptionsDropDown().bind("change",function(c){Cwo.PropertyDetails.PointsOfInterestOptionsDropDown.OptionChange(c)});$("#DetailsContentContainer a[class$='DetailsFloorplan']").bind("click",Cwo.PropertyDetails.HideSocialNetworking);$("#ShowOnMapLink").bind("click",Cwo.PropertyDetails.ClickMapTab);$("#pointsOfInterestShowOnMapLink").bind("click",Cwo.PropertyDetails.ClickMapTab);$("#SocialNetworkingMoreLink").bind("click",function(){Cwo.PropertyDetails.ToggleSocialNetworking()});if(typeof(_gat)==="object"){var b={data_ga_tracker:_gat._getTrackerByName(),data_track_clickback:true}}};if(navigator.userAgent.indexOf("MSIE")>-1){Cwo.PropertyDetails.OnStart();return}try{Cwo.PropertyDetails.OnStart()}catch(a){Cwo.Error.TrackError(a)}});
