function getBrowser()
{
var agt=navigator.userAgent.toLowerCase();
var v_maj=parseInt(navigator.appVersion);
var v_min=parseFloat(navigator.appVersion);
//alert(agt)
is_nav=((agt.indexOf('mozilla')!=-1)&&(agt.indexOf('spoofer')==-1)&&
(agt.indexOf('compatible')==-1)&&
(agt.indexOf('webtv')==-1)&&(agt.indexOf('msie')==-1));
is_nav3=(is_nav&&(v_maj==3));
is_nav4up=(is_nav&&(v_maj>=4)&&(v_maj<5));
is_nav407up=(is_nav&&(v_min>=4.07));
is_nav408up=(is_nav&&(v_min>=4.08));
is_ie=(agt.indexOf("msie")!=-1);
is_ie3=(is_ie&&(v_maj<4));
is_ie4=(is_ie&&(v_maj==4)&&(agt.indexOf("msie 5")==-1));
is_ie4up=(is_ie&&(v_maj>=4));
is_ie5=(is_ie&&(v_maj==4)&&(agt.indexOf("msie 5")!=-1));
is_ie5up=(is_ie&&!is_ie3&&!is_ie4);
is_win=((agt.indexOf("win")!=-1)||(agt.indexOf("16bit")!=-1));
is_win95=((agt.indexOf("win95")!=-1)||(agt.indexOf("windows 95")!=-1));
is_win98=((agt.indexOf("win98")!=-1)||(agt.indexOf("windows 98")!=-1));
is_winnt=((agt.indexOf("winnt")!=-1)||(agt.indexOf("windows nt")!=-1));
is_win32=(is_win95||is_winnt||is_win98||
((v_maj>=4)&&(navigator.platform=="Win32"))||
(agt.indexOf("win32")!=-1)||(agt.indexOf("32bit")!=-1));
is_firefox=(agt.indexOf("firefox")!=-1);
ff_ver = parseFloat(agt.substring(agt.indexOf("firefox/") + 8));
//alert(ff_ver)
is_opera=(agt.indexOf("opera")!=-1);
opera_ver = v_min;
is_safari=(agt.indexOf("safari")!=-1);
safari_ver = parseInt(agt.substring(agt.indexOf("version/") + 8));
//alert(safari_ver)
is_mac=(agt.indexOf("mac")!=-1);
is_macPPC=(is_mac&&((agt.indexOf("ppc")!=-1)||(agt.indexOf("powerpc")!=-1)));
is_macOSX=(is_mac&&((agt.indexOf("powerpc")!=-1)&&(agt.indexOf("msie 5.1")!=-1)));
is_x86linuxmoz=((agt.indexOf("linux")!=-1)&&(agt.indexOf("mozilla")!=-1)&&(agt.indexOf("i686")!=-1));
is_solarismoz=((agt.indexOf("sunos")!=-1)&&(agt.indexOf("mozilla")!=-1));
}
function setCookie(name, value, expires, path, domain, secure) {
var curCookie=name+"="+escape(value)+
((expires)?"; expires="+expires.toGMTString():"")+
((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+
((secure)?"; secure":"");
document.cookie=curCookie;
}
function getCookie(name) {
var dc=document.cookie;
var prefix=name+"=";
var begin=dc.indexOf("; "+prefix);
if(begin==-1) {
begin=dc.indexOf(prefix);
if(begin!=0)
return null;
}
else
begin+=2;
var end=document.cookie.indexOf(";",begin);
if(end==-1)
end=dc.length;
return unescape(dc.substring(begin+prefix.length,end));
}
function deleteCookie(name, path, domain) {
if(getCookie(name))
document.cookie=name+"="+((path)?"; path="+path:"")+
((domain)?"; domain="+domain:"")+"; expires=Thu, 01-Jan-70 00:00:01 GMT";
}
function fixDate(date) {
var base=new Date(0);
var skew=base.getTime();
if(skew>0)
date.setTime(date.getTime()-skew);
}
var svgInstallBase="http://www.adobe.com/svg/viewer/install/";
var svgInstallPage=svgInstallBase+"auto/";
var svgInfoPage="http://www.adobe.com/svg/";
var svgDownloadPage=svgInstallBase;
var checkIntervalDays=30;
var firstSVG=true; // Ask only once per page even without cookies
function getSVGInstallPage() {
return svgInstallPage+"?"+location;
}
function getCheckInterval() {
return checkIntervalDays*24*60*60*1000;
}
function setSVGCookie() {
if(getCheckInterval()>0) {
var expires=new Date();
fixDate(expires); // NN2/Mac bug
expires.setTime(expires.getTime()+getCheckInterval());
setCookie('SVGCheck','0',expires,'/')
}
}
function isSVGPluginInstalled() {
return (navigator.mimeTypes["image/svg"]&&navigator.mimeTypes["image/svg"].enabledPlugin!=null)||
(navigator.mimeTypes["image/svg-xml"]&&navigator.mimeTypes["image/svg-xml"].enabledPlugin!=null)||
(navigator.mimeTypes["image/svg+xml"]&&navigator.mimeTypes["image/svg+xml"].enabledPlugin!=null);
}
function checkSVGViewer() {
window.askForSVGViewer=false;
if(window.svgInstalled)
return;
getBrowser();
if(is_win32 && is_ie4up) {
window.svgViewerAvailable=true;
window.svgInstalled=isSVGControlInstalled();
if(!window.svgInstalled)
window.askForSVGViewer=true;
}
	else if((is_win32 && is_nav4up) || (is_macPPC && is_nav407up) || is_x86linuxmoz || is_solarismoz) {
		window.svgViewerAvailable=true;
		window.svgInstalled=isSVGPluginInstalled();
		if(!window.svgInstalled&&((is_nav408up&&navigator.javaEnabled())||is_x86linuxmoz||is_solarismoz))
			window.askForSVGViewer=true;
	}
	else if(is_macPPC && is_ie5up)
		window.svgViewerAvailable=true;
}
function getSVGViewer() {
if(confirm('The Adobe SVG Viewer is not installed. Download now?\n\n')) location=getSVGInstallPage();
else  location="html/intro.html";
}
function checkAndGetSVGViewer() {
checkSVGViewer();
var svgCookie=getCookie('SVGCheck');
if(firstSVG&&!svgCookie) {
if(window.askForSVGViewer) {
setSVGCookie();
getSVGViewer();
}
firstSVG=false;
}
}
function emitSVG(embedAttrs) {
	if(is_opera) {
		if(opera_ver < 9) {
			document.writeln('<table width=100% border=0 style="margin-top:100px;font-family:arial,helvetica;"><tr><td width=600 align=center>');
			document.writeln('<div style="padding:0px 0px;font-size:18px;">Please <a style="text-decoration:none;" href="http://www.opera.com/download/">upgrade</a> to the latest version.</div>');
			document.writeln('</div></td></tr></table>');
		}
		else document.writeln('<center><embed '+embedAttrs+'></center>');
		return;
	}
	else if(is_firefox) {
		if(ff_ver < 2) {
			document.writeln('<table width=100% border=0 style="margin-top:100px;font-family:arial,helvetica;"><tr><td width=600 align=center>');
			document.writeln('<div style="width:600px;padding:5px 0 20px 0;background-color:#ffff80;font-size:18px;color:#606060;text-align:center;">');
			document.writeln('<p style="font-size:24px;">THIS IS AN SVG SITE.</p>');
			document.writeln('<p">Your browser has native SVG support, not fully finalized.</p>');
			document.writeln('<p">Please upgrade to the <a style="text-decoration:none;" href="http://www.mozilla.com/en-US/firefox/">latest version</a> of Firefox</p>');
			document.writeln('<p">or visit the <a style="text-decoration:none;" href="html/intro.html">html version</a></p>');
			document.writeln('</div></td></tr></table>');
		}
		else document.writeln('<center><embed '+embedAttrs+'></center>');
		return;
	}
	else if(is_safari && safari_ver >= 3) {
		document.writeln('<center><embed '+embedAttrs+'></center>');
		return;
	}
	else if(window.svgInstalled) {
		document.writeln('<center><embed '+embedAttrs+'></center>');
	}
	else if(window.askForSVGViewer)	{
		if(navigator.appName=='Netscape') {
			document.writeln('<p>This is an SVG web site.');
			document.writeln('<a href="'+getSVGInstallPage()+'">Click here</a> to download the plugin.</p>');
			document.writeln('<p>Or view the <a href="html/intro.html">html version</a></p>');
		}
		else document.writeln('<center><embed '+embedAttrs+' pluginspage="'+getSVGInstallPage()+'"></center>');
	}
	else if(window.svgViewerAvailable) document.writeln('<center><embed '+embedAttrs+' pluginspage="'+svgDownloadPage+'"></center>');
	else {
		if (safari) {
			document.writeln('<table width=100% border=0 style="margin-top:100px;font-family:arial,helvetica;"><tr><td width=600 align=center>');
			document.writeln('<div style="width:600px;padding:5px 0 20px 0;background-color:#ffff80;font-size:18px;color:#606060;text-align:center;">');
			document.writeln('<p style="font-size:24px;">THIS IS AN SVG SITE.</p>');
			document.writeln('<p">Safari 3 has native SVG support. Please upgrade to <a style="text-decoration:none;" href="http://www.apple.com/safari/download/">latest version</a> of Safari</p>');
			document.writeln('<p">or install SVG Carbon</p>');
			document.writeln('<p">or visit the <a style="text-decoration:none;" href="html/intro.html">html version</a></p>');
			document.writeln('</div></td></tr></table>');
		}
		else {
			document.writeln('<table width=100% border=0 style="margin-top:100px;font-family:arial,helvetica;"><tr><td width=600 align=center>');
			document.writeln('<div style="width:600px;padding:5px 0 20px 0;background-color:#ffff80;color:#606060;font-family:Arial,Helvetica,Sans Serif;text-align:center;">');
			document.writeln('<p style="font-size:20px;">THIS IS AN SVG SITE.</p>');
			document.writeln('<p>To view this site you can use one of the following browsers:</p><p>Opera 9<br/>Internet Explorer + ASV3 plugin<br/>Safari 3<br/>Firefox 2</p>');
			document.writeln('<p>or visit the <a style="text-decoration:none;" href="html/intro.html">html version</a></p>');
			document.writeln('</div></td></tr></table>');
		}
	}
}

