/*   UoA campuses and maps,  googlemap api script */

// an associative array to hold marker points and info window data
var campuses = {
    'roseworthy': {
	  lat: -34.5284,
	  lng: 138.688,
	  scale: 9,
	  name: 'Roseworthy',
	  icon: "B",
	  info: "<div style='width:300px'><h2>Roseworthy Campus</h2><p>Roseworthy is an internationally renowned centre for excellence in dryland agriculture and animal production. With a range of government and corporate partners, the campus is home to a number of collaborative centres.</p><a href='/campuses/roseworthy/'>Detailed information.</a></div>"
	},
	 'waite': {
	  lat: -34.96805,
	  lng: 138.6355,
	  scale: 12,
	 name: 'waite',
	 icon: "C",
	  info: "<div style='width:300px'><h2>The Waite Campus</h2><p>The internationally renowned Waite campus encompasses the largest agricultural research complex in the Southern Hemisphere. The Waite is home to several Cooperative Research Centres established with government and industry partners.</p><a href='/campuses/waite/'>Detailed information.</a></div>"
	},
	'thebarton': {
	  lat: -34.91127,
	  lng: 138.57341,
	  scale: 13,
	 name: 'thebarton',
	 icon: "D",
	  info: "<div style='width:300px'><h2>Thebarton Campus</h2><p>Thebarton campus is one of the premier University owned technology/research parks in Australia. Within its business incubator, graduates have the chance to develop their skills with some of the country's most innovative companies.</p><a href='/campuses/thebarton/'>Detailed information.</a></div>"
	},
	'singapore': {
	  lat: 1.295488,
	  lng: 103.843426,
	  scale: 10,
	 name: 'singapore',
	 icon: "E",
	  info: "<div style='width:300px'><h2>Singapore</h2><p>The University of Adelaide - Singapore Ngee Ann-Adelaide Education Centre (NAAEC) offers undergraduate and postgraduate academic programs. The vision is to create a regional learning centre of excellence, providing high quality education programs.</p><a href='http://www.adelaide.edu.au/sg/'>Detailed information.</a></div>"
	},
	'winecentre': {
	  lat: -34.9197,
	  lng: 138.614,
	  scale: 14,
	  name: 'winecentre',
	  icon: "F",
	  info: "<div style='width:300px'><h2>The National Wine Centre</h2><p>The National Wine Centre of Australia is an education hub for tourists, the general public and full time students. As well as a teaching centre for wine-related academic programs, it showcases the entire Australian wine industry in an exhibition.</p><a href='http://www.wineaustralia.com.au/'>Detailed information.</a></div>"
	},
	 'northterrace': {
	  lat: -34.91993,
	  lng: 138.60420,
	  scale: 15,
	  name: 'North Terrace',
	  icon: "A",
	  info: "<div style='width:300px'><h2>North Terrace Campus</h2><p>The University of Adelaide's main campus is the site of most teaching and research facilities. Set in the cultural heart of the city, the University offers excellence in its educational and social facilities.</p><a href='/campuses/northtce/'>Campus map and detailed information.</a></div>"
	}
}


// function with two arguments
function map_goto(campus_name) {

    // sets campus to equal the hash lookup
	var campus = campuses[campus_name];

	// set 'spot' to equal a latLing object based on values in the hash lookup;
	var spot = new google.maps.LatLng(campus['lat'], campus['lng']);

	// centre map at latlng and scale required;
    map.setCenter(spot, campus['scale']);

	// hash lookup for icon
	var icon = new GIcon();
    icon.image = "http://www.adelaide.edu.au/global/images/icons/gmaps/kml/university.png";
    icon.shadow = "http://www.adelaide.edu.au/global/images/icons/gmaps/kml/shadow-university.png";
    icon.iconSize = new GSize(32.0, 37.0);
    icon.shadowSize = new GSize(51.0, 37.0);
    icon.iconAnchor = new GPoint(16.0, 18.0);
    icon.infoWindowAnchor = new GPoint(15, 6);

	// create a new marker at the required latlng and requred display options
	var marker = new GMarker(spot, icon);

    //display the marker as an overlay
	map.addOverlay(marker);

	// display a marker my default - in this case the last one in the hash.
	var campinfo = campus['info'];
	marker.openInfoWindow(campinfo);

	// assocaiate a listener function to the marker to display info window onclick
	GEvent.addListener(marker, "click", function() {
	  marker.openInfoWindow(campinfo);
	})
  }

