var sniffer = {
	init:function() {
 
		// Snag the URL, then look for the term "fullbrowser".  If not found, look for "mobile" or "m.exanple" in the url and "Home" or whatever the index.html title.  If mobile isn't
		// there and home is, then run the sniffer.  If we are in the mobile sub-domain, add our text-only stylesheets. 
 
		var fullURL = document.URL;
		var index = fullURL.indexOf("fullbrowser");
		var homeTitle = "Birmingham Web Design and Application Development";
 
		if (index == -1) {
			var referrer = document.referrer;
			var title = document.title;
			
			if (fullURL.indexOf("t.kinetic.com") == -1 && title.indexOf(homeTitle) != -1 && referrer.indexOf(".kinetic.com/") == -1) {
					sniffer.sniff();			
				} else if (fullURL.indexOf("t.kinetic.com") != -1 && fullURL.indexOf("extranet.kinetic.com") == -1 ) {
					document.write('<link rel="stylesheet" type="text/css" media="screen" href="css/anti-screen.css" />\n<link rel="stylesheet" type="text/css" media="screen" href="css/handheld.css" />\n<meta name="viewport" content="width=300" />');
					}
		}
	},
	
	// The following function redirects the user to the appropriate mobile site.
 
	sniff:function() {
		var userAgent = navigator.userAgent;
 
		/*
		 * Some notes...
		 * 
		 * User Agent strings are long and ugly.  Sometimes, one string will be caught
		 * by multiple cases below.  The reason they are in the order they are is to
		 * direct them as accurately as possible.
		 *
		 * - "Mini" is before "Mobi" because some strings contain both, and the ones that
		 *   contain "Mini" are best suited to the text version, whereas the ones that
		 *   contain "Mobi" but NOT "Mini" should be able to handle the graphical one.
		 *   Thus, "Mini" gets handled first to catch those that have both "Mini" and "Mobi"
		 *
		 * - "Symbian" & "Tablet" can handle JavaScript, so they should get the scripty version.
		 *
		 */
 
		if (  userAgent.indexOf("iPhone") != -1 ||
			userAgent.indexOf("iPod") != -1 ||
			userAgent.indexOf("BlackBerry") != -1 ||
			userAgent.indexOf("Symbian") != -1 ||
			userAgent.indexOf("Android") != -1 || 
			userAgent.indexOf("Palm") != -1 ) {
			window.location = "http://www.kinetic.com/mobile";			
		}
 
		if (  userAgent.indexOf("Nokia") != -1 ||
			userAgent.indexOf("MOT") != -1 ) {
			window.location = "http://t.kinetic.com";
		}
 
		if ( userAgent.indexOf("Mini") != -1 ) {
			window.location = "http://t.kinetic.com";
		}
 
		if ( userAgent.indexOf("Mobi") != -1 ) {
			window.location = "http://www.kinetic.com/mobile";
		}
		
		if ( userAgent.indexOf("iPad") != -1 ) {
			window.location = "http://www.kinetic.com/ipad.html";
		}
		
		if ( userAgent.indexOf("Tablet") != -1 ) {
			window.location = "http://www.kinetic.com/tablet.html";
		}
 
	}
};


 
sniffer.init();