// JavaScript Document

  var current_location  = document.location.href; 
  var index             = current_location.indexOf(".net/");
  current_location      = current_location.substring(index+4);
  current_location      = current_location.split("/",2);
  current_location      = current_location[1];

  // If micro with its own domain name (not on yannick.net)
  if (current_location == "") {
    current_location  = document.location.href; 
  }

	//On doit vérifier si c'est un appareil mobile
	var deviceIphone = "iphone";
	var deviceIpod = "ipod";
	var deviceWinMob = "windows ce";
	var deviceAndroid = "android";
	
	//Détection de l'agent dans une variable texte converti en minuscules
	var uagent = navigator.userAgent.toLowerCase();
	
	/*Scripts de détection*/
		// Detects if the current device is an iPhone.
		function DetectIphone(){
		   if (uagent.search(deviceIphone) > -1)
			  return true;
		   else
			  return false;
		}

		// Detects if the current device is an iPod Touch.
		function DetectIpod(){
		   if (uagent.search(deviceIpod) > -1)
			  return true;
		   else
			  return false;
		}

		// Detects if the current device is an Android OS-based device.
		function DetectAndroid(){
		   if (uagent.search(deviceAndroid) > -1)
			  return true;
		   else
			  return false;
		}

		// Detects if the current browser is a Windows Mobile device.
		function DetectWindowsMobile(){
		   if (uagent.search(deviceWinMob) > -1)
			  return true;
		   else
			  return false;
		}

		// Detects if the current device is an Android OS-based device and the browser is based on WebKit.
		function DetectAndroidWebKit(){
			if (DetectAndroid()){
				if (DetectWebkit()){
					return true;
				}else{
					return false;
				}
		   }else{
				return false;
			}
		 }

		// Detecte les quelques OS mobiles
		function DetectMobileOS(){
			if (DetectIphone() || DetectIpod() || DetectAndroid() || DetectAndroidWebKit()|| DetectWindowsMobile()){
				//Création du cookie en fonction de l'agent trouvé
				var url = "http://www.singlefamilyhomesottawa.com/m/index.php"
				//alert('Vous allez être redirigé vers ' + url);
				window.location = url;
				return true;
			}else{
				return false;
			}
		}
	/*Scripts de détection*/
	
	//Détection de l'agent
	DetectMobileOS();



