
window.onerror=function(){return true;};(function(){function d(a){return function(b){this[a]=b}}function e(a){return function(){return this[a]}}var h;function i(a,b,c){this.extend(i,google.maps.OverlayView);this.b=a;this.a=[];this.l=[];this.X=[53,56,66,78,90];this.h=[];this.z=false;c=c||{};this.f=c.gridSize||60;this.T=c.maxZoom||null;this.h=c.styles||[];this.S=c.imagePath||this.M;this.R=c.imageExtension||this.L;this.K=true;if(c.zoomOnClick!=undefined)this.K=c.zoomOnClick;this.p=false;if(c.averageCenter!=undefined)this.p=c.averageCenter;j(this);this.setMap(a);this.G=this.b.getZoom();var f=this;google.maps.event.addListener(this.b,"zoom_changed",function(){var g=f.b.mapTypes[f.b.getMapTypeId()].maxZoom,l=f.b.getZoom();if(!(l<0||l>g))if(f.G!=l){f.G=f.b.getZoom();f.m()}});google.maps.event.addListener(this.b,"idle",function(){if(this.feature=='properties'&&properties_showing||nearby_showing[this.feature])f.j()});b&&b.length&&this.B(b,false)}h=i.prototype;h.M="http://google-maps-utility-library-v3.googlecode.com/svn/trunk/markerclusterer/images/m";h.L="png";h.extend=function(a,b){return function(c){for(property in c.prototype)this.prototype[property]=c.prototype[property];return this}.apply(a,[b])};h.onAdd=function(){if(!this.z){this.z=true;m(this)}};h.draw=function(){};function j(a){if(!a.h.length)for(var b=0,c;c=a.X[b];b++)a.h.push({url:a.S+(b+1)+"."+a.R,height:c,width:c})}h.w=e("h");h.v=e("a");h.Q=e("a");h.F=function(){return this.T||this.b.mapTypes[this.b.getMapTypeId()].maxZoom};h.C=function(a,b){for(var c=0,f=a.length,g=f;g!==0;){g=parseInt(g/10,10);c++}c=Math.min(c,b);return{text:f,index:c}};h.V=d("C");h.D=e("C");h.B=function(a,b){for(var c=0,f;f=a[c];c++)n(this,f);b||this.j()};function n(a,b){b.setVisible(false);b.setMap(null);b.r=false;b.draggable&&google.maps.event.addListener(b,"dragend",function(){b.r=false;a.m();a.j()});a.a.push(b)}h.o=function(a,b){n(this,a);b||this.j()};h.U=function(a){var b=-1;if(this.a.indexOf)b=this.a.indexOf(a);else for(var c=0,f;f=this.a[c];c++)if(f==a)b=c;if(b==-1)return false;this.a.splice(b,1);a.setVisible(false);a.setMap(null);this.m();this.j();return true};h.P=function(){return this.l.length};h.getMap=e("b");h.setMap=d("b");h.u=e("f");h.W=d("f");function o(a,b){var c=a.getProjection(),f=new google.maps.LatLng(b.getNorthEast().lat(),b.getNorthEast().lng()),g=new google.maps.LatLng(b.getSouthWest().lat(),b.getSouthWest().lng());f=c.fromLatLngToDivPixel(f);f.x+=a.f;f.y-=a.f;g=c.fromLatLngToDivPixel(g);g.x-=a.f;g.y+=a.f;f=c.fromDivPixelToLatLng(f);c=c.fromDivPixelToLatLng(g);b.extend(f);b.extend(c);return b}h.N=function(){this.m();this.a=[]};h.m=function(){for(var a=0,b;b=this.l[a];a++)b.remove();for(a=0;b=this.a[a];a++){b.r=false;b.setMap(null);b.setVisible(false)}this.l=[]};h.j=function(){m(this)};function m(a){if(a.z)for(var b=o(a,new google.maps.LatLngBounds(a.b.getBounds().getSouthWest(),a.b.getBounds().getNorthEast())),c=0,f;f=a.a[c];c++){var g=false;if(!f.r&&b.contains(f.getPosition())){for(var l=0,k;k=a.l[l];l++)if(!g&&k.getCenter()&&k.t.contains(f.getPosition())){g=true;k.o(f);break}if(!g){k=new p(a);k.o(f);a.l.push(k)}}}}
function p(a){this.i=a;this.b=a.getMap();this.f=a.u();this.p=a.p;this.d=null;this.a=[];this.t=null;this.k=new q(this,a.w(),a.u())}h=p.prototype;h.o=function(a){var b;a:if(this.a.indexOf)b=this.a.indexOf(a)!=-1;else{b=0;for(var c;c=this.a[b];b++)if(c==a){b=true;break a}b=false}if(b)return false;if(this.d){if(this.p){b=(this.d.lat()+a.getPosition().lat())/2;c=(this.d.lng()+a.getPosition().lng())/2;this.d=new google.maps.LatLng(b,c);r(this)}}else{this.d=a.getPosition();r(this)}if(this.a.length==0){a.setMap(this.b);a.setVisible(true)}else if(this.a.length==1){this.a[0].setMap(null);this.a[0].setVisible(false)}a.r=true;this.a.push(a);if(this.b.getZoom()>this.i.F())for(a=0;b=this.a[a];a++){b.setMap(this.b);b.setVisible(true)}else if(this.a.length<2)s(this.k);else{a=this.i.w().length;b=this.i.D()(this.a,a);this.k.setCenter(this.d);a=this.k;a.A=b;a.$=b.text;a.Y=b.index;if(a.c)a.c.innerHTML=b.text;b=Math.max(0,a.A.index-1);b=Math.min(a.h.length-1,b);b=a.h[b];a.J=b.url;a.g=b.height;a.n=b.width;a.H=b.textColor;a.anchor=b.anchor;a.I=b.textSize;this.k.show()}return true};h.getBounds=function(){r(this);return this.t};h.remove=function(){this.k.remove();this.a.length=0;delete this.a};h.O=function(){return this.a.length};h.v=e("a");h.getCenter=e("d");function r(a){a.t=o(a.i,new google.maps.LatLngBounds(a.d,a.d))}h.getMap=e("b");function q(a,b,c){a.i.extend(q,google.maps.OverlayView);this.h=b;this.Z=c||0;this.q=a;this.d=null;this.b=a.getMap();this.A=this.c=null;this.s=false;this.setMap(this.b)}h=q.prototype;h.onAdd=function(){this.c=document.createElement("DIV");if(this.s){this.c.style.cssText=t(this,u(this,this.d));this.c.innerHTML=this.A.text}this.getPanes().overlayImage.appendChild(this.c);var a=this;google.maps.event.addDomListener(this.c,"click",function(){var b=a.q.i;google.maps.event.trigger(b,"clusterclick",a.q);if(b.K){a.b.panTo(a.q.getCenter());a.b.setZoom(a.b.getZoom()+1);}})};function u(a,b){var c=a.getProjection().fromLatLngToDivPixel(b);c.x-=parseInt(a.n/2,10);c.y-=parseInt(a.g/2,10);return c}h.draw=function(){if(this.s){var a=u(this,this.d);this.c.style.top=a.y+"px";this.c.style.left=a.x+"px"}};function s(a){if(a.c)a.c.style.display="none";a.s=false}h.show=function(){if(this.c){this.c.style.cssText=t(this,u(this,this.d));this.c.style.display=""}this.s=true};h.remove=function(){this.setMap(null)};h.onRemove=function(){if(this.c&&this.c.parentNode){s(this);this.c.parentNode.removeChild(this.c);this.c=null}};h.setCenter=d("d");function t(a,b){var c=[];document.all?c.push('filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(sizingMethod=scale,src="'+a.J+'");'):c.push("background:url("+a.J+");");if(typeof a.e==="object"){typeof a.e[0]==="number"&&a.e[0]>0&&a.e[0]<a.g?c.push("height:"+(a.g-a.e[0])+"px; padding-top:"+a.e[0]+"px;"):c.push("height:"+a.g+"px; line-height:"+a.g+"px;");typeof a.e[1]==="number"&&a.e[1]>0&&a.e[1]<a.n?c.push("width:"+(a.n-a.e[1])+"px; padding-left:"+a.e[1]+"px;"):c.push("width:"+a.n+"px; text-align:center;")}else c.push("height:"+
a.g+"px; line-height:"+a.g+"px; width:"+a.n+"px; text-align:center;");c.push("cursor:pointer; top:"+b.y+"px; left:"+b.x+"px; color:"+(a.H?a.H:"black")+"; position:absolute; font-size:"+(a.I?a.I:11)+"px; font-family:Arial,sans-serif; font-weight:bold");return c.join("")}window.MarkerClusterer=i;i.prototype.addMarker=i.prototype.o;i.prototype.addMarkers=i.prototype.B;i.prototype.clearMarkers=i.prototype.N;i.prototype.getCalculator=i.prototype.D;i.prototype.getGridSize=i.prototype.u;i.prototype.getMap=i.prototype.getMap;i.prototype.getMarkers=i.prototype.v;i.prototype.getMaxZoom=i.prototype.F;i.prototype.getStyles=i.prototype.w;i.prototype.getTotalClusters=i.prototype.P;i.prototype.getTotalMarkers=i.prototype.Q;i.prototype.redraw=i.prototype.j;i.prototype.removeMarker=i.prototype.U;i.prototype.resetViewport=i.prototype.m;i.prototype.setCalculator=i.prototype.V;i.prototype.setGridSize=i.prototype.W;i.prototype.onAdd=i.prototype.onAdd;i.prototype.draw=i.prototype.draw;p.prototype.getCenter=p.prototype.getCenter;p.prototype.getSize=p.prototype.O;p.prototype.getMarkers=p.prototype.v;q.prototype.onAdd=q.prototype.onAdd;q.prototype.draw=q.prototype.draw;q.prototype.onRemove=q.prototype.onRemove;})();function load_smi_map_js(){if(typeof(console)=='undefined')
{console={};console.log=function(variable){};}
$('#gp_properties').attr('checked','');image=new google.maps.MarkerImage('http://c4.dmstatic.com/i/m/nearby_property.png',new google.maps.Size(32,37),new google.maps.Point(0,0),new google.maps.Point(16,32));shadow=new google.maps.MarkerImage('http://c1.dmstatic.com/i/m/nearby_shadow.png',new google.maps.Size(35,26),new google.maps.Point(0,0),new google.maps.Point(17,25));prop_info_window=new CustomDiv(point,map,'');bottom_left_nearby=new google.maps.Point(805,115);top_right_nearby=new google.maps.Point(928,0);mc=new MarkerClusterer(map,[],{gridSize:60,maxZoom:16,zoomOnClick:true,styles:[{url:'http://c4.dmstatic.com/i/cluster.png',height:52,width:53,anchor:[26,26],textSize:11,textColor:'#000'}]});mc.feature='property';open_window=false;properties_showing=false;properties_markers=[];properties_ids=[];hidden_markers_ids=[];hidden_nearby_markers_ids=[];potential_new_properties=true;nearby_showing=[];nearby_markers=[];nearby_ids=[];nearbys_loading=0;potential_new_nearby=[];min_lat=100,max_lng=-100,min_lng=max_lat=0;bounds_seen=[]
bounds_seen['properties']=[]
bounds_seen['properties']['min_lat']=100;bounds_seen['properties']['max_lng']=-100;bounds_seen['properties']['min_lng']=bounds_seen['properties']['max_lat']=0;nearby_icon_sizes=[];nearby_icon_sizes['restaurants']=[32,37,16,32];nearby_icon_sizes['shops']=[32,37,16,32];nearby_icon_sizes['doctor']=[32,37,16,32];nearby_icon_sizes['qype_food_drink']=[32,37,16,32];nearby_icon_sizes['qype_education']=[32,37,16,32];nearby_icon_sizes['qype_shopping']=[32,37,16,32];nearby_icon_sizes['qype_nightlife']=[32,37,16,32];nearby_icon_sizes['qype_doctor']=[32,37,16,16];nearby_clusterers=[];gp_messages=[];features_names_mappings={'shops':['shops','shops'],'restaurants':['restaurants','restaurants'],'doctor':['doctors','doctors'],'qype_food_drink':['restaurants','restaurants'],'qype_education':['schools/colleges','education'],'qype_shopping':['shops','shops'],'qype_nightlife':['bars/clubs','nightlife'],'qype_doctor':['doctors','doctors']};for(var feature in features_names_mappings)
{nearby_showing[feature]=false;nearby_markers[feature]=[];nearby_ids[feature]=[];gp_messages[feature]='';potential_new_nearby[feature]=true;bounds_seen[feature]=[]
bounds_seen[feature]['min_lat']=100;bounds_seen[feature]['max_lng']=-100;bounds_seen[feature]['min_lng']=bounds_seen[feature]['max_lat']=0;nearby_clusterers[feature]=new MarkerClusterer(map,[],{gridSize:60,maxZoom:16,zoomOnClick:true,styles:[{url:'http://c0.dmstatic.com/i/m/cluster_'+features_names_mappings[feature][1]+'.png',height:52,width:53,anchor:[26,26],textSize:11,textColor:'#000'}]});nearby_clusterers[feature].feature=feature;hidden_nearby_markers_ids[feature]=[];}
$('#gp_restaurants, #gp_shops, #gp_doctor, #qype_food_drink, #qype_education, #qype_shopping, #qype_nightlife, #qype_doctor').click(function(){var feature=$(this).attr('id').split('_');var provider='';if(feature[0]=='qype')
{feature=$(this).attr('id');provider='qype';}
else
{feature=feature[1];provider='gp';}
if(nearby_showing[feature])
{nearby_showing[feature]=false;nearby_clusterers[feature].resetViewport();if(open_window)open_window.hide();hide_loading(false);}
else
{var center=map.getCenter();nearby_showing[feature]=true;if(provider=='gp')
{toggleNearbyGP(feature,area,center.lat(),center.lng());}
else
{toggleNearbyQype(feature);}}});$('#gp_properties').click(function(){if(properties_showing)
{properties_showing=false;hide_properties();}
else
{if(zoom>13)
{var bounds=map.getBounds();var sw=bounds.getSouthWest().toString();var ne=bounds.getNorthEast().toString();get_properties(ad_type,ad_id,sw,ne,extra_params);properties_showing=true;}
else
{$('#nb_loading').addClass('largeLoading');$('#nb_loading').html('You are zoomed out too far, please zoom in');$('#nb_loading').show();$('#gp_properties').attr('checked',false);setTimeout('hide_loading(true);',4000);}}});$('#gp_search_more').click(function(){if($('#gp_mo_img').attr('src').indexOf('_down')!==-1)
{$('#gp_mo_img').attr('src','http://c0.dmstatic.com/i/m/gp_arrow_up.png');hideExtraLink();$('#gp_search_text').show();}
else
{$('#gp_mo_img').attr('src','http://c2.dmstatic.com/i/m/gp_arrow_down.png');$('#gp_search_text').hide();}});google.maps.event.addListener(map,'dragend',function(){var bounds=map.getBounds();potential_new_properties=true;for(key in potential_new_nearby)
{potential_new_nearby[key]=true;}
if(is_big_drag(point,map.getCenter()))
{point=map.getCenter();if(properties_showing&&zoom>13)
{show_loading('Properties');get_properties(ad_type,ad_id,bounds.getSouthWest().toString(),bounds.getNorthEast().toString(),extra_params);}
for(feature in nearby_showing)
{if(nearby_showing[feature]&&feature.substring(0,4)=='qype'&&zoom>13)
{show_loading('Services');toggleNearbyQype(feature);}}}});google.maps.event.addListener(map,'rightclick',function(e){throw'Free exception with every context menu.';});google.maps.event.addListener(map,'bounds_changed',function(){var new_zoom=map.getZoom();var get_new;var zoomed_out=false;if(new_zoom!=zoom)
{if(zoom<new_zoom)
{mc.setGridSize(mc.getGridSize()-10);}
else
{mc.setGridSize(mc.getGridSize()+10);zoomed_out=true;}
zoom=new_zoom;var bounds=map.getBounds();potential_new_properties=true;for(key in potential_new_nearby)
{potential_new_nearby[key]=true;}
if(properties_showing&&zoom<=18&&zoom>13)
{if(open_window)open_window.hide();show_loading('Properties');get_properties(ad_type,ad_id,bounds.getSouthWest().toString(),bounds.getNorthEast().toString(),extra_params);}
if(zoom<=18&&zoom>13)
{for(feature in nearby_showing)
{if(nearby_showing[feature]&&feature.substring(0,4)=='qype')
{if(open_window)open_window.hide();if($('#nb_loading').css('display')=='none')
{show_loading('Services');}
toggleNearbyQype(feature);}}}}});}
function toggle_map_view(mode)
{map.setMapTypeId(mode);}
function hide_properties()
{var num_properties=properties_ids.length;for(var i=0;i<num_properties;i++)
{properties_markers[properties_ids[i]].setMap(null);}
mc.resetViewport();if(open_window)open_window.hide();hide_loading(false);}
function get_properties(ad_type,ad_id,sw,ne,extra_params)
{num=0;if(potential_new_properties&&new_bounds(sw,ne,'properties'))
{update_min_max_bounds(sw,ne,'properties');$.getJSON("/ajax_endpoint.php?action=smi_nearby_properties&ad_type="+ad_type+"&ad_id="+ad_id+"&sw="+sw+"&ne="+ne+'&extra_params='+extra_params,function(data){if(data.length)
{num_new=0;$.each(data,function(index)
{if(!in_array(this['id'],properties_ids))
{num++;num_new++;var nearby_point=new google.maps.LatLng(this['lat'],this['long']);var content=get_ad_content(this,ad_type,extra_params);var nearby_marker=new google.maps.Marker({position:nearby_point,map:map,icon:image,shadow:shadow});properties_markers[this['id']]=nearby_marker;properties_ids.push(this['id']);mc.addMarker(nearby_marker);google.maps.event.addListener(nearby_marker,'click',function(){if(open_window)open_window.hide();prop_info_window.setContent(content);prop_info_window.setPosition(nearby_point);prop_info_window.show();open_window=prop_info_window;});}
else
{if(!properties_markers[this['id']].getMap())
{properties_markers[this['id']].setMap(map);}}});}
else
{$('#nb_loading').html("No results found");setTimeout("hide_loading(true)",3000);}
if(data.length&&!nearbys_loading)
{hide_loading(false);}
if(nearbys_loading)
{show_loading('Services');}
potential_new_properties=false;});}
else
{var num_properties=properties_ids.length;for(var i=0;i<num_properties;i++)
{properties_markers[properties_ids[i]].setMap(map);}
mc.redraw();hide_loading(false);}}
function update_min_max_bounds(sw_in,ne_in,feature)
{var sw=sw_in.split(', ');var sw_lat=parseFloat(sw[0].slice(1));var sw_lng=parseFloat(sw[1].slice(0,-1));bounds_seen[feature]['min_lat']=(sw_lat<bounds_seen[feature]['min_lat'])?sw_lat:bounds_seen[feature]['min_lat'];bounds_seen[feature]['min_lng']=(sw_lng<bounds_seen[feature]['min_lng'])?sw_lng:bounds_seen[feature]['min_lng'];var ne=ne_in.split(', ');var ne_lat=parseFloat(ne[0].slice(1));var ne_lng=parseFloat(ne[1].slice(0,-1));bounds_seen[feature]['max_lat']=(ne_lat>bounds_seen[feature]['max_lat'])?ne_lat:bounds_seen[feature]['max_lat'];bounds_seen[feature]['max_lng']=(ne_lng>bounds_seen[feature]['max_lng'])?ne_lng:bounds_seen[feature]['max_lng'];}
function new_bounds(sw,ne,feature)
{sw=sw.split(', ');sw[0]=sw[0].slice(1);sw[1]=sw[1].slice(0,-1);ne=ne.split(', ');ne[0]=ne[0].slice(1);ne[1]=ne[1].slice(0,-1);return(!((sw[0]>=bounds_seen[feature]['min_lat'])&&(sw[1]>=bounds_seen[feature]['min_lng'])&&(ne[0]<=bounds_seen[feature]['max_lat'])&&(ne[1]<=bounds_seen[feature]['max_lng'])));}
function get_ad_content(ad,ad_type,extra_params)
{var text='<div style="margin-top: 11px; margin-left: 20px; padding: 0px; font-size: 11px;">'+'<img src="http://c9.dmstatic.com/i/mapdiv_close.gif" alt="close" style="float: right; margin-right: 10px; cursor: pointer;" onclick="javascript: open_window.hide(); open_window = null;" />';if(ad_type=='new_development')
{ad_type='sale';}
var link='/search'+ad_type+'.daft?id='+ad['id'];if($.browser.msie&&parseFloat($.browser.version)<8.0)
{var ep=eval('('+extra_params+')');}
else
{var ep=JSON.parse(extra_params);}
for(var ep_key in ep)
{switch(ep_key)
{case'pt_id':case'sub_pt_id':if(!isNaN(parseInt(ep[ep_key])))
link+='&s['+ep_key+']='+ep[ep_key];break;case'beds':if(typeof(ep['beds'])=='array')
link+='&s[mnb]='+ep['beds'][0]+'&s[mxb]='+ep['beds'][1];else if(!isNaN(parseInt(ep['beds'])))
link+='&s[bd_no]='+ep['beds'];break;case'price':case'rent':link+='&s[mnp]='+ep[ep_key][0]+'&s[mxp]='+ep[ep_key][1];break;}}
var image='';if(ad['photo'])
{image+='<a href="'+link+'"><img src="'+ad['photo']+'" onerror=\'javascript: this.src = "'+ad['photo_backup']+'"\' style="border: 1px solid #999; float: left;" alt="'+ad['street']+'" width="75px" height="75px" /></a>';text+=image;}
text+='<div style="float: left; margin-left: 10px; line-height: 19px;">';if(ad['street']!='')
{text+='<a style="font-size: 12px; font-weight:bold; text-decoration: underline;" href="'+link+'">'+ad['street']+'</a><br /> ';}
if(ad['area']!='')
{text+=ad['area']+', '+ad['county']+'<br /> ';}
text+=ad['summary']+'<br />';var price=0;if(ad['price']!=0)
{price=ad['price'];}
else
{price=ad['rent'];}
if(price!=0)
{if(ad['is_ni'])
{price_field='&pound;';}
else
{price_field='&euro;';}
text+='<strong>'+price_field+price+'</strong>';}
else
{text+='<strong>P.O.A.</strong>';}
if(ad['price']==0&&!isNaN(remove_comma(ad['rent']))&&remove_comma(ad['rent'])>0&&ad['collection']!=null)
{text+=' '+ad['collection'];}
text+='</div><div style="clear: left; float: left; margin-top: 20px; margin-left: 0px; width: 200px;"><a href="'+link+'" style="padding-left: 16px;">View this property</a></div>'+'</div>';return text;}
function remove_comma(num)
{if(num.indexOf(',')==-1)
{return num;}
num=num.split(',');return parseInt(''+num[0]+num[1]);}
function toggleNearbyGP(feature,area,lat,lon)
{hideExtraLink();nearbys_loading++;if(potential_new_nearby[feature]&&nearby_showing[feature]==true)
{if(!potential_new_properties)
{show_loading('Services');}
$.getJSON("/jscript/daftie/nearby_business.php?feature="+feature+"&area="+area+"&lat="+lat+"&lon="+lon+'&provider=gp',function(data){if(data['total']>0)
{var found_count=0;if(data['geocoded']>0)
{$.each(data['listing'],function(index)
{if(!in_array(this['id'],nearby_ids[feature]))
{var point=new google.maps.LatLng(this['latitude'],this['longitude']);var marker=add_gp_marker(point,feature,this['name'],this['address'],this['link'],this['distance']);nearby_markers[feature][this['id']]=marker;nearby_ids[feature].push(this['id']);found_count++;}
else
{if(!nearby_markers[feature][this['id']].getMap())
{nearby_markers[feature][this['id']].setMap(map);}}});nearbys_loading--;hide_loading(true);}
else
{$('#nb_loading').css('width','295px');$('#nb_loading').html("Sorry - no "+features_names_mappings[feature][0]+" found in this immediate area.");nearbys_loading--;setTimeout("hide_loading(true)",3000);}
if(data['total']>0&&data['total']-found_count>0)
{var plural=feature+'s';var pluralTest=feature.substring(feature.length-1,feature.length);if(pluralTest=='s')
{plural=feature;}
gp_messages[feature]='<a href="http://www.goldenpages.ie'+data.gp_link+'" target="_new" onclick="trackEvent(\'gp_more_link\', \''+feature+'\');">'+(data.total-found_count)+' more '+plural+' available &raquo;</a>';showExtraLink(feature);}}
else
{nearbys_loading--;if(nearbys_loading==0)
{$('#nb_loading').css('width','295px');$('#nb_loading').html("Sorry - no "+features_names_mappings[feature][0]+" found in this immediate area.");setTimeout("hide_loading(true)",3000);}}});potential_new_nearby[feature]=true;nearby_showing[feature]=true;}
else
{if(nearby_markers[feature].length>0&&nearby_showing[feature]==false)
{show_loading('Services');$.each(nearby_markers[feature],function(marker)
{$(this).setMap(map);});nearbys_loading--;hide_loading();nearby_showing[feature]=true;showExtraLink(feature);}
else
{$.each(nearby_markers[feature],function(marker)
{$(this).setMap(null);});nearby_showing[feature]=false;}}
if(nearby_showing[feature]==true)
{trackEvent('gp_nearby',feature);}}
function toggleNearbyQype(feature)
{hideExtraLink();nearbys_loading++;var bounds=map.getBounds();var sw_lat=bounds.getSouthWest().lat(),sw_lon=bounds.getSouthWest().lng(),sw=bounds.getSouthWest().toString();var ne_lat=bounds.getNorthEast().lat(),ne_lon=bounds.getNorthEast().lng(),ne=bounds.getNorthEast().toString();var reload=false;if(potential_new_nearby[feature]&&new_bounds(sw,ne,feature))
{if(!potential_new_properties||properties_markers.length==0)
{show_loading('Services');}
update_min_max_bounds(sw,ne,feature);$.getJSON("/jscript/daftie/nearby_business.php?feature="+feature+"&area="
+area+"&sw_lat="+sw_lat+"&sw_lon="+sw_lon+"&ne_lat="+ne_lat+"&ne_lon="+ne_lon+'&provider=qype',function(data){if(data['total']>0)
{var found_count=0;if(data['geocoded']>0)
{$.each(data['listing'],function(index)
{if(!in_array(this['id'],nearby_ids[feature]))
{var point=new google.maps.LatLng(this['latitude'],this['longitude']);var marker=add_qype_marker(point,feature,this['name'],this['address'],this['link'],this['distance'],this['average_rating'],this['image']);nearby_markers[feature][this['id']]=marker;nearby_ids[feature].push(this['id']);nearby_clusterers[feature].addMarker(marker);}
else
{if(!nearby_markers[feature][this['id']].getMap())
{nearby_markers[feature][this['id']].setMap(map);}}
found_count++;});nearbys_loading--;if(found_count)
{hide_loading(true);}}
else
{reload=true;nearbys_loading--;}}
else
{nearbys_loading--;if(nearbys_loading==0)
{reload=true;}}
if(found_count==0||reload==true)
{if(feature=='qype_education')
{$('#nb_loading').css('width','240px');}
else
{$('#nb_loading').css('width','205px');}
$('#nb_loading').html("No new "+features_names_mappings[feature][0]+" found.");setTimeout("hide_loading(true)",3000);}});potential_new_nearby[feature]=false;nearby_showing[feature]=true;}
else
{for(key in nearby_markers[feature])
{if(!isNaN(key))
{nearby_markers[feature][key].setMap(map);}}
nearby_clusterers[feature].redraw();nearbys_loading--;nearby_showing[feature]=true;hide_loading(true);}
if(nearby_showing[feature]==true)
{trackEvent('qype_nearby',feature);}}
function add_gp_marker(point,feature,name,address,link,distance)
{var text="";var image="";text='<div style="font-family: arial; min-width: 250px; min-height: 50px; line-height: 20px;">'+'<span style="font-size:11pt;">'+'<a href="'+link+'" onclick="trackEvent(\"gp_from_bubble\", \"'+feature+'\");" target="_new">'+name+'</a>'+'</span><br />'+'<span style="font-size: 9pt; margin-top: 4px;">'+address;var color="blue";text+='<br /><a href="'+link+'" onclick="trackEvent(\"gp_from_bubble\", \"'+feature+'\");" target="_new">view more details &raquo;</a></span></div>';icon=new google.maps.MarkerImage('http://c0.dmstatic.com/i/m/nearby_'+feature+'.png',new google.maps.Size(nearby_icon_sizes[feature][0],nearby_icon_sizes[feature][1]),new google.maps.Point(0,0),new google.maps.Point(nearby_icon_sizes[feature][2],nearby_icon_sizes[feature][3]));var marker=new google.maps.Marker({position:point,map:map,icon:icon});var info_window=new google.maps.InfoWindow({content:text,maxWidth:300});google.maps.event.addListener(marker,'click',function(){if(open_window)open_window.close();info_window.open(map,marker);open_window=info_window;});return marker;}
function add_qype_marker(point,feature,name,address,link,distance,average_rating,image)
{var rating_string='';var text='';if(image=='')
{image='http://c2.dmstatic.com/i/m/qype_no_image.png';image_margin_top=13;}
else
{image_margin_top=20;}
if(average_rating==0)
{rating_string="<span style='font-size:10px; color:#0d33f6;'>&nbsp;&nbsp;Not Yet Rated</span>";}
else
{rating_string='<img src="http://c0.dmstatic.com/i/m/qype_star_'+average_rating+'.png" style="float: left; margin: 3px 0px 0px 4px;" />';}
if(name.length>30)
{name=name.slice(0,27)+'...';}
var text='<div style="margin-top: 11px; margin-left: 20px; padding: 0px; font-size: 11px;">'+'<img src="http://c9.dmstatic.com/i/mapdiv_close.gif" alt="close" style="float: right; margin-right: 10px; cursor: pointer;" onclick="javascript: open_window.hide(); open_window = null;" />'+'<a href="'+link+'" onclick="trackEvent(\"daft_from_bubble\", \""+feature+"\", \"qype\");" target="_new">'+'<img src="'+image+'" style="border: 1px solid #999; float: left;" alt="'+name+'" />'+'</a>'+'<div style="float: left; margin-left: 10px; line-height: 19px;">'+'<a style="font-size: 12px; font-weight:bold; text-decoration: underline;" href="'+link+'" onclick="trackEvent(\"daft_from_bubble\", \""+feature+"\", \"qype\");" target="_new">'+name+'</a><br /> '+
address+'<br />'+'<div style="float: left;">Rating: </div>'+rating_string+'<br />'+'<div style="float:left;">Features provided by </div><a href="http://www.qype.co.uk/"><img src="http://c9.dmstatic.com/i/m/qype_logo.png" alt="Qype" height="16" width="46" width="46" style="float: left; margin: 2px 0px 0px 4px;" /></a>'+'</div>'+'<div style="clear: left; float: left; margin-top: '+image_margin_top+'px; margin-left: 0px; width: 200px; background: #e6f0f9;">'+'<a href="'+link+'" onclick="trackEvent(\"daft_from_bubble\", \""+feature+"\", \"qype\");" target="_new">More Details...</a>'+'</div>';icon=new google.maps.MarkerImage('http://c0.dmstatic.com/i/m/nearby_'+feature+'.png',new google.maps.Size(nearby_icon_sizes[feature][0],nearby_icon_sizes[feature][1]),new google.maps.Point(0,0),new google.maps.Point(nearby_icon_sizes[feature][2],nearby_icon_sizes[feature][3]));var marker=new google.maps.Marker({position:point,map:map,icon:icon});google.maps.event.addListener(marker,'click',function(){if(open_window)open_window.hide();prop_info_window.setContent(text);prop_info_window.setPosition(point);prop_info_window.show();open_window=prop_info_window;});return marker;}
function show_loading(text)
{$('#nb_loading').html('<img src="http://c4.dmstatic.com/i/loading.gif" alt="loading" /> Loading '+text);$('#nb_loading').show();}
function hide_loading(reset)
{$('#nb_loading').removeClass('largeLoading');if(nearbys_loading==0)
{$('#nb_loading').hide();if(reset)
{$('#nb_loading').html('<img src="http://c4.dmstatic.com/i/loading.gif" alt="loading" /> Loading Properties');}}
else
{show_loading('Services');}}
function restore_hidden_markers()
{for(pm in properties_markers)
{if(!isNaN(pm)&&in_array(pm,hidden_markers_ids))
{properties_markers[pm].setMap(map);}}
hidden_markers_ids=[];for(feature in nearby_markers)
{for(marker in nearby_markers[feature])
{if(!isNaN(marker)&&in_array(marker,hidden_nearby_markers_ids[feature]))
{nearby_markers[feature][marker].setMap(map);}}
hidden_nearby_markers_ids[feature]=[];}}
function showExtraLink(feature)
{$('#gp_search_extra').hide();$('#gp_search_text').hide();$('#gp_mo_img').attr('src','http://c2.dmstatic.com/i/m/gp_arrow_down.png');options_tog=false;$('#gp_search_links').html(gp_messages[feature]);$('#gp_search_extra').show();}
function hideExtraLink()
{$('#gp_search_extra').hide();}
function trackEvent(evt,page)
{pageTracker._trackEvent('goldenpages',evt,page);}
function is_big_drag(c1,c2)
{var x1=c1.lat(),y1=c1.lng();var x2=c2.lat(),y2=c2.lng();var distance=Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));return(distance>=0.002);}
function in_array(needle,haystack)
{for(key in haystack){if(haystack[key]==needle){return true;}}
return false;}
var myPano;function handleNoFlash(errorCode)
{if(errorCode==603)
{error_message='<div id="streetview_error_msg">Error - Flash viewer not available, please ensure your browser supports Flash.</div>';$("#pano").append(error_message);return;}}
function CustomDiv(latlng,map,text){this.latlng_=latlng;this.text_=text;this.visible_=false;this.setMap(map);}
CustomDiv.prototype=new google.maps.OverlayView();CustomDiv.prototype.draw=function(){var me=this;var div=this.div_;var style='';if(!div){div=this.div_=document.createElement('DIV');if($.browser.msie&&parseInt($.browser.version)==6)
{$(div).css({'color':'#000','border':'none','padding':'0px','width':'324px','height':'131px','background-image':'url(http://c8.dmstatic.com/i/smimapdivbg.gif)','position':'absolute','display':'none','z-index':10000});}
else
{$(div).css({'color':'#000','border':'none','padding':'0px','width':'324px','height':'131px','background-image':'url(http://c8.dmstatic.com/i/smimapdivbg.png)','position':'absolute','display':'none','z-index':10000});}
var panes=this.getPanes();panes.floatPane.appendChild(div);}
div.innerHTML=this.text_;this.visible_=false;var point=this.getProjection().fromLatLngToDivPixel(this.latlng_);if(point){div.style.left=(point.x+16)+'px';div.style.top=(point.y-66)+'px';}};CustomDiv.prototype.hide=function(){if(this.div_){this.div_.style.display='none';}
restore_hidden_markers();this.visible_=false;};CustomDiv.prototype.show=function(){if(this.div_){this.div_.style.display='block';}
this.visible_=true;};CustomDiv.prototype.remove=function(){if(this.div_){this.div_.parentNode.removeChild(this.div_);this.div_=null;}};CustomDiv.prototype.getPosition=function(){return this.latlng_;};CustomDiv.prototype.setPosition=function(latlng){this.latlng_=latlng;var proj=this.getProjection();var point=proj.fromLatLngToDivPixel(this.latlng_);if(point){this.div_.style.left=(point.x+16)+'px';this.div_.style.top=(point.y-66)+'px';}
var bottom_left=proj.fromDivPixelToLatLng(new google.maps.Point(point.x+16,point.y+65));var top_right=proj.fromDivPixelToLatLng(new google.maps.Point(point.x+340,point.y-66));var div_box=new google.maps.LatLngBounds(bottom_left,top_right);if($.browser.msie&&parseInt($.browser.version)==6)
{for(var i=0;i<properties_markers.length;i++)
{if(properties_markers[i]!=null)
{var marker_pos=properties_markers[i].getPosition();var lat=marker_pos.lat();var lng=marker_pos.lng();if(div_box.contains(new google.maps.LatLng(lat,lng))&&properties_markers[i].getMap())
{hidden_markers_ids.push(properties_markers[i]['id']);properties_markers[i].setMap(null);}}}
for(feature in nearby_markers)
{for(key in nearby_markers[feature])
{if(!isNaN(key))
{var marker_pos=nearby_markers[feature][key].getPosition();var lat=marker_pos.lat();var lng=marker_pos.lng();if(div_box.contains(new google.maps.LatLng(lat,lng))&&nearby_markers[feature][key].getMap())
{hidden_nearby_markers_ids[feature].push(key);nearby_markers[feature][key].setMap(null);}}}}}
map.panToBounds(div_box);var nearby_box_coords=new google.maps.LatLngBounds(proj.fromContainerPixelToLatLng(bottom_left_nearby),proj.fromContainerPixelToLatLng(top_right_nearby));if(nearby_box_coords.contains(top_right))
{var div_box_top_right_pixels=proj.fromLatLngToContainerPixel(div_box.getNorthEast());var x_diff=div_box_top_right_pixels.x-bottom_left_nearby.x;var y_diff=div_box_top_right_pixels.y-bottom_left_nearby.y;if(x_diff<y_diff*-1)
{map.panBy(x_diff,0);}
else
{map.panBy(0,y_diff);}}};CustomDiv.prototype.setContent=function(text){this.text_=this.div_.innerHTML=text;};
