//JS below called from index.php page - Interactive Constitution Landing Page
//
//direct inputs: navigator.userAgent
//indirect inputs: none
//
//purpose: determine which browser, browser version and OS user is coming to the site for
//in order to call appropriate style sheet. Spacing in landing page requires different
//spacing for different browsers. 
//Also, code at bottom can be used to see browser variables for testing, and throw those
//up in a pop-up window.
//
//browsers actively checking for: Mac NN, Mac IE, Mac Safari, and other. Other specific
//browsers will be added as needed. 

var detect = navigator.userAgent.toLowerCase();
var OS,browser,total,thestring;
var version = 0;

if (checkIt('konqueror'))
{
	browser = "Konqueror";
	OS = "Linux";
}
else if (checkIt('omniweb')) 
{
	browser = "OmniWeb";
}
else if (checkIt('safari')) 
{
	browser = "Safari";
}	
else if (checkIt('opera')) 
{
	browser = "Opera";
}	
else if (checkIt('webtv')) 
{	
	browser = "WebTV";
}	
else if (checkIt('icab')) 
{
	browser = "iCab";
}
else if (checkIt('msie')) 
{
	browser = "Internet Explorer";
}	
else if (!checkIt('compatible'))
{
	browser = "Netscape Navigator";
	version = detect.charAt(8);
}
else browser = "An unknown browser";

if (!version) version = detect.charAt(place + thestring.length);

if (!OS)
{
	if (checkIt('linux')) OS = "Linux";
	else if (checkIt('x11')) OS = "Unix";
	else if (checkIt('mac')) OS = "Mac";
	else if (checkIt('win')) OS = "Windows";
	else OS = "an unknown operating system";
}

function checkIt(string)
{
	place = detect.indexOf(string) + 1;
	thestring = string;
	return place;
}


//Code to present appropriate style sheet based on browser, browser version and OS.
//Additional conditions can be added as needed.
if ((OS == "Mac") && (browser == "Netscape Navigator") && (version <= 6)) {
	document.write("<link rel='stylesheet' type='text/css' href='css/hp_style_mac_nn.css'>");
	style = 'hp_style_mac_nn.css';
}
else if ((OS =="Mac") && (browser == "Internet Explorer")) {
	document.write("<link rel='stylesheet' type='text/css' href='css/hp_style_mac_ie.css'>");
	style = 'hp_style_mac_ie.css';
}
else if ((OS =="Mac") && (browser == "Safari")) {
	document.write("<link rel='stylesheet' type='text/css' href='css/hp_style_mac_safari.css'>");
	style = 'hp_style_mac_safari.css';
}
else {
	document.write("<link rel='stylesheet' type='text/css' href='css/hp_style_new.css'>");
	style = 'hp_style_new.css';
}

//Code to pop-up window with browser variables for testing 
//var newwin = window.open("", "linklist", "menubar,toolbar=no,scrollbars,resizable,width=500,height=400")
//newwin.document.write('OS=' + OS + '<BR>');
//newwin.document.write('browser=' + browser + '<BR>');
//newwin.document.write('version=' + version + '<BR>');
//newwin.document.write('style=' + style + '<BR>');
//newwin.document.write('detect=' + detect + '<BR>'); 
//newwin.document.write('place=' + place + '<BR>'); 
//newwin.document.write('thestring=' + thestring + '<BR>'); 
//newwin.document.write('navigator.appCodeName=' + navigator.appCodeName + '<BR>');  
//newwin.document.write('navigator.appName=' + navigator.appName + '<BR>');  
//newwin.document.write('navigator.appMinorVersion=' + navigator.appMinorVersion + '<BR>');  
//newwin.document.write('navigator.cpuClass=' + navigator.cpuClass + '<BR>');  
//newwin.document.write('navigator.platform=' + navigator.platform + '<BR>');  
//newwin.document.write('navigator.plugins=' + navigator.plugins + '<BR>');  
//newwin.document.write('navigator.opsProfile=' + navigator.opsProfile + '<BR>');  
//newwin.document.write('navigator.userProfile=' + navigator.userProfile + '<BR>');  
//newwin.document.write('navigator.systemLanguage=' + navigator.systemLanguage + '<BR>'); 
//newwin.document.write('navigator.userLanguage=' + navigator.userLanguage + '<BR>');  
//newwin.document.write('navigator.appVersion=' + navigator.appVersion + '<BR>');  
//newwin.document.write('navigator.userAgent=' + navigator.userAgent + '<BR>');  
//newwin.document.write('navigator.onLine=' + navigator.onLine + '<BR>');  
//newwin.document.write('navigator.cookieEnabled=' + navigator.cookieEnabled + '<BR>');  
//newwin.document.write('navigator.systemLanguage=' + navigator.systemLanguage + '<BR>');  
//newwin.document.write('navigator.mimeTypes=' + navigator.mimeTypes + '<BR>');    