
//Set the following global variables:
//gBrowser, gVersion, gSystem, gNS4

function NextChar(st,findst){
	//Returns 0 if findst is not found, else return charpos following substring.
	//Result is also stored in variable NextCharPos (which is local to outer function block).
	var p=st.indexOf(findst);
	return NextCharPos=(p<0?0:p+findst.length);
}

var NextCharPos;
var UA = navigator.userAgent.toLowerCase();

if (NextChar(UA,'konqueror')){
	gBrowser="Konqueror"; gSystem="Linux";
}else if(NextChar(UA,'opera')) 
	gBrowser="Opera"
else if(NextChar(UA,'webtv'))
	gBrowser="WebTV";
else if(NextChar(UA,'icab'))
	gBrowser="iCab"
else if(NextChar(UA,'msie'))
	gBrowser="IE"
else if(!NextChar(UA,'compatible')){
	gBrowser="NS"
	gVersion=UA.charAt(8);
}else 
	gBrowser="unknown";

if(!window.gVersion)
	gVersion=UA.charAt(NextCharPos+1);
if(!window.gSystem){
	if(NextChar(UA,'linux'))
		gSystem="Linux";
	else if(NextChar(UA,'x11'))
		gSystem="Unix";
	else if(NextChar(UA,'mac'))
		gSystem="Mac"
	else if(NextChar(UA,'win'))
		gSystem="Win"
	else gSystem="unknown";
}

gNS4=(gBrowser=="NS" && gVersion=="4");
