﻿//  FileName:   Global.js
//   Created:   2008-00-00;
//  Modified:   0000-00-00;
//Descrition:   This is the global javascript file.
//    Notice:   This script was purpose written by Professional Web Pages. 
//              Copyright 2008 Professional Web Pages.



 
 
 
//START - Window Onload
window.onload = load;
function load()
    {
        GoogleMap();
    }
//END - Window Onload
//START - Window OnUnload
window.onunload = unload;
function unload()
    {
        GUnload(); // Google Maps Memory Leakage Fix
    }
//END - Window Onload

  

//START - Home Page Image Information Scripts
function jsHideHomePage()
    { 
        document.getElementById("CntHomePagePromotions").style.display      = "none"; 
        document.getElementById("CntHomePageTestimonials").style.display    = "none"; 
        document.getElementById("CntHomePageContact").style.display         = "none"; 
    } 
function jsHomePageServices()
    {
        document.getElementById("CntHomePageServices").style.display        = "block"; 
        document.getElementById("CntHomePagePromotions").style.display      = "none"; 
        document.getElementById("CntHomePageTestimonials").style.display    = "none"; 
        document.getElementById("CntHomePageContact").style.display         = "none";   
    }
function jsHomePagePromotions()
    {
        document.getElementById("CntHomePageServices").style.display        = "none"; 
        document.getElementById("CntHomePagePromotions").style.display      = "block"; 
        document.getElementById("CntHomePageTestimonials").style.display    = "none"; 
        document.getElementById("CntHomePageContact").style.display         = "none";   
    }
function jsHomePageTestimonials()
    {
        document.getElementById("CntHomePageServices").style.display        = "none"; 
        document.getElementById("CntHomePagePromotions").style.display      = "none"; 
        document.getElementById("CntHomePageTestimonials").style.display    = "block"; 
        document.getElementById("CntHomePageContact").style.display         = "none";   
    }
function jsHomePageContact()
    {
        document.getElementById("CntHomePageServices").style.display        = "none"; 
        document.getElementById("CntHomePagePromotions").style.display      = "none"; 
        document.getElementById("CntHomePageTestimonials").style.display    = "none"; 
        document.getElementById("CntHomePageContact").style.display         = "block";   
    }
//END - Home Page Image Information Scripts


// START - Google Maps
function GoogleMap() 
    {
        var arrBusinessName = ["Alexandria","Kingsford", "Brookvale"];
        var arrMapCoodFirst = ["-33.899120","-33.925244", "-33.767244"];//north to south
        var arrMapCoodSecond = ["151.199799","151.224841", "151.269493"];//east to west
        var arrDescription = ["Shop 1/138 Botany Rd<br/>Alexandria NSW 2017","70 Gardeners Rd<br/>Kingsford NSW 2032", "626 Pittwater Rd<br/>Brookvale NSW 2100" ];
 
        //Google maps geo spatial co-ordinates
        //http://www.tech-recipes.com/rx/2403/google_maps_get_latitude_longitude_values/
        //javascript:void(prompt('',gApplication.getMap().getCenter()));
        if ((GBrowserIsCompatible()== true) && (document.getElementById("CntGoogleMap") != null )) 
            {
                //Map Configuration
                var map = new GMap2(document.getElementById("CntGoogleMap"));
                
                
                var mapCenterStartPoint;                           
                
                if (window.location.pathname.search("Alexandria") != -1)
                    {
                        //Alexandria
                        mapCenterStartPoint = 0;  
                    }
                if (window.location.pathname.search("Brookvale") != -1)
                    {
                         //Brookvalue
                         mapCenterStartPoint = 2;        
                    }
                if (window.location.pathname.search("Kingsford") != -1)
                    {
                         //Kingsford
                         mapCenterStartPoint = 1;  
                    }

               //alert(mapCenterStartPoint);

                    
                map.setCenter(new GLatLng(arrMapCoodFirst[mapCenterStartPoint], arrMapCoodSecond[mapCenterStartPoint]), 13);
                //map.addControl(new GLargeMapControl());
                map.addControl(new GSmallMapControl())
                map.printable=function(){return true};
                //map.addControl(new GMapTypeControl());
                //map.addControl(new GScaleControl());
                map.setZoom(15);
   
                // Write Marker Function
                function createMarker(latlng, number)
                    {
                      var marker = new GMarker(latlng);
                      marker.value = number;
                      GEvent.addListener(marker,"click", function() {
                        var myHtml = "<b>" + arrBusinessName[number -1] + "</b><br/>" + arrDescription[number -1];
                        map.openInfoWindowHtml(latlng, myHtml);
                      });
                      return marker;
	                }

                // Write Markers
                var bounds = map.getBounds();
                var southWest = bounds.getSouthWest();
                var northEast = bounds.getNorthEast();
                var lngSpan = northEast.lng() - southWest.lng();
                var latSpan = northEast.lat() - southWest.lat();
                for (var i = 0; i < 3; i++) 
                    {
                        var latlng = new GLatLng(arrMapCoodFirst[i],arrMapCoodSecond[i]);
	                    map.addOverlay(createMarker(latlng, i + 1));
                    }
            }
    }
// END - Google Maps
