//<![CDATA[
if (GBrowserIsCompatible()) {
//Creates an instance of a GMarker
function createMarker(point,htmlContent,icon){	
	var g=(icon)?new GMarker(point,icon):new GMarker(point);
	GEvent.addListener(g,'click',function(){g.openInfoWindowHtml(htmlContent);map.panTo(new GLatLng(point.y,point.x));});
	return g;						
}
//Creates the source marker
function addSourceMarker(point,infoWindowHTML,icon){
	if(src){map.removeOverlay(src);src=null;}
	src=createMarker(point,infoWindowHTML,icon);
	map.addOverlay(src);			
}
function unload(){GUnload();markers=null;src=null;map=null;}
//used by the list view to focus the map on a particular point.
function focusLocation(index){changeView('map');GEvent.trigger(markers[index],'click');}
// switches between list and map view.
function changeView(type) {
	switch(String(type)) {
	case"map":
	$('map').show();
	$('map-list').hide();
	$('tab-map').setAttribute("class","view-tab-selected");$('tab-map').className="view-tab-selected";
	$('tab-list').setAttribute("class","view-tab");$('tab-list').className="view-tab";
	$('result-tabs-map').setAttribute("class","tab-item-selected");$('result-tabs-map').className="tab-item-selected";
	$('result-tabs-list').setAttribute("class","tab-item");$('result-tabs-list').className="tab-item";  
	if($('maplegend')) $('maplegend').show();
	if($('hints')) {		
		$('hints').removeClassName('topelement');
		var ulist = $('hints-list').getElementsByTagName("li");
		for(var i=0;i<ulist.length;i++) {
			var li = $(ulist[i]);
			var className=new String(li.className);
			if(className=='listhint'){
				li.hide();
			}else{
				li.show();
			}
		}
	}
	break;
	case "list":
	$('map').hide();
	$('map-list').show();
	$('tab-map').setAttribute("class","view-tab");$('tab-map').className="view-tab";
	$('tab-list').setAttribute("class","view-tab-selected");$('tab-list').className="view-tab-selected";
	$('result-tabs-map').setAttribute("class","tab-item");$('result-tabs-map').className="tab-item";
	$('result-tabs-list').setAttribute("class","tab-item-selected");$('result-tabs-list').className="tab-item-selected";
	if($('maplegend')) $('maplegend').hide();
	if($('hints')) {
		$('hints').addClassName('topelement');
		var ulist = $('hints-list').getElementsByTagName("li");
		for(var i=0;i<ulist.length;i++){
			var li = $(ulist[i]);
			var className=li.className;
			if(className=='maphint'){
				li.hide();
			}else{
				li.show();
			}
		}
	}
	break;
	}
}
//Loads map for repairshops/glassexpress
function loadMap(){		
	map=new GMap2($('map'));
	map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());	
	map.addControl(new GScaleControl());
	map.enableContinuousZoom();
	var address=loc.location+" Canada";
	var geocoder=new GClientGeocoder();
	geocoder.getLatLng(address,function(point){	
		if(point){
			// center the map to the location
			loc.x=point.x;loc.y=point.y;	
			map.setCenter(new GLatLng(loc.y, loc.x), parseInt(settings.zLevel));
			addSourceMarker(point, sMarker.html, sMarker.icon);
			getPoints();			
			if(settings.defaultview=="list"){changeView('list');}
		}
		else{
			alert("Unable to find the address you entered. \n\n Try the following: \n\n * Remember to include your CITY in the address \n * Check your spelling \n * For numbered streets enter '49' instead of '49th' \n * Try entering your city only \n\n Click 'BACK' on your browser and re-enter a new address.");
			map.setCenter(new GLatLng(loc.y, loc.x), parseInt(settings.zLevel));
			if($('loader')){$('loader').style.display="none";}
		}
	});
}
}
//]]>