// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function toggle_group(parent, group){
  if(Element.visible(group)){
	Effect.BlindUp(group, {duration:0.3});
	Element.removeClassName(parent, 'open');	
  }
  else{
	Effect.BlindDown(group, {duration:0.3});
	Element.addClassName(parent, 'open');
  }
}

function show_map(map)
{	
  var map = new GMap2(document.getElementById("google_map"));
}

var map;
var stores = new Array;

function load() {
  if (GBrowserIsCompatible()) {
    cranbourne = new GLatLng(-38.099157,145.283155);
    mornington = new GLatLng(-38.230853,145.045774);
	//springvale = new GLatLng(-37.930185,145.151528);       
	springvale = new GLatLng(-37.886157,145.283088); //nah, this is really ferntree gully
	pakenham = new GLatLng(-38.063173,145.460967);
	stores.push(cranbourne);
	stores.push(mornington);
	stores.push(springvale);
	stores.push(pakenham);
	
    map = new GMap2(document.getElementById("google_map"));
    map.enableContinuousZoom();
    map.enableScrollWheelZoom()
    map.addControl(new GSmallMapControl());
    centerMap();
    for(i = 0; i < stores.length; i ++){
       map.addOverlay(new GMarker(stores[i]));
	}
    
    //(-38.06214867215861, 145.24200439453125)
  }
}

function centerMap()
{
  map.setCenter(new GLatLng(-38.06214867215861, 145.24200439453125), 10);
}

function pan(store)
{
   if(map.getZoom() == 15){
     centerMap();	
   }

   map.panTo(stores[store]);
   //map.setZoom(15);
   window.setTimeout(function() {
     map.setZoom(15);
   }, 1000);
}

function zoomIn()
{
  map.setZoom(map.getZoom() + 1);
}

function zoomOut()
{
  map.setZoom(map.getZoom() - 1);
}

function showCentre(){
	alert(map.getCenter());
}