var map;var geocoder;var arrowIcon=new GIcon();var mapDiv;var sidebar;var pn=1;var ps=10;var total=0;var guserid;var gpseudoid;var thumbDiv;arrowIcon.image="icons/pin_icon.png";arrowIcon.iconSize=new GSize(30,36);arrowIcon.iconAnchor=new GPoint(9,34);var baseIcon=new GIcon(G_DEFAULT_ICON);baseIcon.shadow="http://www.google.com/mapfiles/shadow50.png";baseIcon.iconSize=new GSize(20,34);baseIcon.shadowSize=new GSize(37,34);baseIcon.iconAnchor=new GPoint(9,34);baseIcon.infoWindowAnchor=new GPoint(9,2);YAHOO.namespace("example.container");function init(){var c=getWindowSize();var a=(c.width-425)+"px";var b=(c.height-72)+"px";YAHOO.example.container.panel2=new YAHOO.widget.Panel("panel2",{width:a,height:b,visible:false,draggable:false,close:true});YAHOO.example.container.panel2.beforeHideEvent.subscribe(function(){mapDiv.style.visibility="visible"})}YAHOO.util.Event.addListener(window,"load",init);function ow(a,d,e){var c;var b;c=(screen.width-d)/2;b=(screen.height-e)/2;window.open(a,"","width="+d+",height="+e+",top="+b+",left="+c+",alwaysRaised=yes,toolbar=0,directories=0,menubar=0,status=0,resizable=yes,location=0,scrollbars=1,copyhistory=1")}function load(){var a=location.search;sidebar=document.getElementById("sidebar");if(a!=""){var b=a.substring(a.indexOf("loc=")+4,a.length);document.getElementById("addressInput").value=b;geocoder=new GClientGeocoder();geocoder.setBaseCountryCode("uk");mapDiv=document.getElementById("map");thumbDiv=document.getElementById("panel2");map=new GMap2(mapDiv);searchLocations()}else{if(GBrowserIsCompatible()){geocoder=new GClientGeocoder();geocoder.setBaseCountryCode("uk");mapDiv=document.getElementById("map");thumbDiv=document.getElementById("panel2");map=new GMap2(mapDiv);map.addControl(new GLargeMapControl());map.addControl(new GScaleControl());map.addControl(new GMapTypeControl());map.setCenter(new GLatLng(30.980252,2.329102),2);GDownloadUrl("GetCounts.aspx",function(d){var c=document.createElement("div");c.innerHTML=d;c.className="section";sidebar.appendChild(c)})}else{alert("Sorry, your browser cannot handle Google Maps")}}}function nextPage(){pn=pn+1;searchLocations();sidebar.scrollTop=0}function previousPage(){if(pn>1){pn=pn-1}searchLocations();sidebar.scrollTop=0}function Trim(a){return a.replace(/^\s*/,"").replace(/\s*$/,"")}function searchLocations(){document.getElementById('fapLogo').href="../fap";document.getElementById('fapLogo').title="Find a Photographer [Home]";if(!Trim(document.getElementById("addressInput").value)||(document.getElementById("addressInput").value=='Enter location')){alert("Please Enter a Location");return false}var a=document.getElementById("addressInput").value;geocoder.getLocations(a,function(b){if(!b||!b.Placemark){alert(a+" not found")}else{if(b.Placemark.length==1){geocoder.getLatLng(b.Placemark[0].address,function(f){if(!f){alert(b.Placemark[0].address+" not found")}else{searchLocationsNear(f,1)}})}else{sidebar.innerHTML="";var e=document.createElement("div");e.innerHTML="<div ><div id='locationlist1'>Did you mean:</div></div>";e.className="section";sidebar.appendChild(e);for(var d=0;d<b.Placemark.length;d++){var e=document.createElement("div");var c="<div class='mainlist1'><div id='namelist1'><ul><li class='heading'> <a href='javascript:document.getElementById(\"addressInput\").value=\""+b.Placemark[d].address+"\"; searchLocations();' title='"+b.Placemark[d].address+"' >"+b.Placemark[d].address+"</a> </li></ul></div></div>";e.innerHTML=c;e.className="section";sidebar.appendChild(e)}}}});YAHOO.example.container.panel2.hide();mapDiv.style.visibility="visible";sidebar.blur()}function searchLocationsNear(b){var a=document.getElementById("radiusSelect").value;var c=document.getElementById("ftrEd").checked;var f=document.getElementById("ftrCom").checked;var e="2";if(c==true&&f==false){e="0"}else{if(c==false&&f==true){e="1"}else{if(c==false&&f==false){document.getElementById("ftrCom").checked=true;document.getElementById("ftrEd").checked=true;e="2"}}}var d=new Date();var g="SrchNearestPhtgphrPaged.aspx?lat="+b.lat()+"&lng="+b.lng()+"&radius="+a+"&ps="+ps+"&pn="+pn+"&categ="+e+"&t="+d.getTime();GDownloadUrl(g,function(K){var m=GXml.parse(K);var H=m.documentElement.getElementsByTagName("marker");var C=0;map.clearOverlays();sidebar.innerHTML="";if(H.length==0){sidebar.innerHTML="<br>No results found.";var q=new GMarker(b,{icon:arrowIcon});map.addOverlay(q);map.setCenter(b,4);return}var p=new GLatLngBounds();var L=m.documentElement.getElementsByTagName("row");var j=parseFloat(L[0].getAttribute("nearest"));if(j>a){var w=((pn-1)*ps)+1;var t=(w-1)+ps;if(t>L[0].getAttribute("total")){t=L[0].getAttribute("total")}sidebar.innerHTML="<br><div><span class = 'info_area'> Nearest Photographer found is</span><span class = 'nearst_dis'> "+j+" km</span> away.</div><br><div style='font-weight:bold;'>Displaying "+w+" - "+t+" of "+L[0].getAttribute("total")+"</div><br>"}else{var w=((pn-1)*ps)+1;var t=(w-1)+ps;if(t>L[0].getAttribute("total")){t=L[0].getAttribute("total")}sidebar.innerHTML="<div style='font-weight:bold;'>Displaying "+w+" - "+t+" of "+L[0].getAttribute("total")+"</div><br>"}for(var G=0;G<H.length;G++){var M=H[G].getAttribute("name");var n=H[G].getAttribute("website");var o=H[G].getAttribute("address");var r=H[G].getAttribute("phoneno");var k=H[G].getAttribute("mobile");var F=H[G].getAttribute("description");var l=parseFloat(H[G].getAttribute("distance"));var E=new GLatLng(parseFloat(H[G].getAttribute("lat")),parseFloat(H[G].getAttribute("lng")));var z=H[G].getElementsByTagName("v");var h=H[G].getAttribute("userid");var D=z[0].getAttribute("email");var J=z[0].getAttribute("pseudoid");var B=L[0].getAttribute("total");if(B.length==0){B=0}var I=String.fromCharCode("A".charCodeAt(0)+G);var u=new GIcon(baseIcon);u.image="http://www.google.com/mapfiles/marker"+I+".png";var q=createMarker(E,M,o,u,D,h,J,n,r,k);map.addOverlay(q);var s=createSidebarEntry(q,M,o,l,"images/marker"+I+".jpg",h,J,n,F);sidebar.appendChild(s);p.extend(E);C=C+5}if(!(B<=10&pn==1)){var A=document.createElement("div");if(pn==1){A.innerHTML="<div style='float:right; padding-right:25px'> <a href='javascript:nextPage()'>Next&gt;</a></div>"}else{if(pn==Math.ceil(B/10)){A.innerHTML="<a href='javascript:previousPage()'>&lt;Previous</a> "}else{A.innerHTML="<div style='float:left'><a href='javascript:previousPage()'>&lt;Previous</a>   </div>   <div style='float:right; padding-right:25px'> <a href='javascript:nextPage()'>Next&gt;</a></div>"}}A.className="section";sidebar.appendChild(A)}var q=new GMarker(b,{icon:arrowIcon});map.addOverlay(q);p.extend(b);map.setCenter(p.getCenter(),map.getBoundsZoomLevel(p));return false})}function createMarker(l,b,k,e,j,h,f,c,d,a){var g=new GMarker(l,{icon:e});var i="<div style='height:7em;width:300px'><div class='mainlist1_bubble'><div id='namelist1_bubble'><ul><li class='heading'> "+b+"</a> </li></ul></div><div id='namelist2_bubble'><ul><div id='namelist3_bubble'><ul><li><span class='txt_bold'>Mobile : </span> "+a+"</li><li><span class='txt_bold'>Telephone :</span> "+d+"</li><li><span class='txt_bold'>email : </span><a href='mailto:"+j+"'>"+j+"</a></li><li><a href='javascript:showThumb(\""+h+'","'+f+'","'+escape(b)+'")\'>Pics on Alamy</a> - <a title="'+c+'" href=\'javascript:ow("http://'+c+"\",1024,600)'>Website</a></li>";"</ul></div></li><li><div></div></li></ul></div></div></div>";GEvent.addListener(g,"click",function(){YAHOO.example.container.panel2.hide();mapDiv.style.visibility="visible";g.openInfoWindowHtml(i)});return g}function createSidebarEntry(k,d,m,c,l,j,i,e,n){var b=document.createElement("div");var h=new Date();var g=crElement("div","<img src='"+l+"'/>","bubblelist","");GEvent.addDomListener(g,"click",function(){GEvent.trigger(k,"click")});b.appendChild(g);var f=crElement("div","","mainlist1","");var a=crElement("div","<ul><li class='heading'><a href='#'>"+d+" ("+c+" km)</a></li></ul>","","namelist1");GEvent.addDomListener(a,"click",function(){GEvent.trigger(k,"click")});f.appendChild(a);a=crElement("div","<ul>"+n+"</ul>","","namelist2");f.appendChild(a);if(e!=""){a=crElement("div","<a href=\"javascript:showThumb('"+j+"','"+i+"','"+d+'\')">Pics on Alamy</a>  -  <a title="'+e+"\" href=javascript:ow('http://"+e+"',1024,600)>Website</a>","","container")}else{a=crElement("div","<a href=\"javascript:showThumb('"+j+"','"+i+"','"+d+"')\">Pics on Alamy</a>","","container")}f.appendChild(a);b.appendChild(f);b.className="section";return b}function crElement(c,b,a,e){var d=document.createElement(c);d.innerHTML=b;if(a!=""){d.className=a}if(e!=""){d.id=e}return d}function showThumb(a,d,b){var c=getPageSize();guserid=a;gpseudoid=d;mapDiv.style.visibility="hidden";YAHOO.example.container.panel2.setHeader(b);loadpage(1,a,d,c)}function loadpage(d,a,b,c){ClearArrays();GDownloadUrl("PseudonymSearch.aspx?userid="+a+"&pid="+b+"&pageno="+d+"&ps="+c,function(e){YAHOO.example.container.panel2.setBody(e);YAHOO.example.container.panel2.render("map");YAHOO.example.container.panel2.show()})}function getPageSize(){var a=getWindowSize();return(Math.floor((a.width-450)/200)*Math.floor((a.height-130)/200))}function resizeApp(){map.setCenter(map.getCenter());var b=getWindowSize();mapDiv.style.width=(b.width-425)+"px";mapDiv.style.height=(b.height-72)+"px";thumbDiv.style.width=(b.width-425)+"px";thumbDiv.style.height=(b.height-72)+"px";sidebar.style.height=(b.height-78)+"px";YAHOO.example.container.panel2=new YAHOO.widget.Panel("panel2",{width:thumbDiv.style.width,height:thumbDiv.style.height,visible:false,draggable:false,close:true});YAHOO.example.container.panel2.beforeHideEvent.subscribe(function(){mapDiv.style.visibility="visible"});var a=0;if(mapDiv.style.visibility=="hidden"){a=getPageSize();loadpage(1,guserid,gpseudoid,a)}}function getWindowSize(){var a=new Object();if(window.self&&self.innerWidth){a.width=self.innerWidth;a.height=self.innerHeight}else{if(document.documentElement&&document.documentElement.clientHeight){a.width=document.documentElement.clientWidth;a.height=document.documentElement.clientHeight}else{a.width=document.body.clientWidth;a.height=document.body.clientHeight}}return a}function doClick(a,d){var c;if(window.event){c=window.event.keyCode}else{c=d.which}if(c==13){var b=document.getElementById(a);if(b!=null){b.click();event.keyCode=0}}};
