var detect = navigator.userAgent.toLowerCase();
//window.alert(detect);
var browsers = new Array();
//Define variable to hold browser that user is using
var userBrowser;
var userBrowserVersion 	= navigator.appVersion;//.charAt(0);

browsers[0] = 'safari';
browsers[1] = 'firefox';
browsers[2] = 'msie';
browsers[4] = 'other';

//Define associative array with stylesheets
var stylesheet 	= new Array();

stylesheet["msie"] 		= "default_ie.css";
stylesheet["safari"] 	= "default_safari.css";
stylesheet["firefox"] 	= "default_firefox.css";
stylesheet["mac_firefox"] 	= "default_mac_firefox.css";
stylesheet["mac_ie"] 	= "default_mac_ie.css";
stylesheet["other"] 	= "default_ie.css";

//Define variable that holds stylesheet directory
var style_dir	= "/css/";

for(i = 0; i < browsers.length; i++)
{
	if(checkBrowser(browsers[i]))
	{
		//If the browser is internet explorer check if it is a macintosh
		if(browsers[i] == "msie")
		{
			//window.alert(navigator.platform);//Debug
			if(navigator.platform == "MacPPC")
			{
					userBrowser = "mac_ie";
			}
			else
			{
				userBrowser = browsers[i];
			}
			
		}
		else if(browsers[i] == "firefox")
		{
			//window.alert(navigator.platform);//Debug
			if((navigator.platform == "MacPPC") || (navigator.platform == "MacIntel"))
			{
			
					userBrowser = "mac_firefox";
			}
			else
			{
				userBrowser = browsers[i];
			}
			
		}
		
		else
		{
			//window.alert('Your browser is ' + browsers[i])
			//Store users browser in variable then break out of the for loop
			userBrowser = browsers[i];
		}
			//Define variable that holds location of css file
			var style_file = style_dir + stylesheet[userBrowser];
			
			//Output correct stylesheet
			window.document.write('<link rel="stylesheet" href='+style_file+' type="text/css">');
//			window.alert(userBrowser); //Debug
			//window.alert(style_file);//Debug
	 
			break;
		
	}
	else if(browsers[i] == "other")
	{
		//Set user browser to other
		userBrowser = "other";

		//Define variable that holds location of css file
		var style_file = style_dir + stylesheet[userBrowser];
		
		//Output correct stylesheet
		window.document.write('<link rel="stylesheet" href='+style_file+' type="text/css">');
	}
	{
		continue;
	}

}

//window.alert(userBrowser); //Debug
//window.alert(detect);
function checkBrowser(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}