var domain = "http://www.advantagelumber.com/mobile/";


//Set a variable to hold whether or not user is coming from the mobile site
if (document.referrer) {
	var referrer_url = document.referrer;
	var first_url_split = referrer_url.split("//");
	var parsed_url = first_url_split[1].split("/");
	var mobile_check = parsed_url[1];
	var full_check = parsed_url[0];
}
else {
	var full_check = "";
}

//Set a variable to hold the path to the desired page
var second_url_split = window.location.href.split(".com/");
var path = second_url_split[1];

//Set the URL of the mobile page
var redirect_url = domain + path;

//Redirect if they're on a mobile device and aren't coming from the mobile site
if ((full_check != "www.advantagelumber.com") && (/iphone|ipod|android|blackberry/i.test(navigator.userAgent))) {
	location.replace(redirect_url);
}
