
/********************************************
 * Fonction redirect
 * 
 * redirige le visiteur vers la version du site
 * la plus adaptee
 ********************************************/
function redirect() {
	var currentWidth = parseInt(screen.width);
	var browser = "webkit";
	// Taille minimum de l'ecran apres laquelle on passe en version smartphone
	var minWidth = 320;
	// Taille maximum de l'ecran apres laquelle on passe en version pc
	var maxWidth = 800;
	var tabPath = document.location.pathname.split("/");
	
	if (currentWidth >= maxWidth) {
		document.location.href = "http://www.kapt.pro";
	} else if (currentWidth >= minWidth && currentWidth < maxWidth) {
		// Si la taille de l'ecran est superieure a minWidth on passe directement en version smartphone
		if (tabPath[1] != "smartphones") document.location.pathname = "/smartphones";
	} else {
		// Si la taille de l'ecran est inferieure a minWidth
		// Si le navigateur est celui indique par 'browser'
		if (navigator.userAgent.toLowerCase().indexOf(browser) >= 0) {
			if (tabPath[1] != "smartphones") document.location.pathname = "/smartphones";
		} else {
			if (tabPath[1] == "smartphones") document.location.pathname = "/";
		}
	}
}

redirect();

// On scroll d'un pixel pour obliger l'iphone a masquer la barre d'adresse
window.onload = function() { setTimeout("window.scrollTo(0, 1)", 100); }
