if (!window.console || !console.firebug) {
	var names = ["log", "debug", "info", "warn", "error", "assert", "dir", "dirxml", "group", "groupEnd", "time", "timeEnd", "count", "trace", "profile", "profileEnd"];

	window.console = {};
	for (var i = 0; i < names.length; ++i)
		window.console[names[i]] = function () { }
}



// jQuery no conflict mode enabled
jQuery.noConflict();

function navMouseover(el)
{
	el.find('ul').css('display', 'block');
	jQuery('#tabs li').addClass('inactive');
	el.removeClass('inactive').addClass('active');	
}

function navMouseout(el)
{
	el.find('ul').css('display', 'none');
	jQuery('#tabs li').removeClass('inactive').removeClass('active');	
}

// On dom ready
jQuery(document).ready(function()
{
	jQuery('.hover').mouseover(function()
	{
		var el = jQuery(this);
		navMouseover(el);
	});
	
	jQuery('.hover').mouseout(function()
	{
		var el = jQuery(this);
		navMouseout(el);
	});
	
	jQuery('#newsletter-form').live('submit', function(event)
   	{
		event.preventDefault();
		
		var newsletterEmail = jQuery('#newsletter-email').val();
		
		jQuery.ajax({
		  url: 'includes/newsletter.inc.php',
		  type: 'POST',
		  data: "newsletter-email="+newsletterEmail+"&submit-newsletter=true",
		  success: function(data) {
			jQuery('#nav-news ul li').html(data);
		  }
		});
   	});
	
	jQuery('#privacy-form').live('submit', function(event)
   	{
		event.preventDefault();
		
		var privacyEmail = jQuery('#privacy-email').val();
		var privacyName = jQuery('#privacy-fullname').val();
		
		jQuery.ajax({
		  url: 'includes/join.inc.php',
		  type: 'POST',
		  data: "privacy-email="+privacyEmail+"&privacy-fullname="+privacyName+"&submit-join=true",
		  success: function(data) {
			jQuery('#nav-join ul li').html(data);
		  }
		});
   	});
	
	// Add facebook social widget
	jQuery('#facebook').html('<iframe id="facebook-iframe" src="http://www.facebook.com/plugins/likebox.php?api_key=113869198637480&channel=http%3A%2F%2Fstatic.ak.fbcdn.net%2Fconnect%2Fxd_proxy.php%23cb%3Df293a233a271182%26origin%3Dhttp%253A%252F%252Fdevelopers.facebook.com%252Ff2cb7f0b4d9f9f8%26relation%3Dparent.parent%26transport%3Dpostmessage&colorscheme=light&connections=5&header=false&height=200&href=http%3A%2F%2Fwww.facebook.com%2F%23!%2Fpages%2FCambridge-Nomads-Hockey-Club%2F145391374104&locale=en_US&sdk=joey&show_faces=false&stream=false&width=300&border=0" scrolling="no" frameborder="0" allowTransparency="true"></iframe>');
});


function insertMap(lat, long, id)
{
	var myLatlng = new google.maps.LatLng(lat, long);
	var myOptions = {
	  zoom: 13,
	  center: myLatlng,
	  mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	var map = new google.maps.Map(document.getElementById("address-map"+id), myOptions);
	
	var marker = new google.maps.Marker({
		position: myLatlng, 
		map: map
	});	
}

// Google maps
function initialiseMap()
{
	if(typeof(lat) != "undefined" &&  typeof(long) != "undefined")
	{
		insertMap(lat, long, '');
	}
	if(typeof(lat1) != "undefined" &&  typeof(long1) != "undefined")
	{
		insertMap(lat1, long1, '1');
	}
	if(typeof(lat2) != "undefined" &&  typeof(long2) != "undefined")
	{
		insertMap(lat2, long2, '2');
	}
	if(typeof(lat3) != "undefined" &&  typeof(long3) != "undefined")
	{
		insertMap(lat3, long3, '3');
	}
}

initialiseMap();
