;(function($) {


if (/1\.(0|1|2)\.(0|1|2)/.test($.fn.jquery) || /^1.1/.test($.fn.jquery)) {
    alert('blockUI requires jQuery v1.2.3 or later!  You are using v' + $.fn.jquery);
    return;
}

$.fn.goHref = function(href,callback,blockTarget) {
	var target = $(this);
	callback = callback || function(){};

	if(blockTarget!=null) {
		$("#"+blockTarget).block({
			message: 'Chargement...', 
			css: { 
					backgroundColor: '#000',
				 	color: '#FFF',
				 	opacity: '.5',
				 	border: 'none',
				 	padding: '5px',
			 		'-webkit-border-radius': '10px',
			 		'-moz-border-radius': '10px' 
			 	},
			overlayCSS: { backgroundColor: '#EBEBEB' }
		});	 
	}

	$.ajax({
		type: "POST",
		url: href,
		dataType : "html",
		data: {}, // necessaire pour passer les proxys sous FF
		success : function(html) {
			target.html(html);
			callback();
			if(blockTarget!=null) {
				$("#"+blockTarget).unblock();
			}
		},
		error : function( httprequest, textStatus, errorThrown){
			if(blockTarget!=null) {
				$("#"+blockTarget).unblock();
			}
		}
	});
};

$.goHref2 = function(href,blockTarget, nbSent) {
	var target = $(this);
	if (nbSent > 2) {
		alert('Attention, le quota d\'envoi de SMS maximal a été atteint pour la session.')
	}
	else {
		if(blockTarget!=null) {
			$("#"+blockTarget).block({
				message: 'Envoi du SMS...', 
				css: { 
						backgroundColor: '#000',
					 	color: '#FFF',
					 	opacity: '.5',
					 	border: 'none',
					 	padding: '5px',
				 		'-webkit-border-radius': '10px',
				 		'-moz-border-radius': '10px' 
				 	},
				overlayCSS: { backgroundColor: '#EBEBEB' }
			});	 
		}
	
		$.ajax({
			type: "POST",
			url: href,
			dataType : "html",
			data: {}, // necessaire pour passer les proxys sous FF
			success : function(html) {
				nbSent = nbSent + 1;
				if(blockTarget!=null) {
					$("#"+blockTarget).unblock();
				}
			},
			error : function( httprequest, textStatus, errorThrown){
				if(blockTarget!=null) {
					$("#"+blockTarget).block({
						message: 'Erreur lors de l\'envoi du SMS...', 
						css: { 
								backgroundColor: '#000',
							 	color: '#FFF',
							 	opacity: '.5',
							 	border: 'none',
							 	padding: '5px',
						 		'-webkit-border-radius': '10px',
						 		'-moz-border-radius': '10px' 
						 	},
						overlayCSS: { backgroundColor: '#EBEBEB' }
					}).unblock();	 
				}
			}
		});
	}
	return nbSent;

};



})(jQuery);
