/* STYLESHEET SELECTOR*/
	
	/* This Javascript identifies what browser and OS is running, and serves stylesheets accordingly.
	
		A standard CSS-file, "common.css" is always linked statically in the HTML header. If there is a need for additional tweaking, these tweaks are contained in separate CSS-files, sorted by browser, version and OS. The code in this file decides what additional stylesheets need to be applied.
	
		Browsers with specially written CSS tweaks so far:
			
			- Firefox versions: 2 (and earlier), 3.0, 3.5
			- Opera 9
			- Chrome running under Windows OS
			- Safari running under Windows OS (other Webkit)
			
			+ All Internet Explorer versions 8 and below, although stylesheets for these are served though conditional comments in the HTML header and not through this script.
	*/
	
	// --- START functions and variables ---
	
	//Print stylesheet link tag
	function print_stylesheet (sheet_string) {
		document.write("<link rel='stylesheet' href='css/"+sheet_string+"' type='text/css'/>");
	}
	
	/*	The following lines deal with activating CSS3-features for compatible browsers. For various reasons you may want to disable this.
	
		To deactivate CSS3 style properties, set "allow_css3" below to false.
	*/
	var allow_css3 = true;
	
	function activate_css3 () {
		
		var css3_activated = allow_css3;
		
		if (css3_activated == true)
			print_stylesheet ("CSS3-compatible.css");
	}
	
	// --- END functions and variables ---
	
	
	
	// --- START detection code ---
	
	var user = navigator.userAgent.toLowerCase();
		
	//Detect Firefox version, serve appropriate stylesheet
	if (/firefox[\/\s](\d+\.\d+)/.test(user)) {
		var ffversion=new Number(RegExp.$1)
		if (ffversion>=3.5) {
			//Firefox 3.5
			print_stylesheet ("FF3-5.css");
			activate_css3();
		} else if (ffversion>=3) {
			//Firefox version 3.0
			print_stylesheet ("FF3-0.css");
			activate_css3();
		} else {
			//Firefox below version 3
			print_stylesheet ("FF2.css");
		}
	}
	
	//Detect Opera version, serve appropriate stylesheet
	if (/opera[\/\s](\d+\.\d+)/.test(user)){
	
		//Common for all Opera versions
		print_stylesheet ("Opera-ALL.css");
		
 		var oprversion=new Number(RegExp.$1)
 		if (!(oprversion>=10))
 			//Opera 9 and below
 			print_stylesheet ("Opera9.css");
 		else
 			//Opera 10 and higher are CSS3-compatible:
 			activate_css3();
 			
 		if (user.indexOf("win",0) != -1)
 			//Opera versions running under Windows:
 			print_stylesheet ("Opera-win.css");
 	}
 	
 	//Detect Webkit browsers, serve appropriate stylesheet
 	if (/safari[\/\s](\d+\.\d+)/.test(user)) {
 	
 		print_stylesheet ("Webkit-all.css");
 		
 		//All supported Webkit versions are CSS3-compatible:
		activate_css3();
 		
 		if (/chrome/.test(user) && user.indexOf("win",0) != -1)
 			//Google Chrome running under Windows:
 			print_stylesheet ("Chrome-win.css");
 			
 		else if (user.indexOf("win",0) != -1)
 			//Other Webkit running under Windows:
 			print_stylesheet ("Safari-win.css");
 	}
 	
 	// --- END detection code ---
