function initialize() {

	var latlng = new google.maps.LatLng(53.74748, -0.309666);
	
	var myOptions = {
	zoom: 16,
	center: latlng,
	mapTypeId: google.maps.MapTypeId.HYBRID
	};
	
	var map = new google.maps.Map(document.getElementById("map"), myOptions);
	var pinIcon = "/_inc/img/mapicon.png";
		
	var marker = new google.maps.Marker({
		position: latlng, 
		map: map,
		icon: pinIcon,
		animation: google.maps.Animation.DROP,
		title: "Smile Foundation"

	});  
	
	google.maps.event.addListener(marker, 'click', function() {
		infowindow.open(map,marker);
	});
	
}

// remap jQuery to $ - Basically, resolves the issue of people writing crappy plugins
(function($){

	// LIGHTBOX
	if ($('.nyroModal').length) {
		$('.nyroModal').nyroModal();
	}

	// ANYTHING SLIDER
	if ($('#homeFeatured').length) {

		$('#homeFeatured').anythingSlider({
			width					: 810,
			height				: 340,
			delay					: 10000,
			animationTime		: 1000,
			buildNavigation	: false,
			autoPlay				: true
		});
	$('#homeFeatured').fadeTo(10, 1);
	}
	
	// HOVER POPUP ON ANYTHING SLIDER BUTTONS
	// LEFT
	$('.back a').mouseenter(function() {
		$('.featButtonTeaserLeft').stop(false, true).fadeIn("slow");
	});
	$('.back a').mouseleave(function() {
		$('.featButtonTeaserLeft').stop(false, true).fadeOut("fast");
	});
	// RIGHT
	$('.forward a').mouseenter(function() {
		$('.featButtonTeaserRight').stop(false, true).fadeIn("slow");
	});
	$('.forward a').mouseleave(function() {
		$('.featButtonTeaserRight').stop(false, true).fadeOut("fast");
	});
	// GO HOME
	$('#header').mouseenter(function() {
		if ($('body').attr('id') == 'home') { return false; }
		$('.goHome').stop(false, true).fadeIn("slow");
	});
	$('#header').mouseleave(function() {
		if ($('body').attr('id') == 'home') { return false; }
		$('.goHome').stop(false, true).fadeOut("fast");
	});
	
	
	
	$('#carousel').infiniteCarousel({
		displayTime: 3000,
		transitionSpeed : 500,
		inView:5,
		advance:1,
		imagePath: '/_inc/scripts/libs/infinitecarousel/images/',
		textholderHeight : .0,
		padding:'11px',
		thumbnailWidth: '140px',
		thumbnailHeight: '80px',
		displayThumbnails: false,
		displayProgressBar: false,
		prevNextInternal: false
	});
	
	//CONTACT MAP
	if ($('#map').length) {
		initialize();
	}

	// HANDLES EXTERNAL LINKS OPENING IN NEW WINDOWS
	$('a[rel~=external]').click(function(){ this.target = "_blank"; });


	// TRICK STRAWB LINK
	$('.featInfo').each(function() {
		
		if($(this).find('h1').text() == 'The 24 hour Smile Foundation Website Build Challenge') {
			
			$(this).find('h1').html('<a href="/smile24">The 24 hour Smile Foundation Website Build Challenge</a>');
			
			$(this).find('p:eq(0) a').css({
				'padding-left' : 0,
				'background' : 'none'
			});
			
			$(this).find('p:eq(1)').remove();
		}
	});

})(this.jQuery);



// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
// used instead of console.log, which will break browsers that don't have a console open
window.log = function(){
  log.history = log.history || [];
  log.history.push(arguments);
  if(this.console){
    console.log( Array.prototype.slice.call(arguments) );
  }
};

// catch all document.write() calls and output them to the log
(function(doc){
  var write = doc.write;
  doc.write = function(q){ 
    log('document.write(): ',arguments); 
    if (/docwriteregexwhitelist/.test(q)) write.apply(doc,arguments);  
  };
})(document);
