
$(document).ready(function()
{
	initHeader();
	$.ajaxSetup({
		type: 'post',
		success: function(resp)
		{
			var r = Ajax.evalResp(resp);
			if (!r.code) 
				alert(r.resp);
		}
	});
	new Cityngo.Spotlight($("#search_line input[name=q]"));
});

$(document).ajaxError(function (event, request, settings)
{
	alert('Impossible de charger les données : url=' + settings.url);
});

function initHeader()
{
	$('.emptyOnFocus').emptyOnFocus();
	$('form.aform').submit(function ()
	{
		$('.emptyOnFocus.intro').val('');
	});
	$('#main_menu a.has_submenu').parent().hover(function ()
	{
		$(this).find('table.submenu').show();
		$(this).children('a.has_submenu').addClass('hover');
	}, function ()
	{
		$(this).find('table.submenu').hide();
		$(this).children('a.has_submenu').removeClass('hover');
	});
	$('a.small_button, a.button').each(function()
	{
		$(this).prepend('<div class="left"></div>').append('<div class="right"></div>');
	});
	$(".open_lightbox").click(function ()
	{
		var l = new LightBox({
			load: {
				url: $(this).attr("href")
			},
			_save_button: 'input[type=submit], button[type=submit]',
			onContentLoaded: function ()
			{
				this.$lightbox_content.find(".emptyOnFocus").emptyOnFocus();
			}
		});
		l.load();
		return false;
	});
}

function redirect(url)
{
	document.location.href = url;
}