// THIS CODE (C) 2007 DAN PROTHERO and FOG CITY RECORDS. ALL RIGHTS RESERVED. DO NOT REPRODUCE.
// contact: dan@fogcityrecords.com

    //<![CDATA[

var inxt=new GIcon();inxt.image="/images/mapredblink.gif";inxt.iconSize=new GSize(18,18);inxt.iconAnchor=new GPoint(9,9);inxt.infoWindowAnchor=new GPoint(9,9);var ipst=new GIcon();ipst.image="/images/mapgrey.png";ipst.iconSize=new GSize(11,11);ipst.iconAnchor=new GPoint(5,5);ipst.infoWindowAnchor=new GPoint(5,5);var icong=new GIcon();icong.image="/images/mapred.png";icong.iconSize=new GSize(15,15);icong.iconAnchor=new GPoint(7,7);icong.infoWindowAnchor=new GPoint(7,10);var map;var nextSL;var nextSM;var mLat;var mLon;var markerTime;var mHTML="";var mType="";var gs;var om;var now=new Date();var unixtime=((now.getTime())/1000)-(now.getTimezoneOffset()*60);OverlayMessage=function(container){var parent=container.parentNode;var wrapper=document.createElement('div');wrapper.style.cssText=container.style.cssText;parent.insertBefore(wrapper,container);parent.removeChild(container);wrapper.appendChild(container);container.style.cssText='position: relative; width: 100%; height: 100%;';this.overlay=document.createElement('div');wrapper.appendChild(this.overlay);this.visibleStyle='color:#000; font-weight:bold; font-style:italic; position:relative; top:-62%; background-color:#eee; width:180px; text-align:center; margin-left:auto; margin-right:auto; padding:1em; border:1px solid #222; z-index:100; opacity:.80; filter:alpha(opacity=80);';this.overlay.style.cssText=this.invisibleStyle;};OverlayMessage.prototype.Update=function(message,percent){this.overlay.innerHTML=message+'<br><div class="prog-border"><div class="prog-bar" style="width:'+percent+'%;">&nbsp;<\/div><div class="prog-text">'+percent+'&#37;</div><\/div>';};OverlayMessage.prototype.Set=function(message){this.overlay.style.cssText=this.visibleStyle;this.overlay.innerHTML=message;};OverlayMessage.prototype.Clear=function(){this.overlay.style.cssText='display: none;';};function regionSelected(sel)
{if(!GBrowserIsCompatible())return;switch(sel)
{case"SE":map.closeInfoWindow();map.setCenter(new GLatLng(33.31,-89.17),5);break;case"NE":map.closeInfoWindow();map.setCenter(new GLatLng(40.59,-83.13),5);break;case"NW":map.closeInfoWindow();map.setCenter(new GLatLng(43.48,-110.76),5);break;case"SW":map.closeInfoWindow();map.setCenter(new GLatLng(38.74,-108.07),5);break;case"USA":map.closeInfoWindow();map.setCenter(new GLatLng(38.84,-97.61),4);break;case"EUROPE":map.closeInfoWindow();map.setCenter(new GLatLng(50.83,4.33),5);break;case"NEXT":map.setCenter(nextSL,6);GEvent.trigger(nextSM,"click");break;}}
function cR(map,pts,n)
{switch(n%6){case 1:clr="#0000ff";break;case 2:clr="#008080";break;case 3:clr="#800080";break;case 4:clr="#008000";break;case 5:clr="#804000";break;default:clr="#ff00ff";}
map.addOverlay(new GPolyline(pts,clr,5,.4));}
function aM(point,num,markerLoc,mType,mHTML)
{if((nextSL!=undefined)&&(nextSL.x==point.x)&&(nextSL.y==point.y))
{mType="NEXT";if(nextSL!=undefined)delete nextSM;}
var thisicon;if(mType=="PAST")thisicon=ipst;else if(mType=="NEXT")thisicon=inxt;else
{icong.image="/images/mapred"+num+".png";thisicon=icong;}
mHTML="<ul>"+mHTML+"</ul>";if(mType=="NEXT")
{nextSL=point;nextSM=cM(point,thisicon,markerLoc,mHTML);map.addOverlay(nextSM);}
else map.addOverlay(cM(point,thisicon,markerLoc,mHTML));}
function cM(point,icon,mLoc,mHTML)
{var marker=new GMarker(point,{icon:icon,clickable:true,title:mLoc});var htm="<div class='mapPopup'><h3>"+mLoc+"</h3>"+mHTML+"</div>";GEvent.addListener(marker,"click",function(){marker.openInfoWindowHtml(htm);return marker;});return marker;}
function pP()
{var mRoute=1;var mNum=0;var markerLoc="";var points=new Array();points=[];var point;for(var i=0;i<gs.length;i++)
{var g=gs[i];if(g.getAttribute("city").length==0)continue;var loc=g.getAttribute("city")+", "+g.getAttribute("state");if((markerLoc!="")&&(markerLoc!=loc))
{point=new GLatLng(parseFloat(mLat),parseFloat(mLon));points.push(point);markerLoc="";}
if(g.getAttribute("route")!=mRoute)
{if(points.length>1)
cR(map,points,mRoute);points=[];}
if(markerLoc=="")
{mLat=g.getAttribute("lat");mLon=g.getAttribute("lng");markerLoc=g.getAttribute("city")+", "+g.getAttribute("state");}
var diff=g.getAttribute("timestamp")-unixtime;if((diff>-11000)&&(nextSL==undefined))
{point=new GLatLng(mLat,mLon);aM(point,0,markerLoc,"NEXT","");}
mRoute=g.getAttribute("route");if(i>=(gs.length-1))
{if(markerLoc!="")
{point=new GLatLng(parseFloat(mLat),parseFloat(mLon));points.push(point);}
if(points.length>1)
cR(map,points,mRoute);}}

if (nextSL != undefined) {
var bounds = map.getBounds();
if (bounds.contains (nextSL) == false)
	map.setCenter(nextSL, 5);
}

window.setTimeout("pM(0,0,'');",50);}
function pM(start,mNum,markerLoc)
{var end=Math.min(start+15,gs.length);for(var i=start;i<end;i++)
{var g=gs[i];if(g.getAttribute("city").length==0)continue;var loc=g.getAttribute("city")+", "+g.getAttribute("state");if((markerLoc!="")&&(markerLoc!=loc))
{var point=new GLatLng(parseFloat(mLat),parseFloat(mLon));aM(point,++mNum,markerLoc,mType,mHTML);mType="";mHTML="";markerLoc="";}
if(markerLoc=="")
{mLat=g.getAttribute("lat");mLon=g.getAttribute("lng");markerLoc=g.getAttribute("city")+", "+g.getAttribute("state");markerTime=g.getAttribute("timestamp");}
var diff=g.getAttribute("timestamp")-unixtime;if(diff<-11000)
mType="PAST";else if(nextSL==undefined)
mType="NEXT";mHTML+="<li><strong>"+g.getAttribute("date")+"</strong>";if((g.getAttribute("venueURL").length>0)&&(g.getAttribute("venue").indexOf("href=")==-1))
mHTML+='<br><strong><a href="'+g.getAttribute("venueURL")+'" target="_blank">'+g.getAttribute("venue")+'</a></strong>';else
mHTML+="<br><strong>"+g.getAttribute("venue")+"</strong>";if(g.getAttribute("address").length>0)
{mHTML+="<br>"+g.getAttribute("address");mHTML+=' <em>(<a href="http://maps.google.com/maps?f=q&hl=en&q='+escape(g.getAttribute("address")+',+'+markerLoc)+'" target="_blank">map</a>)</em>';}
if(g.getAttribute("phone").length>0)mHTML+="<br>"+g.getAttribute("phone");if(g.getAttribute("description").length>0)mHTML+="<br>"+g.getAttribute("description");mHTML+="</li>";if((i>=(gs.length-1))&&(markerLoc!=""))
{var point=new GLatLng(parseFloat(mLat),parseFloat(mLon));aM(point,++mNum,markerLoc,mType,mHTML);}}
om.Update('LOADING TOUR ROUTE',Math.round(i*100/gs.length));if(end<gs.length)
window.setTimeout("pM("+end+","+mNum+",'"+markerLoc+"');",5);else
{om.Clear();map.addControl(new GSmallMapControl());map.addControl(new GMapTypeControl());map.enableContinuousZoom();map.getContainer().style.background='url(null)';}}
function loadMap(xmlFilename)
{if(!GBrowserIsCompatible())
{var mapdiv=document.getElementById("map");mapdiv.innerHTML="<center><br><br><br><br><br><br><br>Cannot display tour map on your browser.<\/center><br />";return;}
map=new GMap2(document.getElementById("map"));map.setCenter(new GLatLng(38.75,-97.5),4);lR=function(data,responseCode)
{var xml=GXml.parse(data);gs=xml.documentElement.getElementsByTagName("marker");window.setTimeout("pP();",10);}
om=new OverlayMessage(document.getElementById('map'));om.Set('LOADING TOUR ROUTE<br>');GDownloadUrl("../blog/geocodes.xml",lR);}

//]]>
