// function de detection appareil mobile
$(document).ready(function () {
	if( 
		(navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) ||
		(navigator.userAgent.match(/Android/i)) || (navigator.userAgent.match(/Blackberry/i)) || (navigator.userAgent.match(/palm/i))  || 
		(navigator.userAgent.match(/opera Mobi/i)) ||(navigator.userAgent.match(/opera Mini/i)) || (navigator.userAgent.match(/nokia/i))  || 
		(navigator.userAgent.match(/SymbianOS/i)) ||(navigator.userAgent.match(/Windows CE/i)) || (navigator.userAgent.match(/BenQ/i)) 
	)	{

		var  url_mobile = ( function() {
		    var url ;
		    $.ajax({
		          async: false,  //mode synchrone très important
		          type: "POST",
		          url: "api/mobile?k=jB10mR03",
		          dataType: 'json',
		          success: function(data) {url = data.url_mobile;}
		    });
		    return(url) ;
		} )() ;
		var  text_confirm = ( function() {
                    var text ;
                    $.ajax({
                          async: false,  //mode synchrone très important
                          type: "POST", 
                          url: "api/mobile?k=jB10mR03",
                          dataType: 'json',
                          success: function(data) {text = data.texte;}
                    });
                    return(text) ;
                } )() ;

		var question = confirm(text_confirm)
			if (question)
			{
			$(location).attr("href", url_mobile);
			}else{ }
		}
});

