var jcrop_api2, jcrop_api, grandeImage, petiteImage, x, x2, y, y2, h, h2, w, w2,p, townOptions, departmentOptions;

$(document).ready(function() {
	$.each($("textarea"), function(val, textarea) {
		if (textarea.value == " ")
			textarea.value = "";
	});

	$("input[value^=' ']").val('');

	$("select").change(function() {
		$("div[class^=formError]", this.offsetParent).fadeOut();
	});

	$("textarea, input, div[class^=formError]").live('click', function() {
		$("div[class^=formError]", this.offsetParent).fadeOut();
	});

	$("div[class^=formError]").fadeIn('slow');

	// logique du prompt de reprise d'inscription
	noQuit = false;

	$("area, .stepping, .bottom_navigation_container").live('click', function() {
		noQuit = true;
	});


	// fais planter l'upload ajax sur step3
	/* $('#signup_form').submit(function() {
	noQuit = true;
	});*/

	$("a#step_inactif").click(function() {
		noQuit = true;
		$("#signup_form").submit();
		return false;
	}) // 
	
	
	function checkEventObj(_event_) {
		// --- IE explorer
		if (window.event)
			return window.event;
		// --- Netscape and other explorers
		else
			return _event_;
	}


	window.onbeforeunload = function(e) {
		var e = checkEventObj(e);

		if (!noQuit) {
			var answer = confirm("Vous allez quitter votre inscription sans l\'avoir finalis\u00E9e.\n\nUn email vous sera envoy\u00E9 d\'ici quelques minutes avec un lien vous permettant de poursuivre l\'inscription l\u00E0 o\u00F9 vous l\'avez laiss\u00E9e.");

			if (answer) {
				$.ajax({
					async: false,
					global: false,
					cache: false,
					type: "POST",
					url: generated_url_repriseinscription,
					success: function(data, textStatus) { alert("Message envoye"); },
					error: function(data, textStatus) { alert("Message non envoye"); }
				});
			}
			else {
				e.returnValue = " ";
				e.preventDefault();
				return false;
			}
		}

	}

	function checkEventObj(_event_) {
		// --- IE explorer
		if (window.event)
			return window.event;
		// --- Netscape and other explorers
		else
			return _event_;
	}


	$(document).keydown(function(e) {
		var Alphacheck = false;

		var winObj = checkEventObj(e);

		var intKeyCode = winObj.keyCode;
		var intAltKey = winObj.altKey;
		var intCtrlKey = winObj.ctrlKey;


		if (!e.charCode) k = String.fromCharCode(e.which);
		else k = String.fromCharCode(e.charCode);


		if (intCtrlKey && (e.which == 82) || e.which == 116) {
			noQuit = true;
		}


	});





});




