/********************************
* Detection navigateurs mobiles *
********************************/

var deviceIphone = "iphone";
var deviceIpod = "ipod";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current device is an iPhone.
function detect_mobile_Iphone()
{
   if (uagent.search(deviceIphone) > -1)
      return true;
   else
      return false;
}

//**************************
// detect_mobile_s if the current device is an iPod Touch.
function detect_mobile_Ipod()
{
   if (uagent.search(deviceIpod) > -1)
      return true;
   else
      return false;
}

//**************************
// detect_mobile_s if the current device is an iPhone or iPod Touch.
function detect_mobile_IphoneOrIpod()
{
    if (detect_mobile_Iphone())
       return true;
    else if (detect_mobile_Ipod())
       return true;
    else
       return false;
}

var deviceS60 = "series60";
var deviceSymbian = "symbian";
var engineWebKit = "webkit";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is the S60 Open Source Browser.
// Screen out older devices and the old WML browser.
function detect_mobile_S60OssBrowser()
{
   if (uagent.search(engineWebKit) > -1)
   {
     if ((uagent.search(deviceS60) > -1 || 
          uagent.search(deviceSymbian) > -1))
        return true;
     else
        return false;
   }
   else
      return false;
}

var deviceAndroid = "android";

//**************************
// detect_mobile_s if the current device is an Android OS-based device.
function detect_mobile_Android()
{
   if (uagent.search(deviceAndroid) > -1)
      return true;
   else
      return false;
}

var deviceWinMob = "windows ce";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is a Windows Mobile device.
function detect_mobile_WindowsMobile()
{
   if (uagent.search(deviceWinMob) > -1)
      return true;
   else
      return false;
}

var deviceBB = "blackberry";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is a BlackBerry of some sort.
function detect_mobile_BlackBerry()
{
   if (uagent.search(deviceBB) > -1)
      return true;
   else
      return false;
}

var devicePalm = "palm";

//Initialize our user agent string to lower case.
var uagent = navigator.userAgent.toLowerCase();

//**************************
// detect_mobile_s if the current browser is on a PalmOS device.
function detect_mobile_PalmOS()
{
   if (uagent.search(devicePalm) > -1)
      return true;
   else
      return false;
}

//**************************
// detecte si c'est un navigateur mobile
function detect_mobile_nav()
{
	if(detect_mobile_IphoneOrIpod() || detect_mobile_S60OssBrowser() || detect_mobile_Android() || detect_mobile_WindowsMobile() || detect_mobile_BlackBerry() || detect_mobile_PalmOS())
	{
		return(true);
	}
	else
	{
		return(false);
	}
}

//**************************
// rebascule vers version mobile si nav mobile
function detect_mobile_rerout(mobileUrl)
{
	if(detect_mobile_nav())
	{
		if(confirm("Ce site dispose d'une version optimisée pour les navigateurs mobiles. Souhaitez vous l'utiliser ?"))
		{
			top.window.location = mobileUrl;
		}
	}
}
