$(document).ready(function() {

	$('#concours_menu .boite').mouseover(function() {
		$(this).addClass('active');
	});
	$('#concours_menu .boite').mouseout(function() {
		if (!$(this).is('.selected')) {
			$(this).removeClass('active');
		}
	});

$("#photoform").submit(function() {
	$(this).ajaxSubmit({
					beforeSubmit: function(before) {
					$('#loadingbook').css('display','block');
					$("#resultbook").html('');
					$("#resultbook").css('display','none');
					},
					success: function(retour) {
						$('#loadingbook').css('display','none');
						if (retour != 'ok') {
							if (retour == 'notcomplete') {
								$('#resultbook').html('<p class=\"bad\">Your form is incomplete.</p>');
							} else if (retour == 'cgu') {
								$('#resultbook').html('<p class=\"bad\">You must accept the terms and conditions to take part in the competition.</p>');
							} else if(retour == 'ban') {
								$('#resultbook').html('<p class=\"bad\">Your account has been banned, you cannot submit a photo. For more information, please send an email to support@fmylife.com.</p>');
							} else if(retour == 'nocompte') {
								$('#resultbook').html('<p class=\"bad\">To submit a photo you must be a member of the website <a href=\"/inscription\">Sign up</a> !</p>');
							} else if(retour == 'wrongtype') {
								$('#resultbook').html('<p class=\"bad\">Your file is not a JPEG.</p>');
							} 
						} else {
							$('#resultbook').html('<p class=\"good\">Your photo has been submitted. You will be notified via email when it has been checked and accepted by our team.</p>');
						}
						$("#resultbook").hide();
						$('#resultbook').fadeIn(500);
						}
				}); 
			return false;
	});

});
	
function SubmitTogglePhoto() {
	if ($('#photosubmit').css('display') == 'none') {
		$('#photosubmit').slideDown();
	} else {
		$('#photosubmit').slideUp();
	}
}

var map = null;
var geocoder = null;

function showAddress(address) {
  if (geocoder) {
	geocoder.getLatLng(
	  address,
	  function(point) {
		if (!point) {
		  $('#map_canvas').html('<p style="padding-top:90px;text-align:center;">The map cannot be displayed</p>');
		} else {
		  map.setCenter(point, 13);
		  var marker = new GMarker(point);
		  map.addOverlay(marker);
		}
	  }
	);
  }
}

function initialize() {
  if (GBrowserIsCompatible()) {
	map = new GMap2(document.getElementById("map_canvas"));
	map.addControl(new GSmallMapControl());
	map.addControl(new GMapTypeControl());
	geocoder = new GClientGeocoder();
  }
}