
var map;
var tooltip;
var gdir;
var gmarkers=[];
var i=0;
var sidebar_html="";
var zoom = 7;
var maptype = G_NORMAL_MAP;
var latitude= 45.33284;
var longitude= -62.935181;
var service;

//Append to URL to link directly to custom lat/lng, zoom, maptype and service type
     // skip the first character, we are not interested in the "?"
      var query = location.search.substring(1);
      // split the rest at each "&" character to give a list of  "argname=value"  pairs
      var pairs = query.split("&");
      for (var i=0; i<pairs.length; i++) {
        // break each pair at the first "=" to obtain the argname and value
    var pos = pairs[i].indexOf("=");
    var argname = pairs[i].substring(0,pos).toLowerCase();
    var value = pairs[i].substring(pos+1).toLowerCase();
        if (argname == "lat") {latitude = parseFloat(value);}
        if (argname == "lng") {longitude = parseFloat(value);}
        if (argname == "zoom") {zoom = parseInt(value);}
        if (argname == "type") {
          if (value == "normal") {maptype = G_NORMAL_MAP;}
          if (value == "sat") {maptype = G_SATELLITE_MAP;}
          if (value == "hybrid") {maptype = G_HYBRID_MAP;}
        }
        if (argname == "service") {
        
            if (value == "access") {service =  "blue";}
            // /snsmr/scripts/1200.htm - /snsmr/img/icons/mm_20_blue.png
        
            if (value == "business") {service =  "purple";}
            // /snsmr/scripts/1201.htm - /snsmr/img/icons/mm_20_purple.png
        
            if (value == "consumer") {service =  "white";}
            // /snsmr/scripts/1202.htm - /snsmr/img/icons/mm_20_white.png
        
            if (value == "debt") {service =  "gray";}
            // /snsmr/scripts/1204.htm - /snsmr/img/icons/mm_20_gray.png
        
            if (value == "driver") {service =  "yellow";}
            // /snsmr/scripts/1205.htm - /snsmr/img/icons/mm_20_yellow.png
        
            if (value == "land") {service =  "green";}
            // /snsmr/scripts/1203.htm - /snsmr/img/icons/mm_20_green.png
        
            if (value == "map") {service =  "darkgreen";}
            // /snsmr/scripts/1206.htm - /snsmr/img/icons/mm_20_darkgreen.png
        
            if (value == "resten") {service =  "brown";}
            // /snsmr/scripts/1209.htm - /snsmr/img/icons/mm_20_brown.png
        
            if (value == "rjsc") {service =  "orange";}
            // /snsmr/scripts/1207.htm - /snsmr/img/icons/mm_20_orange.png
        
            if (value == "rmv") {service =  "red";}
            // /snsmr/scripts/1208.htm - /snsmr/img/icons/mm_20_red.png
        
            if (value == "tax") {service =  "pink";}
            // /snsmr/scripts/1210.htm - /snsmr/img/icons/mm_20_pink.png
        
            if (value == "vital") {service =  "ltblue";}
            // /snsmr/scripts/1211.htm - /snsmr/img/icons/mm_20_lightblue.png
        
      }
      }
var icons=new Array();
icons["red"]=new GIcon();
icons["red"].image="/snsmr/img/icons/mm_20_red.png";
icons["red"].shadow="/snsmr/img/icons/mm_20_shadow.png";
icons["red"].iconSize=new GSize(12,20);
icons["red"].shadowSize=new GSize(22,20);
icons["red"].iconAnchor=new GPoint(6,20);
icons["red"].infoWindowAnchor=new GPoint(5,1);
icons["red"].imageMap=[4,0,0,4,0,7,3,11,4,19,7,19,8,11,11,7,11,4,7,0];
icons["red"].transparent="/snsmr/img/icons/mm_20_transparent.png";
function get_icon(_1){
if((typeof (_1)=="undefined")||(_1==null)){
_1="red";
}
if(!icons[_1]){
icons[_1]=new GIcon(icons["red"]);
icons[_1].image="/snsmr/img/icons/mm_20_"+_1+".png";
}
return icons[_1];
}
function load(){
if(GBrowserIsCompatible()){
var om=new OverlayMessage(document.getElementById("map"));
om.Set("<p><strong>Loading map data, please wait...</strong> </p>");
map=new GMap2(document.getElementById("map"));
        var customUI = map.getDefaultUI();
        customUI.controls.maptypecontrol = false;
        customUI.controls.menumaptypecontrol = true;
        customUI.zoom.scrollwheel = false;
        map.setUI(customUI);      
        map.setCenter(new GLatLng(latitude,longitude), zoom, maptype, service);
gdir=new GDirections(map,document.getElementById("directions"));
var _3=[];
_3[G_GEO_SUCCESS]="Success";
_3[G_GEO_MISSING_ADDRESS]="Missing Address: The address was either missing or had no value.";
_3[G_GEO_UNKNOWN_ADDRESS]="Unknown Address:  No corresponding geographic location could be found for the specified address.";
_3[G_GEO_UNAVAILABLE_ADDRESS]="Unavailable Address:  The geocode for the given address cannot be returned due to legal or contractual reasons.";
_3[G_GEO_BAD_KEY]="Bad Key: The API key is either invalid or does not match the domain for which it was given";
_3[G_GEO_TOO_MANY_QUERIES]="Too Many Queries: The daily geocoding quota for this site has been exceeded.";
_3[G_GEO_SERVER_ERROR]="Server error: The geocoding request could not be successfully processed.";
_3[G_GEO_BAD_REQUEST]="A directions request could not be successfully parsed.";
_3[G_GEO_MISSING_QUERY]="No query was specified in the input.";
_3[G_GEO_UNKNOWN_DIRECTIONS]="Missing Address: The address was either missing or had no value.";
GEvent.addListener(gdir,"error",function(){
var _4=gdir.getStatus().code;
var _5="Code "+_4;
if(_3[_4]){
_5=_3[_4];
}
alert("Failed to obtain directions, "+_5);
});
var mt=map.getMapTypes();
for(var i=0;i<mt.length;i++){
mt[i].getMinimumResolution=function(){
return 7;
};
mt[i].getMaximumResolution=function(){
return 17;
};
}
tooltip=document.createElement("div");
map.getPane(G_MAP_FLOAT_PANE).appendChild(tooltip);
tooltip.style.visibility="hidden";
GEvent.addListener(map,"move",function(){
checkBounds();
});
var _8=new GLatLngBounds(new GLatLng(42.873951,-66.714478),new GLatLng(48.868328,-58.112183));
function checkBounds(){
if(_8.contains(map.getCenter())){
return;
}
var C=map.getCenter();
var X=C.lng();
var Y=C.lat();
var _c=_8.getNorthEast().lng();
var _d=_8.getNorthEast().lat();
var _e=_8.getSouthWest().lng();
var _f=_8.getSouthWest().lat();
if(X<_e){
X=_e;
}
if(X>_c){
X=_c;
}
if(Y<_f){
Y=_f;
}
if(Y>_d){
Y=_d;
}
map.setCenter(new GLatLng(Y,X));
}
GDownloadUrl("/snsmr/xml/locations.xml",function(_10){
var xml=GXml.parse(_10);
var _12=xml.documentElement.getElementsByTagName("marker");
for(var i=0;i<_12.length;i++){
var _14=_12[i].getAttribute("name");
var _15=_12[i].getAttribute("address");
var _16=_12[i].getAttribute("service");
var _17=_12[i].getAttribute("icon");
var _18=_12[i].getAttribute("details");
var _19=_12[i].getAttribute("phone");
var _1a=_12[i].getAttribute("hours");
var lat=_12[i].getAttribute("lat");
var lng=_12[i].getAttribute("lng");
var _1d=new GLatLng(parseFloat(_12[i].getAttribute("lat")),parseFloat(_12[i].getAttribute("lng")));
var _1e=createTabbedMarker(_1d,_14,_17,_15,_18,_16,_19,_1a);
map.addOverlay(_1e);
     
if(_17=="blue"){
_1e.show();
document.getElementById("service-type").selectedIndex=1;
}
else{
_1e.hide();
}
}
om.Clear();
$('p.clearDirections').hide();

///snsmr/scripts/1200.htm
    if (service == "blue"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=1;
        }
    }
///snsmr/scripts/1201.htm
    if (service == "purple"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=2;
        }
    }
///snsmr/scripts/1202.htm
    if (service == "white"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=3;
        }
    }
///snsmr/scripts/1204.htm
    if (service == "gray"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=4;
        }
    }
///snsmr/scripts/1205.htm
    if (service == "yellow"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=5;
        }
    }
///snsmr/scripts/1203.htm
    if (service == "green"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=6;
        }
    }
///snsmr/scripts/1206.htm
    if (service == "darkgreen"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=7;
        }
    }
///snsmr/scripts/1209.htm
    if (service == "brown"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=10;
        }
    }
///snsmr/scripts/1207.htm
    if (service == "orange"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=8;
        }
    }
///snsmr/scripts/1208.htm
    if (service == "red"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=9;
        }
    }
///snsmr/scripts/1210.htm
    if (service == "pink"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=11;
        }
    }
///snsmr/scripts/1211.htm
    if (service == "ltblue"){
        for(var i=0;i<gmarkers.length;i++){
            if(gmarkers[i].icon==service){
            gmarkers[i].show();
            }else{
            gmarkers[i].hide();
            } document.getElementById("service-type").selectedIndex=12;
        }
    }

makeSidebar();
});
}else{
alert("Sorry, the Google Maps API is not compatible with this browser");
}
}
function toggleGroup(opt){
    service=opt;
map.closeInfoWindow();
gdir.clear();
$('p.clearDirections').hide();
map.setCenter(new GLatLng(45.33284,-62.935181),7);
for(var i=0;i<gmarkers.length;i++){
if(gmarkers[i].icon==opt){
gmarkers[i].show();
}else{
gmarkers[i].hide();
}
}
makeSidebar();
 
}

function makeSidebar(){
sidebar_html="";
sidebar_html="<select onChange=\"handleSelected(this.options[this.selectedIndex].value)\">"+"<option selected=\"selected\"> - Select a location - </option>";
for(var i=0;i<gmarkers.length;i++){
if(!gmarkers[i].isHidden()){
sidebar_html+="<option value=\""+i+"\">"+gmarkers[i].name+"</option>";
}
}
sidebar_html+="</select>";
document.getElementById("sidebar").innerHTML=sidebar_html;
}
function handleSelected(opt){
var i=opt;
gdir.clear();
if(i>-1){
GEvent.trigger(gmarkers[i],"click");
}else{
map.closeInfoWindow();
}
}
function mymouseover(i){
showTooltip(gmarkers[i]);
}
function mymouseout(){
tooltip.style.visibility="hidden";
}
function showTooltip(_25){
tooltip.innerHTML=_25.tooltip;
var _26=map.getCurrentMapType().getProjection().fromLatLngToPixel(map.fromDivPixelToLatLng(new GPoint(0,0),true),map.getZoom());
var _27=map.getCurrentMapType().getProjection().fromLatLngToPixel(_25.getPoint(),map.getZoom());
var _28=_25.getIcon().iconAnchor;
var _29=_25.getIcon().iconSize.width;
var _2a=tooltip.clientHeight;
var pos=new GControlPosition(G_ANCHOR_TOP_LEFT,new GSize(_27.x-_26.x-_28.x+_29,_27.y-_26.y-_28.y-_2a));
pos.apply(tooltip);
tooltip.style.visibility="visible";
}
function resetMap(){
map.closeInfoWindow();
gdir.clear();
map.setCenter(new GLatLng(45.33284,-62.935181),7);
}
function getDirections(){
var _2c=document.getElementById("saddr").value;
var _2d=document.getElementById("daddr").value;
gdir.load("from: "+_2c+" to: "+_2d,{"locale":"en"});
map.closeInfoWindow();
}
//Function to clear text from Directions input box
    function clearDefault(el) {
  if (el.defaultValue==el.value) el.value = ""
}

    
               
function createTabbedMarker(_2e,_2f,_30,_31,_32,_33,_34,_35){
var _36;
if(_30){
_36=new GMarker(_2e,get_icon(_30));
}else{
_36=new GMarker(_2e);
}
_36.name=_2f;
_36.icon=_30;
_36.service=_33;
gmarkers.push(_36);
var _37="<div class='infoWindow' ><h2>"+_2f+"</h2> <table ><tr><td valign='top'><strong>Service: </strong></td><td><h4>"+_33+"</h4></td></tr><td valign='top'><strong>Address:  </strong></td><td> "+_31+"</td></tr> <td valign='top'><strong>Phone: </strong></td><td>"+_34+"</td></tr><td valign='top'> <strong>Hours: </strong></td><td>"+_35+"</td></tr></table>"+"<p class='directions'><strong>Get directions to this office:</strong><br /><form action='javascript:getDirections()'>"+"<input type='text' size='35' maxlength='40' name='saddr' id='saddr' value='Enter your starting address...' onfocus='clearDefault(this)' class='input'/>&nbsp;"+"<input value='Go' type='submit' onclick='javascript:$(\"p.clearDirections\").show();' />"+"<input type='hidden' id='daddr' value='"+_2f+" - "+_33+"@"+_2e.lat()+","+_2e.lng()+"'/></form></p>"+"<p class='details'><a href='"+_32+"'><strong>more information &raquo; </a> </strong></p>"+"<p class='zoom'><a href='#zoominlink' onclick='javascript:map.setZoom(15); return false;'><strong>Zoom In</strong></a>&nbsp;&nbsp; |&nbsp;&nbsp;"+"<a href='#resetMap' onclick='javascript:resetMap(); return false;'><strong>Reset Map</strong></a> </p></div>";
GEvent.addListener(_36,"click",function(){
_36.openInfoWindowTabsHtml([new GInfoWindowTab("Address",_37)]);
});
_36.tooltip="<div class='tooltip' style='overflow: visible'>"+_2f+"</div>";
GEvent.addListener(_36,"mouseover",function(){
showTooltip(_36);
});
GEvent.addListener(_36,"mouseout",function(){
tooltip.style.visibility="hidden";
});
return _36;
}