// JavaScript Document

/**
 * JavaScript detectmobilebrowser (http://detectmobilebrowser.com/)
* edited by Tahzoo: Frank M. Taylor on 9.28.11 for Breastcancer.org
 **/

function gomobile()

{
//Create a custom rewrite URL which directs the user to a mobile version

var full=window.location.host;				//get user's current URL
var mobile = "m";							//change this if BCO decides to have a different subdomaain for mobile

var domains = full.split('.'); 
	if (domains.length > 2)                //the user is on a subdomain (we know this because there's more than 2 periods). 
		{
			var domain = domains[1];		//breastcancer
			var type = domains[2]			//.org   
			var newUrl = "http://" + mobile + "." + domain + "." + type  + document.location.pathname;
		}
		else {									//user isn't on a subdomain
			var domain = "breastcancer";		//Change this if you're on a different domain (and if you are, why do you need this?) 
			var type = domains[1]				//.org
			var newUrl = "http://" + mobile + "." + domain + "." + type  + document.location.pathname;
			};
	
	window.location = newUrl;

	}

