// These links have to be set in the base page 
// for the following javascript to work

/*
<LINK REL = "stylesheet" HREF = "Stylesheets/unsupported.css" TYPE = "text/css"> 
<LINK REL = "stylesheet" HREF = "Stylesheets/winie.css" TYPE = "text/css" DISABLED> 
<LINK REL = "stylesheet" HREF = "Stylesheets/win_mac_firefox.css" TYPE = "text/css" DISABLED>

<SCRIPT LANGUAGE="javascript" TYPE="text/javascript" SRC="JavaScript/stylemanager.js"></SCRIPT>
*/
//alert(navigator.userAgent);
// Function to change stylesheet

var ua = navigator.userAgent;
var sheets = document.styleSheets;
var iCurrSheet = 0;

function toggleSheets(index) 
{
  sheets[(index+1)%3].disabled = true;
  sheets[(index+2)%3].disabled = true;
  sheets[index].disabled = false;
} 
function toggleSheets2(index) 
{
  sheets[iCurrSheet].disabled = true;
  sheets[index].disabled = false;
  iCurrSheet = index;
} 
/*
function printSheets() 
{
  alert(sheets[0].disabled); 
  alert(sheets[1].disabled);
  alert(sheets[2].disabled);
}
*/
// Function to manage stylesheet change

var ua = navigator.userAgent;
var browserName=navigator.appName;

if (ua.indexOf("Windows") !=-1)
{
	if (ua.indexOf("MSIE") != -1)
	{
//		alert('MSIE stylesheet 1');
		toggleSheets(1);
//		printSheets();
	}
	else if (ua.indexOf("Gecko") != -1)
	{
//		alert('Netscape stylesheet2');
		toggleSheets(2);
//		printSheets();
	}
	else
	{
		//alert("Error (WIN01): The " + browserName + " browser is not supported! \n\n Browser recommendations for Windows users: \n\n Microsoft Internet Explorer 6.0 \n Firefox 1.0 \n Netscape 7.2");
		//history.back();
		self.location.href = "unsupported.aspx";
	}
}
else if (ua.indexOf("Mac") !=-1)
{
	if (ua.indexOf("Safari") != -1)
	{
		//alert("Error (MAC01): The javascript logic designed to manage Cascading Style Sheets for this Website has failed for the " + browserName + " browser! \n\n Browser recommendations for Macintosh users: \n\n Firefox 1.0 \n Netscape 7.2");
		//history.back();
		self.location.href = "unsupported.aspx";
	}
	else if (ua.indexOf("MSIE") != -1)
	{
		//alert("Error (MAC02): The javascript logic designed to manage Cascading Style Sheets for this Website has failed for the " + browserName + " browser! \n\n Browser recommendations for Macintosh users: \n\n Firefox 1.0 \n Netscape 7.2");
		//history.back();
		self.location.href = "unsupported.aspx";
	}
	else if (ua.indexOf("Gecko"))
	{	
//		alert('MAC Netscape stylesheet 2');
		toggleSheets(2);
//		printSheets();
	}
	else
	{
		//alert("Error (MAC03): The " + browserName + " browser is not supported! \n\n Browser recommendations for Macintosh users: \n\n Firefox 1.0 \n Netscape 7.2");
		//history.back();
		self.location.href = "unsupported.aspx";
	}
}
else if (ua.indexOf('X11') !=-1)
{
	if (ua.indexOf("Gecko")!= -1 && ua.indexOf("KHTML") < 0)
	{	
//		alert('Linux Netscape stylesheet 2');
		toggleSheets(2);
//		printSheets();
	}
	else
	{
		//alert("Error (Linux01): The " + browserName + " browser is not supported! \n\n Browser recommendations for Linux users: \n\n Firefox 1.0 \n Netscape 7.2");
		//history.back();
		self.location.href = "unsupported.aspx";
	}
}
else
{
	//alert("Error (UNI01): The " + browserName + " browser is not supported! \n\n Browser recommendations for Windows users: \n\n Microsoft Internet Explorer 6.0 \n Firefox 1.0 \n Netscape 7.2 \n\n Browser recommendations for Macintosh users: \n\n Firefox 1.0 \n Netscape 7.2");
	//history.back();
	self.location.href = "unsupported.aspx";
}