$(document).ready(function(){

	$(document).pngFix();
	var currentLocation = window.location.href;
	//alert(currentLocation.indexOf('collection'));
	if(currentLocation.indexOf('/collection/') != -1){
		$('#navigation-collections').addClass('active');
	}else if(currentLocation.indexOf('/blog/') != -1){
		$('#navigation-blog').addClass('active');
	}else if(currentLocation.indexOf('/buy/') != -1){
		$('#navigation-buy').addClass('active');		
	}else if(currentLocation.indexOf('/contact/') != -1){
		$('#navigation-contact').addClass('active');
	}else if(currentLocation.indexOf('/about/') != -1){
		$('#navigation-about').addClass('active');
	}
	
	// http://www.appelsiini.net/projects/lazyload
	$("img:not(.slides img)").lazyload({
		placeholder : "/blog/wp-content/themes/socialsuicide-2/images/blank.gif",
		effect : "fadeIn"
	});
	
	$('.slideshow').cycle({
		fx: 'fade' // choose your transition type, ex: fade, scrollUp, shuffle, etc...
	});
	
	if( $('body').hasClass('page-id-584') ){
		GoogleMaps.attachLocation('ganton-street');
	}
	
});


/*
	GoogleMaps
--------------------------------------------------------------------- */
var GoogleMaps = {
	init: function(){
		// intentionally left blank
	},
	attachLocation: function(location){
		// attach action to the #map-link
		var locationImage = "";
		$('#map-link').click(function(){
			
			if($(this).is('.map')){
				$('#location-map-or-image').html(locationImage);
				$(this).removeClass('map');
				$(this).text('Show Map');
			}else{
				locationImage = $('#location-map-or-image').html();
				GoogleMaps.attachMap('location-map-or-image', location);
				$(this).addClass('map');
				$(this).text('Hide Map');
			}
			return false;
		})
		
	},
	attachMap: function(id, location){
		// the map
		if (GBrowserIsCompatible()){
			var map = new GMap2( document.getElementById(id));
			var coordinates = this.getCoordinates(location)
			var latitudeLongitude = new GLatLng(coordinates.x,coordinates.y);
			
			map.setCenter(latitudeLongitude, 15);
			map.addControl(new GLargeMapControl());
			//map.addControl(new GMapTypeControl());

			/*
			var iconConf = new GIcon();
				iconConf.image = "/images/locationMapIcon.png";
				iconConf.shadow = "/images/logoGoogleMaps_bg.png";
				iconConf.iconSize = new GSize(143, 53);
				iconConf.shadowSize = new GSize(0, 0);
				iconConf.iconAnchor = new GPoint(63, 53);
				iconConf.infoWindowAnchor = new GPoint(0, 0);
				iconConf.infoShadowAnchor = new GPoint(0, 0);
			markerOptions = { icon:iconConf };
			
			map.addOverlay(new GMarker(latitudeLongitude, markerOptions));
			*/
			
			map.addOverlay(new GMarker(latitudeLongitude));
		}
	},
	getCoordinates: function(location){
		// the cordinates for the different locations
		// http://maps.google.com/maps/geo?q=YOUR+SEARCH+QUERY+HERE&output=csv&key=YOUR+API+KEY+HERE
		switch(location){
			case 'ganton-street'	: return {x:51.5132908,y:-0.1383504}; break; 
			case 'islington'	: return {x:51.539551,y:-0.102468}; break;
			case 'kensington'	: return {x:51.502943,y:-0.193359}; break;
			case 'belgravia'	: return {x:51.499224,y:-0.156938}; break;
		}
	}
}
