// (c) P N Jenkin & GuidebookPlus

var globalNumExistingPois=0;var globalNumInfoWindowMarkers=0;var globalNumInfoWindowWithLinksMarkers=0;var globalCheckBoxListener1=new Array;var globalCheckBoxListener2=new Array;var globalCheckBoxListener3=new Array;var globalCheckBoxListener4=new Array;var globalVisibleMarkerListener=new Array;var globalBookInfoWindowClickListener=new Array;var globalInfoButtonDomreadyListener=new Array;var globalInfoWindowClickListener=new Array;var globalContinentListener=null;var globalCountryListener=null;var globalRegionListener=null;var globalCityListener=null;var globalBookPageListButtonListener=null;var globalLeftClickListener=null;var globalPoiMarker=new Array();var globalBookMarker=new Array();var globalLabel=new Array();var globalAreaPoiMarker=new Array();var globalAreaPoiLabel=new Array();var globalAreaPoiGenreListener=new Array();var globalDummyAreaLabel;var globalAreaPoiGenreVisibility=new Array();var globalboolWikiButtonStatus=false;var globalboolHotelButtonStatus=false;var globalboolPoisButtonStatus=false;var globalboolPhotosShown=false;var globalAllMarkersLoaded=false;var globalColourRed='#FF0000';var globalColourGreen='#00E400';var globalColourBlue='#0000FF';var globalColourYellow='#D2D200';var globalColourGreyRed='E6A1A1';var globalColourGreyGreen='A1E6A1';var globalColourGreyBlue='A1A1E6';var globalColourGreyYellow='E6E6A1';var globalButtonColour='#d2f5f7';var globalGenresHidden=0;var map;var fluster;var globalPoiGenreVisibility;var globalPoiBookVisibility;var geocoder;var globalAddress;var globalResult;var globalCookieName='booksandplaces';var globalBoundsMemory=new Array();var globalBoundsIndex=0;var globalMapCentre=null;var globalMapZoom=null;var polyShape;var polyLineColor="#3355ff";var polyFillColor="#335599";var polyPoints=new Array();var markerArray=new Array();var clickMarkerArray=new Array();var markerTextArray=new Array();var globalBoolPolygon=false;var globalCircle=null;var globalPlinePois=new Array();var globalArrowMarkers=new Array();var globalBookAreaLabels=new Array();globalBookAreaMarkers=new Array();var userRectangle=null;var rectangleMarker1=null;var rectangleMarker2=null;var globalBoolClusterVisible=true;var globalBoolShowLineBooksVisible=false;var globalNumberGenres;var globalViews;var globalCurrentAreaSearchId;var globalInfoWindows=new Array();var globalDirectionsChangeListener;var result;var globalResult;var globalGeocodingDone=false;var directionsDisplay=new google.maps.DirectionsRenderer({draggable:true});var directionsService=new google.maps.DirectionsService();var globalWaypointsArray=new Array();var globalWaypointsPoibookidArray=new Array();var globalWaypointsDescriptionArray=new Array();var globalWaypointsPoiidArray=new Array();var globalWaypointsPageArray=new Array();var globalWaypointsBookidArray=new Array();globalcopyWaypointsArray=new Array();globalcopyWaypointsPoibookidArray=new Array();globalcopyWaypointsDescriptionArray=new Array();globalcopyWaypointsPoiidArray=new Array();globalcopyWaypointsPageArray=new Array();globalcopyWaypointsBookidArray=new Array();var globalOrigin;var globalOriginName;var globalDestination;var globalDestinationName;var globalboolOptimise;var globalboolCircular;var globalstartPlace;var globalfinishPlace;var globalWikiMarkers=new Array(100);var globalWikiClickListeners=new Array(100);var globalWikiInfoWindows=new Array(100);var globalHotelMarkers=new Array();var globalHotelClickListeners=new Array();var globalHotelInfoWindows=new Array();var globalBookPageListText123=new Array();var globalBookPageListValues123=new Array();var globalBookPageListTextABC=new Array();var globalBookPageListValuesABC=new Array();function setupUi()
{var myPlaces=document.getElementById('myplacesbutton');var myBooks=document.getElementById('mybooksbutton');var myGenreButton=document.getElementById('genredialoguebutton');var myLegendButton=document.getElementById('legenddialoguebutton');var myRoutes=document.getElementById('myroutesbutton');var myPoisButton=document.getElementById('poisbutton');var myHotelButton=document.getElementById('hotelbutton');var myWikiButton=document.getElementById('wikibutton');var myPrintButton=document.getElementById('printbutton');var myZoomButton=document.getElementById('zoombutton');var myPhotoButton=document.getElementById('photobutton');var myPolygonButton=document.getElementById('polygonbutton');var myPoisearchButton=document.getElementById('poisearchbutton');var myZoomButtonIcon=document.getElementById('zoombuttonicon');var myPhotoButtonIcon=document.getElementById('photobuttonicon');var myPolygonButtonIcon=document.getElementById('polygonbuttonicon');var myHotelButtonIcon=document.getElementById('hotelbuttonicon');var myPrintButtonIcon=document.getElementById('printbuttonicon');var myEmailButton=document.getElementById('gbplusemailbutton');var myHelpButton=document.getElementById('gbplushelpbutton');var myBlogButton=document.getElementById('gbplusblogbutton');var myGenreTickButton=document.getElementById('genretickbutton');var myGenreUntickButton=document.getElementById('genreuntickbutton');var myLastGenreCheckbox=document.getElementById('genrecheckbox'+document.getElementById('numcheckboxes').value);var theAtlas=document.getElementById('atlas');$(function(){myWidth=400;x1=document.getElementById('atlas').offsetLeft+document.getElementById('atlas').offsetWidth-myWidth-60;x2=document.getElementById('atlas').offsetLeft+20;y1=document.getElementById('atlas').offsetTop;var myHeight=document.getElementById('atlas').offsetHeight;$("#genres").dialog({height:myHeight,width:myWidth,position:[x1,y1],autoOpen:false,show:'slide',close:function(event,ui){document.getElementById('genredialoguebutton').innerHTML='Show Interests';document.getElementById('hideshowgenrebutton').click();}});var myHeight2=document.getElementById('atlas').offsetHeight;$("#legend").dialog({height:600,width:myWidth,position:[x2,y1],autoOpen:false,show:'slide',close:function(event,ui){document.getElementById('legenddialoguebutton').innerHTML='Show Legend';}});});$(function(){var x=document.getElementById('atlas').offsetLeft+'px';var y=document.getElementById('atlas').offsetTop+parseInt((document.getElementById('atlas').offsetHeight/2))+'px';document.getElementById('progressbar').style.position='absolute';document.getElementById('progressbar').style.width=document.getElementById('atlas').offsetWidth+'px';document.getElementById('progressbar').style.left=document.getElementById('atlas').offsetLeft+'px';document.getElementById('progressbar').style.top=document.getElementById('atlas').offsetTop+parseInt((document.getElementById('atlas').offsetHeight/2))+'px';$("#progressbar").progressbar({value:0,change:function(event,ui){var t=setTimeout("window.scrollBy(100,100);",100);}});});$('#progressbar').progressbar('destroy');document.getElementById('progressbar').style.visibility='hidden';myPoisButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myHotelButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myWikiButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myPrintButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myZoomButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myPhotoButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myPolygonButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myPoisearchButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-45;myZoomButtonIcon.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-40;myPhotoButtonIcon.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-40;myHotelButtonIcon.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-40;myPolygonButtonIcon.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-40;myPrintButtonIcon.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-40;myEmailButton.style.left=theAtlas.offsetLeft+50;if(theAtlas.offsetWidth>550)
myBlogButton.style.left=theAtlas.offsetLeft+theAtlas.offsetWidth-200;if(theAtlas.offsetWidth>550)
myHelpButton.style.left=theAtlas.offsetLeft+((myBlogButton.offsetLeft-myEmailButton.offsetWidth)/2);if(navigator.appName=="Microsoft Internet Explorer")
{for(var i=1;i<document.getElementById('numcheckboxes').value;i++)
{document.getElementById('genrelabel'+i).style.position='absolute';document.getElementById('genrelabel'+i).style.top=50+(20*i);}
document.getElementById('genretickbutton').style.position='absolute';document.getElementById('genreuntickbutton').style.position='absolute';document.getElementById('genretickbutton').style.top=50+(document.getElementById('numcheckboxes').value*20)+30;document.getElementById('genreuntickbutton').style.top=50+(document.getElementById('numcheckboxes').value*20)+30;document.getElementById('genretickbutton').style.left=20;document.getElementById('genreuntickbutton').style.left=200;}
if((myPlaces.offsetLeft+myPlaces.offsetWidth)>myLegendButton.offsetLeft)
{if(myLegendButton.offsetLeft<(myPlaces.offsetWidth+myBooks.offsetWidth+300))
{myPlaces.style.left=myGenreButton.offsetLeft;myBooks.style.left=myGenreButton.offsetLeft-myBooks.offsetWidth;myGenreButton.style.top=myGenreButton.offsetTop+35;myLegendButton.style.top=myLegendButton.offsetTop+35;myPlaces.style.top=myGenreButton.offsetTop+40;myBooks.style.top=myGenreButton.offsetTop+40;myRoutes.style.top=myGenreButton.offsetTop+65;}
else
{myPlaces.style.left=385;myPlaces.style.top=505;myBooks.style.left=300;myBooks.style.top=505;myRoutes.style.top=545;myRoutes.style.left=300;myGenreButton.style.top=70;myLegendButton.style.top=70;}}}
function resizeElements()
{myBase=document.getElementById('base');myMapCanvas=document.getElementById('atlas');myTitleBlock=document.getElementById('titleblock');myTopAdvert=document.getElementById('topadvert');myLeftAdvert=document.getElementById('leftadvert');myRightAdvert=document.getElementById('rightadvert');myDemoAdvert=document.getElementById('demoadvert');myTopBlock=document.getElementById('topblock');myBookSelectBlock=document.getElementById('bookselectblock');myBookShowBlock=document.getElementById('bookshowblock');myBookShowBlockBorder=document.getElementById('bookshowblockborder');myBackgroundImage=document.getElementById('backgroundimage');myDeleteBookButton=document.getElementById('deletebookbutton');myStretchableControls=document.getElementById('stretchablecontrols');myPageSubtitle=document.getElementById('pagesubtitle');myGetABookExplanation=document.getElementById('getabookexplanation');myGotABookExplanation=document.getElementById('gotabookexplanation');myGetABookBackground=document.getElementById('getabookbackground');myGotABookBackground=document.getElementById('gotabookbackground');myPlaces=document.getElementById('myplacesbutton');myBooks=document.getElementById('mybooksbutton');myGenres=document.getElementById('genres');myInvisibleBlock=document.getElementById('invisibleblock');myCopyright=document.getElementById('copyright');myAddThis=document.getElementById('addthis');myBase.style.width=getWidth()-myLeftAdvert.offsetWidth-myRightAdvert.offsetWidth;myBase.style.left=myLeftAdvert.offsetLeft+myLeftAdvert.offsetWidth;myMapCanvas.style.width=myBase.offsetWidth;myMapCanvas.style.left=myLeftAdvert.offsetLeft+myLeftAdvert.offsetWidth;myBookSelectBlock.style.left=myMapCanvas.offsetLeft-15;myBookSelectBlock.style.width=myMapCanvas.offsetWidth+30;myBookSelectBlock.style.top=myMapCanvas.offsetTop-15;myBookSelectBlock.style.height=myMapCanvas.offsetHeight+30;myBookShowBlock.style.left=myDeleteBookButton.offsetLeft+myBase.offsetLeft-2;myBookShowBlock.style.width=myMapCanvas.offsetWidth-myDeleteBookButton.offsetLeft+12;myBookShowBlock.style.top=myDeleteBookButton.offsetTop+myBase.offsetTop-2;myBookShowBlock.style.height=250+2;myBookShowBlockBorder.style.left=myMapCanvas.offsetLeft-10;myBookShowBlockBorder.style.width=myMapCanvas.offsetWidth+20;myBookShowBlockBorder.style.top=myMapCanvas.offsetTop-10;myBookShowBlockBorder.style.height=myMapCanvas.offsetHeight+20;myInvisibleBlock.style.top=0;myInvisibleBlock.style.height=screen.height;myInvisibleBlock.style.left=0;myInvisibleBlock.style.width=screen.width;myRightAdvert.style.left=myMapCanvas.offsetLeft+myMapCanvas.offsetWidth;myCopyright.style.left=myRightAdvert.offsetLeft-400;myCopyright.style.width=400;myAddThis.style.left=myRightAdvert.offsetLeft-400;myTopBlock.style.width=screen.width;var middle=((document.getElementById('atlas').offsetLeft+(document.getElementById('atlas').offsetWidth)/2));document.getElementById('legenddialoguebutton').style.left=middle-document.getElementById('legenddialoguebutton').offsetWidth;document.getElementById('genredialoguebutton').style.left=middle;$('#progressbar').progressbar('destroy');document.getElementById('progressbar').style.visibility='hidden';document.getElementById('genredialoguebutton').style.top=document.getElementById('atlas').offsetTop+5;document.getElementById('legenddialoguebutton').style.top=document.getElementById('atlas').offsetTop+5;document.getElementById('booktextred').style.width=greater(screen.width-document.getElementById('booktextred').offsetLeft-150,100);document.getElementById('booktextblue').style.width=greater(screen.width-document.getElementById('booktextblue').offsetLeft-150,100);document.getElementById('booktextgreen').style.width=greater(screen.width-document.getElementById('booktextgreen').offsetLeft-150,100);document.getElementById('booktextyellow').style.width=greater(screen.width-document.getElementById('booktextyellow').offsetLeft-150,100);var cookieEnabled=(navigator.cookieEnabled)?true:false
if(typeof navigator.cookieEnabled=="undefined"&&!cookieEnabled){document.cookie="testcookie"
cookieEnabled=(document.cookie.indexOf("testcookie")!=-1)?true:false}
if(!cookieEnabled)
{document.getElementById('mybooksbutton').style.visibility='hidden';document.getElementById('myplacesbutton').style.visibility='hidden';}
setupUi();}
function legendDialogueButtonClick()
{var x1,y1;var myHeight=document.getElementById('atlas').offsetHeight;myHeight=600;var myWidth=400;x1=document.getElementById('atlas').offsetLeft+40;y1=document.getElementById('atlas').offsetTop-document.body.scrollTop;if(!$('#legend').dialog('isOpen'))
{$('#legend').dialog('option','height',600);$('#legend').dialog('option','width',myWidth);$('#legend').dialog('option','position',[x1,y1]);$('#legend').dialog('open');document.getElementById('legenddialoguebutton').innerHTML='Hide Legend';}
else
{$('#legend').dialog('close');document.getElementById('legenddialoguebutton').innerHTML='Show Legend';}}
function genreDialogueButtonClick()
{var x1,y1;x1=document.getElementById('atlas').offsetLeft+document.getElementById('atlas').offsetWidth-myWidth-40;y1=document.getElementById('atlas').offsetTop-document.body.scrollTop;if(!$('#genres').dialog('isOpen'))
{$('#genres').dialog('option','position',[x1,y1]);$('#genres').dialog('open');document.getElementById('genredialoguebutton').innerHTML='Hide Interests';}
else
{$('#genres').dialog('close');document.getElementById('genredialoguebutton').innerHTML='Show Interests';}}
function bookButtonClick()
{var bookList=document.getElementById('book');var bookId=bookList.item(bookList.selectedIndex).value;var mapbookidBox=document.getElementById('mapbookid');if(bookId!=0)
{mapbookidBox.value=mapbookidBox.value+bookId+',';globalMapCentre=map.getCenter();globalMapZoom=map.getZoom();initialise('envelope');replaceAdvertUsingBookList();}}
function deleteBookButtonClick()
{var mapbookid=document.getElementById('mapbookid').value;if(mapbookid!='')
{var radbuttons=document.getElementsByName('bookradio');var radvalue;var currentBounds;currentBounds=map.getBounds();for(var i=0;i<radbuttons.length;i++)
{if(radbuttons[i].checked)radvalue=radbuttons[i].value;}
updateShownBookInfo('',0,radvalue);globalMapCentre=map.getCenter();globalMapZoom=map.getZoom();initialise('');map.fitBounds(currentBounds);}
else
alert('There is no book being mapped.');}
function updateShownBookInfo(booktitletext,bookid,colour)
{var mapbookid=document.getElementById('mapbookid');var mapbookidValue=mapbookid.value;var strMapbookid="";var splitMapbookid;var bookpagelist1=document.getElementById('bookpagelist1');var redbox=document.getElementById('booktextred');var bluebox=document.getElementById('booktextblue');var greenbox=document.getElementById('booktextgreen');var yellowbox=document.getElementById('booktextyellow');var redradiobutton=document.getElementById('bookradiored');var blueradiobutton=document.getElementById('bookradioblue');var greenradiobutton=document.getElementById('bookradiogreen');var yellowradiobutton=document.getElementById('bookradioyellow');var redcheckbox=document.getElementById('bookcheckbox1');var bluecheckbox=document.getElementById('bookcheckbox2');var greencheckbox=document.getElementById('bookcheckbox3');var yellowcheckbox=document.getElementById('bookcheckbox4');document.getElementById('hintpara1').style.visibility='hidden';document.getElementById('hintpara2').style.visibility='hidden';document.getElementById('hintpara3').style.visibility='hidden';document.getElementById('hintlogo').style.visibility='hidden';booktitletext='&nbsp;'+booktitletext;if(bookid!=0)
{var bookIsbnOption=document.getElementById('invisiblebook'+bookid);var isbn=bookIsbnOption.getAttribute('data-isbn10');if(redbox.innerHTML=='')
{redbox.innerHTML=booktitletext;showBookCover(isbn);}
else if(bluebox.innerHTML=='')
{bluebox.innerHTML=booktitletext;showBookCover(isbn);}
else if(greenbox.innerHTML=='')
{greenbox.innerHTML=booktitletext;showBookCover(isbn);}
else if(yellowbox.innerHTML=='')
{yellowbox.innerHTML=booktitletext;showBookCover(isbn);}
setGGCookie(globalCookieName,'book:'+bookid,7);}
else
{switch(colour)
{case'red':redbox.innerHTML=bluebox.innerHTML;bluebox.innerHTML=greenbox.innerHTML;greenbox.innerHTML=yellowbox.innerHTML;yellowbox.innerHTML='';splitMapbookid=mapbookid.value.split(',');for(var i=0;i<splitMapbookid.length;i++)
{if(i!=0&&splitMapbookid[i].length>0)
strMapbookid+=splitMapbookid[i]+',';}
for(var i=bookpagelist1.options.length-1;i>=0;i--)
{if(bookpagelist1.options[i].style.backgroundColor=='red')
bookpagelist1.removeChild(bookpagelist1.options[i]);else
{if(bookpagelist1.options[i].style.backgroundColor==globalColourBlue)
bookpagelist1.options[i].style.backgroundColor=globalColourRed;if(bookpagelist1.options[i].style.backgroundColor==globalColourGreen)
bookpagelist1.options[i].style.backgroundColor=globalColourBlue;if(bookpagelist1.options[i].style.backgroundColor==globalColourYellow)
bookpagelist1.options[i].style.backgroundColor=globalColourGreen;}}
break;case'blue':bluebox.innerHTML=greenbox.innerHTML;greenbox.innerHTML=yellowbox.innerHTML;yellowbox.innerHTML='';splitMapbookid=mapbookid.value.split(',');for(var i=0;i<splitMapbookid.length;i++)
{if(i!=1&&splitMapbookid[i].length>0)
strMapbookid+=splitMapbookid[i]+',';}
for(var i=bookpagelist1.options.length-1;i>=0;i--)
{if(bookpagelist1.options[i].style.backgroundColor==globalColourBlue)
bookpagelist1.removeChild(bookpagelist1.options[i]);else
{if(bookpagelist1.options[i].style.backgroundColor==globalColourGreen)
bookpagelist1.options[i].style.backgroundColor=globalColourBlue;if(bookpagelist1.options[i].style.backgroundColor==globalColourYellow)
bookpagelist1.options[i].style.backgroundColor=globalColourGreen;}}
break;case'green':greenbox.innerHTML=yellowbox.innerHTML;yellowbox.innerHTML='';splitMapbookid=mapbookid.value.split(',');for(var i=0;i<splitMapbookid.length;i++)
{if(i!=2&&splitMapbookid[i].length>0)
strMapbookid+=splitMapbookid[i]+',';}
for(var i=bookpagelist1.options.length-1;i>=0;i--)
{if(bookpagelist1.options[i].style.backgroundColor==globalColourGreen)
bookpagelist1.removeChild(bookpagelist1.options[i]);else
{if(bookpagelist1.options[i].style.backgroundColor==globalColourYellow)
bookpagelist1.options[i].style.backgroundColor=globalColourGreen;}}
break;case'yellow':yellowbox.innerHTML='';splitMapbookid=mapbookid.value.split(',');for(var i=0;i<splitMapbookid.length;i++)
{if(i!=3&&splitMapbookid[i].length>0)
strMapbookid+=splitMapbookid[i]+',';}
for(var i=bookpagelist1.options.length-1;i>=0;i--)
{if(bookpagelist1.options[i].style.backgroundColor==globalColourYellow)
bookpagelist1.removeChild(bookpagelist1.options[i]);}
break;}
mapbookid.value=strMapbookid;}
if(yellowbox.innerHTML=='')
{yellowbox.style.backgroundColor=globalColourGreyYellow;yellowradiobutton.style.backgroundColor=globalColourGreyYellow;yellowcheckbox.style.backgroundColor=globalColourGreyYellow;yellowradiobutton.style.visibility='hidden';yellowcheckbox.style.visibility='hidden';greenradiobutton.checked=true;yellowbox.style.visibility='hidden';}
else
{yellowbox.style.backgroundColor=globalColourYellow;yellowradiobutton.style.backgroundColor=globalColourYellow;yellowcheckbox.style.backgroundColor=globalColourYellow;yellowradiobutton.style.visibility='visible';yellowcheckbox.style.visibility='visible';yellowbox.style.visibility='visible';}
if(greenbox.innerHTML=='')
{greenbox.style.backgroundColor=globalColourGreyGreen;greenradiobutton.style.backgroundColor=globalColourGreyGreen;greencheckbox.style.backgroundColor=globalColourGreyGreen;greenradiobutton.style.visibility='hidden';greencheckbox.style.visibility='hidden';blueradiobutton.checked=true;greenbox.style.visibility='hidden';}
else
{greenbox.style.backgroundColor=globalColourGreen;greenradiobutton.style.backgroundColor=globalColourGreen;greencheckbox.style.backgroundColor=globalColourGreen;greenradiobutton.style.visibility='visible';greencheckbox.style.visibility='visible';greenbox.style.visibility='visible';}
if(bluebox.innerHTML=='')
{bluebox.style.backgroundColor=globalColourGreyBlue;blueradiobutton.style.backgroundColor=globalColourGreyBlue;bluecheckbox.style.backgroundColor=globalColourGreyBlue;blueradiobutton.style.visibility='hidden';bluecheckbox.style.visibility='hidden';redradiobutton.checked=true;bluebox.style.visibility='hidden';}
else
{bluebox.style.backgroundColor=globalColourBlue;blueradiobutton.style.backgroundColor=globalColourBlue;bluecheckbox.style.backgroundColor=globalColourBlue;blueradiobutton.style.visibility='visible';bluecheckbox.style.visibility='visible';bluebox.style.visibility='visible';}
if(redbox.innerHTML=='')
{redbox.style.backgroundColor=globalColourGreyRed;redradiobutton.style.backgroundColor=globalColourGreyRed;redcheckbox.style.backgroundColor=globalColourGreyRed;redradiobutton.style.visibility='hidden';redcheckbox.style.visibility='hidden';redbox.style.visibility='hidden';}
else
{redbox.style.backgroundColor=globalColourRed;redradiobutton.style.backgroundColor=globalColourRed;redcheckbox.style.backgroundColor=globalColourRed;redradiobutton.style.visibility='visible';redcheckbox.style.visibility='visible';redbox.style.visibility='visible';}}
function getAreaListBoxInfo(listName,strField,strParameter,boolCumulative)
{var thisList=document.getElementById(listName);implementListboxDependency(thisList.getAttribute("data-dependent"),thisList.options[thisList.selectedIndex].value,strField,strParameter,boolCumulative);}
function implementListboxDependency(listNames,containerId,strField,strParameter,boolCumulative)
{var i;var splitList=listNames.split(",");var strPrefix='invisible_';for(i=0;i<splitList.length;i++)
{if(!boolCumulative)
{repopulateListbox(strPrefix+splitList[i].replace("*",""),splitList[i].replace("*",""));}
filterListboxes(splitList[i],containerId,strField,strParameter);}}
function filterListboxes(listName,containerId,strFieldName,strParameter)
{var i,j;var theList;var intStringLength;var containerString;var splitIdList;var optionAttributes;var theOption;var strPrefix='invisible';intStringLength=listName.length;if(listName.substring(intStringLength-1)=="*")
{strFieldName=listName.substring(0,intStringLength-1);theList=document.getElementById(strFieldName);}
else
theList=document.getElementById(listName);for(i=0;i<theList.options.length;i++)
{theOption=document.getElementById(strPrefix+strFieldName+theList.options[i].value);containerString=theOption.getAttribute(strParameter);splitIdList=containerString.split(",");for(j=0;j<splitIdList.length;j++)
{if((splitIdList[j]==containerId)||(containerId==0)||(theOption.value==0))
break;}
if(j==splitIdList.length)
{theList.remove(i);i--;}}}
function backwardFilterListbox(strTargetListName,strEndListName,strParameterName)
{var theTargetList=document.getElementById(strTargetListName);var theEndList=document.getElementById(strEndListName);var strData,splitIdList,theOptionValue,theEndOption;var i,j,k;var strPrefix='invisible';for(i=0;i<theTargetList.options.length;i++)
{theOptionValue=theTargetList.options[i].value;for(j=0;j<theEndList.options.length;j++)
{theEndOption=document.getElementById(strPrefix+strEndListName+theEndList.options[j].value);strData=theEndOption.getAttribute(strParameterName);splitIdList=strData.split(",");for(k=0;k<splitIdList.length;k++)
{if((splitIdList[k]==theOptionValue)||(theOptionValue==0))
{k=0;j=theEndList.options.length;break;}}}
if((j==theEndList.options.length)&&(k==splitIdList.length))
{theTargetList.remove(i);i--;}}}
function getAreaListBoxInfoExclusive(listName,strField,strParameter,boolCumulative)
{var thisList=document.getElementById(listName);implementListboxDependencyExclusive(thisList.getAttribute("data-dependent"),thisList.options[thisList.selectedIndex].value,strField,strParameter,boolCumulative);}
function implementListboxDependencyExclusive(listNames,containerId,strField,strParameter,boolCumulative)
{var i;var splitList=listNames.split(",");var strPrefix='invisible_';for(i=0;i<splitList.length;i++)
{if(!boolCumulative)
{repopulateListbox(strPrefix+splitList[i].replace("*",""),splitList[i].replace("*",""));}
filterListboxesExclusive(splitList[i],containerId,strField,strParameter);}}
function filterListboxesExclusive(listName,containerId,strFieldName,strParameter)
{var i,j;var theList;var intStringLength;var containerString;var splitIdList;var optionAttributes;var theOption;var strPrefix='invisible';intStringLength=listName.length;if(listName.substring(intStringLength-1)=="*")
{strFieldName=listName.substring(0,intStringLength-1);theList=document.getElementById(strFieldName);}
else
theList=document.getElementById(listName);for(i=0;i<theList.options.length;i++)
{theOption=document.getElementById(strPrefix+strFieldName+theList.options[i].value);containerString=theOption.getAttribute(strParameter);splitIdList=containerString.split(",");for(j=0;j<splitIdList.length;j++)
{if((splitIdList[j]==containerId)||(containerId==0)||(theOption.value==0))
break;}
if(j==splitIdList.length)
{theList.remove(i);i--;}}}
function repopulateListbox(sourceListName,targetListName)
{var i;var theTargetList=document.getElementById(targetListName);var theSourceList=document.getElementById(sourceListName);for(i=theTargetList.options.length-1;i>=0;i--)
{theTargetList.remove(i);}
for(i=theSourceList.options.length-1;i>=0;i--)
{theNewOption=new Option(theSourceList.item(i).text,theSourceList.item(i).value);theTargetList.appendChild(theNewOption);theTargetList.item(theTargetList.options.length-1).text=theSourceList.item(i).text;theTargetList.item(theTargetList.options.length-1).value=theSourceList.item(i).value;}}
function showBookMarkers(bookId)
{alert('book id = '+bookId);}
RepeatingOperation=function(op,yieldEveryIteration){var count=0;var instance=this;this.step=function(args){if(++count>=yieldEveryIteration){count=0;setTimeout(function(){op(args);},1,[])
return;}
op(args);};};function showBookPages(map,fluster){globalPoiGenreVisibility=new Array();globalPoiBookVisibility=new Array();var theBookPageList=document.getElementById('bookpagelist1');clearBookPageList('bookpagelist1');var theOption=new Option('Index',0);theBookPageList.appendChild(theOption);theBookPageList.item(theBookPageList.options.length-1).text='Index';theBookPageList.item(theBookPageList.options.length-1).value=0;theBookPageList.item(theBookPageList.options.length-1).title='Option';var mapbookidBox=document.getElementById('mapbookid');var strBookId=mapbookidBox.value;_gaq.push(['_setCustomVar',1,"bookids",strBookId,1]);for(var i=0;i<strBookId.split(',').length-1;i++)
{strBookTitle="";for(j=0;j<document.getElementById("book").options.length;j++)
{if(document.getElementById("book").options[j].value==strBookId.split(',')[i])
{strBookTitle=document.getElementById("book").options[j].text;}}
_gaq.push(['_trackEvent','bookids','book-load',strBookTitle,parseInt(strBookId.split(',')[i])]);}
_gaq.push(['_trackPageview']);var searchUrl='PoIRelKML.php?bookid='+strBookId;downloadUrl(searchUrl,function(data){var xml=parseXml(data);if(xml.documentElement==null)
return;var markerNodes=xml.documentElement.getElementsByTagName("Placemark");var bounds=new google.maps.LatLngBounds();var floatPoiLength=new Array(markerNodes.length);var strfractions='';for(var i=markerNodes.length-1;i>0;i--)
{var intPageNumRearward=parseInt(markerNodes[i].getAttribute("placemark-name"));var intPageNumForeward=0;var floatPageFraction=0;for(var j=i-1;j>=0;j--)
{intPageNumForeward=parseInt(markerNodes[j].getAttribute("placemark-name"));if(intPageNumForeward!=intPageNumRearward)
{floatPageFraction=(intPageNumRearward-intPageNumForeward)/(i-j);for(var k=j;k<=i-1;k++)
{floatPoiLength[k]=floatPageFraction;strfractions=strfractions+floatPageFraction+',';}
i=j+1;j=-1;}}}
if(markerNodes.length>1)
{floatPoiLength[0]=parseInt((markerNodes[1].getAttribute("placemark-name"))-parseInt(markerNodes[0].getAttribute("placemark-name"))/1)
floatPoiLength[markerNodes.length-1]=1;}
boolGlobalMarkersLoaded=false;var intCountLowerLimit=0;var intCountUpperLimit=markerNodes.length;for(j=0;j<globalNumExistingPois;j++)
{globalPoiMarker[j].setMap=null;}
var roCounter=0;var ro=new RepeatingOperation(function(){processMarkerNode(map,fluster,markerNodes,strBookId,floatPoiLength,roCounter);if(++roCounter<markerNodes.length){ro.step();}
else{$('#progressbar').progressbar('destroy');document.getElementById('progressbar').style.visibility='hidden';fluster.initialize();globalAllMarkersLoaded=true;map.setZoom(map.getZoom());map.panTo(map.getCenter());registerBookPageList();}},100);ro.step();globalNumExistingPois=markerNodes.length;});boolGlobalMarkersLoaded=true;}
function processMarkerNode(map,fluster,markerNodes,strBookId,floatPoiLength,i)
{var name=markerNodes[i].getAttribute("placemark-name");var description=markerNodes[i].getAttribute("placemark-description");var coords=markerNodes[i].getAttribute("placemark-coordinates");var size=markerNodes[i].getAttribute("placemark-size");var poibookid=markerNodes[i].getAttribute("placemark-poibookid");var bookid=markerNodes[i].getAttribute("placemark-bookid");var genreids=markerNodes[i].getAttribute("placemark-genreids");var confidence=markerNodes[i].getAttribute("placemark-confidence");var poiid=markerNodes[i].getAttribute("placemark-Point");var splitCoords=coords.split(",");var lon=parseFloat(splitCoords[0]);var lat=parseFloat(splitCoords[1]);strBookIdTrimmed=strBookId.substr(0,strBookId.length-1);var bookIdSplit=strBookIdTrimmed.split(',');var labelColour="";for(var j=0;j<bookIdSplit.length;j++)
{if(bookIdSplit[j]==bookid)
{switch(j)
{case 0:labelColour='red';labelColour=globalColourRed;break;case 1:labelColour='blue';labelColour=globalColourBlue;break;case 2:labelColour='green';labelColour=globalColourGreen;labelColour=globalColourGreen;break;default:labelColour='yellow';labelColour='#d2d200';labelColour=globalColourYellow;}}}
var pageOccurrences=0;var pageOccurrenceRegister=new Array;var strOrdinal="";for(var j=0;j<markerNodes.length;j++)
{if((markerNodes[j].getAttribute("placemark-name")==name)&&(markerNodes[j].getAttribute("placemark-bookid")==bookid))
{pageOccurrenceRegister[pageOccurrences]=j;pageOccurrences++;}}
if(pageOccurrences>1)
{for(var j=0;j<pageOccurrenceRegister.length;j++)
{if(i==pageOccurrenceRegister[j])
{switch(j)
{case 0:strOrdinal="st"
break;case 1:strOrdinal="nd"
break;case 2:strOrdinal="rd"
break;default:strOrdinal="th"}
strOrdinal="-"+(j+1)+strOrdinal;}}}
var poiLength=floatPoiLength[i];addMarkerAndLabel(map,fluster,lat,lon,name,labelColour,strOrdinal,poiLength,genreids,bookid,i,poiid,poibookid,description,confidence);populateBookPageList(name+strOrdinal+' : '+description,description,lat,lon,size,confidence,'bookpagelist1',labelColour,bookid,poiid);var t=setTimeout($("#progressbar").progressbar('value',parseInt(((i/markerNodes.length)*100))),10);}
function downloadUrl(url,callback){var request=window.ActiveXObject?new ActiveXObject('Microsoft.XMLHTTP'):new XMLHttpRequest;request.onreadystatechange=function(){if(request.readyState==4){request.onreadystatechange=doNothing;callback(request.responseText,request.status);}};request.open('GET',url,true);request.send(null);}
function parseXml(str){if(window.ActiveXObject){var doc=new ActiveXObject('Microsoft.XMLDOM');doc.loadXML(str);return doc;}else{var mystring=str;if(mystring.indexOf('geonames')!=-1)
{mystring=mystring.replace('\n','');if(mystring.indexOf('<xml>')==-1)
{mystring=mystring.substring(0,mystring.indexOf('?>')+2)+'<xml xmlns="http://ws.geonames.org/wikipediaBoundingBox"><Document>'+mystring.substring(mystring.indexOf('?>')+2)+'</Document></xml>';}
mystring=mystring.replace(/<thumbnailImg \/>/g,'');mystring=mystring.replace(/<thumbnailImg\/>/g,'');}
var parser=new DOMParser();var dom=parser.parseFromString(mystring,'text/xml');if(dom.documentElement.nodeName=="parsererror")
{}
return dom;}}
function doNothing(){}
function addMarkerAndLabel(map,fluster,lat,lng,labelText,labelColour,strOrdinal,poiLength,genreIds,bookId,i,poiid,poibookid,description,confidence)
{var myNewLatLng=new google.maps.LatLng(lat,lng);var myLabel=new Label({zIndex:2,visible:false,map:map});globalLabel[i]=myLabel;var image='images/1px.png';var strPoiBookIdAndBookId=poibookid+'#'+bookId;globalPoiMarker[i]=new google.maps.Marker({position:myNewLatLng,icon:image,title:strPoiBookIdAndBookId,draggable:false});google.maps.event.addListener(globalPoiMarker[i],'visible_changed',function(){if(this.getVisible()==true)
myLabel.show();else
myLabel.hide();});if(description=="Cornwall: Press for Progress!")
{myLabel.getDiv().onclick=function(e){CornwallClick();}}
else
{myLabel.getDiv().onmouseup=function(e){replaceAdvertUsingBookId(bookId);var rightclick;if(!e)var e=window.event;if(e.which)rightclick=(e.which==3);else if(e.button)rightclick=(e.button==2);if(rightclick==false){}else{showLocationPageDialogue(poiid,myLabel.getLat(),myLabel.getLng(),poibookid);}}
myLabel.getDiv().onclick=function(e){replaceAdvertUsingBookId(bookId);toggleWaypoint(myLabel,myNewLatLng,poibookid,labelText,bookId,description,poiid);}}
fluster.addMarker(globalPoiMarker[i]);myLabel.set('colour',labelColour);myLabel.set('text',labelText);myLabel.set('title',description+". This label shows the page number describing this location. Left-Click the label to add this location to your route plan. Right-Click for Wikipedia articles and accommodation info.");myLabel.set('ordinal',strOrdinal);if(poiLength>1)
myLabel.set('fontstyle','bold');else
myLabel.set('fontstyle','italic');if(confidence==2)
{var parkCount=0;for(k=0;k<genreIds.split(',').length;k++)
{if(genreIds.split(',')[k]==11||genreIds.split(',')[k]==12||genreIds.split(',')[k]==13)
{parkCount++;}}
if(parkCount==3)
{myLabel.setBorderAsArea();}}
myLabel.set('genreIds',genreIds);myLabel.set('description',description);myLabel.set('poibookid',poibookid);myLabel.set('poiid',poiid);myLabel.set('bookId',bookId);myLabel.bindTo('position',globalPoiMarker[i],'position');myLabel.setPoibookid(poibookid);myLabel.setDescription(description);myLabel.setLat(lat);myLabel.setLng(lng);var strPoibookId=poibookid;globalPoiGenreVisibility[poibookid]=true;globalPoiBookVisibility[poibookid]=true;var myHideButton=document.getElementById('hideshowgenrebutton');var myBooksButton=document.getElementById('mybooksbutton');var myPlacesButton=document.getElementById('myplacesbutton');google.maps.event.addDomListener(myHideButton,'click',function(){var strChkPoiBookId=poibookid;myLabel.hide();var splitGenreId=genreIds.split(',');for(var i=0;i<splitGenreId.length;i++){var chkbox=document.getElementById('genrecheckbox'+splitGenreId[i]);if(chkbox!=null){if(chkbox.checked==true||(splitGenreId[i]==globalNumberGenres)){globalPoiGenreVisibility[strChkPoiBookId]=true;i=splitGenreId.length;}else{globalPoiGenreVisibility[strChkPoiBookId]=false;}if(globalGenresHidden>0)document.getElementById('genredialoguebutton').style.backgroundColor='#ff0000';else document.getElementById('genredialoguebutton').style.backgroundColor=globalButtonColour;}}});var myBookCheckbox1=document.getElementById('bookcheckbox1');var myBookCheckbox2=document.getElementById('bookcheckbox2');var myBookCheckbox3=document.getElementById('bookcheckbox3');var myBookCheckbox4=document.getElementById('bookcheckbox4');globalCheckBoxListener1[i]=google.maps.event.addDomListener(myBookCheckbox1,'click',function(){var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');if(splitBookId.length>0){if(splitBookId[0]==bookId){if(myBookCheckbox1.checked==true){globalPoiBookVisibility[poibookid]=true;if(globalPoiGenreVisibility[poibookid]==true){}}else{myLabel.hide();globalPoiBookVisibility[poibookid]=false;}}}});globalCheckBoxListener2[i]=google.maps.event.addDomListener(myBookCheckbox2,'click',function(){var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');if(splitBookId.length>1){if(splitBookId[1]==bookId){if(myBookCheckbox2.checked==true){globalPoiBookVisibility[poibookid]=true;if(globalPoiGenreVisibility[poibookid]==true){}}else{myLabel.hide();globalPoiBookVisibility[poibookid]=false;}}}});globalCheckBoxListener3[i]=google.maps.event.addDomListener(myBookCheckbox3,'click',function(){var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');if(splitBookId.length>2){if(splitBookId[2]==bookId){if(myBookCheckbox3.checked==true){globalPoiBookVisibility[poibookid]=true;if(globalPoiGenreVisibility[poibookid]==true){}}else{myLabel.hide();globalPoiBookVisibility[poibookid]=false;}}}});globalCheckBoxListener4[i]=google.maps.event.addDomListener(myBookCheckbox4,'click',function(){var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');if(splitBookId.length>3){if(splitBookId[3]==bookId){if(myBookCheckbox4.checked==true){globalPoiBookVisibility[poibookid]=true;if(globalPoiGenreVisibility[poibookid]==true){}}else{myLabel.hide();globalPoiBookVisibility[poibookid]=false;}}}});}
function showAreaBooks(map)
{for(j=0;j<globalNumInfoWindowMarkers;j++)
{}
globalNumInfoWindowMarkers=0;var searchUrl='BooksKML.php';downloadUrl(searchUrl,function(data){var xml=parseXml(data);var markerNodes=xml.documentElement.getElementsByTagName("Area");var markers=[];var infowindows=[];var booksArray=[];var infowindow=new google.maps.InfoWindow();for(var i=0;i<markerNodes.length;i++)
{var name=markerNodes[i].getAttribute("Name");var areatype=markerNodes[i].getAttribute("AreaType");var areaid=markerNodes[i].getAttribute("areaid");var lat=markerNodes[i].getAttribute("LatAreaCentre");var lon=markerNodes[i].getAttribute("LonAreaCentre");var areaid=markerNodes[i].getAttribute("areaid");var books=markerNodes[i].getAttribute("Books");var imageSize;var image;var content='<DIV class="content" ID="content"><BUTTON class="standardbutton" style="float:right" onclick="javascript:for (i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i] != null) {globalInfoWindows[i].close();}}">Close</BUTTON><P><H2>'+name+'</H2><IMG SRC="images/GGlogo6.png" STYLE="float:right;margin:5px;" WIDTH=100 HEIGHT=100></P>';var content='<BUTTON class="standardbutton" style="float:right" onclick="javascript:closeBookAreaDialogue();for (i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i] != null) {globalInfoWindows[i].close();}}">Close</BUTTON><IMG SRC="images/GGlogo6.png" STYLE="float:right;margin:5px;" WIDTH=100 HEIGHT=100>';var strBook="";var strBookIds="";if(books.length==0)
content+='Unfortunately, there is no information on page locations for guide books specifically about '+name+' - (though there may be related information in guide books for a neighbouring or surrounding area).';else
{var splitBooks=books.split(';');var maxNumBooks=5;strBook='<I>Locations</I> in '+name+' have been mapped for the following '+((splitBooks.length>1)?splitBooks.length+' ':'')+'guidebook'+((splitBooks.length>1)?'s':'')+':<TABLE>';for(var j=0;j<splitBooks.length&&j<maxNumBooks;j++)
{var splitBookFields=splitBooks[j].split('/');if(splitBookFields[4]==0)
{strBook+='<TR><TD>This book not yet ready for mapping: <B>'+splitBookFields[1]+'</B> (<I>'+splitBookFields[2]+'</I>), edition:'+splitBookFields[3]+'</TD>&nbsp;&nbsp;<TD ALIGN="CENTER" VALIGN="CENTER"></TD></TR>';}
else
{publisherId=('publisher'+splitBookFields[5]).toString();lstBooks=document.getElementById('book');for(k=0;k<lstBooks.length;k++)
{if(parseInt(lstBooks.options[k].value)==parseInt(splitBookFields[0]))
{theTitle=lstBooks.options[k].text;titleLength=theTitle.indexOf("),(");strBook+='<TR><TD><B>'+theTitle.substr(0,titleLength)+'</B>'+theTitle.substr(titleLength,3)+'<I>'+theTitle.substr(titleLength+3,4)+'</I>'+theTitle.substr(titleLength+7).replace(/,/g,', ')+'</TD>&nbsp;&nbsp;<TD ALIGN="CENTER" VALIGN="CENTER"><BUTTON class="standardbutton" ID="infobutton'+splitBookFields[0]+'" name= "infobutton'+splitBookFields[0]+'" onclick="AreaSearchId='+areaid+';updateDemoAdvert();replaceAdvert(/*AreaSearchId*/);self.location.hash = '+String.fromCharCode(39)+'#atlas'+String.fromCharCode(39)+';var mymapbookidtext = document.getElementById('+String.fromCharCode(39)+'mapbookid'+String.fromCharCode(39)+'); mymapbookidtext.value += '+splitBookFields[0]+'+'+String.fromCharCode(39)+','+String.fromCharCode(39)+';globalMapCentre=map.getCenter();globalmapZoom=map.getZoom();initialise('+String.fromCharCode(39)+'view-'+areaid+'/'+splitBookFields[0]+String.fromCharCode(39)+');" >Map pages</BUTTON></TD>';strBook+='<TD><iframe src="http://rcm-uk.amazon.co.uk/e/cm?t=guimap-21&o=2&p=8&l=as1&asins='+splitBookFields[6]+'&fc1=000000&IS2=1&lt1=_blank&m=amazon&lc1=0000FF&bc1=000000&bg1=FFFFFF&f=ifr" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe>'+'</TD></TR>';}}
strBookIds+=splitBookFields[0]+',';}}
strBookIds=strBookIds.substr(0,strBookIds.length-1);}
content+=strBook+'</TABLE>';addMarkerWithInfowindow(lat,lon,areatype,content,map,strBookIds,areaid,name,i);}});}
function addMarkerWithInfowindow(lat,lon,areatype,books,map,strBookIds,areaid,name,i)
{var myNewLatLng=new google.maps.LatLng(lat,lon);var image;var zIndex;var shadowImage;var anchor;switch(parseInt(areatype))
{case 1:image=new google.maps.MarkerImage('images/bookareaiconredcontinentscaled.png');shadowImage=new google.maps.MarkerImage('images/bookareaiconshadow80.png');zIndex=6;break;case 2:image=new google.maps.MarkerImage('images/bookareaicongreencountryscaled.png');shadowImage=new google.maps.MarkerImage('images/bookareaiconshadow40.png');zIndex=8;break;case 3:image=new google.maps.MarkerImage('images/bookareaiconblueregionscaled.png');shadowImage=new google.maps.MarkerImage('images/bookareaiconshadow30.png');zIndex=10;break;case 4:image=new google.maps.MarkerImage('images/bookareaiconyellowcityscaled.png');shadowImage=new google.maps.MarkerImage('images/bookareaiconshadow25.png');zIndex=11;break;default:image=new google.maps.MarkerImage('BookIcon20.png');shadowImage=new google.maps.MarkerImage('images/bookareaiconGREYshadow25.png');zIndex=5;}
var myMarker=new google.maps.Marker({position:myNewLatLng,title:'Click to see books about '+name,draggable:false,icon:image,zIndex:zIndex,shadow:shadowImage,map:map});var infowindow=new google.maps.InfoWindow({content:books});globalBookInfoWindowClickListener[i]=google.maps.event.addListener(myMarker,'click',function(){for(i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i]!=null){globalInfoWindows[i].close();}}AreaSearchId=areaid;replaceAdvert();document.getElementById('areabooksdialoguetext').innerHTML=books;;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?600:600;$("#areabooksdialogue").dialog({width:660,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#areabooksdialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('areabooksdialogue').style.height='600px';window.setTimeout(function(){$("#areabooksdialogue").dialog("option","position","center");},1000);}});globalInfoWindows.push(infowindow);var splitBookIds=strBookIds.split(',');for(var j=0;j<splitBookIds.length;j++)
{if(splitBookIds[j].length>0)
{addInfoButtonListener(infowindow,splitBookIds[j],areaid,splitBookIds[j],globalNumInfoWindowMarkers);}
else
addInfoWindowWithoutBooksListener(infowindow,areaid);}
globalBookAreaMarkers[i]=myMarker;var myBookAreaLabel=new BookAreaLabel({map:map});globalBookAreaLabels[i]=myBookAreaLabel;if(splitBookIds!=null)
{if(strBookIds.length>0)
{myBookAreaLabel.set('text',splitBookIds.length);}
else
{myBookAreaLabel.set('text','0');}}
else
{myBookAreaLabel.set('text','0');}
myBookAreaLabel.bindTo('position',globalBookAreaMarkers[i],'position');myBookAreaLabel.setLat(lat);myBookAreaLabel.setLng(lon);if(parseInt(areatype)==1)
{myBookAreaLabel.set('offsetVertical',-30);}
else if(parseInt(areatype)==3||parseInt(areatype)==4)
{myBookAreaLabel.set('offsetVertical',6);}
else
{myBookAreaLabel.set('offsetVertical',0);}
myBookAreaLabel.show();}
function addInfoButtonListener(infowindow,infobuttonid,areaid,bookid,i)
{globalInfoButtonDomreadyListener[i]=google.maps.event.addListener(infowindow,'domready',function(){alert('hello');AreaSearchId=areaid;updateDemoAdvert();replaceAdvert();self.location.hash='#atlas';var myinfobutton=document.getElementById('infobutton'+infobuttonid);globalInfoWindowClickListener[i]=google.maps.event.addDomListener(myinfobutton,'click',function(){;var mymapbookidtext=document.getElementById('mapbookid');mymapbookidtext.value+=infobuttonid+',';globalMapCentre=map.getCenter();globalmapZoom=map.getZoom();initialise('view-'+areaid+'/'+bookid);});});globalNumInfoWindowMarkers++;}
function addInfoWindowWithoutBooksListener(infowindow,areaid)
{google.maps.event.addListener(infowindow,'domready',function(){AreaSearchId=areaid;replaceAdvert();updateDemoAdvert();});}
function clearBookPageList(bookpagelistid)
{var theBookPageList=document.getElementById(bookpagelistid);for(var i=theBookPageList.options.length-1;i>=0;i--)
{theBookPageList.remove(i);}}
function populateBookPageList(page,description,lat,lon,size,confidence,bookpagelistid,labelColour,bookid,poiid)
{var theBookPageList=document.getElementById(bookpagelistid);var zoomLevel;switch(parseInt(size))
{case 1:zoomLevel=11;break;case 2:zoomLevel=12;break;case 3:zoomLevel=13;break;case 4:zoomLevel=14;break;case 5:zoomLevel=15;break;case 6:zoomLevel=11;break;default:zoomLevel=11;}
if(confidence==3||confidence==6)
{zoomLevel=11;}
var theOption=new Option(page,lat+','+lon+'@'+zoomLevel+'@'+bookid+'-'+poiid);theOption.style.backgroundColor=labelColour;theBookPageList.appendChild(theOption);theBookPageList.item(theBookPageList.options.length-1).text=page;theBookPageList.item(theBookPageList.options.length-1).value=lat+','+lon+'@'+zoomLevel+'@'+bookid+'-'+poiid;}
function ABC123ButtonClick()
{var mapbookids=document.getElementById('mapbookid').value.split(",");var theABC123button=document.getElementById('ABC123button');clearBookPageList('bookpagelist1');var theBookPageList=document.getElementById('bookpagelist1');var zoomLevel;var theOption=new Option('Index',0);theBookPageList.appendChild(theOption);theBookPageList.item(theBookPageList.options.length-1).text='Index';theBookPageList.item(theBookPageList.options.length-1).value=0;for(i=0;i<globalBookPageListValuesABC.length;i++)
{if(theABC123button.value=='ABC')
{var theOption=new Option(globalBookPageListTextABC[i],globalBookPageListValuesABC[i]);theBookPageList.appendChild(theOption);theBookPageList.item(theBookPageList.options.length-1).text=globalBookPageListTextABC[i];theBookPageList.item(theBookPageList.options.length-1).value=globalBookPageListValuesABC[i];switch(globalBookPageListValues123[i].split("@")[2].split("-")[0])
{case mapbookids[0]:theOption.style.backgroundColor=globalColourRed;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourRed;break;case mapbookids[1]:theOption.style.backgroundColor=globalColourBlue;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourBlue;break;case mapbookids[2]:theOption.style.backgroundColor=globalColourGreen;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourGreen;break;case mapbookids[3]:theOption.style.backgroundColor=globalColourYellow;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourYellow;break;}}
else
{var theOption=new Option(globalBookPageListText123[i],globalBookPageListValues123[i]);theBookPageList.appendChild(theOption);theBookPageList.item(theBookPageList.options.length-1).text=globalBookPageListText123[i];theBookPageList.item(theBookPageList.options.length-1).value=globalBookPageListValues123[i];switch(globalBookPageListValues123[i].split("@")[2].split("-")[0])
{case mapbookids[0]:theOption.style.backgroundColor=globalColourRed;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourRed;break;case mapbookids[1]:theOption.style.backgroundColor=globalColourBlue;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourBlue;break;case mapbookids[2]:theOption.style.backgroundColor=globalColourGreen;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourGreen;break;case mapbookids[3]:theOption.style.backgroundColor=globalColourYellow;theBookPageList.item(theBookPageList.options.length-1).style.backgroundColor=globalColourYellow;break;}}}
if(theABC123button.value=='ABC')
{theABC123button.value='123';theABC123button.innerHTML='123';}
else
{theABC123button.value='ABC';theABC123button.innerHTML='ABC';}}
function registerBookPageList()
{globalBookPageListText123=new Array();globalBookPageListValues123=new Array();globalBookPageListTextABC=new Array();globalBookPageListValuesABC=new Array();var bookPageListSortABC=new Array();var currentBookId;var theBookPageList=document.getElementById('bookpagelist1');var theABC123button=document.getElementById('ABC123button');for(i=1;i<theBookPageList.options.length;i++)
{globalBookPageListText123.push(theBookPageList.options[i].text);globalBookPageListValues123.push(theBookPageList.options[i].value);}
currentBookId=globalBookPageListValues123[1].split("@")[2].split("-")[0];for(i=0;i<globalBookPageListValues123.length;i++)
{globalBookPageListValuesABC.push(globalBookPageListText123[i].split(" : ")[1]+' : '+globalBookPageListText123[i].split(" : ")[0]+'|'+globalBookPageListValues123[i]);if(i==globalBookPageListValues123.length-1)
{bookPageListSortABC.push(globalBookPageListValuesABC[i]);bookPageListSortABC.sort();globalBookPageListTextABC=globalBookPageListTextABC.concat(bookPageListSortABC);}
else if(currentBookId==globalBookPageListValues123[i].split("@")[2].split("-")[0])
{bookPageListSortABC.push(globalBookPageListValuesABC[i]);currentBookId=globalBookPageListValues123[i].split("@")[2].split("-")[0];}
else
{bookPageListSortABC.sort();globalBookPageListTextABC=globalBookPageListTextABC.concat(bookPageListSortABC);bookPageListSortABC=new Array();bookPageListSortABC.push(globalBookPageListValuesABC[i]);currentBookId=globalBookPageListValues123[i].split("@")[2].split("-")[0];}}
for(i=0;i<globalBookPageListValues123.length;i++)
{globalBookPageListValuesABC[i]=globalBookPageListTextABC[i].split("|")[1];globalBookPageListTextABC[i]=globalBookPageListTextABC[i].split("|")[0];}
theABC123button.value='ABC';}
function panZoomToArea(envelope,map)
{var splitCoords=envelope.split(',');var sw=splitCoords[0].split(' ');var ne=splitCoords[2].split(' ');;var swLatLon=new google.maps.LatLng(sw[0],sw[1]);var neLatLon=new google.maps.LatLng(ne[0],ne[1]);var envelopeBounds=new google.maps.LatLngBounds(swLatLon,neLatLon);map.fitBounds(envelopeBounds);saveView(envelopeBounds);}
function initialise(envelope){var myLatlng=new google.maps.LatLng(50.1,-4.1);var myZoom=5;if(globalMapCentre!=null)
{myLatlng=globalMapCentre;myZoom=globalMapZoom;}
var myOptions={zoom:myZoom,center:myLatlng,mapTypeId:google.maps.MapTypeId.ROADMAP,scaleControl:true,streetViewControl:true,minZoom:3};map=new google.maps.Map(document.getElementById("atlas"),myOptions);fluster=new Fluster2(map);geocoder=new google.maps.Geocoder();directionsDisplay.setMap(map);directionsDisplay.setPanel(document.getElementById('routedialoguetext'));window.setTimeout(function(){document.getElementById('genredialoguebutton').style.visibility='visible';document.getElementById('legenddialoguebutton').style.visibility='visible';},1000);var my2ndHideButton=document.getElementById('HideButton2');boolGlobalMarkersLoaded=false;globalBoolClusterVisible=true;document.getElementById('clusterbutton').style.backgroundColor=globalButtonColour;document.getElementById('photobutton').style.backgroundColor=globalButtonColour;document.getElementById('poisbutton').style.backgroundColor=globalButtonColour;document.getElementById('hotelbutton').style.backgroundColor=globalButtonColour;document.getElementById('wikibutton').style.backgroundColor=globalButtonColour;document.getElementById('showbooklinesbutton').style.backgroundColor=globalButtonColour;if(document.getElementById('polygonButton')!=null)
document.getElementById('polygonButton').style.backgroundColor=globalButtonColour;document.getElementById('ABC123button').value='ABC';globalboolPhotosShown=false;globalboolHotelButtonStatus=false;globalboolPoisButtonStatus=false;globalboolWikiButtonStatus=false;globalBoolShowLineBooksVisible=false;globalBoolPolygon=false;if(userRectangle!=null)
userRectangle.setMap(null);if(rectangleMarker1!=null)
rectangleMarker1.setMap(null);if(rectangleMarker2!=null)
rectangleMarker2.setMap(null);userRectangle=null;$("#progressbar").progressbar({value:0});var myBookList=document.getElementById('book');var theTitle="";var theBookId="";var theYear="";var titleLength;if(globalBookPageListButtonListener!=null)
{google.maps.event.removeListener(globalBookPageListButtonListener);}
var myContinentList=document.getElementById('continent');var myCountryList=document.getElementById('country');var myRegionList=document.getElementById('region');var myCityList=document.getElementById('city');if(globalContinentListener!=null)
{google.maps.event.removeListener(globalContinentListener);google.maps.event.removeListener(globalCountryListener);google.maps.event.removeListener(globalRegionListener);google.maps.event.removeListener(globalCityListener);}
globalContinentListener=google.maps.event.addDomListener(myContinentList,'change',function(){panZoomToArea(document.getElementById('invisiblearea'+myContinentList.item(myContinentList.selectedIndex).value).getAttribute('data-envelope'),map);});globalCountryListener=google.maps.event.addDomListener(myCountryList,'change',function(){panZoomToArea(document.getElementById('invisiblearea'+myCountryList.item(myCountryList.selectedIndex).value).getAttribute('data-envelope'),map);});globalRegionListener=google.maps.event.addDomListener(myRegionList,'change',function(){panZoomToArea(document.getElementById('invisiblearea'+myRegionList.item(myRegionList.selectedIndex).value).getAttribute('data-envelope'),map);});globalCityListener=google.maps.event.addDomListener(myCityList,'change',function(){panZoomToArea(document.getElementById('invisiblearea'+myCityList.item(myCityList.selectedIndex).value).getAttribute('data-envelope'),map);});clearPoly();showAreaBooks(map);getGGCookie('booksandplaces');if(globalLeftClickListener!=null)
google.maps.event.removeListener(globalLeftClickListener);if((envelope=='initial_load'))
{globalDummyAreaLabel=new Label({map:map});globalDummyAreaLabel.set('colour','white');globalDummyAreaLabel.set('text','');globalDummyAreaLabel.set('title','');globalDummyAreaLabel.setPoibookid('');globalDummyAreaLabel.set('ordinal','');globalDummyAreaLabel.set('fontstyle','bold');globalDummyAreaLabel.bindTo('position',new google.maps.Marker({map:map,position:new google.maps.LatLng(0,0),visible:false}),'position');globalDummyAreaLabel.setLat(0);globalDummyAreaLabel.setLng(0);globalDummyAreaLabel.hide();globalWaypointsArray=new Array();downloadUrl('http://www.guidebookplus.com/getBoundingBoxHotels.php?north=51&south=50&west=-2&east=0',function(data){});if(navigator.appName=="Microsoft Internet Explorer")
document.getElementById('bookcountpara').innerHTML=(document.getElementById('book').options.length-1)+' '+document.getElementById('bookcountpara').innerHTML;else
document.getElementById('bookcountpara').textContent=(document.getElementById('book').options.length-1)+' '+document.getElementById('bookcountpara').textContent;}
else if((envelope=='envelope')||(envelope.indexOf('view')!=-1))
{clearCurrentRoute();var mapbookidTextBox=document.getElementById('mapbookid');var mapbookid=mapbookidTextBox.value;if(mapbookidTextBox.value!='')
{document.getElementById('pdfbutton').style.visibility='visible';document.getElementById('deletebookbutton').style.visibility='visible';document.getElementById('kmlbutton').style.visibility='visible';}
if(mapbookid.split(',').length>5)
{document.getElementById('progressbar').style.visibility='visible';alert('We can only show 4 books\' maps at once. Please remove one or more books in order to show this one.');showBookPages(map,fluster);map.setZoom(map.getZoom());map.panTo(map.getCenter());}
else
{document.getElementById('progressbar').style.visibility='visible';showBookPages(map,fluster);theOption=document.getElementById("invisiblebook"+myBookList.options[myBookList.selectedIndex].value);theTitle=theOption.text;theBookId=theOption.value;theYear=document.getElementById("invisiblebook"+myBookList.options[myBookList.selectedIndex].value).getAttribute('data-year');if((envelope=='envelope'))
{panZoomToArea(theOption.getAttribute("data-envelope"),map);titleLength=theTitle.indexOf(",(");theTitle='<B>'+theTitle.substr(0,titleLength)+'</B>'+theTitle.substr(titleLength,2)+'<I>'+theTitle.substr(titleLength+2,4)+'</I>'+theTitle.substr(titleLength+6);}
else
{var invisibleArea=document.getElementById('invisiblearea'+envelope.substr(5,(envelope.length-5)-(envelope.length-envelope.indexOf('/'))));if(envelope.substr(5,(envelope.length-5)-(envelope.length-envelope.indexOf('/')))!=0)
{panZoomToArea(invisibleArea.getAttribute("data-envelope"),map);}
var theInvisibleBook=document.getElementById('invisiblebook'+envelope.substr(envelope.indexOf('/')+1,envelope.length-(envelope.indexOf('/')+1)));theTitle=theInvisibleBook.text;theBookId=theInvisibleBook.value;theYear=theInvisibleBook.getAttribute('data-year');titleLength=theTitle.indexOf("),(");theTitle='<B>'+theTitle.substr(0,titleLength)+'</B>'+theTitle.substr(titleLength,3)+'<I>'+theTitle.substr(titleLength+3,4)+'</I>'+theTitle.substr(titleLength+7);}
updateShownBookInfo(theTitle,theBookId,'any');}}
else
{showAreaBooks(map);showBookPages(map,fluster);map.setZoom(map.getZoom());map.panTo(map.getCenter());if(document.getElementById('mapbookid').value.length==0)
$('#progressbar').progressbar('destroy');document.getElementById('progressbar').style.visibility='hidden';var mapbookidTextBox=document.getElementById('mapbookid');var mapbookid=mapbookidTextBox.value;if(mapbookidTextBox.value=='')
{document.getElementById('pdfbutton').style.visibility='hidden';document.getElementById('deletebookbutton').style.visibility='hidden';document.getElementById('kmlbutton').style.visibility='hidden';}}
globalDirectionsChangeListener=google.maps.event.addListener(directionsDisplay,'directions_changed',function(){totalLength=0;totalDuration=0;if(directionsDisplay.directions!=null)
{if(directionsDisplay.directions.routes!=null)
{for(var i=0;i<globalResult.routes[0].legs.length;i++)
{totalLength+=directionsDisplay.directions.routes[0].legs[i].distance.value;totalDuration+=directionsDisplay.directions.routes[0].legs[i].duration.value;}}
if(document.getElementById("routedistancetimecalcs")!=null)
{document.getElementById("routedistancetimecalcs").innerHTML='Total distance = <B>'+Math.round(totalLength/1000)+' km</B>. Total duration = <B>'+Math.floor(totalDuration/3600)+' hours</B>, <B>'+Math.floor((totalDuration%3600)/60)+' minutes</B>.';}}});}
function checkGlobalMarkersLoaded()
{alert('in checkGlobalMarkersLoaded');if(boolGlobalMarkersLoaded!=true)
{setTimeout(checkGlobalMarkersLoaded,1000);alert('in checkGlobalMarkersLoaded timing');}}
function greater(firstValue,secondValue)
{if(firstValue>secondValue)
return firstValue;else
return secondValue;}
function getWidth()
{var x=0;if(self.innerHeight)
{x=self.innerWidth;}
else if(document.documentElement&&document.documentElement.clientHeight)
{x=document.documentElement.clientWidth;}
else if(document.body)
{x=document.body.clientWidth;}
return x;}
function getHeight()
{var y=0;if(self.innerHeight)
{y=self.innerHeight;}
else if(document.documentElement&&document.documentElement.clientHeight)
{y=document.documentElement.clientHeight;}
else if(document.body)
{y=document.body.clientHeight;}
return y;}
function countryCityButtonClick()
{document.getElementById('city').style.visibility='visible';document.getElementById('country').style.visibility='hidden';document.getElementById('countryregionradio').style.visibility='hidden';document.getElementById('countryregionlabel').style.visibility='hidden';document.getElementById('countrycityradio').style.visibility='hidden';document.getElementById('countrycitylabel').style.visibility='hidden';document.getElementById('city').style.visibility='visible';document.getElementById('citypublisherradio').style.visibility='visible';document.getElementById('citypublisherlabel').style.visibility='visible';setTimeout(function(){document.getElementById('citypublisherradio').checked=true;},1000);document.getElementById('exactareaupperradio').style.visibility='visible';document.getElementById('exactareaupperlabel').style.visibility='visible';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';getAreaListBoxInfo('country','area','data-containers',true);document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function regionAndCityButtonClick()
{if(document.getElementById('region').style.visibility=='visible')
getAreaListBoxInfo('region','area','data-containers',true)
else
getAreaListBoxInfo('city','area','data-containers',true);document.getElementById('publisher').style.visibility='visible';document.getElementById('citypublisherradio').style.visibility='hidden';document.getElementById('citypublisherlabel').style.visibility='hidden';document.getElementById('regionpublisherradio').style.visibility='hidden';document.getElementById('regionpublisherlabel').style.visibility='hidden';document.getElementById('exactareaupperradio').style.visibility='hidden';document.getElementById('exactareaupperlabel').style.visibility='hidden';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';document.getElementById('region').style.visibility='hidden';document.getElementById('city').style.visibility='hidden';document.getElementById('publisher').style.visibility='visible';document.getElementById('publisheryearradio').style.visibility='visible';document.getElementById('publisheryearlabel').style.visibility='visible';document.getElementById('publishereditionradio').style.visibility='visible';document.getElementById('publishereditionlabel').style.visibility='visible';setTimeout(function(){document.getElementById('publisheryearradio').checked=true;},1000);document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function continentButtonClick()
{document.getElementById('continent').style.visibility='hidden';document.getElementById('country').style.visibility='visible';document.getElementById('countryregionradio').style.visibility='visible';document.getElementById('countryregionlabel').style.visibility='visible';setTimeout(function(){document.getElementById('countryregionradio').checked=true},1000);document.getElementById('countrycityradio').style.visibility='visible';document.getElementById('countrycitylabel').style.visibility='visible';document.getElementById('continentcountryradio').style.visibility='hidden';document.getElementById('continentcountrylabel').style.visibility='hidden';document.getElementById('exactareaupperradio').style.visibility='hidden';document.getElementById('exactareaupperlabel').style.visibility='hidden';document.getElementById('exactarealowerradio').style.visibility='visible';document.getElementById('exactarealowerlabel').style.visibility='visible';document.getElementById('isbntitleradio').style.visibility='hidden';document.getElementById('isbntitlelabel').style.visibility='hidden';getAreaListBoxInfo('continent','area','data-containers',0);document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function countryRegionButtonClick()
{document.getElementById('region').style.visibility='visible';document.getElementById('country').style.visibility='hidden';document.getElementById('countryregionlabel').style.visibility='hidden';document.getElementById('countryregionradio').style.visibility='hidden';setTimeout(function(){document.getElementById('regionpublisherradio').checked=true;},1000);document.getElementById('countrycitylabel').style.visibility='hidden';document.getElementById('countrycityradio').style.visibility='hidden';document.getElementById('region').style.visibility='visible';document.getElementById('regionpublisherradio').style.visibility='visible';document.getElementById('regionpublisherlabel').style.visibility='visible';document.getElementById('exactareaupperradio').style.visibility='hidden';document.getElementById('exactareaupperlabel').style.visibility='hidden';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';getAreaListBoxInfo('country','area','data-containers',true);document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function publisherYearButtonClick()
{document.getElementById('publisher').style.visibility='hidden';document.getElementById('publisheryearradio').style.visibility='hidden';document.getElementById('publisheryearlabel').style.visibility='hidden';document.getElementById('publishereditionradio').style.visibility='hidden';document.getElementById('publishereditionlabel').style.visibility='hidden';document.getElementById('year').style.visibility='visible';document.getElementById('yearradio').style.visibility='visible';document.getElementById('yearlabel').style.visibility='visible';setTimeout(function(){document.getElementById('yearradio').checked=true;},1000);document.getElementById('exactareaupperradio').style.visibility='hidden';document.getElementById('exactareaupperlabel').style.visibility='hidden';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';getAreaListBoxInfo('publisher','publisher','data-publisher',1);backwardFilterListbox('year','book','data-year');document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function publisherEditionButtonClick()
{document.getElementById('publisher').style.visibility='hidden';document.getElementById('publisheryearradio').style.visibility='hidden';document.getElementById('publisheryearlabel').style.visibility='hidden';document.getElementById('publishereditionradio').style.visibility='hidden';document.getElementById('publishereditionlabel').style.visibility='hidden';document.getElementById('edition').style.visibility='visible';document.getElementById('editionradio').style.visibility='visible';document.getElementById('editionlabel').style.visibility='visible';setTimeout(function(){document.getElementById('editionradio').checked=true;},1000);getAreaListBoxInfo('publisher','publisher','data-publisher',1);backwardFilterListbox('edition','book','data-edition');document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function yearAndEditionButtonClick()
{if(document.getElementById('year').style.visibility=='visible')getAreaListBoxInfo('year','year','data-year',true);else
getAreaListBoxInfo('edition','edition','data-edition',true);document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('exactareaupperradio').style.visibility='hidden';document.getElementById('exactareaupperlabel').style.visibility='hidden';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function thisIsTheAreaButtonClick()
{if(document.getElementById('continent').style.visibility!='hidden'){getAreaListBoxInfo('continent','area','data-bookareas',0);}
else if(document.getElementById('country').style.visibility!='hidden'){getAreaListBoxInfo('country','area','data-bookareas',0);}
else if(document.getElementById('region').style.visibility!='hidden'){getAreaListBoxInfo('region','area','data-bookareas',0);}
else if(document.getElementById('city').style.visibility=='visible'){getAreaListBoxInfo('city','area','data-bookareas',0);}
document.getElementById('continent').style.visibility='hidden';document.getElementById('country').style.visibility='hidden';document.getElementById('region').style.visibility='hidden';document.getElementById('city').style.visibility='hidden';document.getElementById('continentcountryradio').style.visibility='hidden';document.getElementById('continentcountrylabel').style.visibility='hidden';document.getElementById('countryregionradio').style.visibility='hidden';document.getElementById('countryregionlabel').style.visibility='hidden';document.getElementById('countrycityradio').style.visibility='hidden';document.getElementById('countrycitylabel').style.visibility='hidden';document.getElementById('citypublisherradio').style.visibility='hidden';document.getElementById('citypublisherlabel').style.visibility='hidden';document.getElementById('regionpublisherradio').style.visibility='hidden';document.getElementById('regionpublisherlabel').style.visibility='hidden';document.getElementById('publisheryearradio').style.visibility='visible';document.getElementById('publisheryearlabel').style.visibility='visible';document.getElementById('publishereditionradio').style.visibility='visible';document.getElementById('publishereditionlabel').style.visibility='visible';document.getElementById('yearradio').style.visibility='hidden';document.getElementById('yearlabel').style.visibility='hidden';document.getElementById('editionradio').style.visibility='hidden';document.getElementById('editionlabel').style.visibility='hidden';setTimeout(function(){document.getElementById('publisheryearradio').checked=true;},1000);document.getElementById('exactareaupperradio').style.visibility='hidden';document.getElementById('exactareaupperlabel').style.visibility='hidden';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';document.getElementById('isbntitleradio').style.visibility='hidden';document.getElementById('isbntitlelabel').style.visibility='hidden';document.getElementById('publisher').style.visibility='visible';document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function resetSearch()
{repopulateListbox('invisible_book','book');repopulateListbox('invisible_continent','continent');repopulateListbox('invisible_country','country');repopulateListbox('invisible_region','region');repopulateListbox('invisible_city','city');repopulateListbox('invisible_publisher','publisher');repopulateListbox('invisible_year','year');repopulateListbox('invisible_edition','edition');document.getElementById('continentcountryradio').style.visibility='visible';document.getElementById('continentcountrylabel').style.visibility='visible';document.getElementById('countryregionradio').style.visibility='hidden';document.getElementById('countryregionlabel').style.visibility='hidden';document.getElementById('countrycityradio').style.visibility='hidden';document.getElementById('countrycitylabel').style.visibility='hidden';document.getElementById('citypublisherradio').style.visibility='hidden';document.getElementById('citypublisherlabel').style.visibility='hidden';document.getElementById('regionpublisherradio').style.visibility='hidden';document.getElementById('regionpublisherlabel').style.visibility='hidden';document.getElementById('publisheryearradio').style.visibility='hidden';document.getElementById('publisheryearlabel').style.visibility='hidden';document.getElementById('publishereditionradio').style.visibility='hidden';document.getElementById('publishereditionlabel').style.visibility='hidden';document.getElementById('yearradio').style.visibility='hidden';document.getElementById('yearlabel').style.visibility='hidden';document.getElementById('editionradio').style.visibility='hidden';document.getElementById('editionlabel').style.visibility='hidden';document.getElementById('exactareaupperradio').style.visibility='visible';document.getElementById('exactareaupperlabel').style.visibility='visible';document.getElementById('exactarealowerradio').style.visibility='hidden';document.getElementById('exactarealowerlabel').style.visibility='hidden';document.getElementById('isbntitleradio').style.visibility='visible';document.getElementById('isbntitlelabel').style.visibility='visible';document.getElementById('isbntitlesearchtextbox').value='';document.getElementById('isbntitlesearchtextbox').style.visibility='hidden';document.getElementById('continentcountryradio').checked=true;document.getElementById('edition').style.visibility='hidden';document.getElementById('year').style.visibility='hidden';document.getElementById('publisher').style.visibility='hidden';document.getElementById('city').style.visibility='hidden';document.getElementById('region').style.visibility='hidden';document.getElementById('country').style.visibility='hidden';document.getElementById('continent').style.visibility='visible';document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function pdfButtonClick()
{var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');var bookid=0;var url='';if(strMapbookid!='')
{var radbuttons=document.getElementsByName('bookradio');var radvalue;for(var i=0;i<radbuttons.length;i++)
{if(radbuttons[i].checked)radvalue=radbuttons[i].value;}
if(radvalue=='red'){bookid=splitBookId[0];}
else if(radvalue=='blue'){bookid=splitBookId[1];}
else if(radvalue=='green'){bookid=splitBookId[2];}
else{bookid=splitBookId[3];};url=document.getElementById('invisiblebook'+bookid).getAttribute('data-mapurl');window.open(self.location.href.substring(0,(self.location.href.indexOf('#')!=-1?(self.location.href.length-(self.location.href.length-self.location.href.indexOf('#'))):self.location.href.length))+'/images/maps/'+url,'MAP_WINDOW');}
else
alert('There is no book being mapped.');}
function searchTitleOrISBNButtonClick()
{var mysearchtextbox=document.getElementById('isbntitlesearchtextbox');var mybooklist=document.getElementById('book');var count=mybooklist.options.length;var characterNumberCount=0;var minimumISBN=6;if((mysearchtextbox.value=='Type keyword/ISBN here')||(mysearchtextbox.value==''))
{alert("Please type a keyword or the ISBN of the book you wish to use, in the text box above.");geocoder=null;}
else
{for(var i=0;i<mysearchtextbox.value.length;i++)
{if(!isNaN(mysearchtextbox.value.charAt(i)))
{characterNumberCount++;}}
if(characterNumberCount>minimumISBN)
{for(var i=count-1;i>=0;i--)
{if(document.getElementById('invisiblebook'+mybooklist.options[i].value).getAttribute('data-isbn10').replace(/-/gi,'')!=mysearchtextbox.value.replace(/-/gi,'')&&document.getElementById('invisiblebook'+mybooklist.options[i].value).getAttribute('data-isbn13').replace(/-/gi,'')!=mysearchtextbox.value.replace(/-/gi,''))
if(mybooklist.options[i].value!=0)
{mybooklist.removeChild(mybooklist.options[i]);}}
if(mybooklist.options.length==1)
{self.location.hash='#atlas';document.getElementById('isbndialogtext').innerHTML="";document.getElementById('isbniframe').width=600;document.getElementById('isbniframe').height=150;document.getElementById('isbniframe').src="isbndblookup.php?isbn="+mysearchtextbox.value;myMapCanvas=document.getElementById('atlas');$("#isbndialoguetext").dialog({width:660,height:240,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',close:function(event,ui){}});$("#isbndialoguetext").dialog('open');resetSearch();}
else
{alert('Searched for ISBN '+mysearchtextbox.value.replace(/-/gi,'')+' : Match found. Please see book list above. To search again, press the "Reset Search" button and try another ISBN or another method.');AreaSearchId=document.getElementById('invisiblebook'+mybooklist.options[1].value).getAttribute('data-bookareas').split(',')[0];showBookCover(document.getElementById('invisiblebook'+mybooklist.options[1].value).getAttribute('data-isbn10'));replaceAdvert();}}
else
{for(var i=count-1;i>=0;i--)
{if(mybooklist.options[i].text.toLowerCase().search(mysearchtextbox.value.toLowerCase())==-1)
{if(mybooklist.options[i].value!=0)
{mybooklist.removeChild(mybooklist.options[i]);}}}
alert('Searched by title: '+(mybooklist.options.length-1)+' match'+(((mybooklist.options.length-1)!=1)?'es':'')+' out of '+(count-1)+' books. Please see book list.To search again, press the "Reset Search" button and try another keyword, another ISBN, or another method.');if(mybooklist.options.length==1)
resetSearch();}
document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}}
function replaceAdvertUsingAreaListValue(strListName)
{AreaSearchId=document.getElementById(strListName).options[document.getElementById(strListName).selectedIndex].value;replaceAdvert();}
function recordVisibleGenres()
{var strGenres="";for(i=1;i<parseInt(document.getElementById('numcheckboxes').value)+1;i++)
{if(document.getElementById('genrecheckbox'+i).checked)
{strGenres+=i+',';}}
return strGenres;}
function replaceAdvertUsingBookList()
{var bookAreasOption=document.getElementById('invisiblebook'+document.getElementById('book').options[document.getElementById('book').selectedIndex].value);var bookAreas=bookAreasOption.getAttribute('data-bookareas');var bookAreaSplit=bookAreas.split(',');AreaSearchId=bookAreaSplit[0];replaceAdvert();}
function replaceAdvertUsingBookId(bookId)
{var bookAreasOption=document.getElementById('invisiblebook'+bookId);var bookAreas=bookAreasOption.getAttribute('data-bookareas');var bookAreaSplit=bookAreas.split(',');AreaSearchId=bookAreaSplit[0];replaceAdvert();}
function replaceAdvertByLatLng(locationPoint)
{var boolValidBook;var splitBookAreas;var polygonEnvelope;var pathEnvelope=new Array();var splitEnvelope;var areaId=0;var selectLists=["continent","country","region","city"];for(i=0;i<selectLists.length;i++)
{var myList=document.getElementById('invisible_'+selectLists[i]);var count=myList.options.length;for(j=0;j<count;j++)
{if(myList.options[j].value!=0)
{splitEnvelope=document.getElementById('invisiblearea'+myList.options[j].value).getAttribute('data-envelope').split(',');for(k=0;k<splitEnvelope.length-1;k++)
{pathEnvelope[k]=new google.maps.LatLng(splitEnvelope[k].split(' ')[0],splitEnvelope[k].split(' ')[1]);}
polygonEnvelope=new google.maps.Polygon({paths:pathEnvelope});if(polygonEnvelope.getPath()!=null)
{if(polygonEnvelope.Contains(locationPoint))
{areaId=document.getElementById('invisiblearea'+myList.options[j].value).value;}}}}}
if(areaId>0)
{AreaSearchId=areaId;replaceAdvert();}}
function replaceAdvert()
{var cachebuster=Math.round(99999999999*Math.random());var ad_link="openx/www/delivery/ck.php?n=a2475164&cb=";var left_ad_link="openx/www/delivery/ck.php?n=acfa0e8b&zoneid=3&cb=";replaceIframeSource('a57737f6');replaceIframeSource('a77010c4');replaceIframeSource('af9a352c');updateDemoAdvert();}
function replaceIframeSource(id){obj=document.getElementById(id);obj.src=obj.src.replace(/AreaSearchId=[a-zA-Z0-9-_]+(&.*)?/,'AreaSearchId='+AreaSearchId);obj.src=obj.src.replace(/cb=[a-zA-Z0-9-_]+(&.*)?/,'cb='+Math.floor(Math.random()*99999999999)+'$1');}
function showBookCoverUsingBookList()
{var bookIsbnOption=document.getElementById('invisiblebook'+document.getElementById('book').options[document.getElementById('book').selectedIndex].value);var isbn=bookIsbnOption.getAttribute('data-isbn10');showBookCover(isbn);}
function showBookCoverUsingBookPageList()
{theBookPageList=document.getElementById('bookpagelist1');}
function showBookCover(isbn)
{var theBookIframe=document.getElementById('bookcoveriframe');var mapbookid=document.getElementById('mapbookid');var splitMapbookid=mapbookid.value.split(',');if((AreaSearchId!=globalCurrentAreaSearchId)||(theBookIframe.src.indexOf('&colour=FFFFFF')!=-1))
{var theBookIframe=document.getElementById('bookcoveriframe');var mapbookid=document.getElementById('mapbookid');var splitMapbookid=mapbookid.value.split(',');var colour="FFFFFF";for(var i=0;i<splitMapbookid.length;i++)
{if(splitMapbookid[i].length>0)
{if((i==0)&&(document.getElementById('invisiblebook'+splitMapbookid[i]).getAttribute('data-isbn10')==isbn))
{colour='FF0000';i=splitMapbookid.length;}
else if((i==1)&&(document.getElementById('invisiblebook'+splitMapbookid[i]).getAttribute('data-isbn10')==isbn))
{colour='0000FF';i=splitMapbookid.length;}
else if((i==2)&&(document.getElementById('invisiblebook'+splitMapbookid[i]).getAttribute('data-isbn10')==isbn))
{colour='00FF00';i=splitMapbookid.length;}
else if((i==3)&&(document.getElementById('invisiblebook'+splitMapbookid[i]).getAttribute('data-isbn10')==isbn))
{colour=globalColourYellow;i=splitMapbookid.length;}}}
theBookIframe.src="amlink.php?isbn="+isbn+"&colour="+colour;myMapCanvas=document.getElementById('atlas');$("#bookimage").dialog({width:180,position:[myMapCanvas.offsetLeft+myMapCanvas.offsetWidth-200,myMapCanvas.offsetTop+30-document.body.scrollTop],autoOpen:true,show:'slide',close:function(event,ui){}});$("#bookimage").dialog('open');globalCurrentAreaSearchId=AreaSearchId;}
updateDemoAdvert();}
function updateDemoAdvert()
{var areaName=document.getElementById('invisiblearea'+AreaSearchId).text;var demoAdvertText=document.getElementById('demoadverttext');demoAdvertText.innerHTML='Interested in advertising your <SPAN style="font-size:14">'+areaName+'</SPAN> based business ? <A HREF="mailto:info@guidebookplus.com?subject=Advertising">Contact us !</A>';}
function updateFluster()
{fluster.hideClusters();fluster.clearClusters();fluster=null;fluster=new Fluster2(map);for(var i=0;i<globalNumExistingPois;i++)
{fluster.addMarker(globalPoiMarker[i]);}
fluster.initialize();map.setZoom(map.getZoom());}
function closeAllInfowindows()
{for(i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i]!=null){globalInfoWindows[i].close();}}}
function defineClusterInfowindow(map,_cluster,_div,bookName,bookNum,bookName0,bookNum0)
{var strTally='<TABLE><TR><TD><BUTTON class="standardbutton" onclick="javascript:clusterInfowindow.close();">Click to Close this window</BUTTON></TD>';strTally+='<TD><BUTTON class="standardbutton" onclick="javascript:map.fitBounds('+_cluster.getMarkerBounds()+');/*map.fitBounds(bounds);*//*globalBoundsMemory.push('+_cluster.getMarkerBounds()+');*/saveView('+_cluster.getMarkerBounds()+');">Pan map to this cluster</BUTTON><BR/></TD></TR></TABLE>';strTally+=_cluster.getMarkerBounds().getSouthWest().toString()+'<BR/>'+_cluster.getMarkerBounds().toString()+'<BR/>';strTally+='This cluster contains the following numbers of ??all??<I>currently visible</I> Places of Interest in each book:</BR>';strTally+='<TABLE><TR><TD WIDTH="50%"><B>'+bookName0+'</B></TD><TD WIDTH="50%" ALIGN="CENTER"> '+bookNum0+'</TD></TR><TR><TD><B>'+bookName[1]+'</B></TD><TD> '+bookNum[1]+'</TD></TR><TR><TD><B>'+bookName[2]+'</B></TD><TD> '+bookNum[2]+'</TD></TR><TR><TD><B>'+bookName[3]+'</B></TD><TD> '+bookNum[3]+'</TD></TR></TABLE>';var clusterInfowindow=new google.maps.InfoWindow({content:strTally});_div.style.cursor='pointer';google.maps.event.addDomListener(_div,'click',function(){clusterInfowindow.open(map,_cluster.marker);});}
google.maps.Polygon.prototype.Contains=function(point){var j=0;var func_oddNodes=false;var x=point.lng();var y=point.lat();for(var i=0;i<this.getPath().getLength();i++){j++;if(j==this.getPath().getLength()){j=0;}
if(((this.getPath().getAt(i).lat()<y)&&(this.getPath().getAt(j).lat()>=y))||((this.getPath().getAt(j).lat()<y)&&(this.getPath().getAt(i).lat()>=y))){if(this.getPath().getAt(i).lng()+(y-this.getPath().getAt(i).lat())
/  (this.getPath().getAt(j).lat()-this.getPath().getAt(i).lat())
         *  (this.getPath().getAt(j).lng() - this.getPath().getAt(i).lng())<x ) {
           func_oddNodes = !func_oddNodes
         }
       }
     }

    
    return func_oddNodes;
  }


function lookupBookPageList() 
 {
 var myBookPageList1 = document.getElementById('bookpagelist1');
 if (myBookPageList1.item(myBookPageList1.selectedIndex).value != 0) //if value not 0 i.e.not'Index'title option
{var panZoomNumbers=myBookPageList1.item(myBookPageList1.selectedIndex).value.split('@');var zoomLevel=panZoomNumbers[1];var coords=panZoomNumbers[0].split(',');var lat=coords[0];var lon=coords[1];map.panTo(new google.maps.LatLng(lat,lon));map.setZoom(parseInt(zoomLevel));var bookPoiInfo=panZoomNumbers[2].split('-');var bookid=panZoomNumbers[2].split('-')[0];var bookAreas=document.getElementById('invisiblebook'+bookid).getAttribute('data-bookareas');var bookAreaSplit=bookAreas.split(',');AreaSearchId=bookAreaSplit[0];showBookCover(document.getElementById('invisiblebook'+bookid).getAttribute('data-isbn10'));}
replaceAdvert();}
function getGeocodeJSON()
{var j;var cnt=-1;var numSearchTerms=1;for(j=0;j<numSearchTerms;j++){downloadUrl("http://maps.google.com/maps/api/geocode/json?address="+"Bolzano"+"&sensor=false",function(data,responseCode){cnt++;var streetName="";var city="";var state="";var zipCode="";var point=null;jsonResults=JSON.parse(data);var i;for(i=0;i<jsonResults.Placemark.length;i++){xCoord=jsonResults.Placemark[i].Point.coordinates[0];yCoord=jsonResults.Placemark[i].Point.coordinates[1];if(jsonResults.Placemark[i].AddressDetails.Country.AdministrativeArea.Locality!=null){if(jsonResults.Placemark[i].AddressDetails.Country.AdministrativeArea.Locality.Thoroughfare!=null){streetName=jsonResults.Placemark[i].AddressDetails.Country.AdministrativeArea.Locality.Thoroughfare.ThoroughfareName;}
city=jsonResults.Placemark[i].AddressDetails.Country.AdministrativeArea.Locality.LocalityName;zipCode=jsonResults.Placemark[i].AddressDetails.Country.AdministrativeArea.Locality.PostalCode.PostalCodeNumber;}
state=jsonResults.Placemark[i].AddressDetails.Country.AdministrativeArea.AdministrativeAreaName;point=new GLatLng(yCoord,xCoord);map.addOverlay(createMarker(point,cnt,streetName,city,state,zipCode));}
map.setCenter(point,11);});}}
function codeAddress(){var NWlat;var NWlon;var NElat;var NElon;var SElat;var SElon;var SWlat;var SWlon;var strBounds;resetSearch();var address=document.getElementById("geocodesearchtextbox").value;if((address=='Type place name here')||(address==''))
{alert("Please type the name of the place you wish to find, in the text box next to the 'Find Place' button");geocoder=null;}
if(geocoder){geocoder.geocode({'address':address},function(results,status){if(status==google.maps.GeocoderStatus.OK){map.setCenter(results[0].geometry.location);filterBooksByLatLon(results[0].geometry.location);map.fitBounds(new google.maps.LatLngBounds(results[0].geometry.viewport.getSouthWest(),results[0].geometry.viewport.getNorthEast()));saveView(new google.maps.LatLngBounds(results[0].geometry.viewport.getSouthWest(),results[0].geometry.viewport.getNorthEast()));if(results[0].types[0]=='locality')
{if(globalCircle!=null)
{globalCircle.setMap(null);}
globalCircle=new google.maps.Circle({map:map,radius:3000,center:results[0].geometry.viewport.getCenter()});}
globalAddress=address;globalResult=results[0];performGeocodedPoiSearch(globalAddress,globalResult);self.location.hash='#atlas';setGGCookie(globalCookieName,'place:'+address,7);}
else{alert("There was a problem finding this place: "+status);}});}}
function gotoAddress(){var NWlat;var NWlon;var NElat;var NElon;var SElat;var SElon;var SWlat;var SWlon;var strBounds;var address=document.getElementById("geocodesearchtextbox").value;if((address=='Type place name here')||(address==''))
{alert("Please type the name of the place you wish to find, in the text box above the 'Find Place' button");geocoder=null;}
if(geocoder){geocoder.geocode({'address':address},function(results,status){if(status==google.maps.GeocoderStatus.OK){map.setCenter(results[0].geometry.location);map.fitBounds(new google.maps.LatLngBounds(results[0].geometry.viewport.getSouthWest(),results[0].geometry.viewport.getNorthEast()));saveView(new google.maps.LatLngBounds(results[0].geometry.viewport.getSouthWest(),results[0].geometry.viewport.getNorthEast()));if(results[0].types[0]=='locality')
{if(globalCircle!=null)
{globalCircle.setMap(null);}
globalCircle=new google.maps.Circle({map:map,radius:3000,center:results[0].geometry.viewport.getCenter()});}
globalAddress=address;globalResult=results[0];self.location.hash='#atlas';setGGCookie(globalCookieName,'place:'+address,7);}
else{alert("There was a problem finding this place: "+status);}});}}
function performGeocodedPoiSearch(address,result)
{var NWlat;var NWlon;var NElat;var NElon;var SElat;var SElon;var SWlat;var SWlon;var strBounds;if(result.geometry.bounds!=null)
{NWlat=result.geometry.bounds.getNorthEast().lat();NWlon=result.geometry.bounds.getSouthWest().lng();NElat=result.geometry.bounds.getNorthEast().lat();NElon=result.geometry.bounds.getNorthEast().lng();SElat=result.geometry.bounds.getSouthWest().lat();SElon=result.geometry.bounds.getNorthEast().lng();SWlat=result.geometry.bounds.getSouthWest().lat();SWlon=result.geometry.bounds.getSouthWest().lng();}
else
{NWlat=result.geometry.viewport.getNorthEast().lat();NWlon=result.geometry.viewport.getSouthWest().lng();NElat=result.geometry.viewport.getNorthEast().lat();NElon=result.geometry.viewport.getNorthEast().lng();SElat=result.geometry.viewport.getSouthWest().lat();SElon=result.geometry.viewport.getNorthEast().lng();SWlat=result.geometry.viewport.getSouthWest().lat();SWlon=result.geometry.viewport.getSouthWest().lng();}
strBounds='('+NWlat+' '+NWlon+','+NElat+' '+NElon+','+SElat+' '+SElon+','+SWlat+' '+SWlon+','+NWlat+' '+NWlon+')';document.getElementById('isbndialogtext').innerHTML="Performing search . . . Please wait . . . ";document.getElementById('isbniframe').width=600;document.getElementById('isbniframe').height=200;document.getElementById('isbniframe').src="PoisPerArea.php?bounds="+encodeURIComponent(strBounds)+"&name="+address;myMapCanvas=document.getElementById('atlas');var myDeltaHeight=-10;$("#isbndialoguetext").dialog({width:660,height:300+myDeltaHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,draggable:true,resizable:true,show:'slide',close:function(event,ui){}});$("#isbndialoguetext").dialog('open');}
function performRectangularPoiSearch(bounds,boundsName)
{var NWlat;var NWlon;var NElat;var NElon;var SElat;var SElon;var SWlat;var SWlon;var strBounds;NWlat=bounds.getNorthEast().lat();NWlon=bounds.getSouthWest().lng();NElat=bounds.getNorthEast().lat();NElon=bounds.getNorthEast().lng();SElat=bounds.getSouthWest().lat();SElon=bounds.getNorthEast().lng();SWlat=bounds.getSouthWest().lat();SWlon=bounds.getSouthWest().lng();strBounds='('+NWlat+' '+NWlon+','+NElat+' '+NElon+','+SElat+' '+SElon+','+SWlat+' '+SWlon+','+NWlat+' '+NWlon+')';document.getElementById('isbndialogtext').innerHTML="Performing search . . . Please wait . . . ";document.getElementById('isbniframe').width=600;document.getElementById('isbniframe').height=200;document.getElementById('isbniframe').src="PoisPerArea.php?bounds="+encodeURIComponent(strBounds)+"&name="+boundsName;myMapCanvas=document.getElementById('atlas');var myDeltaHeight=-10;$("#isbndialoguetext").dialog({width:660,height:300+myDeltaHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#isbndialoguetext").dialog('open');}
function performPolygonPoiSearch(polygonBounds,boundsName)
{var strBounds='(';for(var i=0;i<polygonBounds.length;i++)
{strBounds+=polygonBounds[i].getPosition().lat()+' '+polygonBounds[i].getPosition().lng()+',';}
strBounds+=polygonBounds[0].getPosition().lat()+' '+polygonBounds[0].getPosition().lng()+')';document.getElementById('isbndialogtext').innerHTML="Performing search . . . Please wait . . . <BUTTON class='standardbutton' onclick='$("+String.fromCharCode(34)+"#isbndialoguetext"+String.fromCharCode(34)+").dialog("+String.fromCharCode(34)+"close"+String.fromCharCode(34)+");' style='float:right;'>Close</BUTTON>";document.getElementById('isbniframe').width=600;document.getElementById('isbniframe').height=200;document.getElementById('isbniframe').src="PoisPerArea.php?bounds="+encodeURIComponent(strBounds)+"&name="+boundsName;myMapCanvas=document.getElementById('atlas');var myDeltaHeight=-10;$("#isbndialoguetext").dialog({width:660,height:300+myDeltaHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#isbndialoguetext").dialog('open');}
function filterBooksByLatLon(locationPoint)
{var mybooklist=document.getElementById('book');var count=mybooklist.options.length;var boolValidBook;var splitBookAreas;var polygonEnvelope;var pathEnvelope;var splitEnvelope;for(var i=count-1;i>=0;i--)
{boolValidBook=false;splitBookAreas=document.getElementById('invisiblebook'+mybooklist.options[i].value).getAttribute('data-bookareas').split(',');for(var j=0;j<splitBookAreas.length;j++)
{polygonEnvelope=null;pathEnvelope=new Array();polygonEnvelope=new google.maps.Polygon();splitEnvelope=document.getElementById('invisiblearea'+splitBookAreas[j]).getAttribute('data-envelope').split(',');for(k=0;k<splitEnvelope.length-1;k++)
{pathEnvelope[k]=new google.maps.LatLng(splitEnvelope[k].split(' ')[0],splitEnvelope[k].split(' ')[1]);}
polygonEnvelope=new google.maps.Polygon({paths:pathEnvelope});if(polygonEnvelope.getPath()!=null)
{if(polygonEnvelope.Contains(locationPoint))
{boolValidBook=true;}}
if('invisiblebook'+mybooklist.options[i].value=='invisiblebook0')
{boolValidBook=true;}}
if(boolValidBook==false)
mybooklist.removeChild(mybooklist.options[i]);}
document.getElementById('bookcountpara').textContent=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';document.getElementById('bookcountpara').innerHTML=document.getElementById('book').options.length-1+' book'+((document.getElementById('book').options.length-1>1)?'s':'')+' in list';}
function setCookie(c_name,value,expiredays)
{var exdate=new Date();exdate.setDate(exdate.getDate()+expiredays);document.cookie=c_name+"="+escape(value)+
((expiredays==null)?"":";expires="+exdate.toUTCString());}
function getCookie(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;return unescape(document.cookie.substring(c_start,c_end));}}
return"";}
function setGGCookie(c_name,value,expiredays)
{var strData=getGGCookie(c_name);var splitData=strData.split('&');var boolDataIncluded=false;for(var i=0;i<splitData.length;i++)
{if((splitData[i].split(':')[0]=='book')&&(value.split(':')[0]=='book')&&(value.split(':')[1].toLowerCase()==splitData[i].split(':')[1].toLowerCase()))
boolDataIncluded=true;else if((splitData[i].split(':')[0]=='place')&&(value.split(':')[0]=='place')&&(value.split(':')[1]==splitData[i].split(':')[1]))
boolDataIncluded=true;else if((splitData[i].split(':')[0]=='route')&&(value.split(':')[0]=='route')&&(value.split(':')[1].toLowerCase()==splitData[i].split(':')[1].toLowerCase()))
boolDataIncluded=true;}
if(!boolDataIncluded)
{setCookie(c_name,'',-1);setCookie(c_name,value+'&'+strData,expiredays);}}
function getGGCookie(c_name)
{if(document.cookie.length>0)
{c_start=document.cookie.indexOf(c_name+"=");if(c_start!=-1)
{c_start=c_start+c_name.length+1;c_end=document.cookie.indexOf(";",c_start);if(c_end==-1)c_end=document.cookie.length;var books=new Array();var places=new Array();var strBooks,strPlaces;var cookieData=unescape(document.cookie.substring(c_start,c_end));var splitData=cookieData.split('&');strBooks="";strPlaces="";for(var i=0;i<splitData.length;i++)
{if(splitData[i].split(':')[0]=='book')
strBooks+=splitData[i].split(':')[1]+',';}
return cookieData;}}
return"";}
function checkCookie()
{username=getCookie('username');if(username!=null&&username!="")
{alert('Welcome again '+username+'!');}
else
{username=prompt('Please enter your name:',"");if(username!=null&&username!="")
{setCookie('username',username,365);}}}
function myBooksButtonClick()
{var bookids=new Array();var splitCookie=getGGCookie(globalCookieName).split('&');var theCookieList=document.getElementById('cookiebookselect');var theOption;var theNewOption;var theTitle;var titleLength;self.location.hash='#atlas';for(var i=theCookieList.options.length-1;i>=0;i--)
{theOption=theCookieList.options[i];theCookieList.removeChild(theOption);}
theNewOption=new Option('List of previously viewed books',0);theCookieList.appendChild(theNewOption);theCookieList.item(theCookieList.options.length-1).text='List of previously viewed books';theCookieList.item(theCookieList.options.length-1).value=0;for(var i=0;i<splitCookie.length;i++)
{if(splitCookie[i].split(':')[0]=='book')
{theOption=document.getElementById("invisiblebook"+splitCookie[i].split(':')[1]);theTitle=theOption.text;titleLength=theTitle.indexOf(",(");theNewOption=new Option(theTitle,splitCookie[i].split(':')[1]);theCookieList.appendChild(theNewOption);theCookieList.item(theCookieList.options.length-1).text=theTitle;theCookieList.item(theCookieList.options.length-1).value=splitCookie[i].split(':')[1];}}
document.getElementById('mybooksdialoguetext').innerHTML="<IMG SRC='images/GGlogo6.png' HEIGHT=100 WIDTH=100 STYLE='float:left;margin:5px;'><BUTTON class='standardbutton' onclick='$("+String.fromCharCode(34)+"#mybooksdialogue"+String.fromCharCode(34)+").dialog("+String.fromCharCode(34)+"close"+String.fromCharCode(34)+");' style='float:right;'>Close</BUTTON>List of books whose pages you\'ve mapped previously: click to load again.";myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?600:400;$("#mybooksdialogue").dialog({width:850,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-400,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,draggable:true,resizable:true,show:'slide',close:function(event,ui){}});$("#mybooksdialogue").dialog('open');}
function cookieBookSelectChange()
{var cookiebookselect=document.getElementById('cookiebookselect');var bookid=cookiebookselect.options[cookiebookselect.selectedIndex].value;if(bookid>0)
{document.getElementById('mapbookid').value=document.getElementById('mapbookid').value+bookid+',';globalMapCentre=map.getCenter();globalMapZoom=map.getZoom();initialise('view-0/'+bookid);panZoomToArea(document.getElementById("invisiblebook"+bookid).getAttribute("data-envelope"),map);AreaSearchId=document.getElementById('invisiblebook'+bookid).getAttribute('data-bookareas').split(',')[0];replaceAdvert();}}
function myPlacesButtonClick()
{var bookids=new Array();var splitCookie=getGGCookie(globalCookieName).split('&');var theCookieList=document.getElementById('cookieplaceselect');var theOption;var theNewOption;var theTitle;var titleLength;self.location.hash='#atlas';for(var i=theCookieList.options.length-1;i>=0;i--)
{theOption=theCookieList.options[i];theCookieList.removeChild(theOption);}
theNewOption=new Option('List of previously searched-in places',0);theCookieList.appendChild(theNewOption);theCookieList.item(theCookieList.options.length-1).text='List of previously searched-in places';theCookieList.item(theCookieList.options.length-1).value=0;for(var i=0;i<splitCookie.length;i++)
{if(splitCookie[i].split(':')[0]=='place')
{theNewOption=new Option(splitCookie[i].split(':')[1].split('|')[0],splitCookie[i].split(':')[1]);theCookieList.appendChild(theNewOption);theCookieList.item(theCookieList.options.length-1).text=splitCookie[i].split(':')[1].split('|')[0];theCookieList.item(theCookieList.options.length-1).value=splitCookie[i].split(':')[1];}}
document.getElementById('myplacesdialoguetext').innerHTML="<IMG SRC='images/GGlogo6.png' HEIGHT=100 WIDTH=100 STYLE='float:left;margin:5px;'><BUTTON class='standardbutton' onclick='$("+String.fromCharCode(34)+"#myplacesdialogue"+String.fromCharCode(34)+").dialog("+String.fromCharCode(34)+"close"+String.fromCharCode(34)+");' style='float:right;'>Close</BUTTON>List of places whose pages you\'ve mapped previously: click to load again.";myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?600:400;$("#myplacesdialogue").dialog({width:660,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#myplacesdialogue").dialog('open');}
function cookiePlaceSelectChange()
{var cookieplaceselect=document.getElementById('cookieplaceselect');var address=cookieplaceselect.options[cookieplaceselect.selectedIndex].value;if(address!=0)
{var splitMyPlace=address.split('|');if(splitMyPlace.length>1)
{map.setCenter(new google.maps.LatLng(splitMyPlace[1],splitMyPlace[2]));map.setZoom(parseInt(splitMyPlace[3]));}
else
{document.getElementById("geocodesearchtextbox").value=address;gotoAddress();}
$("#myplacesdialogue").dialog('close');}}
function addMyPlaceButtonClick()
{var name=prompt("Enter the new myPlace name here.",('myPlace'+Math.round((Math.random()*10000))));if(name!=null)
{name=name.replace(/|/g,'');setGGCookie(globalCookieName,'place:'+name+'|'+map.getCenter().lat()+'|'+map.getCenter().lng()+'|'+map.getZoom(),7);}
alert('New myPlace added.');}
String.prototype.capitalize=function(){return this.replace(/(^|\s)([a-z])/g,function(m,p1,p2){return p1+p2.toUpperCase();});};function capWords(strIn){return strIn.capitalize();}
function poiSearchButtonClick()
{if(userRectangle!=null)
{clickMarkerArray[0]=new google.maps.Marker({position:new google.maps.LatLng(userRectangle.getBounds().getSouthWest().lat(),userRectangle.getBounds().getSouthWest().lng()),visible:false});clickMarkerArray[1]=new google.maps.Marker({position:new google.maps.LatLng(userRectangle.getBounds().getNorthEast().lat(),userRectangle.getBounds().getSouthWest().lng()),visible:false});clickMarkerArray[2]=new google.maps.Marker({position:new google.maps.LatLng(userRectangle.getBounds().getNorthEast().lat(),userRectangle.getBounds().getNorthEast().lng()),visible:false});clickMarkerArray[3]=new google.maps.Marker({position:new google.maps.LatLng(userRectangle.getBounds().getSouthWest().lat(),userRectangle.getBounds().getNorthEast().lng()),visible:false});performPolygonPoiSearch(clickMarkerArray,'the area you highlighted')}
else
performRectangularPoiSearch(map.getBounds(),'the current map view')}
function rectangleRedraw(){var SW=rectangleMarker1.getPosition();var NE=rectangleMarker2.getPosition();if(SW.lng()>NE.lng())
{SW=rectangleMarker2.getPosition();NE=rectangleMarker1.getPosition();}
var latLngBounds=new google.maps.LatLngBounds(SW,NE);userRectangle.setBounds(latLngBounds);}
userRectangle=null;function polygonButtonClick()
{var polygonButton=document.getElementById('polygonbutton');globalBoolPolygon=!globalBoolPolygon;if(globalBoolPolygon)
{polygonButton.style.backgroundColor='red';clearPoly();rectangleNE=new google.maps.LatLng(map.getBounds().getCenter().lat()+(map.getBounds().getNorthEast().lat()-map.getBounds().getCenter().lat())/2,map.getBounds().getCenter().lng()+(map.getBounds().getNorthEast().lng()-map.getBounds().getCenter().lng())/2);rectangleSW=new google.maps.LatLng(map.getBounds().getCenter().lat()-(map.getBounds().getCenter().lat()-map.getBounds().getSouthWest().lat())/2,map.getBounds().getCenter().lng()-(map.getBounds().getCenter().lng()-map.getBounds().getSouthWest().lng())/2);if(rectangleSW.lng()>90&&rectangleNE.lng()<0)
{rectangleNE=new google.maps.LatLng(rectangleNE.lat(),179);}
else if(rectangleNE.lng()>90&&rectangleSW.lng()<0)
{var SWLat=rectangleSW.lat();rectangleSW=rectangleNE;rectangleNE=new google.maps.LatLng(SWLat,179);}
else if(rectangleSW.lng()>90&&map.getBounds().getNorthEast().lng()<0)
{rectangleNE=new google.maps.LatLng(rectangleNE.lat(),179);}
userRectangle=new google.maps.Rectangle({map:map,zIndex:100});var icon;((navigator.appName!='Microsoft Internet Explorer')?icon=icon=new google.maps.MarkerImage('images/crosshairs1.png',null,null,new google.maps.Point(60,-60)):icon=new google.maps.MarkerImage('images/crosshairs1.png',null,null,new google.maps.Point(15,15)));rectangleMarker1=new google.maps.Marker({map:map,position:rectangleSW,icon:icon,draggable:true,title:'Drag to alter search or zoom area.'});((navigator.appName!='Microsoft Internet Explorer')?icon=icon=new google.maps.MarkerImage('images/crosshairs1.png',null,null,new google.maps.Point(-45,45)):icon=new google.maps.MarkerImage('images/crosshairs1.png',null,null,new google.maps.Point(15,15)));rectangleMarker2=new google.maps.Marker({map:map,position:rectangleNE,icon:icon,draggable:true,zIndex:500,title:'Drag to alter search or zoom area.'});rectangleMarker1DragListener=google.maps.event.addListener(rectangleMarker1,'drag',rectangleRedraw);rectangleMarker1DragListener=google.maps.event.addListener(rectangleMarker2,'drag',rectangleRedraw);rectangleRedraw();}
else
{polygonButton.style.backgroundColor=globalButtonColour;userRectangle.setMap(null);rectangleMarker1.setMap(null);rectangleMarker2.setMap(null);userRectangle=null;}}
function clearPoly(){for(var i=0;i<clickMarkerArray.length;i++)
{clickMarkerArray[i].setMap(null);}
if(polyShape)
{polyShape.setMap(null);}
polyPoints.length=0;clickMarkerArray.length=0;}
function showBookLinesButtonClick()
{bookLocationsPath=new Array();var currentBookColour;var poppedPoint;var theShowBookLinesButton=document.getElementById('showbooklinesbutton');if(globalBoolShowLineBooksVisible==true)
{if(globalPlinePois.length>0)
{for(i=0;i<globalPlinePois.length;i++)
{globalPlinePois[i].setMap(null);}
theShowBookLinesButton.style.backgroundColor=globalButtonColour;globalBoolShowLineBooksVisible=false;for(i=0;i<globalArrowMarkers.length;i++)
{globalArrowMarkers[i].setMap(null);}}}
else
{globalPlinePois=new Array();globalArrowMarkers=new Array();if(document.getElementById('mapbookid').value!='')
{currentBookColour=globalLabel[0].get('colour');numberBooksIeSegments=0;for(i=0;i<globalLabel.length;i++)
{bookLocationsPath.push(new google.maps.LatLng(globalLabel[i].getLat(),globalLabel[i].getLng()));if(currentBookColour!=globalLabel[i].get('colour')||i==globalLabel.length-1)
{if(i!=globalLabel.length-1)
{poppedPoint=bookLocationsPath.pop();}
globalPlinePois[numberBooksIeSegments]=new google.maps.Polyline({path:bookLocationsPath,strokeColor:currentBookColour,strokeWeight:3,map:map});globalBoolShowLineBooksVisible=true;theShowBookLinesButton.style.backgroundColor='#FF0000';numberBooksIeSegments++;bookLocationsPath=new Array();if(i!=globalLabel.length-1)
{bookLocationsPath.push(poppedPoint);currentBookColour=globalLabel[i].get('colour');}}}}
else
{alert('There is no book being mapped. Please load a book to use this button to draw a line between its page markers.');}}}
function createMarkerArrow(point,dir){var image="http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png";var marker=new google.maps.Marker({position:point,icon:image,map:map});globalArrowMarkers.push(marker);}
var degreesPerRadian=180.0/Math.PI;function bearing(from,to){var lat1=from.lat()/Math.PI;var lon1=from.lng()/Math.PI;var lat2=to.lat()/Math.PI;var lon2=to.lng()/Math.PI;var angle=-Math.atan2(Math.sin(lon1-lon2)*Math.cos(lat2),Math.cos(lat1)*Math.sin(lat2)-Math.sin(lat1)*Math.cos(lat2)*Math.cos(lon1-lon2));if(angle<0.0)
angle+=Math.PI*2.0;angle=angle*degreesPerRadian;angle=angle.toFixed(1);return angle;}
function arrowHead(points){var p1=points[points.length-1];var p2=points[points.length-2];var dir=bearing(p2,p1);var dir=Math.round(dir/3)*3;while(dir>=120){dir-=120;}
var arrowIcon=new google.maps.MarkerImage({url:"http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png"});createMarkerArrow(p1,dir);}
function midArrows(points){for(var i=1;i<points.length-1;i++){var p1=points[i-1];var p2=points[i+1];var dir=bearing(p1,p2);var dir=Math.round(dir/3)*3;while(dir>=120){dir-=120;}
var arrowIcon=new google.maps.MarkerImage({url:"http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png"});createMarkerArrow(points[i],dir);}}
function midLineArrows(points){for(var i=0;i<points.length-1;i++){var p1=points[i];var p2=points[i+1];var p3=new google.maps.LatLng((p1.lat()+p2.lat())/2,(p1.lng()+p2.lng())/2)
var dir=bearing(p1,p2);var dir=Math.round(dir/3)*3;while(dir>=120){dir-=120;}
var arrowIcon=new google.maps.MarkerImage({url:"http://www.google.com/intl/en_ALL/mapfiles/dir_"+dir+".png"});var arrowIcon=new google.maps.MarkerImage({url:"http://www.google.com/intl/en_ALL/mapfiles/dir_105.png"});createMarkerArrow(p3,dir);}}
function nextPoiButtonClick()
{if(document.getElementById('mapbookid').value!='')
{var myIndex=document.getElementById('bookpagelist1');myIndex.selectedIndex++;if(myIndex.selectedIndex>-1)
{if(myIndex.item(myIndex.selectedIndex).value!=0)
{var panZoomNumbers=myIndex.item(myIndex.selectedIndex).value.split('@');var zoomLevel=panZoomNumbers[1];var coords=panZoomNumbers[0].split(',');var lat=coords[0];var lon=coords[1];map.panTo(new google.maps.LatLng(lat,lon));if(myIndex.selectedIndex==1)
{map.setZoom(parseInt(zoomLevel));}
fluster.showClusters();var bookPoiInfo=panZoomNumbers[2].split('-');var bookid=panZoomNumbers[2].split('-')[0];var bookAreas=document.getElementById('invisiblebook'+bookid).getAttribute('data-bookareas');var bookAreaSplit=bookAreas.split(',');AreaSearchId=bookAreaSplit[0];replaceAdvert();showBookCover(document.getElementById('invisiblebook'+bookid).getAttribute('data-isbn10'));}}}
else
alert('There is no book being mapped. Please load a book to use this button to move between its page markers.');}
function clusterButtonClick()
{if(document.getElementById('mapbookid').value!='')
{var myClusterButton=document.getElementById('clusterbutton');if(globalBoolClusterVisible==true)
{myClusterButton.style.backgroundColor='#ff0000'
globalBoolClusterVisible=false;}
else
{myClusterButton.style.backgroundColor=globalButtonColour;globalBoolClusterVisible=true;}}
else
alert('There is no book being mapped. Please load a book to use this button to turn on, or off, clustering of its page markers.');}
function previousViewButtonClick()
{if(globalBoundsMemory.length>0)
map.fitBounds(globalBoundsMemory.pop());}
function nextViewButtonClick()
{}
function saveView(bounds)
{globalBoundsMemory.push(bounds);globalBoundsIndex=globalBoundsMemory.length-1;}
function drawPoly(){if(polyShape)polyShape.setMap(null);polyPoints.length=0;for(i=0;i<clickMarkerArray.length;i++){polyPoints.push(clickMarkerArray[i].getPosition());}
polyShape=new google.maps.Polygon({paths:polyPoints,strokeColor:polyLineColor,strokeWeight:3,strokeOpacity:0.8,fillColor:polyFillColor,fillOpacity:0.3});var unit=" km&sup2;";if(clickMarkerArray.length<=2){}
else if(clickMarkerArray.length>2){}
polyShape.setMap(map);}
function leftClick(point){if(globalBoolPolygon){var image='images/square.png';clickMarkerArray[clickMarkerArray.length]=polygonMarker=new google.maps.Marker({position:point,icon:image,draggable:true});polygonMarker.setMap(map);google.maps.event.addListener(polygonMarker,'drag',function(){drawPoly();});google.maps.event.addListener(polygonMarker,'drag',function(){for(var n=0;n<clickMarkerArray.length;n++){if(clickMarkerArray[n]==polygonMarker){clickMarkerArray[n].setMap(null);break;}}
clickMarkerArray.splice(n,1);drawPoly();});drawPoly();}}
function checkListRadioButtons()
{var radbuttons=document.getElementsByName('stepradio');var radvalue;var boolButtonChecked=false;for(var i=0;i<radbuttons.length;i++)
{if(radbuttons[i].checked)
{boolButtonChecked=true;switch(radbuttons[i].value)
{case'continent':continentButtonClick();break;case'countryregion':countryRegionButtonClick();break;case'countrycity':countryCityButtonClick();break;case'regionpublisher':regionAndCityButtonClick();break;case'citypublisher':regionAndCityButtonClick();break;case'publisheryear':publisherYearButtonClick();break;case'publisheredition':publisherEditionButtonClick();break;case'year':yearAndEditionButtonClick();break;case'edition':yearAndEditionButtonClick();break;case'exactareaupper':thisIsTheAreaButtonClick();break;case'exactarealower':thisIsTheAreaButtonClick();break;case'isbntitle':searchTitleOrISBNButtonClick();break;default:alert("Please select one of the options, then click the 'Next' button.");}}}
if(boolButtonChecked==false)
{alert("Please select one of the items in the list above");}}
function kmlButtonClick()
{var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');var bookid=0;if(strMapbookid!='')
{if(confirm("Click 'OK' to continue and download a KML file describing locations of page numbers in this book. Then choose 'Save As' from the message box that appears after this one. The KML file can be opened in Google Earth."))
{var radbuttons=document.getElementsByName('bookradio');var radvalue;for(var i=0;i<radbuttons.length;i++)
{if(radbuttons[i].checked)radvalue=radbuttons[i].value;}
var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');var bookid=0;if(radvalue=='red'){bookid=splitBookId[0];}
else if(radvalue=='blue'){bookid=splitBookId[1];}
else if(radvalue=='green'){bookid=splitBookId[2];}
else{bookid=splitBookId[3];};var url="PoIRelKMLDownload.php?bookid="+bookid;self.location.href=url;}}
else
alert('There is no book being mapped. To use this button, load one by using the controls above, or the book icons on the map.');}
function routeButtonClick()
{if(globalboolOptimise!=null)
calculateRoute(globalboolOptimise,globalboolCircular,globalstartPlace,globalfinishPlace);else
calculateRoute(false,false,0,0);}
function toggleWaypoint(label,latlng,poibookid,page,bookid,description,poiid)
{var maxNumWaypoints=10;for(var i=0;i<globalWaypointsPoibookidArray.length;i++)
{if(globalWaypointsPoibookidArray[i]==poibookid)
{globalWaypointsArray.splice(i,1);globalWaypointsPoibookidArray.splice(i,1);globalWaypointsDescriptionArray.splice(i,1);globalWaypointsPoiidArray.splice(i,1);globalWaypointsPageArray.splice(i,1);globalWaypointsBookidArray.splice(i,1);label.setBlack();return;}}
if(globalWaypointsPoibookidArray.length>=maxNumWaypoints)
{if(confirm('You can visit a maximum of locations in your route plan. Do you want to replace an earlier location you selected with this one instead ?')==true)
{for(i=0;i<globalLabel.length;i++)
{if(globalLabel[i].getPoibookid()==globalWaypointsPoibookidArray[0])
{globalLabel[i].setBlack();}}
globalWaypointsArray.shift();globalWaypointsPoibookidArray.shift();globalWaypointsDescriptionArray.shift();globalWaypointsPoiidArray.shift();globalWaypointsPageArray.shift();globalWaypointsBookidArray.shift();}
else
{return;}}
globalWaypointsArray.push(latlng);globalWaypointsPoibookidArray.push(poibookid);globalWaypointsDescriptionArray.push(description);globalWaypointsPoiidArray.push(poiid);globalWaypointsPageArray.push(page);globalWaypointsBookidArray.push(bookid);label.setWhite();}
function calculateRoute(boolOptimise,boolCircular,startPlace,finishPlace){var totalLength=0;var totalDuration=0;globalboolOptimise=boolOptimise;globalboolCircular=boolCircular;globalstartPlace=startPlace;globalfinishPlace=finishPlace;if(globalWaypointsArray.length>1)
{var start=globalWaypointsArray[0];var end=globalWaypointsArray[globalWaypointsArray.length-1];var waypointsArray=[];if(startPlace!=0)
{var splitStartPlace=startPlace.split('|');if(splitStartPlace.length>1)
{start=new google.maps.LatLng(splitStartPlace[1],splitStartPlace[2]);}
else
{if(geocoder){geocoder.geocode({'address':startPlace},function(results,status){if(status==google.maps.GeocoderStatus.OK){start=results[0].geometry.location
globalGeocodingDone=true;}else{alert("Geocoding "+startPlace+" failed due to: "+status);}});}}}
for(var i=(startPlace!=0)?0:1;i<globalWaypointsArray.length-1;i++)
{waypointsArray.push({location:globalWaypointsArray[i],stopover:true});}
if(boolCircular==true||finishPlace!=0)
{waypointsArray.push({location:globalWaypointsArray[globalWaypointsArray.length-1],stopover:true});if(finishPlace!=0)
{var splitFinishPlace=finishPlace.split('|');if(splitFinishPlace.length>1)
{end=new google.maps.LatLng(splitFinishPlace[1],splitFinishPlace[2]);if(boolCircular==true)
{waypointsArray.push();}}
else
{if(geocoder){geocoder.geocode({'address':finishPlace},function(results,status){if(status==google.maps.GeocoderStatus.OK){end=results[0].geometry.location;if(boolCircular==true)
{waypointsArray.push(new google.maps.LatLng(splitStartPlace[1],splitStartPlace[2]));}}else{alert("Geocoding "+startPlace+" failed due to: "+status);}});}}
if(boolCircular==true)
{end=globalWaypointsArray[0];}
else
{}}
else
{end=globalWaypointsArray[0];}}
if((startPlace!=0&&start==globalWaypointsArray[0])||(finishPlace!=0&&end==globalWaypointsArray[globalWaypointsArray.length-1]))
{setTimeout(function(){calculateRoute(boolOptimise,boolCircular,startPlace,finishPlace);},1500);}
else
{if(boolCircular==true&&startPlace!=0)
{end=start;}
var request={origin:start,destination:end,waypoints:waypointsArray,optimizeWaypoints:boolOptimise,travelMode:google.maps.DirectionsTravelMode.DRIVING};globalGeocodingDone=false;directionsService.route(request,function(result,status){if(status==google.maps.DirectionsStatus.OK){var routePlanningDialogue=document.getElementById('routedialoguetext');var strRoutePlanningDialogue='';globalResult=result;strRoutePlanningDialogue='<IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=100 HEIGHT=100><TABLE><TR><TD><BUTTON TITLE="Show these directions on a new page, in your browser, in a new window." class="standardbutton routebutton" onclick="javascript:showDirectionsOnNewPageButtonClick();">Show on New Page</BUTTON></TD><TD><BUTTON TITLE="NB: Any drag-and-drop route alterations not fixed via a waypoint (e.g. a page-location,accommodation,wikipedia or myPlace) are not saved." class="standardbutton routebutton" onclick="javascript:'+((boolOptimise==true)?'setOptimisedRoute();':'')+'promptToSaveCookie();">Save in myRoutes</BUTTON></TD></TR><TR><TD><BUTTON TITLE="Show the shortest route between these waypoints, in whichever order is fastest." class="standardbutton routebutton" onclick="javascript:calculateRoute(true,'+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">Show Shortest Route</BUTTON></TD><TD><BUTTON TITLE="Show route between these waypoints, in the order in which the waypoints have been selected." class="standardbutton routebutton" onclick="javascript:calculateRoute(false,'+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">Show Route in Order</BUTTON></TD></TR><TR><TD><BUTTON TITLE="Clear this route, to free the map or to plan a new route." class="standardbutton routebutton" onclick="javascript:clearCurrentRoute();">Clear Current Route</BUTTON></TD><TD>'+((boolOptimise==true)?'<BUTTON TITLE="The selected waypoints have been re-ordered into the shortest route - if you want to alter this order, you must first click this button." class="standardbutton routebutton" onclick="javascript:setOptimisedRoute();calculateRoute(false,'+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">Edit shortened route</BUTTON>':'&nbsp;')+'</TD></TR><TR><TD><INPUT TITLE="Tick this box for a circular route, i.e. a return trip to the first waypoint." TYPE="CHECKBOX" onclick="this.blur();" onchange="javascript:if (this.checked==true){calculateRoute('+boolOptimise+',true,document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);boolCircular=true;} else {calculateRoute('+boolOptimise+',false,document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);boolCircular=false;}"'+((boolCircular==true)?' CHECKED="TRUE"':'')+'>Circular Route</TD><TD>'+((boolOptimise==false)?'<BUTTON TITLE="Produce this route in a GPX text stream, for using it in other applications, or GPS devices (NB: requires user to open a text editor)." class="standardbutton routebutton" onclick="javascript:gpxButtonClick();">GPX</BUTTON>':'&nbsp;')+'</TD></TR></TABLE>';if(boolOptimise==true)
{strRoutePlanningDialogue+='<P ALIGN="CENTER">Showing Shortest Route.</P>';}
else
{strRoutePlanningDialogue+='<P ALIGN="CENTER">Showing Route In Order.</P>';}
routePlanningDialogue.innerHTML=strRoutePlanningDialogue+'<TABLE><TR><TD>Start At:</TD><TD> <SELECT ID='+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+' onchange="javascript:calculateRoute('+boolOptimise+','+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);"></SELECT></TD></TR><TR><TD>Finish At:</TD><TD><SELECT ID='+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+' onchange="javascript:calculateRoute('+boolOptimise+','+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);"></SELECT></TD></TR></TABLE>';var theStartList=document.getElementById('startselect');var theFinishList=document.getElementById('finishselect');var splitCookie=getGGCookie(globalCookieName).split('&');var theOption;var theNewOption;var theTitle;theNewOption=new Option('To start from myPlace, select it below.',0);theStartList.appendChild(theNewOption);theStartList.item(theStartList.options.length-1).text='To start from myPlace instead of a page, select it here.';theStartList.item(theStartList.options.length-1).value=0;theNewOption=new Option('To finish at myPlace, select it below.',0);theFinishList.appendChild(theNewOption);theFinishList.item(theFinishList.options.length-1).text='To finish at myPlace instead of a page, select it here.';theFinishList.item(theFinishList.options.length-1).value=0;for(var i=0;i<splitCookie.length;i++)
{if(splitCookie[i].split(':')[0]=='place')
{theNewOption=new Option(splitCookie[i].split(':')[1].split('|')[0],splitCookie[i].split(':')[1]);theStartList.appendChild(theNewOption);theStartList.item(theStartList.options.length-1).text=splitCookie[i].split(':')[1].split('|')[0];theStartList.item(theStartList.options.length-1).value=splitCookie[i].split(':')[1];theNewOption=new Option(splitCookie[i].split(':')[1].split('|')[0],splitCookie[i].split(':')[1]);theFinishList.appendChild(theNewOption);theFinishList.item(theFinishList.options.length-1).text=splitCookie[i].split(':')[1].split('|')[0];theFinishList.item(theFinishList.options.length-1).value=splitCookie[i].split(':')[1];}}
for(var i=0;i<theStartList.options.length;i++)
{if(theStartList.options[i].value==startPlace)
{theStartList.selectedIndex=i;}}
for(var i=0;i<theFinishList.options.length;i++)
{if(theFinishList.options[i].value==finishPlace)
{theFinishList.selectedIndex=i;}}
var booksInRouteArray=new Array();var boolBookAlreadyListed=false;var strBooksList='';var booksInRouteArrayIds=new Array();var numBooks;for(i=0;i<globalWaypointsArray.length;i++)
{boolBookAlreadyListed=false;booksInRouteArrayIds[i]=0;for(j=0;j<booksInRouteArray.length;j++)
{booksInRouteArrayIds[i]=j;if(globalWaypointsBookidArray[i]==booksInRouteArray[j])
{boolBookAlreadyListed=true;j=booksInRouteArray.length;}}
if(boolBookAlreadyListed==false&&(globalWaypointsBookidArray[i]!=0))
{booksInRouteArrayIds[i]=booksInRouteArray.length;booksInRouteArray.push(globalWaypointsBookidArray[i]);numBooks++;}}
var strMapbookid=document.getElementById('mapbookid').value;var splitBookId=strMapbookid.split(',');var boolBookLoaded;for(i=0;i<booksInRouteArray.length;i++)
{theTitle=document.getElementById('invisiblebook'+booksInRouteArray[i]).text
titleLength=theTitle.indexOf("),(");strBooksList+='<P>'+((booksInRouteArray.length>1)?'Book '+(i+1)+': ':'')+'<B>'+theTitle.substr(0,titleLength)+'</B>'+theTitle.substr(titleLength,3)+'<I>'+theTitle.substr(titleLength+3,4)+'</I>'+theTitle.substr(titleLength+7).replace(/,/g,', ');boolBookLoaded=false;for(var j=0;j<splitBookId.length;j++)
{if(booksInRouteArray[i]==splitBookId[j])
{boolBookLoaded=true;}}
if(boolBookLoaded==false)
{strBooksList+='&nbsp;<BUTTON class="standardbutton" onclick="javascript:document.getElementById('+String.fromCharCode(39)+'mapbookid'+String.fromCharCode(39)+').value = document.getElementById('+String.fromCharCode(39)+'mapbookid'+String.fromCharCode(39)+').value+'+String.fromCharCode(39)+booksInRouteArray[i]+String.fromCharCode(39)+'+'+String.fromCharCode(39)+','+String.fromCharCode(39)+';globalMapCentre = map.getCenter();globalMapZoom = map.getZoom();initialise('+String.fromCharCode(39)+'view-'+document.getElementById('invisiblebook'+booksInRouteArray[i]).getAttribute('data-bookareas').split(',')[0]+'/'+document.getElementById('invisiblebook'+booksInRouteArray[i]).value+String.fromCharCode(39)+');this.style.visibility='+String.fromCharCode(39)+'hidden'+String.fromCharCode(39)+';">Load book</BUTTON>';}
strBooksList+='</P>';}
routePlanningDialogue.innerHTML+=strBooksList;if(startPlace!=0)
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(65)+' = '+startPlace.split('|')[0]+'</P>';}
else
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(65)+' = '+globalWaypointsDescriptionArray[0]+((globalWaypointsPageArray[0]!=0)?', page '+globalWaypointsPageArray[0]:'')+((booksInRouteArray.length>1&&(globalWaypointsPageArray[0]!=0))?', <I>book '+(booksInRouteArrayIds[0]+1):'')+'<I>&nbsp;<BUTTON class="standardbutton" TITLE="Click to remove this waypoint from your route." onclick="javascript:removeWaypointElement(0);calculateRoute('+boolOptimise+','+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">X</BUTTON></P>';}
strRoutePlanningOption='';var numWaypointsToTraverse;if(startPlace!=0&&finishPlace==0)
numWaypointsToTraverse=result.routes[0].waypoint_order.length-1;else if(startPlace==0&&finishPlace!=0)
numWaypointsToTraverse=result.routes[0].waypoint_order.length;else if(startPlace!=0&&finishPlace!=0)
numWaypointsToTraverse=result.routes[0].waypoint_order.length-1;else
numWaypointsToTraverse=result.routes[0].waypoint_order.length;var adjustableIndex;for(var i=(startPlace!=0)?0:1;i<=numWaypointsToTraverse;i++)
{if(boolOptimise==true)
{(startPlace!=0)?adjustableIndex=0:adjustableIndex=1;strRoutePlanningOption+='<P>'+String.fromCharCode(((startPlace!=0)?66:65)+i)+' = '+globalWaypointsDescriptionArray[result.routes[0].waypoint_order[i-1+(1-adjustableIndex)]+adjustableIndex]+((globalWaypointsPageArray[result.routes[0].waypoint_order[i-1+(1-adjustableIndex)]+adjustableIndex]!=0)?', page '+globalWaypointsPageArray[result.routes[0].waypoint_order[i-1+(1-adjustableIndex)]+adjustableIndex]:'')+((booksInRouteArray.length>1&&(globalWaypointsPageArray[result.routes[0].waypoint_order[i-1+(1-adjustableIndex)]+adjustableIndex]!=0))?', <I>book '+(booksInRouteArrayIds[result.routes[0].waypoint_order[i-1+(1-adjustableIndex)]+adjustableIndex]+1):'')+'</I>&nbsp;<BUTTON class="standardbutton" TITLE="Click to remove this waypoint from your route." onclick="javascript:removeWaypointElement('+(result.routes[0].waypoint_order[i-1+(1-adjustableIndex)]+adjustableIndex)+');calculateRoute('+boolOptimise+','+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">X</BUTTON></P>';}
else
{strRoutePlanningOption+='<P>'+String.fromCharCode(((startPlace!=0)?66:65)+i)+' = '+globalWaypointsDescriptionArray[i]+((globalWaypointsPageArray[i]!=0)?', page '+globalWaypointsPageArray[i]:'')+((booksInRouteArray.length>1&&(globalWaypointsPageArray[i]!=0))?', <I>book '+(booksInRouteArrayIds[i]+1):'')+'</I>&nbsp<BUTTON class="standardbutton" onclick="javascript:swapWaypointElements('+(i).toString()+','+(i-1).toString()+');calculateRoute(false,'+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);" title="Click to schedule sooner in journey.">^</BUTTON>&nbsp;<BUTTON class="standardbutton" TITLE="Click to remove this waypoint from your route." onclick="javascript:removeWaypointElement('+i+');calculateRoute('+boolOptimise+','+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">X</BUTTON></P>';if(i>2)
{}}}
routePlanningDialogue.innerHTML+=strRoutePlanningOption;if(boolCircular==true)
{if(startPlace!=0)
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(66+result.routes[0].waypoint_order.length)+' = Return to '+startPlace.split('|')[0]+'</P>';}
else if(finishPlace!=0)
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(66+result.routes[0].waypoint_order.length)+' = Return to '+finishPlace.split('|')[0]+'</P>';}
else
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(66+result.routes[0].waypoint_order.length)+' = Return to '+globalWaypointsDescriptionArray[0]+((globalWaypointsPageArray[0]!=0)?', page '+globalWaypointsPageArray[0]:'')+((booksInRouteArray.length>1&&(globalWaypointsPageArray[0]!=0))?', <I>book '+(booksInRouteArrayIds[0]+1):'')+'</I></P>';}}
else
{if(finishPlace!=0)
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(66+result.routes[0].waypoint_order.length)+' = '+finishPlace.split('|')[0]+'</P>';}
else
{routePlanningDialogue.innerHTML+='<P>'+String.fromCharCode(66+result.routes[0].waypoint_order.length)+' = '+globalWaypointsDescriptionArray[globalWaypointsDescriptionArray.length-1]+((globalWaypointsPageArray[globalWaypointsPageArray.length-1]!=0)?', page '+globalWaypointsPageArray[globalWaypointsPageArray.length-1]:'')+((booksInRouteArray.length>1&&(globalWaypointsPageArray[globalWaypointsPageArray.length-1]!=0))?', <I>book '+(booksInRouteArrayIds[i]+1):'')+((boolOptimise==false)?'</I>&nbsp;<BUTTON class="standardbutton" onclick="javascript:swapWaypointElements('+(globalWaypointsPageArray.length-1).toString()+','+(globalWaypointsPageArray.length-2).toString()+');calculateRoute(false,'+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);" title="Click to schedule sooner in journey.">^</BUTTON>':'')+'&nbsp;<BUTTON class="standardbutton" TITLE="Click to remove this waypoint from your route." onclick="javascript:removeWaypointElement('+(numWaypointsToTraverse+1)+');calculateRoute('+boolOptimise+','+boolCircular+',document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'startselect'+String.fromCharCode(39)+').selectedIndex].value,document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').options[document.getElementById('+String.fromCharCode(39)+'finishselect'+String.fromCharCode(39)+').selectedIndex].value);">X</BUTTON></P>';}}
for(var i=0;i<result.routes[0].legs.length;i++)
{totalLength+=result.routes[0].legs[i].distance.value;totalDuration+=result.routes[0].legs[i].duration.value;}
routePlanningDialogue.innerHTML+='<P ID="routedistancetimecalcs">Total distance = <B>'+Math.round(totalLength/1000)+' km</B>. Total duration = <B>'+Math.floor(totalDuration/3600)+' hours</B>, <B>'+Math.floor((totalDuration%3600)/60)+' minutes</B>.</P>';var myHeight=(navigator.appName=='Microsoft Internet Explorer')?1200:600;directionsDisplay.setDirections(result);myMapCanvas=document.getElementById('atlas');$("#routedialoguetext").dialog({width:680,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)-100-document.body.scrollTop],autoOpen:true,show:'slide',close:function(event,ui){}});$("#routedialoguetext").dialog('open');}
else
{alert('Failed to calculate a route for you. Please check that your route waypoints do not include any seriously inaccessible/off-road locations (such as in a sea or lake - in which case you can define a myPlace on the shore nearby to use in the route instead), and that there are not more 10 points in your route');}});}}
else
{alert('Please select 2 or more page numbers/locations to use route planning.');}}
google.maps.event.addListener(directionsDisplay,'directions_changed',function(){totalLength=0;totalDuration=0;if(directionsDisplay.directions!=null)
{if(directionsDisplay.directions.routes!=null)
{for(var i=0;i<globalResult.routes[0].legs.length;i++)
{totalLength+=directionsDisplay.directions.routes[0].legs[i].distance.value;totalDuration+=directionsDisplay.directions.routes[0].legs[i].duration.value;}}
if(document.getElementById("routedistancetimecalcs")!=null)
{document.getElementById("routedistancetimecalcs").innerHTML='Total distance = <B>'+Math.round(totalLength/1000)+' km</B>. Total duration = <B>'+Math.floor(totalDuration/3600)+' hours</B>, <B>'+Math.floor((totalDuration%3600)/60)+' minutes</B>.';}}});function swapWaypointElements(fromIndex,toIndex)
{var latLngGlobalWaypointsArrayToIndex=new google.maps.LatLng(globalWaypointsArray[toIndex].lat(),globalWaypointsArray[toIndex].lng());var latLngGlobalWaypointsArrayFromIndex=new google.maps.LatLng(globalWaypointsArray[fromIndex].lat(),globalWaypointsArray[fromIndex].lng());globalWaypointsArray.splice(fromIndex,1,latLngGlobalWaypointsArrayToIndex);globalWaypointsArray.splice(toIndex,1,latLngGlobalWaypointsArrayFromIndex);globalWaypointsPoibookidArray[toIndex]=globalWaypointsPoibookidArray.splice(fromIndex,1,globalWaypointsPoibookidArray[toIndex]);globalWaypointsDescriptionArray[toIndex]=new String(globalWaypointsDescriptionArray.splice(fromIndex,1,new String(globalWaypointsDescriptionArray[toIndex])));globalWaypointsPoiidArray[toIndex]=globalWaypointsPoiidArray.splice(fromIndex,1,globalWaypointsPoiidArray[toIndex]);globalWaypointsPageArray[toIndex]=globalWaypointsPageArray.splice(fromIndex,1,globalWaypointsPageArray[toIndex]);globalWaypointsBookidArray[toIndex]=globalWaypointsBookidArray.splice(fromIndex,1,globalWaypointsBookidArray[toIndex]);}
function removeWaypointElement(removeIndex)
{for(i=0;i<globalLabel.length;i++)
{if(globalLabel[i]!=null)
{if(globalLabel[i].getPoibookid()==globalWaypointsPoibookidArray[removeIndex])
{globalLabel[i].setBlack();}}}
for(i=0;i<globalAreaPoiLabel.length;i++)
{if(globalAreaPoiLabel[i]!=null)
{if(globalAreaPoiLabel[i].getPoibookid()==globalWaypointsPoibookidArray[removeIndex])
{globalAreaPoiLabel[i].setBlack();}}}
globalWaypointsArray.splice(removeIndex,1);globalWaypointsPoibookidArray.splice(removeIndex,1);globalWaypointsDescriptionArray.splice(removeIndex,1);globalWaypointsPoiidArray.splice(removeIndex,1);globalWaypointsPageArray.splice(removeIndex,1);globalWaypointsBookidArray.splice(removeIndex,1);}
function promptToSaveCookie()
{if(geocoder){geocoder.geocode({'latLng':globalWaypointsArray[0]},function(results,status){if(status==google.maps.GeocoderStatus.OK){if(results[1]){var name=prompt("Enter route name here.",results[1].formatted_address.replace(/[\(\)\.\&\:\;\$\-\s,]/g,"")+Math.round((Math.random()*1000)));if(name!=null)
saveRouteInCookie(name);}}else{var name=prompt("Enter route name here.",'random route name'.replace(/[\(\)\.\&\:\;\$\-\s,]/g,"")+Math.round((Math.random()*1000)));if(name!=null)
saveRouteInCookie(name);}});}}
function saveRouteInCookie(strRouteCookie)
{for(var i=0;i<globalWaypointsArray.length;i++)
{strRouteCookie+='$'+globalWaypointsArray[i].lat()+';';strRouteCookie+=globalWaypointsArray[i].lng()+';';strRouteCookie+=globalWaypointsPoibookidArray[i]+';';strRouteCookie+=globalWaypointsDescriptionArray[i].replace(/[\(\)\.\&\:\;\$\-\s,]/g,"")+';';strRouteCookie+=globalWaypointsPoiidArray[i]+';';strRouteCookie+=globalWaypointsPageArray[i]+';';strRouteCookie+=globalWaypointsBookidArray[i]+';';}
setGGCookie(globalCookieName,'route:'+strRouteCookie,7);}
function myRoutesButtonClick()
{var bookids=new Array();var splitCookie=getGGCookie(globalCookieName).split('&');var theCookieList=document.getElementById('cookierouteselect');var theOption;var theNewOption;var theTitle;var titleLength;self.location.hash='#atlas';for(var i=theCookieList.options.length-1;i>=0;i--)
{theOption=theCookieList.options[i];theCookieList.removeChild(theOption);}
theNewOption=new Option('List of previously saved routes',0);theCookieList.appendChild(theNewOption);theCookieList.item(theCookieList.options.length-1).text='List of previously saved routes';theCookieList.item(theCookieList.options.length-1).value=0;for(var i=0;i<splitCookie.length;i++)
{if(splitCookie[i].split(':')[0]=='route')
{theNewOption=new Option(splitCookie[i].split(':')[1].split('$')[0],splitCookie[i].split(':')[1]);theCookieList.appendChild(theNewOption);theCookieList.item(theCookieList.options.length-1).text=splitCookie[i].split(':')[1].split('$')[0];theCookieList.item(theCookieList.options.length-1).value=splitCookie[i].split(':')[1];}}
document.getElementById('myroutesdialoguetext').innerHTML="<IMG SRC='images/GGlogo6.png' HEIGHT=100 WIDTH=100 STYLE='float:left;margin:5px;'><BUTTON class='standardbutton' onclick='$("+String.fromCharCode(34)+"#myroutesdialogue"+String.fromCharCode(34)+").dialog("+String.fromCharCode(34)+"close"+String.fromCharCode(34)+");' style='float:right;'>Close</BUTTON>List of routes you\'ve saved previously: click to load again.";myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?600:400;$("#myroutesdialogue").dialog({width:660,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#myroutesdialogue").dialog('open');}
function cookieRouteSelectChange()
{for(var i=0;i<globalLabel.length;i++)
{globalLabel[i].setBlack();}
globalWaypointsArray=new Array();globalWaypointsPoibookidArray=new Array();globalWaypointsDescriptionArray=new Array();globalWaypointsPoiidArray=new Array();globalWaypointsPageArray=new Array();globalWaypointsBookidArray=new Array();var cookierouteselect=document.getElementById('cookierouteselect');var splitCookieString=cookierouteselect.options[cookierouteselect.selectedIndex].value.split('$');var splitWaypointString;for(i=1;i<splitCookieString.length;i++)
{splitWaypointString=splitCookieString[i].split(';')
globalWaypointsArray.push(new google.maps.LatLng(splitWaypointString[0],splitWaypointString[1]));globalWaypointsPoibookidArray.push(splitWaypointString[2]);globalWaypointsDescriptionArray.push(splitWaypointString[3]);globalWaypointsPoiidArray.push(splitWaypointString[4]);globalWaypointsPageArray.push(splitWaypointString[5]);globalWaypointsBookidArray.push(splitWaypointString[6]);}
calculateRoute(false,false,0,0);$("#myroutesdialogue").dialog('close');}
function clearCurrentRoute()
{directionsDisplay.setMap(null);directionsDisplay.setPanel(null);directionsDisplay=new google.maps.DirectionsRenderer({draggable:true});directionsDisplay.setMap(map);directionsDisplay.setPanel(document.getElementById('routedialoguetext'));globalWaypointsArray=new Array();globalWaypointsPoibookidArray=new Array();globalWaypointsDescriptionArray=new Array();globalWaypointsPoiidArray=new Array();globalWaypointsPageArray=new Array();globalWaypointsBookidArray=new Array();for(var i=0;i<globalLabel.length;i++)
{globalLabel[i].setBlack();}
$("#myroutesdialogue").dialog('close');}
function setOptimisedRoute()
{for(i=0;i<globalWaypointsArray.length;i++)
{globalcopyWaypointsArray[i]=globalWaypointsArray[i];globalcopyWaypointsPoibookidArray[i]=globalWaypointsPoibookidArray[i];globalcopyWaypointsDescriptionArray[i]=globalWaypointsDescriptionArray[i];globalcopyWaypointsPoiidArray[i]=globalWaypointsPoiidArray[i];globalcopyWaypointsPageArray[i]=globalWaypointsPageArray[i];globalcopyWaypointsBookidArray[i]=globalWaypointsBookidArray[i];}
for(i=0;i<(globalResult.routes[0].waypoint_order.length);i++)
{reassignWaypointElements((globalResult.routes[0].waypoint_order[i]+1),i+1);}}
function reassignWaypointElements(fromIndex,toIndex)
{globalWaypointsArray[toIndex]=globalcopyWaypointsArray[fromIndex];globalWaypointsPoibookidArray[toIndex]=globalcopyWaypointsPoibookidArray[fromIndex];globalWaypointsDescriptionArray[toIndex]=globalcopyWaypointsDescriptionArray[fromIndex];globalWaypointsPoiidArray[toIndex]=globalcopyWaypointsPoiidArray[fromIndex];globalWaypointsPageArray[toIndex]=globalcopyWaypointsPageArray[fromIndex];globalWaypointsBookidArray[toIndex]=globalcopyWaypointsBookidArray[fromIndex];}
function getNearbyWiki(lat,lng)
{var searchUrl='getNearbyWiki.php?lat='+lat+'&lng='+lng;downloadUrl(searchUrl,function(data){{strContent='<HTML><H1>Wikipedia Articles</H1><DIV class="content"><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=100 HEIGHT=100><H2>Wikipedia articles</H2>';strContent='<BUTTON onclick="$('+String.fromCharCode(39)+'#wikipediadialogue'+String.fromCharCode(39)+').dialog('+String.fromCharCode(39)+'close'+String.fromCharCode(39)+');" class="standardbutton" style="float:right;">Close</BUTTON><B>Wikipedia Articles</B><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=100 HEIGHT=100><TABLE WIDTH="400" HEIGHT="400">';var xml=parseXml(data);if(xml.documentElement.getElementsByTagName("entry")!=null)
{var markerNodes=xml.documentElement.getElementsByTagName("entry");if(markerNodes.length==0)
{if(xml.documentElement.getElementsByTagName("status")!=null)
{alert('There seems to be a server issue: '+xml.documentElement.getElementsByTagName("status")[0].getAttribute("message")+' - Please try again later.');}
else
{alert('There may be no articles in this area (try another area). It is possible that there may alternatively be a problem with the Geonames Wikipedia articles server.)');}}
else
{for(i=0;i<markerNodes.length;i++)
{var entry=markerNodes[i];var title=markerNodes[i].getElementsByTagName("title")[0].firstChild.nodeValue;var summary=markerNodes[i].getElementsByTagName("summary")[0].firstChild.nodeValue;var wikipediaUrl=markerNodes[i].getElementsByTagName("wikipediaUrl")[0].firstChild.nodeValue;strContent+='<TR><TD><B><A HREF="'+wikipediaUrl+'" TARGET= "wikiwindow">'+title+'</A></B></TD></TR><TR><TD>'+summary.substring(0,200)+' ...</TD></TR>';}
strContent+='</TABLE>';for(i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i]!=null){globalInfoWindows[i].close();}}
document.getElementById('wikipediadialoguetext').innerHTML=strContent;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?400:400;$("#wikipediadialogue").dialog({width:600,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#wikipediadialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('wikipediadialogue').style.height='500px';window.setTimeout(function(){$("#wikipediadialogue").dialog("option","position","center");},2000);}}}}});}
function showWikiWindow()
{}
function showDirectionsOnNewPageButtonClick()
{var myWin=window.open('','directions');var directionHtml=document.getElementById('routedialoguetext').innerHTML;var intDirectionStart;intDirectionStart=directionHtml.indexOf('<P>Book');if(intDirectionStart==-1)
{intDirectionStart=directionHtml.indexOf('A = ');}
directionHtml=directionHtml.substring(intDirectionStart);myWin.document.write('<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd"><html><P><IMG src="http://www.guidebookplus.com/images/GGlogo6.png" height="200" width="200"></IMG></P><H1><P>Route Planning Results via www.Guidebookplus.com</H1></P><P><h2>Results from Google Map directions</h2></P><head><title>My Window</title></head><body>'+directionHtml+'</body></html>');}
function gpxButtonClick()
{if(confirm('A new page or tab will open in your browser. It contains a valid GPX text stream of the current route, which can be used in any suitable device. To save this stream, (1) Highlight, then "Edit/Copy" all of the GPX text stream, (2) Open a text editor such as Notepad or vi, (3) "Edit/Paste" the GPX source, and (4) Save this file, with a .gpx extension, for use with your device.'))
{var myWin=window.open('','gpx');var strGPX='<?xml version="1.0" encoding="UTF-8" standalone="no" ?><gpx xmlns="http://www.topografix.com/GPX/1/1" xmlns:gpxx="http://www.garmin.com/xmlschemas/GpxExtensions/v3" xmlns:gpxtpx="http://www.garmin.com/xmlschemas/TrackPointExtension/v1" creator="Oregon 400t" version="1.1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd http://www.garmin.com/xmlschemas/GpxExtensions/v3 http://www.garmin.com/xmlschemas/GpxExtensionsv3.xsd http://www.garmin.com/xmlschemas/TrackPointExtension/v1 http://www.garmin.com/xmlschemas/TrackPointExtensionv1.xsd">';strGPX+='<metadata><link href="http://www.guidebookplus.com"><text>Route from google map directions, supplied by Guidebook+</text></link></metadata>';strGPX+='<rte>';for(i=0;i<globalResult.routes[0].legs.length;i++)
{for(j=0;j<globalResult.routes[0].legs[i].steps.length;j++)
{strGPX+='<rtept lat="'+globalResult.routes[0].legs[i].steps[j].start_location.lat()+'" lon="'+globalResult.routes[0].legs[i].steps[j].start_location.lng()+'">';if(j==globalResult.routes[0].legs[i].steps.length-1)
{strGPX+='<name>Arrived at '+String.fromCharCode(65+i)+'.See book page.'+removeAccents(removeHTMLTags(globalResult.routes[0].legs[i].steps[j].instructions).replace(/\//g,' '))+' (distance:'+globalResult.routes[0].legs[i].steps[j].distance.text+', duration: '+globalResult.routes[0].legs[i].steps[j].duration.text+')</name><desc>'+removeAccents(removeHTMLTags(globalResult.routes[0].legs[i].steps[j].instructions).replace(/\//g,' '))+'(distance:'+globalResult.routes[0].legs[i].steps[j].distance.text+', duration: '+globalResult.routes[0].legs[i].steps[j].duration.text+')</desc>';}
else
{strGPX+='<name>en route to '+String.fromCharCode(65+i)+'. Step '+(j+1)+' of '+globalResult.routes[0].legs[i].steps.length+'.'+removeAccents(removeHTMLTags(globalResult.routes[0].legs[i].steps[j].instructions).replace(/\//g,' '))+' (distance:'+globalResult.routes[0].legs[i].steps[j].distance.text+', duration: '+globalResult.routes[0].legs[i].steps[j].duration.text+')</name><desc>'+removeAccents(removeHTMLTags(globalResult.routes[0].legs[i].steps[j].instructions).replace(/\//g,' '))+'(distance:'+globalResult.routes[0].legs[i].steps[j].distance.text+', duration: '+globalResult.routes[0].legs[i].steps[j].duration.text+')</desc>';}
strGPX+='</rtept>';}}
strGPX+='</rte>';strGPX+='</gpx>';strGPX=strGPX.replace(/</g,"&lt;");strGPX=strGPX.replace(/>/g,"&gt;");myWin.document.write(strGPX);}}
function removeHTMLTags(strInput){strInput=strInput.replace(/&(lt|gt);/g,function(strMatch,p1){return(p1=="lt")?"<":">";});var strTagStrippedText=strInput.replace(/<\/?[^>]+(>|$)/g,"");return strTagStrippedText;}
function removeAccents(strAccents){strAccents=strAccents.split('');strAccentsOut=new Array();strAccentsLen=strAccents.length;var accents='ÀÁÂÃÄÅàáâãäåÒÓÔÕÕÖØòóôõöøÈÉÊËèéêëðÇçÐÌÍÎÏìíîïÙÚÛÜùúûüÑñŠšŸÿýŽž';var accentsOut=['A','A','A','A','A','A','a','a','a','a','a','a','O','O','O','O','O','O','O','o','o','o','o','o','o','E','E','E','E','e','e','e','e','e','C','c','D','I','I','I','I','i','i','i','i','U','U','U','U','u','u','u','u','N','n','S','s','Y','y','y','Z','z'];for(var i=0;i<strAccentsLen;i++){if(accents.indexOf(strAccents[i])!=-1){strAccentsOut[i]=accentsOut[accents.indexOf(strAccents[i])];}
else
strAccentsOut[i]=strAccents[i];}
strAccentsOut=strAccentsOut.join('');return strAccentsOut;}
var wikiMapDragListener=null;var wikiZoomChangeListener=null;function wikiButtonClick()
{globalboolWikiButtonStatus=!globalboolWikiButtonStatus;for(i=0;i<globalWikiMarkers.length;i++)
{if(globalWikiMarkers[i]!=null)
{globalWikiMarkers[i].setMap(null);}}
if(globalboolWikiButtonStatus==true)
{document.getElementById('wikibutton').style.backgroundColor=globalColourRed;addWikiMarkers();if(wikiMapDragListener==null)
{wikiMapDragListener=google.maps.event.addListener(map,"dragend",function(){addWikiMarkers();});}
if(wikiZoomChangeListener==null)
{wikiZoomChangeListener=google.maps.event.addListener(map,"zoom_changed",function(){addWikiMarkers();});}}
else
{document.getElementById('wikibutton').style.backgroundColor=globalButtonColour;if(wikiMapDragListener!=null)
{google.maps.event.removeListener(wikiMapDragListener);wikiMapDragListener=null;google.maps.event.removeListener(wikiZoomChangeListener);wikiZoomChangeListener=null;}
for(i=0;i<globalWikiMarkers.length;i++)
{if(globalWikiMarkers[i]!=null)
{globalWikiMarkers[i].setMap(null);}}}}
function addWikiMarkers()
{for(i=0;i<globalWikiMarkers.length;i++)
{if(globalWikiMarkers[i]!=null)
{globalWikiMarkers[i].setMap(null);}}
var searchUrl='getBoundingBoxWiki.php?north='+map.getBounds().getNorthEast().lat().toFixed(2)+'&south='+map.getBounds().getSouthWest().lat().toFixed(2)+'&east='+map.getBounds().getNorthEast().lng().toFixed(2)+'&west='+map.getBounds().getSouthWest().lng().toFixed(2);downloadUrl(searchUrl,function(data){if(data.length>0)
{var xml=parseXml(data);if(xml.documentElement.getElementsByTagName("entry")!=null)
{var markerNodes=xml.documentElement.getElementsByTagName("entry");if(markerNodes.length==0)
{if(xml.documentElement.getElementsByTagName("status")!=null)
{alert('There seems to be a server issue with finding the Wikipedia articles: '+xml.documentElement.getElementsByTagName("status")[0].getAttribute("message")+' - Please try again later.');}
else
{alert('There may be no articles in this area (try another area). It is possible that there may alternatively be a problem with the Geonames Wikipedia articles server.)');}}
if(markerNodes.length==200)
{alert('The maximum number of articles has been shown (200). To be sure of seeing all articles, try a smaller area.');}
for(i=0;i<markerNodes.length;i++)
{var entry=markerNodes[i];if(markerNodes[i].getElementsByTagName("title").length>0)
{if(markerNodes[i].getElementsByTagName("title")[0].firstChild!=null)
var title=markerNodes[i].getElementsByTagName("title")[0].firstChild.nodeValue;else
var title='';}
else
var title='';if(markerNodes[i].getElementsByTagName("summary").length>0)
{if(markerNodes[i].getElementsByTagName("summary")[0].firstChild!=null)
var summary=markerNodes[i].getElementsByTagName("summary")[0].firstChild.nodeValue;else
var summary='';}
else
var summary='';if(markerNodes[i].getElementsByTagName("wikipediaUrl").length>0)
{if(markerNodes[i].getElementsByTagName("wikipediaUrl")[0].firstChild!=null)
var wikipediaUrl=markerNodes[i].getElementsByTagName("wikipediaUrl")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("rank").length>0)
{if(markerNodes[i].getElementsByTagName("rank")[0].firstChild!=null)
var rank=markerNodes[i].getElementsByTagName("rank")[0].firstChild.nodeValue;else
rank=1;}
else
rank=1;if(markerNodes[i].getElementsByTagName("lat").length>0)
{if(markerNodes[i].getElementsByTagName("lat")[0].firstChild!=null)
var lat=markerNodes[i].getElementsByTagName("lat")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("lng").length>0)
{if(markerNodes[i].getElementsByTagName("lng")[0].firstChild!=null)
var lng=markerNodes[i].getElementsByTagName("lng")[0].firstChild.nodeValue;else
continue;}
else
continue;var myNewLatLng=new google.maps.LatLng(lat,lng);var wikiMarkerSize=Math.floor(10+((rank/100)*20))
if(wikiMarkerSize<1||wikiMarkerSize>35)
wikiMarkerSize=30;var image=new google.maps.MarkerImage('images/wikiicon.png',new google.maps.Size(wikiMarkerSize,wikiMarkerSize),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(wikiMarkerSize,wikiMarkerSize));var shadowImage=new google.maps.MarkerImage('images/marker_shadow.png');var myMarker=new google.maps.Marker({position:myNewLatLng,title:title+'. Click to read Wikipedia article, or to add to your route.',draggable:false,icon:image,map:map});globalWikiMarkers[i]=myMarker;strContent='<HTML><DIV class="content"><BUTTON class="standardbutton" onclick="for (i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i] != null) {globalInfoWindows[i].close();}}" style="float:right;">Close</BUTTON><P><H2>'+title+'</H2></P><P><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=100 HEIGHT=100>'+summary+'<BUTTON class="standardbutton" onclick="javascript:window.open('+String.fromCharCode(39)+wikipediaUrl+String.fromCharCode(39)+','+String.fromCharCode(39)+'wiki'+String.fromCharCode(39)+');">View Article</BUTTON></P><P><BUTTON class="standardbutton" onclick="javascript:toggleWaypoint(globalDummyAreaLabel,new google.maps.LatLng('+lat+','+lng+'),'+String.fromCharCode(39)+title+String.fromCharCode(39)+',0'+',0,'+String.fromCharCode(39)+title+String.fromCharCode(39)+',0);alert('+String.fromCharCode(39)+'Your route has been amended.'+String.fromCharCode(39)+');">Add/Remove As Route Waypoint</BUTTON></P></DIV></HTML>';strContent='<BUTTON class="standardbutton" onclick="javascript:$('+String.fromCharCode(39)+'#wikipediadialogue'+String.fromCharCode(39)+').dialog('+String.fromCharCode(39)+'close'+String.fromCharCode(39)+');" style="float:right;">Close</BUTTON><BR><B>'+title+'<B><BR><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=100 HEIGHT=100>'+summary+'<BUTTON class="standardbutton" onclick="javascript:window.open('+String.fromCharCode(39)+wikipediaUrl+String.fromCharCode(39)+','+String.fromCharCode(39)+'wiki'+String.fromCharCode(39)+');">View Article</BUTTON><BR><BUTTON class="standardbutton" onclick="javascript:toggleWaypoint(globalDummyAreaLabel,new google.maps.LatLng('+lat+','+lng+'),'+String.fromCharCode(39)+title+String.fromCharCode(39)+',0'+',0,'+String.fromCharCode(39)+title+String.fromCharCode(39)+',0);alert('+String.fromCharCode(39)+'Your route has been amended.'+String.fromCharCode(39)+');">Add/Remove As Route Waypoint</BUTTON>';globalWikiClickListeners[i]=addWikiInfowindow(strContent,myMarker);}}}});}
function addWikiInfowindow(strContent,myMarker)
{var infowindow=new google.maps.InfoWindow({content:strContent});globalInfoWindows.push(infowindow);return google.maps.event.addListener(myMarker,'click',function(){document.getElementById('wikipediadialoguetext').innerHTML=strContent;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?300:300;$("#wikipediadialogue").dialog({width:600,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#wikipediadialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('wikipediadialogue').style.height='300px';window.setTimeout(function(){$("#wikipediadialogue").dialog("option","position","center");},1000);}});}
var hotelMapDragListener=null;var hotelZoomChangeListener=null;function hotelButtonClick()
{globalboolHotelButtonStatus=!globalboolHotelButtonStatus;for(i=0;i<globalHotelMarkers.length;i++)
{if(globalHotelMarkers[i]!=null)
{globalHotelMarkers[i].setMap(null);}}
if(globalboolHotelButtonStatus==true)
{document.getElementById('hotelbutton').style.backgroundColor=globalColourRed;addHotelMarkers();if(hotelMapDragListener==null)
{hotelMapDragListener=google.maps.event.addListener(map,"dragend",function(){addHotelMarkers();});}
if(hotelZoomChangeListener==null)
{hotelZoomChangeListener=google.maps.event.addListener(map,"zoom_changed",function(){addHotelMarkers();});}}
else
{document.getElementById('hotelbutton').style.backgroundColor=globalButtonColour;if(hotelMapDragListener!=null)
{google.maps.event.removeListener(hotelMapDragListener);hotelMapDragListener=null;google.maps.event.removeListener(hotelZoomChangeListener);hotelZoomChangeListener=null;}
for(i=0;i<globalHotelMarkers.length;i++)
{if(globalHotelMarkers[i]!=null)
{globalHotelMarkers[i].setMap(null);}}}}
function addHotelMarkers()
{for(i=0;i<globalHotelMarkers.length;i++)
{if(globalHotelMarkers[i]!=null)
{globalHotelMarkers[i].setMap(null);}}
var searchUrl='getBoundingBoxHotels.php?north='+map.getBounds().getNorthEast().lat().toFixed(2)+'&south='+map.getBounds().getSouthWest().lat().toFixed(2)+'&east='+map.getBounds().getNorthEast().lng().toFixed(2)+'&west='+map.getBounds().getSouthWest().lng().toFixed(2);downloadUrl(searchUrl,function(data){if(data.length>0)
{var xml=parseXml(removeAccents(data));if(xml.documentElement.getElementsByTagName("Accommodation")!=null)
{var markerNodes=xml.documentElement.getElementsByTagName("Accommodation");if(markerNodes.length==0)
{alert('There may be no recorded accommodation in this area (try another area). Otherwise, your browser may be having trouble reading this accommodation feed.');}
if(markerNodes.length==200)
{alert('The maximum number of hotels (200) is shown here: there may be more (zoom in to try searching a smaller area).');}
for(i=0;i<markerNodes.length;i++)
{var entry=markerNodes[i];if(markerNodes[i].getElementsByTagName("hotelId").length>0)
{if(markerNodes[i].getElementsByTagName("hotelId")[0].firstChild!=null)
var hotelId=markerNodes[i].getElementsByTagName("hotelId")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("hotelFileName").length>0)
{if(markerNodes[i].getElementsByTagName("hotelFileName")[0].firstChild!=null)
hotelFileName=markerNodes[i].getElementsByTagName("hotelFileName")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("hotelName").length>0)
{if(markerNodes[i].getElementsByTagName("hotelName")[0].firstChild!=null)
var hotelName=markerNodes[i].getElementsByTagName("hotelName")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("rating").length>0)
{if(markerNodes[i].getElementsByTagName("rating")[0].firstChild!=null)
var rating=markerNodes[i].getElementsByTagName("rating")[0].firstChild.nodeValue;else
var rating=0;}
else
var rating=0;if(markerNodes[i].getElementsByTagName("cityName").length>0)
{if(markerNodes[i].getElementsByTagName("cityName")[0].firstChild!=null)
var cityName=markerNodes[i].getElementsByTagName("cityName")[0].firstChild.nodeValue;else
var cityName='';}
else
var cityName='';if(markerNodes[i].getElementsByTagName("imageId").length>0)
{if(markerNodes[i].getElementsByTagName("imageId")[0].firstChild!=null)
var imageId=markerNodes[i].getElementsByTagName("imageId")[0].firstChild.nodeValue;else
var imageId='';}
else
var imageId='';if(markerNodes[i].getElementsByTagName("address").length>0)
{if(markerNodes[i].getElementsByTagName("address")[0].firstChild!=null)
var address=markerNodes[i].getElementsByTagName("address")[0].firstChild.nodeValue;else
var address='';}
else
var address='';if(markerNodes[i].getElementsByTagName("Latitude").length>0)
{if(markerNodes[i].getElementsByTagName("Latitude")[0].firstChild!=null)
var Latitude=markerNodes[i].getElementsByTagName("Latitude")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("Longitude").length>0)
{if(markerNodes[i].getElementsByTagName("Longitude")[0].firstChild!=null)
var Longitude=markerNodes[i].getElementsByTagName("Longitude")[0].firstChild.nodeValue;else
continue;}
else
continue;if(markerNodes[i].getElementsByTagName("PropertyType").length>0)
{if(markerNodes[i].getElementsByTagName("PropertyType")[0].firstChild!=null)
var PropertyType=markerNodes[i].getElementsByTagName("PropertyType")[0].firstChild.nodeValue;else
var PropertyType=8;}
else
var PropertyType=8;if(markerNodes[i].getElementsByTagName("Facilities").length>0)
{if(markerNodes[i].getElementsByTagName("Facilities")[0].firstChild!=null)
var Facilities=markerNodes[i].getElementsByTagName("Facilities")[0].firstChild.nodeValue;else
var Facilities='';}
else
var Facilities='';var strPropertyType='';switch(PropertyType)
{case 0:strPropertyType='Hotel';break;case 1:strPropertyType='Motel';break;case 2:strPropertyType='Inn';break;case 3:strPropertyType='Bed and Breakfast';break;case 4:strPropertyType='Rental';break;case 5:strPropertyType='Hostel';break;case 6:strPropertyType='Retreat';break;case 7:strPropertyType='Resort';break;case 8:strPropertyType='Other';break;case 9:strPropertyType='Apartment';break;default:strPropertyType='Hotel';break;}
var image;switch(parseInt(rating))
{case 1:image=new google.maps.MarkerImage('images/accom1.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(10,20));break;case 2:image=new google.maps.MarkerImage('images/accom2.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;case 3:image=new google.maps.MarkerImage('images/accom3.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;case 4:image=new google.maps.MarkerImage('images/accom4.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;case 5:image=new google.maps.MarkerImage('images/accom5.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;default:image=new google.maps.MarkerImage('images/accom0.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;}
var myNewLatLng=new google.maps.LatLng(Latitude,Longitude);var shadowImage=new google.maps.MarkerImage('images/marker_shadow.png');var myMarker=new google.maps.Marker({position:myNewLatLng,title:hotelName+'. Click to view accommodation details, or to add to your route.',draggable:false,icon:image,map:map});globalHotelMarkers[i]=myMarker;strContent='<HTML><DIV class="content"><BUTTON class="standardbutton" onclick="for (i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i] != null) {globalInfoWindows[i].close();}}" style="float:right;">Close</BUTTON><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=80 HEIGHT=80><H3>Accommodation Details</H3><P><H2><I>'+hotelName+'</I></H2><P></P><P ALIGN="CENTER">'+((imageId==0)?'':'<IMG SRC="http://media.hotelscombined.com/HT'+imageId+'.jpg" HEIGHT="100" WIDTH="100" /></P>')+'<P><I>Name: </I>'+hotelName+'</P><P><I>Address: </I>'+address+', '+cityName+'</P><P><I>Accommodation type: </I>'+rating+' star '+strPropertyType+'</P><P ALIGN="CENTER"><BUTTON class="standardbutton" onclick="javascript:window.open('+String.fromCharCode(39)+'http://www.hotelscombined.com/Hotel/'+hotelFileName+'.htm?a_aid=20973&brandid=29164'+String.fromCharCode(39)+','+String.fromCharCode(39)+'accommodation'+String.fromCharCode(39)+');" ALIGN="CENTER">View Accommodation</BUTTON></P><P ALIGN="CENTER"><BUTTON class="standardbutton" onclick="javascript:toggleWaypoint(globalDummyAreaLabel,new google.maps.LatLng('+Latitude+','+Longitude+'),'+String.fromCharCode(39)+hotelName+String.fromCharCode(39)+',0'+',0,'+String.fromCharCode(39)+hotelName+String.fromCharCode(39)+',0);alert('+String.fromCharCode(39)+'Your route has been amended.'+String.fromCharCode(39)+');" ALIGN="CENTER">Add/Remove As Route Waypoint</BUTTON></P></DIV></HTML>';strContent='<BUTTON class="standardbutton" onclick="$('+String.fromCharCode(39)+'#accommodationdialogue'+String.fromCharCode(39)+').dialog('+String.fromCharCode(39)+'close'+String.fromCharCode(39)+');" style="float:right;">Close</BUTTON><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=80 HEIGHT=80>Accommodation Details<BR><I>'+hotelName+'</I><BR>'+((imageId==0)?'':'<IMG SRC="http://media.hotelscombined.com/HT'+imageId+'.jpg" HEIGHT="100" WIDTH="100" />')+'<BR><I>Name: </I>'+hotelName+'<BR><I>Address: </I>'+address+', '+cityName+'<BR><I>Accommodation type: </I>'+rating+' star '+strPropertyType+'<BR><BUTTON class="standardbutton" onclick="javascript:window.open('+String.fromCharCode(39)+'http://www.hotelscombined.com/Hotel/'+hotelFileName+'.htm?a_aid=20973&brandid=29164'+String.fromCharCode(39)+','+String.fromCharCode(39)+'accommodation'+String.fromCharCode(39)+');" ALIGN="CENTER">View Accommodation</BUTTON><BR><BUTTON class="standardbutton" onclick="javascript:toggleWaypoint(globalDummyAreaLabel,new google.maps.LatLng('+Latitude+','+Longitude+'),'+String.fromCharCode(39)+hotelName+String.fromCharCode(39)+',0'+',0,'+String.fromCharCode(39)+hotelName+String.fromCharCode(39)+',0);alert('+String.fromCharCode(39)+'Your route has been amended.'+String.fromCharCode(39)+');" ALIGN="CENTER">Add/Remove As Route Waypoint</BUTTON>';globalHotelClickListeners[i]=addHotelInfowindow(strContent,myMarker);}}}});}
function addHotelInfowindow(strContent,myMarker)
{var infowindow=new google.maps.InfoWindow({content:strContent});return google.maps.event.addListener(myMarker,'click',function(){document.getElementById('accommodationdialoguetext').innerHTML=strContent;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?400:400;$("#accommodationdialogue").dialog({width:600,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#accommodationdialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('accommodationdialogue').style.height='400px';window.setTimeout(function(){$("#accommodationdialogue").dialog("option","position","center");},1000);}});}
function showLocationDialogue(poiid,lat,lng)
{strContent='<IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=50 HEIGHT=50><BUTTON STYLE="float:right;margin:5px;" CLASS="standardbutton" onclick="javascript:closeLocationDialogue();">Close</BUTTON><BR><BUTTON class="standardbutton" onclick="javascript:for (i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i] != null) {globalInfoWindows[i].close();}}getNearbyWiki('+lat+','+lng+');">Show Wikipedia articles</BUTTON><BUTTON class="standardbutton" onclick="getNearbyHotels('+lat+','+lng+','+'document.getElementById('+String.fromCharCode(39)+'AccomSelectPoi'+poiid+String.fromCharCode(39)+').value)">Show Accommodation</BUTTON>&nbsp;Within :&nbsp;<SELECT id='+String.fromCharCode(39)+'AccomSelectPoi'+poiid+String.fromCharCode(39)+'><OPTION VALUE=1>1 km<OPTION VALUE=5>5 km<OPTION VALUE=10>10 km<OPTION VALUE=20>20 km<OPTION VALUE=50>50 km</SELECT>';document.getElementById('locationdialoguetext').innerHTML=strContent;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?200:200;$('#locationdialogue').dialog({width:600,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$('#locationdialogue').dialog('open');if(navigator.appName=="Microsoft Internet Explorer")
{document.getElementById('locationdialogue').style.height='200px';window.setTimeout(function(){$('#locationdialogue').dialog('option','position','center');},1000);}}
function showLocationPageDialogue(poiid,lat,lng,poibookid)
{strContent='<IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=50 HEIGHT=50><BUTTON STYLE="float:right;margin:5px;" CLASS="standardbutton" onclick="javascript:closeLocationDialogue();">Close</BUTTON><BR><BUTTON class="standardbutton" onclick="javascript:for (i=0;i<globalInfoWindows.length;i++){if(globalInfoWindows[i] != null) {globalInfoWindows[i].close();}}getNearbyWiki('+lat+','+lng+');">Show Wikipedia articles</BUTTON><BR><BUTTON class="standardbutton" onclick="getNearbyHotels('+lat+','+lng+','+'document.getElementById('+String.fromCharCode(39)+'AccomSelect'+poibookid+String.fromCharCode(39)+').value)">Show Accommodation</BUTTON>&nbsp;Within :&nbsp;<SELECT id='+String.fromCharCode(39)+'AccomSelect'+poibookid+String.fromCharCode(39)+'><OPTION VALUE=1>1 km<OPTION VALUE=5>5 km<OPTION VALUE=10>10 km<OPTION VALUE=20>20 km<OPTION VALUE=50>50 km</SELECT>';document.getElementById('locationdialoguetext').innerHTML=strContent;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?200:200;$('#locationdialogue').dialog({width:600,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$('#locationdialogue').dialog('open');if(navigator.appName=="Microsoft Internet Explorer")
{document.getElementById('locationdialogue').style.height='200px';window.setTimeout(function(){$('#locationdialogue').dialog('option','position','center');},1000);}}
function getNearbyHotels(lat,lng,distance)
{var searchUrl='getNearbyHotels.php?lat='+lat+'&lng='+lng+'&distance='+distance;downloadUrl(searchUrl,function(data){if(data.length>0)
{var xml=parseXml(removeAccents(data));if(xml.documentElement.getElementsByTagName("Accommodation")!=null)
{var markerNodes=xml.documentElement.getElementsByTagName("Accommodation");for(i=0;i<100;i++)
{if(globalHotelMarkers[i]!=null)
{globalHotelMarkers[i].setMap(null);}}
if(markerNodes.length==0)
{alert('There may be no recorded accommodation in this area (try another area). Otherwise, your browser may have trouble reading this accommodation feed. (It definitely works with Internet Explorer.)');}
if(markerNodes.length==200)
{alert('The maximum number of hotels (200) is shown here: there may be more (zoom in to try searching a smaller area).');}
for(i=0;i<markerNodes.length;i++)
{var entry=markerNodes[i];var hotelId=markerNodes[i].getElementsByTagName("hotelId")[0].firstChild.nodeValue;var hotelFileName=markerNodes[i].getElementsByTagName("hotelFileName")[0].firstChild.nodeValue;var hotelName=markerNodes[i].getElementsByTagName("hotelName")[0].firstChild.nodeValue;var rating=markerNodes[i].getElementsByTagName("rating")[0].firstChild.nodeValue;var cityName=markerNodes[i].getElementsByTagName("cityName")[0].firstChild.nodeValue;var imageId=markerNodes[i].getElementsByTagName("imageId")[0].firstChild.nodeValue;var address=markerNodes[i].getElementsByTagName("address")[0].firstChild.nodeValue;var Latitude=markerNodes[i].getElementsByTagName("Latitude")[0].firstChild.nodeValue;var Longitude=markerNodes[i].getElementsByTagName("Longitude")[0].firstChild.nodeValue;var PropertyType=markerNodes[i].getElementsByTagName("PropertyType")[0].firstChild.nodeValue;var Facilities=markerNodes[i].getElementsByTagName("Facilities")[0].firstChild.nodeValue;Distance=markerNodes[i].getElementsByTagName("Distance")[0].firstChild.nodeValue;var strPropertyType='';switch(PropertyType)
{case 0:strPropertyType='Hotel';break;case 1:strPropertyType='Motel';break;case 2:strPropertyType='Inn';break;case 3:strPropertyType='Bed and Breakfast';break;case 4:strPropertyType='Rental';break;case 5:strPropertyType='Hostel';break;case 6:strPropertyType='Retreat';break;case 7:strPropertyType='Resort';break;case 8:strPropertyType='Other';break;case 9:strPropertyType='Apartment';break;default:strPropertyType='Hotel';break;}
switch(parseInt(rating))
{case 1:image=new google.maps.MarkerImage('images/accom1.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(10,20));break;case 2:image=new google.maps.MarkerImage('images/accom2.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;case 3:image=new google.maps.MarkerImage('images/accom3.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;case 4:image=new google.maps.MarkerImage('images/accom4.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;case 5:image=new google.maps.MarkerImage('images/accom5.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;default:image=new google.maps.MarkerImage('images/accom0.png',new google.maps.Size(20,20),new google.maps.Point(0,0),new google.maps.Point(0,0),new google.maps.Size(20,20));break;}
var myNewLatLng=new google.maps.LatLng(Latitude,Longitude);var shadowImage=new google.maps.MarkerImage('images/marker_shadow.png');var myMarker=new google.maps.Marker({position:myNewLatLng,title:hotelName+'. Click to view accommodation details, or to add to your route.',draggable:false,icon:image,map:map});globalHotelMarkers[i]=myMarker;strContent='<BUTTON class="standardbutton" onclick="$('+String.fromCharCode(39)+'#accommodationdialogue'+String.fromCharCode(39)+').dialog('+String.fromCharCode(39)+'close'+String.fromCharCode(39)+');" style="float:right;">Close</BUTTON><IMG SRC="images/GGlogo6.png" STYLE="float:left;margin:5px;" WIDTH=80 HEIGHT=80>Accommodation Details<BR><I>'+hotelName+'</I><BR>'+((imageId==0)?'':'<IMG SRC="http://media.hotelscombined.com/HT'+imageId+'.jpg" HEIGHT="100" WIDTH="100" />')+'<BR><I>Name: </I>'+hotelName+'<BR><I>Address: </I>'+address+', '+cityName+'<BR><I>Accommodation type: </I>'+rating+' star '+strPropertyType+'<BR><BUTTON class="standardbutton" onclick="javascript:window.open('+String.fromCharCode(39)+'http://www.hotelscombined.com/Hotel/'+hotelFileName+'.htm?a_aid=20973&brandid=29164'+String.fromCharCode(39)+','+String.fromCharCode(39)+'accommodation'+String.fromCharCode(39)+');" ALIGN="CENTER">View Accommodation</BUTTON><BR><BUTTON class="standardbutton" onclick="javascript:toggleWaypoint(globalDummyAreaLabel,new google.maps.LatLng('+Latitude+','+Longitude+'),'+String.fromCharCode(39)+hotelName+String.fromCharCode(39)+',0'+',0,'+String.fromCharCode(39)+hotelName+String.fromCharCode(39)+',0);alert('+String.fromCharCode(39)+'Your route has been amended.'+String.fromCharCode(39)+');" ALIGN="CENTER">Add/Remove As Route Waypoint</BUTTON>';globalHotelClickListeners[i]=addHotelInfowindow(strContent,myMarker);}}}});}
var locationMapDragListener=null;var locationZoomChangeListener=null;function poisButtonClick()
{globalboolPoisButtonStatus=!globalboolPoisButtonStatus;for(i=0;i<globalAreaPoiMarker.length;i++)
{if(globalAreaPoiMarker[i]!=null)
{globalAreaPoiMarker[i].setMap(null);globalAreaPoiMarker[i]=null;globalAreaPoiLabel[i].hide();globalAreaPoiLabel[i]=null;if(globalAreaPoiGenreListener[i]!=null)
{google.maps.event.removeListener(globalAreaPoiGenreListener[i]);}}}
if(globalboolPoisButtonStatus==true)
{document.getElementById('poisbutton').style.backgroundColor=globalColourRed;addLocationMarkers();if(locationMapDragListener==null)
{locationMapDragListener=google.maps.event.addListener(map,"dragend",function(){addLocationMarkers();});}
if(locationZoomChangeListener==null)
{locationZoomChangeListener=google.maps.event.addListener(map,"zoom_changed",function(){addLocationMarkers();});}}
else
{document.getElementById('poisbutton').style.backgroundColor=globalButtonColour;if(locationMapDragListener!=null)
{google.maps.event.removeListener(locationMapDragListener);locationMapDragListener=null;google.maps.event.removeListener(locationZoomChangeListener);locationZoomChangeListener=null;}
for(i=0;i<globalAreaPoiMarker.length;i++)
{if(globalAreaPoiMarker[i]!=null)
{globalAreaPoiMarker[i].setMap(null);globalAreaPoiMarker[i]=null;globalAreaPoiLabel[i].hide();globalAreaPoiLabel[i]=null;if(globalAreaPoiGenreListener[i]!=null)
{google.maps.event.removeListener(globalAreaPoiGenreListener[i]);}}}}}
function addLocationMarkers()
{for(i=0;i<globalAreaPoiMarker.length;i++)
{if(globalAreaPoiMarker[i]!=null)
{globalAreaPoiMarker[i].setMap(null);globalAreaPoiMarker[i]=null;globalAreaPoiLabel[i].hide();globalAreaPoiLabel[i]=null;if(globalAreaPoiGenreListener[i]!=null)
{google.maps.event.removeListener(globalAreaPoiGenreListener[i]);}}}
var searchUrl='getBoundingBoxPois.php?north='+map.getBounds().getNorthEast().lat().toFixed(2)+'&south='+map.getBounds().getSouthWest().lat().toFixed(2)+'&east='+map.getBounds().getNorthEast().lng().toFixed(2)+'&west='+map.getBounds().getSouthWest().lng().toFixed(2);downloadUrl(searchUrl,function(data){if(data.length>0)
{var xml=parseXml(data);if(xml.documentElement.getElementsByTagName("Placemark")!=null)
{var markerNodes=xml.documentElement.getElementsByTagName("Placemark");if(markerNodes.length==0)
{alert('GuidebookPlus may have no recorded location of interest in this area (try another area). It may be, otherwise, that your browser has trouble reading this feed.');}
if(markerNodes.length==400)
{alert('The maximum number of locations is shown. Try a smaller area to be sure of seeing all recorded locations.');}
for(i=0;i<markerNodes.length;i++)
{var name=markerNodes[i].getAttribute("placemark-name");var description=markerNodes[i].getAttribute("placemark-description");var coords=markerNodes[i].getAttribute("placemark-coordinates");var size=markerNodes[i].getAttribute("placemark-size");var poibookid=markerNodes[i].getAttribute("placemark-poibookid");var bookid=markerNodes[i].getAttribute("placemark-bookid");var genreids=markerNodes[i].getAttribute("placemark-genreids");var confidence=markerNodes[i].getAttribute("placemark-confidence");var poiid=markerNodes[i].getAttribute("placemark-Point");var splitCoords=coords.split(",");var lon=parseFloat(splitCoords[0]);var lat=parseFloat(splitCoords[1]);addAreaPoisMarkerAndLabel(i,lat,lon,name,description,genreids,confidence);var poiLength=1;}
setTimeout(function(){for(i=0;i<globalAreaPoiLabel.length;i++){if(globalAreaPoiLabel[i]!=null){globalAreaPoiLabel[i].setBlack();globalAreaPoiLabel[i].show();}}},1200);}}});}
function addAreaPoisMarkerAndLabel(i,lat,lon,poiid,description,genreIds,confidence)
{var myNewLatLng=new google.maps.LatLng(lat,lon);var myLabel=new Label({map:map});globalAreaPoiLabel[i]=myLabel;var image='images/1px.png';var myMarker=new google.maps.Marker({position:myNewLatLng,icon:image,title:description,draggable:false,map:map});globalAreaPoiMarker[i]=myMarker;var labelColour='black';labelText=description;myLabel.set('colour',labelColour);myLabel.set('text',labelText);myLabel.set('title',description+". Left-Click to add this location to your route. Right-Click for Wikipedia articles and accommodation info.");myLabel.setPoibookid('poi'+poiid);myLabel.set('ordinal','');if(confidence==2)
{var parkCount=0;for(k=0;k<genreIds.split(',').length;k++)
{if(genreIds.split(',')[k]==11||genreIds.split(',')[k]==12||genreIds.split(',')[k]==13)
{parkCount++;}}
if(parkCount==3)
{myLabel.setBorderAsArea();}}
myLabel.set('genreIds',genreIds);myLabel.set('description',description);myLabel.set('poiid',poiid);myLabel.set('fontstyle','bold');myLabel.bindTo('position',myMarker,'position');myLabel.setLat(lat);myLabel.setLng(lon);google.maps.event.addListener(globalAreaPoiMarker[i],'visible_changed',function(){if(this.getVisible()==true)
myLabel.show();else
myLabel.hide();});if(description=="Cornwall: Press for Progress!")
{myLabel.getDiv().onclick=function(e){CornwallClick();}}
else
{myLabel.getDiv().onmouseup=function(e){replaceAdvertByLatLng(new google.maps.LatLng(lat,lon));var rightclick;if(!e)var e=window.event;if(e.which)rightclick=(e.which==3);else if(e.button)rightclick=(e.button==2);if(rightclick==false){}else{showLocationDialogue(poiid,lat,lon);}}
myLabel.getDiv().onclick=function(e){replaceAdvertByLatLng(new google.maps.LatLng(lat,lon));toggleWaypoint(myLabel,myNewLatLng,myLabel.getPoibookid(),labelText,0,description,poiid);}}
var myHideButton=document.getElementById('hideshowgenrebutton');globalAreaPoiGenreListener[i]=google.maps.event.addDomListener(myHideButton,'click',function(){var strChkPoiid=poiid;myLabel.hide();var splitGenreId=genreIds.split(',');for(var i=0;i<splitGenreId.length;i++){var chkbox=document.getElementById('genrecheckbox'+splitGenreId[i]);if(chkbox!=null){if(chkbox.checked==true||(splitGenreId[i]==globalNumberGenres))myLabel.show();i=splitGenreId.length;}}});}
function setAreaPoiGenreListener(myLabel,poiid,genreids)
{var strChkPoiid=poiid;myLabel.hide();var splitGenreId=genreids.split(',');for(var i=0;i<splitGenreId.length;i++)
{var chkbox=document.getElementById('genrecheckbox'+splitGenreId[i]);if(chkbox!=null)
{if(chkbox.checked==true)
{myLabel.show();}
else
{}}}}
function zoomButtonClick()
{if(userRectangle!=null)
{map.fitBounds(userRectangle.getBounds());}
else
if(map.getZoom()<20)
{map.setZoom(map.getZoom()+1);}}
function photoButtonClick()
{var myPhotoButton=document.getElementById('photobutton');if(globalboolPhotosShown==false)
{ShowPhotos();globalboolPhotosShown=true;myPhotoButton.style.backgroundColor=globalColourRed;}
else
{HidePhotos();globalboolPhotosShown=false;myPhotoButton.style.backgroundColor=globalButtonColour;}}
function printButtonClick()
{window.open('print.php');}
var photooverlays=[];var ids=[];var photoMapDragListener=null;var photoZoomChangeListener=null;function ShowPhotos()
{for(var i=0;i<photooverlays.length;i++){photooverlays[i].setMap(null);}
photooverlays=[];ids=[];var bounds=map.getBounds();var southWest=bounds.getSouthWest();var northEast=bounds.getNorthEast();Panoramio.load(ProcessPhotos,{maxy:northEast.lat(),miny:southWest.lat(),maxx:northEast.lng(),minx:southWest.lng()});photoMapDragListener=google.maps.event.addListener(map,"dragend",function(){var bounds=map.getBounds();var southWest=bounds.getSouthWest();var northEast=bounds.getNorthEast();Panoramio.load(ProcessPhotos,{maxy:northEast.lat(),miny:southWest.lat(),maxx:northEast.lng(),minx:southWest.lng()});});photoZoomChangeListener=google.maps.event.addListener(map,"zoom_changed",function(){var bounds=map.getBounds();var southWest=bounds.getSouthWest();var northEast=bounds.getNorthEast();Panoramio.load(ProcessPhotos,{maxy:northEast.lat(),miny:southWest.lat(),maxx:northEast.lng(),minx:southWest.lng()});});globalboolPhotosShown=true;}
function ProcessPhotos(json){for(var i=0;i<json.photos.length;i++){var photo=json.photos[i];if(!ids[photo.photo_id]){CreatePhotoMarker(photo,json.formImgUrl(photo.photo_id,"square"));ids[photo.photo_id]="exists";}}}
function CreatePhotoMarker(photo,photoUrl){var photoMarker=new google.maps.Marker({position:new google.maps.LatLng(photo.latitude,photo.longitude),map:map,title:'Click to view photo: '+photo.photo_title,icon:GetPhotoIcon(photoUrl),shadow:new google.maps.MarkerImage('http://www.guidebookplus.com/images/white40.png',new google.maps.Size(40,40),new google.maps.Point(0,0),new google.maps.Point(20,36))});if(photo.photo_title.length>33){photo.photo_title=photo.photo_title.substring(0,33)+"&#8230;";}
var strContent="<a href='http://www.panoramio.com/' target='_blank'>"+"<img src='http://www.panoramio.com/img/logo-small.gif' width='119px' height='25px' alt='Panoramio logo' /><\/a>"+"<IMG SRC='images/GGlogo6.png' HEIGHT='40' WIDTH='40' TITLE='GuidebookPlus'>"+"<a id='photo_infowin' target='_blank' href='"+photo.photo_url+"' TITLE='Click to open larger photo in a new window.'>"+"<img src='"+photoUrl+"'/><\/a><BUTTON style='float:right;' class='standardbutton' onclick='closePhotoDialogue();'>Close</BUTTON>"+"<BR><a target='_blank' class='photo_title' href='"+photo.photo_url+"'><strong>"+photo.photo_title+"<\/strong><\/a>"+"<BR>Published by <a target='_blank' href='"+photo.owner_url+"'>"+
photo.owner_name.replace('[object Object]','')+"<\/a>";google.maps.event.addListener(photoMarker,"click",function(){document.getElementById('photodialoguetext').innerHTML=strContent;myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?200:200;$("#photodialogue").dialog({width:400,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#photodialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('photodialogue').style.height='200px';window.setTimeout(function(){$("#photodialogue").dialog("option","position","center");},1000);}});photoMarker.setMap(map);photooverlays.push(photoMarker);return;}
function GetPhotoIcon(photoUrl){var icon=new google.maps.MarkerImage(photoUrl,new google.maps.Size(32,32));return icon;}
function HidePhotos(){for(var i=0;i<photooverlays.length;i++){photooverlays[i].setMap(null);}
photooverlays=[];ids=[];if(photoMapDragListener!=null)
google.maps.event.removeListener(photoMapDragListener);if(photoZoomChangeListener!=null)
google.maps.event.removeListener(photoZoomChangeListener);}
var Panoramio=function(json,options){this.options=options||{};this.photos=json.photos;this.count=json.count;this.index=[];for(var x=0;x<this.photos.length;x++){this.index[this.photos[x].photo_id]=x;}
this.each=function(callback){for(var x=0;x<this.photos.length;x++){callback(this.photos[x]);}};this.select=function(id){if(typeof id=='string'){return this.photos[this.index[id]];}else{return this.photos[id];}};this.formImgUrl=function(photoId,imgType){return'http://www.panoramio.com/photos/'+imgType+'/'+photoId+'.jpg';}
this.formPageUrl=function(photoId){return'http://www.panoramio.com/photo/'+photoId;}
this.displayAll=function(inlineCSS,options){if(!options['countPerRow'])options['countPerRow']=5;if(!options['photoSize'])options['photoSize']="square";if(!inlineCSS)inlineCSS='';var table="<table cellpadding='5' cellspacing='0' "+inlineCSS+">";var self=this;table+="<tr>";for(var x=0;x<this.photos.length;x++){var aStart="";var aEnd="";if(options['linkToPhoto']){aStart="<a href='"+this.formPageUrl(this.photos[x].photo_id)+"' target='_blank'>";aEnd="</a>";}
table+="<td style='border: 1px solid grey;'>"
+aStart+"<img src='"+this.formImgUrl(this.photos[x].photo_id,options['photoSize'])+"'/>"
+aEnd+"</td><TD><IMG SRC='images/GGlogo6.png' HEIGHT='100' WEIGHT='100'></TD>";if((x+1)%options['countPerRow']==0){table+="</tr><tr>";}}
table+="</tr>";table+="</table>";return table;};this.displayRow=function(id){var row=this.select(id);var keyvalues=[];for(var x in row){keyvalues.push(x+' = '+row[x]);}
return keyvalues.join(', ');}}
Panoramio.load=function(callback,userOptions){var options={order:"all",set:"public",from:"0",to:"40",minx:"-180",miny:"-90",maxx:"180",maxy:"90"};for(optionName in userOptions){if(userOptions.hasOwnProperty(optionName)){options[optionName]=userOptions[optionName];}}
var url="http://www.panoramio.com/map/get_panoramas.php?";var uniqueID="";for(optionName in options){if(options.hasOwnProperty(optionName)){var optionVal=""+options[optionName]+"";url+=optionName+"="+optionVal+"&";uniqueID+=optionVal.replace(/[^\w]+/g,"");}}
var callbackName="Panoramio.loader"+uniqueID;eval(callbackName+" = function(json) { var pa = new Panoramio(json, options); callback(pa); }");var script=document.createElement('script');script.setAttribute('src',url+'callback='+callbackName);script.setAttribute('id','jsonScript');script.setAttribute('type','text/javascript');document.documentElement.firstChild.appendChild(script);}
function closeBookAreaDialogue()
{$('#areabooksdialogue').dialog('close');}
function closePhotoDialogue()
{$('#photodialogue').dialog('close');}
function closeLocationDialogue()
{$('#locationdialogue').dialog('close');}
function closeGeneralDialogue()
{$('#generaldialogue').dialog('close');}
function emailClick()
{document.getElementById('generaliframe').src='http://www.guidebookplus.com/contact.php';myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?700:700;document.getElementById("generaldialogue").title="GuidebookPlus";document.getElementById("generaliframe").width=500;document.getElementById("generaliframe").height=620;$("#generaldialogue").dialog({width:580,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#generaldialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('generaldialogue').style.height='700px';document.getElementById('generaliframe').style.height='600px';window.setTimeout(function(){$("#generaldialogue").dialog("option","position","center");document.getElementById('generaliframe').src='http://www.guidebookplus.com/contact.php';},1000);}}
function helpClick()
{document.getElementById('generaliframe').src='http://www.guidebookplus.com/help.php';myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?700:700;document.getElementById("generaldialogue").title="GuidebookPlus";document.getElementById("generaliframe").width=750;$("#generaldialogue").dialog({width:800,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#generaldialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('generaldialogue').style.height='700px';document.getElementById('generaliframe').style.height='600px';window.setTimeout(function(){$("#generaldialogue").dialog("option","position","center");document.getElementById('generaliframe').src='http://www.guidebookplus.com/help.php';},1000);}}
function blogClick()
{if((document.body.clientWidth<1100)||(window.innerWidth<1100))
{window.open('http://www.guidebookplus.com/mapmybook/','blog');}
else
{document.getElementById('generaliframe').src='http://www.guidebookplus.com/mapmybook/';myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?700:700;document.getElementById("generaldialogue").title="GuidebookPlus";document.getElementById("generaliframe").width=1050;$("#generaldialogue").dialog({width:1100,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#generaldialogue").dialog('open');if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('generaldialogue').style.height='700px';document.getElementById('generaliframe').style.height='600px';window.setTimeout(function(){$("#generaldialogue").dialog("option","position","center");document.getElementById('generaliframe').src='http://www.guidebookplus.com/mapmybook/';},1000);}}}
function CornwallClick()
{if(navigator.appName=='Microsoft Internet Explorer')
{document.getElementById('areabooksdialoguetext').innerHTML="<IMG SRC='images/cornwall_flag.png' HEIGHT='216' WIDTH='177' style='float:left;'>The domination of Tourism has done Cornwall far more harm than good: Cornish culture has been suppressed, and Cornish workers are among the lowest-paid in Europe.</BR><A HREF='http://www.guidebookplus.com/mapmybook/?p=447' TARGET='kernow'>GuidebookPlus will not be indexing guidebook locations in Cornwall.</A>";}
else
{document.getElementById('areabooksdialoguetext').innerHTML="<P><IMG SRC='images/cornwall_flag.png' HEIGHT='216' WIDTH='177' style='float:left;'>The domination of Tourism has done Cornwall far more harm than good: Cornish culture has been suppressed, and Cornish workers are among the lowest-paid in Europe.</P><P><A HREF='http://www.guidebookplus.com/mapmybook/?p=447' TARGET='kernow'>GuidebookPlus will not be indexing guidebook locations in Cornwall.</A></P>";}
myMapCanvas=document.getElementById('atlas');var myHeight=(navigator.appName=='Microsoft Internet Explorer')?550:500;document.getElementById("areabooksdialogue").title="GuidebookPlus";$("#areabooksdialogue").dialog({width:600,height:myHeight,position:[((myMapCanvas.offsetLeft+myMapCanvas.offsetWidth)/2)-300,((myMapCanvas.offsetTop+myMapCanvas.offsetHeight)/2)+100-document.body.scrollTop],autoOpen:true,show:'slide',draggable:true,resizable:true,close:function(event,ui){}});$("#areabooksdialogue").dialog('open');}
