$(document).ready(function() {

	$('.alignright').each(function() {
		$(this).wrapAll('<div class="alignrightHolder" style="float:right;width:'+$(this).width()+'px;"></div>').after('<p>'+$(this).attr('title')+'</p>');
	});

	// main menu
	var t;
	$('ul.mainMenu').children('li').each(function() {
		var ul = $(this).children('ul');
		$(this).children('a').mouseover(function() {
			clearTimeout(t);
			if(ul.length > 0) {
				$(this).parent().addClass('submenu');
			}
			$(this).parent().siblings().removeClass('submenu');
		}).mouseout(function() {
			clearTimeout(t);
			t = setTimeout(function() {
				ul.parent().removeClass('submenu');
			}, 500);
		});
		$(this).children('ul').find('a').mouseout(function() {
			clearTimeout(t);
			t = setTimeout(function() {
				ul.parent().removeClass('submenu');
			}, 500);
		}).mouseover(function() {
			clearTimeout(t);
		});
	});

	// google map
	$('#map_canvas').each(function() {
		initialize();
	});
});

function initialize() {
	var myLatlng = new google.maps.LatLng(52.799836,-1.666757);
	var myOptions = {
		zoom: 13,
		center: myLatlng,
		mapTypeControl: true,
		mapTypeControlOptions: {style: google.maps.MapTypeControlStyle.DROPDOWN_MENU},
		navigationControl: true,
		navigationControlOptions: {style: google.maps.NavigationControlStyle.SMALL},
		mapTypeId: google.maps.MapTypeId.ROADMAP
	}
	
	var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
	
	var contentString = 'Redfern Contract Consultants Limited';
	
	var infowindow = new google.maps.InfoWindow({
		content: '<p>'+contentString+'</p>'
	});
	
	var marker = new google.maps.Marker({
		position: myLatlng,
		map: map,
		title: contentString
	});

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