// JavaScript Document

// Designer will set the next variable - theTitle
var theTitle = "Map of New Hanover Co. NC";
if (theTitle.indexOf("###TITLE##")!=-1) theTitle = "ArcIMS HTML Viewer";
var webParams = document.location.search;
var docTitle = "";
if (webParams!="") {
	webParams = replacePlus(webParams);
	var wpUC = webParams.toUpperCase();
	
	if (wpUC.indexOf("TITLE=")==-1) {
		docTitle = "&Title=" + escape(theTitle);
	} 
} else {
	docTitle = "?Title=" + escape(theTitle);
}
document.writeln("<TITLE>" + theTitle + "</TITLE>");
		
		

function checkBrowser() {

	var version = navigator.appVersion;
	var versNum = parseFloat(version);

	var browser = navigator.appName;
	var isMSIE50 = false;
	
	if (navigator.userAgent.indexOf('MSIE 5') || navigator.userAgent.indexOf('MSIE 6'))
	{isMSIE50 = true};

	var itsOK = false;
	
	
	if (versNum >= 4) 
	{ 
	// Start Mike A's - Resize the window to maximum extent
	window.moveTo(0,0)
	window.resizeTo(window.screen.width -35,window.screen.height -35)
	// End Mike A's - Resize
	
			if (navigator.platform != "MacPPC")
		{ 
			itsOK = true;
		}
		else
		{ 
			// only Netscape on Mac 
			// ... and OK for IE5.0 on Mac 
			if (browser=="Netscape")
			{
				itsOK = true; 
			}
			else
			{
				//OK for IE5.0 on a Mac 
				if (isMSIE50 != false)
				{ 
					itsOK = true;
				}
				else
				{
					itsOk = false;			
				}
			} 
		} 
	}

	if (itsOK == false) {
			//document.write ('<center>The modules available on this site make extensive use of JavaScript <br> and requires a 4.0 Browser (or newer. . . IE5.0 on Mac)</center>');
			// this line added 9/25/02
			document.location = "viewer.htm" + webParams + docTitle;
			// end new line
	} else {
		document.location = "viewer.htm" + webParams + docTitle;
	}
}

function replacePlus(inText) {
	var pos=9;
	while (pos != -1) {
		pos = inText.indexOf('+');
		if (pos!=-1) {
			var lastpos = inText.length;
			var midend = pos;
			var midstart = pos + 1;
			var leftSide = inText.substring(0,midend);
			var rightSide = inText.substring(midstart,lastpos);
			inText = leftSide + "%20" + rightSide;
		}
	}
	return inText;
}