$(document).ready(function() {
  $("#map-nsw").css({
		height: 400,
		width: 400
	});
	var myLatLng = new google.maps.LatLng(-35.324124,149.176269);
  MYMAPNSW.init('#map-nsw', myLatLng, 12);
  
		MYMAPNSW.placeMarkers('/accessories/markers-nsw.xml');

});

var MYMAPNSW = {
  map: null,
	bounds: null
}

MYMAPNSW.init = function(selector, latLng, zoom) {
  var myOptions = {
    zoom:zoom,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  this.map = new google.maps.Map($(selector)[0], myOptions);
	this.bounds = new google.maps.LatLngBounds();
}

MYMAPNSW.placeMarkers = function(filename) {
	$.get(filename, function(xml){
		$(xml).find("marker").each(function(){

			var name = $(this).find('name').text();
			var address = $(this).find('address').text();
			var phone = $(this).find('phone').text();


			// create a new LatLng point for the marker
			var lat = $(this).find('lat').text();
			var lng = $(this).find('lng').text();
			var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
			
			// extend the bounds to include the new point
			MYMAPNSW.bounds.extend(point);
			
			var marker = new google.maps.Marker({
				position: point,
				map: MYMAPNSW.map
			});
			
			var infoWindow = new google.maps.InfoWindow();
			var html='<h3>'+name+'</h3<p>'+address+'</p><p>Ph: '+phone+'</p>';
			google.maps.event.addListener(marker, 'click', function() {
				infoWindow.setContent(html);
				infoWindow.open(MYMAPNSW.map, marker);
			});
			MYMAPNSW.map.fitBounds(MYMAPNSW.bounds);
		});
	});
}



$(document).ready(function() {
  $("#map-qld").css({
		height: 400,
		width: 400
	});
	var myLatLng = new google.maps.LatLng(-35.324124,149.176269);
  MYMAPQLD.init('#map-qld', myLatLng, 12);
  
		MYMAPQLD.placeMarkers('/accessories/markers-qld.xml');

});

var MYMAPQLD = {
  map: null,
	bounds: null
}

MYMAPQLD.init = function(selector, latLng, zoom) {
  var myOptions = {
    zoom:zoom,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  this.map = new google.maps.Map($(selector)[0], myOptions);
	this.bounds = new google.maps.LatLngBounds();
}

MYMAPQLD.placeMarkers = function(filename) {
	$.get(filename, function(xml){
		$(xml).find("marker").each(function(){
			var name = $(this).find('name').text();
			var address = $(this).find('address').text();
			var phone = $(this).find('phone').text();
			
			// create a new LatLng point for the marker
			var lat = $(this).find('lat').text();
			var lng = $(this).find('lng').text();
			var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
			
			// extend the bounds to include the new point
			MYMAPQLD.bounds.extend(point);
			
			var marker = new google.maps.Marker({
				position: point,
				map: MYMAPQLD.map
			});
			
			var infoWindow = new google.maps.InfoWindow();
			var html='<h3>'+name+'</h3<p>'+address+'</p><p>Ph: '+phone+'</p>';
			google.maps.event.addListener(marker, 'click', function() {
				infoWindow.setContent(html);
				infoWindow.open(MYMAPQLD.map, marker);
			});
			MYMAPQLD.map.fitBounds(MYMAPQLD.bounds);
		});
	});
}



$(document).ready(function() {
  $("#map-sa").css({
		height: 400,
		width: 400
	});
	var myLatLng = new google.maps.LatLng(-34.920335,138.618042);
  MYMAPSA.init('#map-sa', myLatLng, 12);
  
		MYMAPSA.placeMarkers('/accessories/markers-sa.xml');

});

var MYMAPSA = {
  map: null,
	bounds: null
}

MYMAPSA.init = function(selector, latLng, zoom) {
  var myOptions = {
    zoom:zoom,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  this.map = new google.maps.Map($(selector)[0], myOptions);
	this.bounds = new google.maps.LatLngBounds();
}

MYMAPSA.placeMarkers = function(filename) {
	$.get(filename, function(xml){
		$(xml).find("marker").each(function(){
			var name = $(this).find('name').text();
			var address = $(this).find('address').text();
			var phone = $(this).find('phone').text();
			
			// create a new LatLng point for the marker
			var lat = $(this).find('lat').text();
			var lng = $(this).find('lng').text();
			var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
			
			// extend the bounds to include the new point
			MYMAPSA.bounds.extend(point);
			
			var marker = new google.maps.Marker({
				position: point,
				map: MYMAPSA.map
			});
			
			var infoWindow = new google.maps.InfoWindow();
			var html='<h3>'+name+'</h3<p>'+address+'</p><p>Ph: '+phone+'</p>';
			google.maps.event.addListener(marker, 'click', function() {
				infoWindow.setContent(html);
				infoWindow.open(MYMAPSA.map, marker);
			});
			MYMAPSA.map.fitBounds(MYMAPSA.bounds);
		});
	});
}



$(document).ready(function() {
  $("#map-vic").css({
		height: 400,
		width: 400
	});
	var myLatLng = new google.maps.LatLng(-37.938444,145.002129);
  MYMAPVIC.init('#map-vic', myLatLng, 11);
  
		MYMAPVIC.placeMarkers('/accessories/markers-vic.xml');

});

var MYMAPVIC = {
  map: null,
	bounds: null
}

MYMAPVIC.init = function(selector, latLng, zoom) {
  var myOptions = {
    zoom:zoom,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  this.map = new google.maps.Map($(selector)[0], myOptions);
	this.bounds = new google.maps.LatLngBounds();
}

MYMAPVIC.placeMarkers = function(filename) {
	$.get(filename, function(xml){
		$(xml).find("marker").each(function(){
			var name = $(this).find('name').text();
			var address = $(this).find('address').text();
			var phone = $(this).find('phone').text();
			
			// create a new LatLng point for the marker
			var lat = $(this).find('lat').text();
			var lng = $(this).find('lng').text();
			var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
			
			// extend the bounds to include the new point
			MYMAPVIC.bounds.extend(point);
			
			var marker = new google.maps.Marker({
				position: point,
				map: MYMAPVIC.map
			});
			
			var infoWindow = new google.maps.InfoWindow();
			var html='<h3>'+name+'</h3<p>'+address+'</p><p>Ph: '+phone+'</p>';
			google.maps.event.addListener(marker, 'click', function() {
				infoWindow.setContent(html);
				infoWindow.open(MYMAPVIC.map, marker);
			});
			MYMAPVIC.map.fitBounds(MYMAPVIC.bounds);
		});
	});
}


$(document).ready(function() {
  $("#map-wa").css({
		height: 400,
		width: 400
	});
	var myLatLng = new google.maps.LatLng(-31.94823,115.839565);
  MYMAPWA.init('#map-wa', myLatLng, 12);
  
		MYMAPWA.placeMarkers('/accessories/markers-wa.xml');

});

var MYMAPWA = {
  map: null,
	bounds: null
}

MYMAPWA.init = function(selector, latLng, zoom) {
  var myOptions = {
    zoom:zoom,
    center: latLng,
    mapTypeId: google.maps.MapTypeId.ROADMAP
  }
  this.map = new google.maps.Map($(selector)[0], myOptions);
	this.bounds = new google.maps.LatLngBounds();
}

MYMAPWA.placeMarkers = function(filename) {
	$.get(filename, function(xml){
		$(xml).find("marker").each(function(){
			var name = $(this).find('name').text();
			var address = $(this).find('address').text();
			var phone = $(this).find('phone').text();
			
			// create a new LatLng point for the marker
			var lat = $(this).find('lat').text();
			var lng = $(this).find('lng').text();
			var point = new google.maps.LatLng(parseFloat(lat),parseFloat(lng));
			
			// extend the bounds to include the new point
			MYMAPWA.bounds.extend(point);
			
			var marker = new google.maps.Marker({
				position: point,
				map: MYMAPWA.map
			});
			
			var infoWindow = new google.maps.InfoWindow();
			var html='<h3>'+name+'</h3<p>'+address+'</p><p>Ph: '+phone+'</p>';
			google.maps.event.addListener(marker, 'click', function() {
				infoWindow.setContent(html);
				infoWindow.open(MYMAPWA.map, marker);
			});
			MYMAPWA.map.fitBounds(MYMAPWA.bounds);
		});
	});
}
