/* Author: Matt King

*/


mapload = function() {
  if (GBrowserIsCompatible()) {
  			insiteLoc = new GLatLng(51.476719,-0.199353);
  			
	    	mapUK = new GMap2(document.getElementById("googlemap"));
			mapUK.addControl(new GLargeMapControl3D());
			mapUK.addControl(new GMapTypeControl());
			mapUK.removeMapType(G_SATELLITE_MAP);
			mapUK.addMapType(G_PHYSICAL_MAP);
			mapUK.setCenter(insiteLoc, 15);
			//mapUK.setMapType(G_PHYSICAL_MAP);
			
			
			
	
		// Create our "tiny" marker icon
		var icon = new GIcon();
			icon.image = "http://labs.google.com/ridefinder/images/mm_20_red.png";
			icon.shadow = "http://labs.google.com/ridefinder/images/mm_20_shadow.png";
			icon.iconSize = new GSize(12, 20);
			icon.shadowSize = new GSize(22, 20);
			icon.iconAnchor = new GPoint(6, 20);
			icon.infoWindowAnchor = new GPoint(5, 1);
	
			var point = new GMarker(insiteLoc);
			mapUK.addOverlay(point, icon);
		
	}
}




$(function(){
	
	if ($('#googlemap').length > 0) {
		mapload();
	}
	
	$('.cols.two.columnise').columnize({ columns: 2 });
	$('.cols.three.columnise').columnize({ columns: 3 });
	
	$('.slides a').hide();
	$('.slides div').addClass('selected');
	$('.controls a').click(function(e) {
		e.preventDefault();
		$('.controls li').removeClass('selected');
		$(this).parent().addClass('selected').parents('ul').removeClass('noneselected');
		$whatSlide = $(this).attr('href');
		$whatSlideHash = $whatSlide.split('#');
		$('.slides .selected').fadeOut(1000).removeClass('selected');
		$('.slides #'+$whatSlideHash[1]).fadeIn(1000).addClass('selected');
		if ($whatSlideHash[1] == "print") {
			 $('.controls ul').addClass('noneselected');
		}
	});
	
	//GALLERY
	if ($('#gallery').length > 0){
		Galleria.loadTheme('/js/themes/classic/galleria.classic.js');
		$('#gallery').galleria({
	        width:460,
	        height:350,
	        thumbnails: "numbers",
	        autoplay: 5000,
	        showInfo: false
    	});
	}
	
	$('.selectable .circle').click(function(e){
		e.preventDefault();
		$('.circle').removeClass('active');
		$(this).addClass('active');
		$thisIndex = $(this).attr('id').split('_')[1];
		$('.standaccordian').hide();
		$('#' + $thisIndex).stop(1,1).fadeIn("slow");
		$('.standoption h3').removeClass('active');
		$('.text').hide();
	});
	
	$('.numbers a').click(function(e){
		e.preventDefault();
		var number = $(this).attr('href');
		$('.numbers a').removeClass('active');
		$(this).addClass('active');
		$('.selectable').hide();
		$(number).fadeIn();
		$('.standaccordian').fadeOut();
		$('.standoption h3').removeClass('active');
		$('.text').slideUp("slow");
	});
	
	$('.change a').click(function(e){
		e.preventDefault();
		var nextNumber = $('.numbers a.active').next('a').attr('href');
		var currNumber = $('.numbers a.active').attr('href');
		if(currNumber == '#three'){
			nextNumber = '#one';
			$('.numbers a.active').removeClass('active');
			$('.numbers a:first-child').addClass('active');
		} else {
			$('.numbers a.active').removeClass('active').next('a').addClass('active');
		}
		$('.selectable').hide();
		$(nextNumber).fadeIn();
		$('.standaccordian').fadeOut();
		$('.standoption h3').removeClass('active');
		$('.text').slideUp("slow");
	});
	
	
		$('.standoption h3').click(function(){
			if ($(this).hasClass('active')){
				$('.standoption h3').removeClass('active');
				$('.text').slideUp("slow");
			} else {
				$('.standoption h3').removeClass('active');
				$(this).addClass('active');
				$('.text').slideUp("slow");
				$(this).next('.text').stop(1,1).slideDown("slow");
			}
		});
});























