

//open close box 
	//Hide (Collapse) the toggle containers on load
	$(".toggle_container").hide(); 

	//Switch the "Open" and "Close" state per click then slide up/down (depending on open/close state)
	$("h5.trigger").click(function(){
		$(this).toggleClass("active").next().slideToggle("slow");
		return false; //Prevent the browser jump to the link anchor
	});


	/* Author: 

	*/		

	 $.Isotope.prototype._getCenteredMasonryColumns = function() {
	   this.width = this.element.width();

	   var parentWidth = this.element.parent().width();

	                 // i.e. options.masonry && options.masonry.columnWidth
	   var colW = this.options.masonry && this.options.masonry.columnWidth ||
	                 // or use the size of the first item
	                 this.$filteredAtoms.outerWidth(true) ||
	                 // if there's no items, use size of container
	                 parentWidth;

	   var cols = Math.floor( parentWidth / colW );
	   cols = Math.max( cols, 1 );

	   // i.e. this.masonry.cols = ....
	   this.masonry.cols = cols;
	   // i.e. this.masonry.columnWidth = ...
	   this.masonry.columnWidth = colW;
	 };

	 $.Isotope.prototype._masonryReset = function() {
	   // layout-specific props
	   this.masonry = {};
	   // FIXME shouldn't have to call this again
	   this._getCenteredMasonryColumns();
	   var i = this.masonry.cols;
	   this.masonry.colYs = [];
	   while (i--) {
	     this.masonry.colYs.push( 0 );
	   }
	 };

	 $.Isotope.prototype._masonryResizeChanged = function() {
	   var prevColCount = this.masonry.cols;
	   // get updated colCount
	   this._getCenteredMasonryColumns();
	   return ( this.masonry.cols !== prevColCount );
	 };

	 $.Isotope.prototype._masonryGetContainerSize = function() {
	   var unusedCols = 0,
	       i = this.masonry.cols;
	   // count unused columns
	   while ( --i ) {
	     if ( this.masonry.colYs[i] !== 0 ) {
	       break;
	     }
	     unusedCols++;
	   }

	   return {
	         height : Math.max.apply( Math, this.masonry.colYs ),
	         // fit container to columns that have been used;
	         width : (this.masonry.cols - unusedCols) * this.masonry.columnWidth
	       };
	 };



	   var $container = $('#container');


	     // add randomish size classes
	     $container.find('.element').each(function(){
	       var $this = $(this),
	           number = parseInt( $this.find('.number').text(), 10 );
	       if ( number % 7 % 2 === 1 ) {
	         $this.addClass('width2');
	       }
	       if ( number % 3 === 0 ) {
	         $this.addClass('height2');
	       }
	     });

	   $container.isotope({
	     itemSelector : '.element',
	     masonry : {
	       columnWidth : 20
	     },
	     getSortData : {
	       category : function( $elem ) {
	         return $elem.attr('data-category');
	       },
	     }
	   });


	     var $optionSets = $('#options .option-set'),
	         $optionLinks = $optionSets.find('a');

	     $optionLinks.click(function(){
	       var $this = $(this);
	       // don't proceed if already selected
	       if ( $this.hasClass('selected') ) {
	         return false;
	       }
	       var $optionSet = $this.parents('.option-set');
	       $optionSet.find('.selected').removeClass('selected');
	       $this.addClass('selected');

	       // make option object dynamically, i.e. { filter: '.my-filter-class' }
	       var options = {},
	           key = $optionSet.attr('data-option-key'),
	           value = $this.attr('data-option-value');
	       // parse 'false' as false boolean
	       value = value === 'false' ? false : value;
	       options[ key ] = value;
	       if ( key === 'layoutMode' && typeof changeLayoutMode === 'function' ) {
	         // changes in layout modes need extra logic
	         changeLayoutMode( $this, options )
	       } else {
	         // otherwise, apply new options
	         $container.isotope( options );
	       }

	       return false;
	     });



	     $('#insert a').click(function(){
	       var $newEls = $( fakeElement.getGroup() );
	       $container.isotope( 'insert', $newEls );

	       return false;
	     });

	     $('#append a').click(function(){
	       var $newEls = $( fakeElement.getGroup() );
	       $container.append( $newEls ).isotope( 'appended', $newEls );

	       return false;
	     });



	     // change size of clicked element
	     $container.delegate( '.element', 'click', function(){
	       $(this).toggleClass('large');
	       $container.isotope('reLayout');
	     });

	     // toggle variable sizes of all elements
	     $('#toggle-sizes').find('a').click(function(){
	       $container
	         .toggleClass('variable-sizes')
	         .isotope('reLayout');
	       return false;
	     });


	   var $sortBy = $('#sort-by');
	   $('#shuffle a').click(function(){
	     $container.isotope('shuffle');
	     $sortBy.find('.selected').removeClass('selected');
	     $sortBy.find('[data-option-value="random"]').addClass('selected');
	     return false;
	   });



	//waypoints
		$('.top').addClass('hidden');
		$.waypoints.settings.scrollThrottle = 30;
		$('#wrap').waypoint(function(event, direction) {
			$('.top').toggleClass('hidden', direction === "up");
		}, {
			offset: '-100%'
		}).find('#holder').waypoint(function(event, direction) {
			$(this).parent().toggleClass('sticky', direction === "down");
			event.stopPropagation();
		});

	// google map

	//Google Map //
	var directionDisplay;
	var directionsService = new google.maps.DirectionsService();
	var map;
	var Latlng = new google.maps.LatLng(51.52309698578392,-0.08005857467651367);


	function getDirections(startFrom,mode) {
	    if (mode === 'WALKING') {
	        modeOfTravel = google.maps.DirectionsTravelMode.WALKING;
	    } else {
	        modeOfTravel = google.maps.DirectionsTravelMode.DRIVING;
	    }
	    var request = {
	        origin: startFrom,
	        destination: Latlng,
	        travelMode: modeOfTravel
	    };
	    directionsService.route(request, function(result, status) {
	        if (status == google.maps.DirectionsStatus.OK) {
	            $('#transport').toggle();
	            $('#directions').toggle();
	            directionsDisplay.setDirections(result);
	        } else {
	            alert('Not a valid address');
	        }
	    });
	}

	function doTheMap() {

	    directionsDisplay = new google.maps.DirectionsRenderer();

	    var myOptions = {
			scrollwheel: false,
			navigationControl: true,
		    mapTypeControl: true,
		    scaleControl: true,
	        center: Latlng,
	        disableDefaultUI: true,
	        mapTypeId: google.maps.MapTypeId.ROADMAP,
	        zoom: 15
	    };

	    map = new google.maps.Map(document.getElementById('map'),myOptions);

	    directionsDisplay.setMap(map);
	    directionsDisplay.setPanel(document.getElementById('directions'));

	    var markerImage = new google.maps.MarkerImage('../images/assets/marker.png',
	        new google.maps.Size(68,70),
	        new google.maps.Point(0,0),
	        new google.maps.Point(22,70));

	    var marker = new google.maps.Marker({
	        icon: markerImage,
	        map: map, 
	        position: Latlng,
	        title:"Cure Studio"
	    });

	    $('.tube p a, .train p a').bind('click',function(e){
	        var startFrom = $(this).data('start');
	        getDirections(startFrom,'WALKING');
	        e.preventDefault();
	    });

	     $('#find-directions').bind('submit',function(e){
	        var startFrom = $(this).find('input');
	        if ($(startFrom).val().length > 0) {
	            getDirections(startFrom.val());
	        } else {
	            $(startFrom).val('Enter a start address');
	        };
	        e.preventDefault();
	    });

	    $('#directions .back').live('click',function(e){
	        $('#transport').toggle();
	        $('#directions').toggle();
	        e.preventDefault();
	    });

	}

	$(document).ready(function(){
	   {doTheMap();} 
	});

