/*
<script type="text/javascript">
	$(document).ready(function(){
		$("#c2c_button").click(function(){
			$("#c2c").click2call({
				token : '<?php echo md5($_SERVER['HTTP_HOST']) ?>',
				url	  : '<?php echo WB_URL ?>/c2c.plugin.php'
			});
		});
	});				
</script>
*/
(function($)
{
	$.fn.click2call = function(options)
	{
		var defaults = 
		{
			token : '',
			url : ''
		}
		var o = $.extend(defaults, options);
		var $this = $(this);
		var num = $this.val();
		
		if ( num == '' )
		{
			alert('Veuillez saisir un numéro de télephone afin que nous puissions vous joindres.');	
		} else {
			$this.val('Patientez...');
			var requests = 
			{
				'token'	   : o.token,
				'function' : 'calling',
				'numero'   : num	
			}
			
			$.post(o.url, requests, function(json){
				
				$this.val(json.reponse);
				
			}, "json");	
		}		
	}
})(jQuery);
