﻿   $(document).ready(function(){

        LoadLondonMap(); 
        LoadRedhillMap();

         
        // When the collapse button is clicked:
        $('#london').click(function() {
  	        
            if ( $(this).hasClass("smallheaderClose") ) {
                $(this).removeClass("smallheaderClose");
	            $(this).addClass("smallheaderOpen");
                $.cookie("london", ""); 
                $(this).next().toggle();
               
            }
            else {
                $(this).removeClass("smallheaderOpen");
                $(this).addClass("smallheaderClose");
                $.cookie("london", "expanded"); 
                $(this).next().toggle();
                LoadLondonMap();                    
            }
            
      
        });
         
         $('#redhill').click(function() {
      	        
	            if ( $(this).hasClass("smallheaderClose") ) {
	                $(this).removeClass("smallheaderClose");
		            $(this).addClass("smallheaderOpen");
                    $.cookie("redhill", ""); 
                    $(this).next().toggle();
	            }
	            else {
	                
	                $(this).removeClass("smallheaderOpen");
                    $(this).addClass("smallheaderClose");
                    $.cookie("redhill", "expanded"); 
                    $(this).next().toggle();
                    LoadRedhillMap();
	            }
         });
  

        // COOKIES
        var redhillCookie = $.cookie('redhill');
        var londonCookie = $.cookie('london');

        // Set the user's selection for the left column
        if (redhillCookie != 'expanded') {
             $('#redhill').removeClass("smallheaderClose");
		     $('#redhill').addClass("smallheaderOpen");
		     $('#redhill').next().hide();
        };
        if (londonCookie != 'expanded') {
             $('#london').removeClass("smallheaderClose");
		     $('#london').addClass("smallheaderOpen");
		     $('#london').next().hide();
        };
	           	  	
    });
    
    function LoadMap( mapID, x, y) {

        if (GBrowserIsCompatible()) {
            var map = new GMap2(document.getElementById(mapID));

            map.setCenter(new GLatLng(x,y), parseInt('16'), G_NORMAL_MAP);
        
            var point = new GLatLng(x,y);
            map.addOverlay(new GMarker(point));
            map.addControl(new GMapTypeControl());
            map.addControl(new GLargeMapControl());
            //alert('map loaded');
        }
            
     }
     
