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 fullRequest = fullURL.indexOf("fullbrowser");
 
		if (fullRequest == -1) {
				sniffer.sniff();
            }
        
 
	},
	
	// 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("iPad") != -1 ||
			userAgent.indexOf("BlackBerry") != -1 ||
			userAgent.indexOf("Symbian") != -1 ||
			userAgent.indexOf("Android") != -1 ||
			userAgent.indexOf("Tablet") != -1 || 
			userAgent.indexOf("Palm") != -1 ||
			userAgent.indexOf("Nokia") != -1 ||
			userAgent.indexOf("MOT") != -1 ||
			userAgent.indexOf("Mini") != -1 ||
			userAgent.indexOf("Mobi") != -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" />'); 
			$(document).ready(
				function() {
					$("ul").removeClass("sf-menu sf-js-enabled sf-shadow");
					$("#header").prepend("<h1>Alabama Ballet</h1>");
					$("#header-subpage").prepend("<h1><a href='index.shtml'>Alabama Ballet</a></h1>");
					$("#footer").append("<span style='display:block;background-color: #333;text-align:center;font-size:12px;padding: 10px 0;margin:10px 0;'><a href='?fullbrowser' style='color: #ccc;text-decoration:none;'>View Full Site</a></span>");
			});
		}
 
	}
};
 
sniffer.init();


