urlSite = "http://www.auto-selection.com/";

/**
 * Affiche le message après une redirection lorsqu'un contenu est supprimé
 * @param string out Identifiant du bloc html de sortie
 */
function isExpired(out) {
	var ajax_url = urlSite + 'ajax/getExpiredMessage.php';
	var url = '';
	url = document.location.href;
	if( url.search(/#expired/) > -1 ) {
		$.get(
			ajax_url,
			{},
			function(data){
				$('#'+out).html(data);
			}
		);
	}
}

/**
 * Ouvre une fenêtre popup
 * @todo A remplacer par de l'ajax
 */
function as_popup(page, largeur, hauteur, options) {
	var top = (screen.height-hauteur)/2;
	var left = (screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function recharge(form) {
	var action = form.action.value;
	form.submit();
}

/**
 * Redirection
 * @param string url
 */
function goToUrl(url) {
	window.location.href = url;
}

/**
 * Affiche l'alerte e-mail
 * @param string email Adresse e-mail de l'internaute
 */
var mouseIsInside = false;
function showAlerteEmailUI(selector){
	$.colorbox({
		html: (function(){
			var html;
			$.ajax({
				async: false,
				url: '/ajax/alerte-email.php',
				type: 'get',
				data: $(selector).serialize(),
				dataType: 'html',
				success: function(data){
					html = data;
				}
			});
			return html;
		})()
		,onComplete: function(){
			$('#colorbox-alerte-email div.error').hover(function(){
				mouseIsInside = true;
			}
			,function(){
				mouseIsInside = false;
			});
			$('body').mousedown(function(){ 
				if(!mouseIsInside){
					$('#colorbox-alerte-email div.error').hide();
				}
			});
		}
	});
}
