function MyMobileDetect(pref, url) {

if(pref == "bureau"){setPrefDesktop();}
if(pref == "mobile"){setPrefMobile();}
if(pref == "nothing"){
	if(
		(navigator.userAgent.match(/iPhone/i) && !navigator.userAgent.match(/iPad/i))||
		(navigator.userAgent.match(/iPod/i))||
		(navigator.userAgent.match(/BlackBerry/i))||
		(navigator.userAgent.match(/SymbianOS/i))||
		(navigator.userAgent.match(/Android/i))||
		(navigator.userAgent.match(/NetFront/i))
	){
		if ( Cookie.get( "mobile_gbizet" ) == null ) {
			var question = confirm("Utiliser la version optimise pour mobile de guillaumebizet.fr ?")
			if (question){setPrefMobile();window.location = "http://mobile.guillaumebizet.fr/" + url;}
			else{setPrefDesktop();}
		}
		else if(Cookie.get( "mobile_gbizet" ) == '1'){setPrefMobile();window.location = "http://mobile.guillaumebizet.fr/" + url;}
	}
}
}

function setPrefMobile(){Cookie.set("mobile_gbizet", '1', 7);}
function setPrefDesktop(){Cookie.set("mobile_gbizet", '2', 7);}

var Cookie = {
  set: function(name, value, daysToExpire) {  
    var expire = '';  
    if (daysToExpire != undefined) {  
      var d = new Date();
      d.setTime(d.getTime() + (86400000 * parseFloat(daysToExpire)));  
      expire = '; expires=' + d.toGMTString();  
    }  
    return (document.cookie = escape(name) + '=' + escape(value || '') + expire);  
  },
  get: function(name) {  
    var cookie = document.cookie.match(new RegExp('(^|;)\s*' + escape(name) + '=([^;\s]*)'));  
    return (cookie ? unescape(cookie[2]) : null);  
  }  
};
