$(document).ready(
	function(){
	
	// Frontpage slideshow
	if ($('.frontpage').length > 0){
    		
		$('#panel_1').cycle({
			fx: 'scrollDown',
			speed: 1000,
    		sync:1,
			timeout: 10000,
			easing: 'easeInOutQuad',
			pause:1

		});
		$('#panel_2').cycle({
			fx: 'scrollDown',
			speed: 1000,
    		sync:1,
			timeout: 10000,
			delay:2000,
			easing: 'easeInOutQuad',
			pause:1
		});
		$('#panel_3').cycle({
			fx: 'scrollDown',
			speed: 1000,
    		sync:1,
			timeout: 10000,
			delay:4000,
			easing: 'easeInOutQuad',
			pause:1

		});
		
		$('#hero dl dt').hide();
		
		function animate(){
			$('#hero #panel_1 dl dt').slideDown('fast');
			$('#hero #panel_2 dl dt').slideDown('normal');
			$('#hero #panel_3 dl dt').slideDown('slow');
		}
		
		animate();
		
    	$('#hero dl').hover(
 			function(){
				$(this).find('dd').css('display','block');
			},
			function(){
				$(this).find('dd').css('display','none');
 			})
    		
   	 }

	// Frontpage slideshow
	if ($('.competitions').length > 0){
		$('#hero ul').cycle({
			fx: 'scrollDown',
			speed: 1000,
			random: '0',
			timeout: 10000,
			easing: 'easeInOutQuad'

		});
	}


	$('.caption span.name').hide();
	$('.caption').hover(
		function(){
		$('.caption span.name').show();
		},
		function(){
		$('.caption span.name').hide();
		}
	)
	

	$("#details a").addClass("external").click(function() { window.open($(this).href); return false; });
	


	if ($(".label").length>0) {
	$("input:text").labelify({
		text: "label",
		labelledClass: "labeltext"
		});
	}
	
	
	$('#competitions_menu ul').cycle();

	$('#competitions_menu').hover(
		function(){
			 $(this).find('ul').cycle('destroy');
			  $(this).find('li').attr('style','');
			
		},
		function(){
			 $(this).find('ul').cycle();
		}
	)



	//$("a[href^='http:']").not("[href*='malcolmreading.co.uk']").not("[href*='jmdentand.com']").attr('target','_blank');


	$("a.pdf").click(function(){
			pageTracker._trackPageview('/downloads/'+ $(this).attr('href'));
	})
	
	if ($("#q_and_a ul li").length > 0){
	 $("#q_and_a ul li  a").bigTarget({
    	hoverClass: 'active', 
	    clickZone : 'li:eq(0)' 
	    });
}





function createMap() {

  // Create an array of styles.
  var MRCStyles = [
    {
      featureType: "all",
      stylers: [
      	{ hue: "#000000" },
        { saturation: -100 },
        {lightness: -30}
      ]
    }
  ];

  // Create a new StyledMapType object, passing it the array of styles,
  // as well as the name to be displayed on the map type control.
  var mapType = new google.maps.StyledMapType(MRCStyles,
    {name: "Malcolm Reading Consultants"});

  var mapOptions = {
    zoom: 15,
    center: new google.maps.LatLng(51.5208392, -0.1080217),
    disableDefaultUI: true,
    mapTypeControlOptions: {
      mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'mrc_map']
    }
  };
  var map = new google.maps.Map(document.getElementById('map'),
    mapOptions);

  //Associate the styled map with the MapTypeId and set it to display.
  map.mapTypes.set('mrc_map', mapType);
  map.setMapTypeId('mrc_map');


    //var image = '/images/interface/marker.png';
    var myLatLng = new google.maps.LatLng(51.5188392, -0.1070217);
    var marker = new google.maps.Marker({
        position: myLatLng, 
        map: map
    });   

}
createMap() 

})






