
	// NEEDS to be false in a production environment
	var debug = false;

	// GLOBAL variables
	var _apppath = 'http://www2.verizon.net/micro/speedtest/hsi';
	var _speed = '';
	var _service_class;
	var _dl_class;
	var _ul_class;
	var _local_test_flag = 'false';
	var _debugging_flag = 'false';
	
	// Array for results returned by the Java Applet.
	var testResults = new Array(22);
	var STATUS = 0;
	var SHOW_TEST_ERROR = 1;
	var SHOW_TEST_RESULTS = 2;
	var SPEED_UPLOAD = 3;
	var SPEED_DOWNLOAD = 4;
	var JWEB100_ANALYSIS = 5;
	var SND_LIMITED_PCT = 6;
	var RCV_LIMITED_PCT = 7;
	var NET_LIMITED_PCT = 8;
	var SVC_CLASS_DOWNLOAD = 9;
	var SVC_CLASS_UPLOAD = 10;
	var SERVICE_CLASS = 11;
	var BAD_CABLE = 12;
	var NETWORK_CONGESTION = 13;
	var OPTIMIZATION_NEEDED = 14;
	var HALF_DUPLEX = 15;
	var JWEB100_USER_TEXT = 16;
	var CLIENT_RCV_WINDOW_SIZE = 17;
	var PACKET_LOSS_PCT = 18;
	var DUPLEX_MISMATCH = 19;
	var WIRELESS_LINK = 20;
	var SELECT_SERVER = 21;


//
////////////////////////////////////////////////////////////////////////////////
// General Functions
////////////////////////////////////////////////////////////////////////////////
//

	function isMac()
	{
		var agt=navigator.userAgent.toLowerCase();
		return (agt.indexOf("mac")!=-1);
	}
	
	function isIE()
	{
		var appVer = navigator.appVersion.toLowerCase();
		var iePos  = appVer.indexOf('msie');
		return (iePos!=-1);
	}
	
	function getCookie( name, keyname )
	{
		var nameEQ = name + "=";
		var keynameEQ = keyname + "=";
		
		var cookies = document.cookie.split(';');
		
		for(var i = 0; i < cookies.length; i++)
		{
			var cookie = cookies[i];
			
			while (cookie.charAt(0) == ' ') 
			{
				cookie = cookie.substring(1, cookie.length);
			}
			
			if (cookie.indexOf(nameEQ) == 0) 
			{
				var decoded_cookie = unescape(cookie.substring(nameEQ.length,cookie.length));
				var dc_kv_pairs = decoded_cookie.split('&');
				for (var j = 0; j < dc_kv_pairs.length; j++)
				{
					if (dc_kv_pairs[j].indexOf(keynameEQ) == 0)
					{
						return dc_kv_pairs[j].substring(keynameEQ.length, dc_kv_pairs[j].length);
					}
				}
			}
		}
		return null;
	}
	
	function setCookie( name, value, days )
	{
		if( days )
		{
			var date = new Date();
			date.setTime( date.getTime() + ( days * 24 * 60 * 60 * 1000 ) );
			var expires = "; expires=" + date.toGMTString();
		}
		else 
		{
			var expires = "";
		}
		document.cookie = name + "=" + escape( value ) + expires + "; path=/";
	}
	
	function removeAlpha( theString )
	{
		return theString.replace(/\D/g, "");
	}

	function zeroTestResults ()
	{
		for (i=0; i > 21; i++)
		{
			testResults[i] = '';
		}
		testResults[SPEED_UPLOAD] = '0.0';
		testResults[SPEED_DOWNLOAD] = '0.0';
		testResults[JWEB100_ANALYSIS] = 'Test results are missing.';
		testResults[SND_LIMITED_PCT] = '0.0';
		testResults[RCV_LIMITED_PCT] = '0.0';
		testResults[NET_LIMITED_PCT] = '0.0';
		testResults[SVC_CLASS_DOWNLOAD] = _dl_class;
		testResults[SVC_CLASS_UPLOAD] = _ul_class;
		testResults[SERVICE_CLASS] = _service_class;
		testResults[SELECT_SERVER] = _select_server;
	}

	function switchContent( theContent )
	{
		document.getElementById("st_content").innerHTML = theContent;
	}

	function readSpeedFromCookie()
	{
		var temp;
		var temp2;
		var speed_inrange = false;
		var speeds_allowed = new Array(
			'5M/2M',
			'5M/5M',
			'10M/2M',
			'15M/2M',
			'20M/5M',
			'20M/20M',
			'30M/5M',
			'35M/10M',
			'50M/5M',
			'50M/10M'
			);

		var linespeed = getCookie( 'user_profile', 'linespeed' );

		if (linespeed != undefined && 
				linespeed != '' &&
				linespeed != null)
		{
			for (var i = 0; i < speeds_allowed.length; i++)
			{
				if (linespeed.toUpperCase() == speeds_allowed[i].toUpperCase())
				{
					speed_inrange = true;
				}
			}
			
			temp = linespeed.split('/');
			
			if (temp.length == 2 && speed_inrange)
			{
				_speed = removeAlpha( temp[0] ) +	'_' +	removeAlpha( temp[1] );
				_service_class = _speed;
				temp2 = _service_class.split('_');
				_dl_class = temp2[0];
				_ul_class = temp2[1];
			}
		}
		
		if (debug)
		{
			alert(
				"_speed: " + _speed + "\n" +
				"_service_class: " + _service_class + "\n" +
				"_dl_class: " + _dl_class + "\n" +
				"_ul_class: " + _ul_class + "\n"
				);
		}
	}
	
	function speedConversion ( speed )
	{
		kbps = " Kbps";
		mbps = " Mbps";
		if (speed < 1)
		{
			speed *= 1000;
			return speed + kbps;
		}
		else
		{
			return speed + mbps;
		}
	}
//
////////////////////////////////////////////////////////////////////////////////
// Applet/Object that includes Jweb100 Java Application
////////////////////////////////////////////////////////////////////////////////
//

	function printJavaEmbed ( speedServer, debugFlag, testFlag, isIE )
	{
		var appletMarkup = 
			'<!-- JWeb100 applet parms:' +
			'    DEBUGGING: enables output to java console if value = "true"' +
			'    LOCAL_TEST: produces faux results after 5 second sleep if value = "true"' +
			'    RUN_NOW: will launch the testing thread immediately upon init if value = "true"' +
			'-->' +
			'<applet ' +
			'	id="APPLET_JWEB100" ' +
			'	archive="JWeb100.jar" ' +
			'	width="1" ' +
			'	height="1" ' +
			'	code="JWeb100.class" ' +
			'	codebase="http://' + speedServer + '/SpeedTester/" ' +
			'	MAYSCRIPT>' +
			'  <param ' +
			'		name="TESTPORT" '+
			'		value="2257">' +
			'  <param ' +
			'		name="DEBUGGING" ' +
			'		value="' + debugFlag + '">' +
			'  <param ' +
			'		name="LOCAL_TEST" ' +
			'		value="' + testFlag + '">' +
			'  <param ' +
			'		name="RUN_NOW" ' +
			'		value="true">' +
			'</applet>';	

		var objectMarkup = 
			'<!-- JWeb100 applet parms:' +
			'    DEBUGGING: enables output to java console if value = "true"' +
			'    LOCAL_TEST: produces faux results after 5 second sleep if value = "true"' +
			'    RUN_NOW: will launch the testing thread immediately upon init if value = "true"' +
			'-->' +
			'<OBJECT ' +
			'           id = "APPLET_JWEB100" ' +
			'           name = "APPLET_JWEB100" ' +
		 	'           classid = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" ' +
		 	'           codebase = "http://java.sun.com/update/1.4.2/jinstall-1_4-windows-i586.cab#Version=1,2,0,0" ' +
		 	'           WIDTH = "1" HEIGHT = "1" > ' +
			'								<param name="TESTPORT" value="2257"> ' +
		 	'               <PARAM NAME="CODE" VALUE="JWeb100.class" > ' +
		 	'               <PARAM NAME="CODEBASE" VALUE="http://' + speedServer + '/SpeedTester/" > ' +
		 	'               <PARAM NAME="ARCHIVE" VALUE="JWeb100.jar" > ' +
		 	'               <PARAM NAME="MAYSCRIPT" VALUE="true"> ' +
		 	'               <PARAM NAME="type" VALUE="application/x-java-applet;version=1.4"> ' +
		 	'               <PARAM NAME="scriptable" VALUE="false"> ' +
		 	'               <PARAM NAME="DEBUGGING" VALUE="' + debugFlag + '"> ' +
		 	'               <PARAM NAME="LOCAL_TEST" VALUE="' + testFlag + '"> ' +
		 	'               <PARAM NAME="RUN_NOW" VALUE="true">' +
			'</OBJECT>';
			
		if (isIE)
		{
			return objectMarkup;
		}
		else
		{
			return appletMarkup;
		}
	}

//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Results page functions and content
////////////////////////////////////////////////////////////////////////////////
//

	function speedLimit( testResults )
	{
		return	(testResults[SPEED_UPLOAD] < (testResults[SVC_CLASS_UPLOAD] / 5) ||
						testResults[SPEED_DOWNLOAD] < (testResults[SVC_CLASS_DOWNLOAD] / 5));
	}
	
	var pxLength = 230;
	var downSpeeds = new Array(1, 3, 5, 7.1);
	var upSpeeds = new Array(0.056, 0.128, 0.256, 0.384, 0.768);
	var ARROWUP = 0;
	var ARROWDOWN = 1;
	var ARROWNONE = 2;
	
	function printBox( state, boxContent )
	{
		var leftBoxImgs = new Array( 
			'<img src="' + _apppath + '/images/boxLeftArrowUp.gif" alt="" width="34" height="65" border="0" /><br />',
			'<img src="' + _apppath + '/images/boxLeftArrowDown.gif" alt="" width="34" height="65" border="0" /><br />',
			'<img src="' + _apppath + '/images/boxLeft.gif" alt="" width="14" height="65" border="0" /><br />'
			);
		var leftBoxImg = '';
		if (state == ARROWUP || state == ARROWDOWN || state == ARROWNONE)
		{
			leftBoxImg = leftBoxImgs[state];
		}
		else
		{
			leftBoxImg = leftBoxImgs[ARROWNONE];
		}
		
		var boxMarkup =
			'<table cellspacing="0" cellpadding="0" border="0">' +
			'	<tr>' +
			'		<td>' +
			leftBoxImg +
			'		</td>' +
			'		<td style="vertical-align: middle; background-image: url(' + _apppath + '/images/boxMid.gif);" height="65" valign="top">' +
			'			<div style="font-size: smaller;	text-align: center;">' + boxContent + '</div>' +
			'		</td>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/boxRight.gif" alt="" width="14" height="65" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'</table>';
		return boxMarkup;
	}
	
	function printBoxes( download, upload, package )
	{
		var statusText = '';
		var downText = 'Your <span style="color: #cc0000; font-weight: bold;">download</span><br /> speed is:<br /><span style="color: #309618;	font-weight: bold;">' + speedConversion( download ) + '</span>';
		var upText = 'Your <span style="color: #cc0000; font-weight: bold;">upload</span><br /> speed is:<br /><span style="color: #309618;	font-weight: bold;">' + speedConversion( upload ) + '</span>';
		
		var boxesMarkup =
			'<b>We have finished your connection speed test.</b><br />' +
			'<br />' +
			'<center>' +
			'<table cellspacing="0" cellpadding="0" border="0">' +
			'	<tr>' +
			'		<td valign="top" width="50%">' +
			'			' + printBox(ARROWDOWN, downText) +
			'		</td>' +
			'		<td valign="top" width="50%">' +
			'		  ' + printBox(ARROWUP, upText) +
			'		</td>' +
			'	</tr>' +
			'</table>' +
			'</center>';
		return boxesMarkup;
	}
	
	function printHeader( headline, colOneHeader, colTwoHeader )
	{
		var headerMarkup = 
			'<table border="0" cellpadding="0" cellspacing="0" width="100%">' +
			'	<tr>' +
			'		<td colspan="3" style="padding: 20px 0 3px 10px;	color: #cc0000;	font-weight: bold; font-size: large;">' +
			'			' + headline +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td width="150" style="padding: 1px 0 1px 0;	margin: 1px 0 1px 0; border-top: dashed 1px #cccccc; border-bottom: dashed 1px #cccccc;">' +
			'			<div style="padding: 3px 0 3px 10px; background-color: ffdddd; font-weight: bold;">' + colOneHeader + '</div>' +
			'		</td>' +
			'		<td width="350" style="padding: 1px 0 1px 0;	margin: 1px 0 1px 0; border-top: dashed 1px #cccccc; border-bottom: dashed 1px #cccccc;">' +
			'			<div style="padding: 3px 0 3px 10px; background-color: ffdddd; font-weight: bold;">' + colTwoHeader + '</div>' +
			'		</td>' +
			'		<td style="padding: 1px 0 1px 0;	margin: 1px 0 1px 0; border-top: dashed 1px #cccccc; border-bottom: dashed 1px #cccccc;">' +
			'			<div style="padding: 3px 0 3px 10px; background-color: ffdddd; font-weight: bold;">&nbsp;</div>' +
			'		</td>' +
			'	</tr>' +
			'</table>';
		return headerMarkup + '\n';
	}

	function printResultsMessage( testResults )
	{
		var test_okay = false;
		var message = '';
		var testMessage = '';
		var passImg = _apppath + '/images/info/green_checkmark.gif';
		var passAlt = 'Pass';
		var failImg = _apppath + '/images/info/red_x.gif';
		var failAlt = 'Fail';

		var testMessageImg = failImg
		var testMessageAlt = failAlt
		var testMessageStyle = 'padding: 5px; border: 1px solid #cc0000; background: #ffcccc;';

		if (testResults == undefined)
		{
			return 'An error was encountered and no test results have been returned. Please try your test again later.<br />';;
		}
		
		if (testResults[SHOW_TEST_RESULTS])
		{
			message = 	
				'We have finished your connection speed test. You can review the ' +
				'<a href="#" onclick="routeControl(\'resultsinfo\'); return false;">\'speed information\'</a> ' +
				'or <a href="#" onclick="routeControl(\'resultsanalysis\'); return false;">\'analysis\'</a> for more connection speed test information.<br />';
		}
		else
		{
			message = testResults[SHOW_TEST_ERROR];
		}
		
		if (testResults[CLIENT_RCV_WINDOW_SIZE] < 300000)
		{
			if (isMac())
			{
				helpcase = "27244";
			}
			else
			{
				helpcase = "c31603";
			}
			testMessage = 
				'Your PC has not been optimized for the premium experience offered by High Speed Internet. ' +
				'<a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">Learn more about HSI Optimizer</a> and run this test again.';
		}
		else if ( speedLimit( testResults ) && testResults[PACKET_LOSS_PCT] >= 0.03 && testResults[PACKET_LOSS_PCT] <= 0.06)
		{
			helpcase = "packet_loss";
			testMessage = 
				'We are sorry, but your test is being affected by a temporary network problem. ' +
				'<a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">Learn more about network issues</a> and test your PC speed later.';
		}
		else if ( speedLimit( testResults ) && testResults[PACKET_LOSS_PCT] >= 0.06)
		{
			testMessage = 
				'There appears to be a problem affecting your speed due to serious packet loss. ' +
				'Please reboot your router and PC, and try the test again.  If the problem continues, call technical support. ' +
				'Consumers please call 1-888-553-1555. Business Customers please call 1-888-244-4440.';
		}
		else if ( speedLimit( testResults ) && testResults[SND_LIMITED_PCT] >= 0.10)
		{
			testMessage = 'We’re sorry, our test server is experiencing a problem. Please try your test again later.';
		}
		else if ( speedLimit( testResults ) && parseInt(testResults[BAD_CABLE]) != 0)
		{
			helpcase = "check_ethernet";
			testMessage = 
				'The test indicates that you may have a bad Ethernet cable. ' +
				'Please <a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">check the troubleshooting guide</a> for more information.';
		}
		else if ( speedLimit( testResults ) &&
							(	parseInt(testResults[DUPLEX_MISMATCH]) != 0 || 
							  parseInt(testResults[HALF_DUPLEX]) != 0 || 
								parseInt(testResults[WIRELESS_LINK]) != 0 ) )
		{
			helpcase = "nic_config";
			testMessage = 
				'To accurately measure the speed of your connection, you must use an Ethernet connected PC. ' +
				'If you receive this testMessage, you are either testing from a wireless connection, ' +
				'or your PC’s Ethernet adapter may be configured incorrectly.  Please try your test from a wired connection, or ' +
				'<a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">learn how to reconfigure your adapter</a> for proper operation.';
		}
		else
		{
			testMessage = "Congratulations!  This test result indicates your service is operating normally.";
			test_okay = true;
		}

		if( test_okay )
		{
			testMessageImg = passImg
			testMessageAlt = passAlt
			testMessageStyle = 'padding: 5px; border: 1px solid #00cc00; background: #ccffcc;';
		}
		
		var resultsMessageMarkup =
			'<div>' + message + '</div>' +
			'<br />' +
			'<table cellpadding="0" cellspacing="0" border="0">' +
			'	<tr>' +
			'		<td>' +
			'			<img src="' + testMessageImg + '" alt="' + testMessageAlt + '" width="19" height="16" border="0" style="padding: 5px;" />' +
			'		</td>' +
			'		<td>' +
			'			<div style="' + testMessageStyle + '">' + testMessage + '</div>' +
			'		</td>' +
			'	</tr>' +
			'</table>';
	
		if( debug )
		{
			alert("" +
				"CLIENT_RCV_WINDOW_SIZE: " 	+ testResults[CLIENT_RCV_WINDOW_SIZE] + "\n" +
				"PACKET_LOSS_PCT: " 				+ testResults[PACKET_LOSS_PCT] + "\n" +
				"SVC_CLASS_DOWNLOAD: " 			+ testResults[SVC_CLASS_DOWNLOAD] + "\n" +
				"SVC_CLASS_UPLOAD: " 				+ testResults[SVC_CLASS_UPLOAD] + "\n" +
				"SPEED_UPLOAD: " 						+ testResults[SPEED_UPLOAD] + "\n" +
				"SPEED_DOWNLOAD: " 					+ testResults[SPEED_DOWNLOAD] + "\n" +
				"HALF_DUPLEX: " 						+ testResults[HALF_DUPLEX] + "\n" +
				"DUPLEX_MISMATCH: " 				+ testResults[DUPLEX_MISMATCH] + "\n" +
				"WIRELESS_LINK: " 					+ testResults[WIRELESS_LINK] + "\n" +
				"SND_LIMITED_PCT: " 				+ testResults[SND_LIMITED_PCT] + "\n" +
				"RCV_LIMITED_PCT: " 				+ testResults[RCV_LIMITED_PCT] + "\n" +
				"NET_LIMITED_PCT: " 				+ testResults[NET_LIMITED_PCT] + "\n" +
				"BAD_CABLE: " 							+ testResults[BAD_CABLE] + "\n");
		}
		
		return resultsMessageMarkup;
	}
	

	function printFooter( package, testResults )
	{
		var footerMarkup = '';
		var resultsMessage = printResultsMessage (testResults);
		var footerPackageMarkup = 
			'<br />' +
			'<a href="http://www22.verizon.com/content/consumerdsl/plans/all+plans/all+plans.htm">Want to go faster?</a><br />' +
			'<br />' +
			resultsMessage + 
			'<br />' +
			'<a href="javascript: routeControl(\'resultsrunagain\');"><img src="' + _apppath + '/images/btnRunTheTestAgain.gif" alt="Run the test again &gt;" width="122" height="18" border="0" /></a>';
		var footerNoPackageMarkup =
			'<br />' +
			'<a href="http://www22.verizon.com/content/consumerdsl/plans/all+plans/all+plans.htm">Want to go faster?</a><br />' +
			'<br />' +
			resultsMessage +
			'<br />' +
			'<a href="javascript: routeControl(\'resultsrunagain\');"><img src="' + _apppath + '/images/btnRunTheTestAgain.gif" alt="Run the test again &gt;" width="122" height="18" border="0" /></a>';
		
		if (package == undefined || package == '')
		{
			footerMarkup = footerNoPackageMarkup;
		}
		else
		{
			footerMarkup = footerPackageMarkup;
		}
		return footerMarkup;
	}
	
	function printBar( speed, barcolor )
	{
		if (speed <= 0) { speed = 1; };
		if (speed > 7.1) { speed = 7.1; };
		var percentile = (pxLength / 100 * (speed * 14));
		barMarkup = 
			'<table cellspacing="0" cellpadding="0" border="0">' +
			'	<tr>' +
			'		<td width="1">' +
			'			<img src="' + _apppath + '/images/'+ barcolor + 'PipeCap.gif" alt="" width="1" height="13" border="0" /><br />' +
			'		</td>' +
			'		<td style="background-image: url(' + _apppath + '/images/bkg'+ barcolor + 'Pipe.gif);" width="' + percentile + '" height="13">' +
			'		</td>' +
			'		<td width="1">' +
			'			<img src="' + _apppath + '/images/'+ barcolor + 'PipeCap.gif" alt="" width="1" height="13" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'</table>';
		return barMarkup;
	}

	function printResultsRow( speed, barcolor, desc, packageSpeed )
	{
		var rowDesc = '';
		var rowLabelStyle = 'color: #aaaaaa;';
		
		if (desc != '')
		{
			rowDesc =  
				'<div style="color: #306918;	font-weight: bold;">' +
				desc +
				'</div>';
			rowLabelStyle = 'color: #306918;	font-weight: bold;';
		}
		else
		{
			rowDesc = 'Up to ' + speedConversion( speed );
			if (packageSpeed != undefined && 
				  packageSpeed != 0 && 
					packageSpeed == speed)
			{
				rowDesc += '<span style="color: #cc0000;">*</span>';
			}
		}
		resultsRowMarkup = 
			'<table cellspacing="0" cellpadding="0" border="0">' +
			'	<tr>' +
			'		<td style="padding: 3px 0 1px 10px;" width="150">' +
			rowDesc +
			'		</td>' +
			'		<td>' +
			'			<table cellspacing="0" cellpadding="0" border="0">' +
			'				<tr>' +
			'					<td>' +
			printBar( speed, barcolor ) + 
			'					</td>' +
			'					<td style="padding: 0 0 0 10px; ' + rowLabelStyle + '">' +
			'						' + speedConversion( speed ) +
			'					</td>' +
			'				</tr>' +
			'			</table>' +
			'		</td>' +
			'	</tr>' +
			'</table>';
		return resultsRowMarkup;
	}

	function printUserSpeed( userSpeed, packageSpeed )
	{
		return '<div style="color: #306918;	font-weight: bold;">' +
			printResultsRow( userSpeed, 'green', 'Your Speed Result', packageSpeed ) +
			'</div>';
	}

	function printSpeeds( speeds, userSpeed, packageSpeed )
	{	
		var results = '';
		var userSpeedPrinted = false;
		for (speed in speeds)
		{
			if (userSpeed < speeds[speed] && !userSpeedPrinted)
			{
				results += printUserSpeed( userSpeed, packageSpeed );
				userSpeedPrinted = true;
			}
			results += printResultsRow( speeds[speed], 'grey', '', packageSpeed );
		}
		if (!userSpeedPrinted)
		{
			results += printUserSpeed( userSpeed, packageSpeed );
		}
		return results;
	}
	
	function printResults( testResults )
	{
		var download = testResults[SPEED_DOWNLOAD]
		var upload = testResults[SPEED_UPLOAD]
		var packageDown = testResults[SVC_CLASS_DOWNLOAD]
		var packageUp = testResults[SVC_CLASS_UPLOAD]
		
		var packageStr = '';
		if (packageDown == undefined) { packageDown = ''; }
		if (packageUp == undefined) { packageUp = ''; }

		if (packageDown != '' && packageUp != '')
		{
			packageStr = packageDown + '/' + packageUp;
		}
		
		var resultsMarkup = 
			printBoxes(download, upload, packageStr) + 
			printHeader('Download speed test comparison', 'Connection Type', 'Connection Speed') +
			printSpeeds(downSpeeds, download, packageDown) +
			printHeader('Upload speed test comparison', 'Connection Type', 'Connection Speed') +
			printSpeeds(upSpeeds, upload, packageUp) +
			printFooter( packageStr, testResults );
		return resultsMarkup;
	}

//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Start page functions and content
////////////////////////////////////////////////////////////////////////////////
//
	function printStartPage ()
	{
		var startPageMarkup = 
			'<h2>How <i>fast</i> is your<br /> ' +
			'<span style="font-size: larger;">Verizon High Speed Internet connection?</span></h2> ' +
			'As a Verizon High Speed Internet customer, you can measure your Verizon High Speed Internet ' +
			'service by testing the speed of your connection.<br />' +
			'<br /> ' +
			'The speed test measures the amount of data that is transferred from the Internet to your ' +
			'computer (download) and from your computer to the Internet (upload) within a set amount of ' +
			'time. In other words, it shows how fast data moves through your Verizon High Speed Internet ' +
			'connection and demonstrates the speeds that Verizon High Speed Internet delivers.<br /> ' +
			'<br /> ' +
			'<a href="#" onclick="routeControl(\'start\'); return false;"><img src="' +	_apppath +	'/images/cover/check_my_speed_button.gif" alt="Check My Speed &gt;" width="164" height="28" border="0" /></a><br />' +
			'<br /> ' +
			'<b>How does the Verizon Online Speed Test work?</b><br /> ' +
			'Verizon High Speed Internet Speed test sends bursts of random data for 10 seconds and ' +
			'calculates the upload and download speed of your connection by measuring ' +
			'how many bits of data were transferred during the 10-second period.<br /> ' +
			'<br />';
		return startPageMarkup;
	}
	
//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Disclaimer page functions and content
////////////////////////////////////////////////////////////////////////////////
//
	function printDisclaimer ()
	{
		var disclaimerMarkup = 
			'<b>Disclaimer</b><br /><br /> ' +
			'Actual throughput speed will vary based on factors such as the condition of wiring inside a specific ' +
			'location, computer configuration, network or Internet congestion; and the server speed of the Web ' +
			'sites accessed, among other factors. Speed and uninterrupted use of the service are not ' +
			'guaranteed.<br /> ' +
			'<br /> ' +
			'Click <b>Continue</b> to start the Verizon High Speed Internet Speed test.<br /> ' +
			'<br /> ' +
			'<a href="#" onclick="routeControl(\'disclaimer\'); return false;"><img src="'+ _apppath + '/images/disclaimer/continue_button.gif" alt="Continue &gt;" width="85" height="18" border="0" /></a><br /> ' +
			'<br />';
		return disclaimerMarkup;
	}
	
//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Select Your Speed page functions and content
////////////////////////////////////////////////////////////////////////////////
//
	function setSelectedSpeed()
	{
		var speed = document.getElementById("speed").options[document.getElementById("speed").selectedIndex].value;
		
		if (speed == undefined || speed == '')
		{
			alert("Please select a FiOS package speed!");
		}
		else
		{
			_speed = speed;
			_service_class = _speed;
			var temp2 = _service_class.split('_');
			_dl_class = temp2[0];
			_ul_class = temp2[1];
			routeControl('speedselection');
		}
	}

	function printSelectSpeed()
	{
		var selectSpeedMarkup =
			'<b>Select Your Speed</b><br /><br />' +
			'This will allow you to analyze your network performance, both uploading ' +
			'and downloading. (Please note, this test may take up to 2 minutes to ' +
			'complete.)<br />' +
			'<br />' +
			'Please indicate your FiOS package maximum speed (download/upload) or allow us to <a href="https://sso.verizon.net/ssowebapp/VOLPortalLogin?ActualTarget=' + _apppath + '/Default.asp">check it for you</a>.<br />' +
			'<br />' +
			'<form name="speeds" id="speeds">' +
			'<select name="speed" id="speed">' +
			'	<option value="">Select your speed</option>' +
			'	<option value="5_2">Up to 5 Mbps / 2 Mbps</option>' +
			'	<option value="5_5">Up to 5 Mbps / 5 Mbps</option>' +
			'	<option value="10_2">Up to 10 Mbps / 2 Mbps</option>' +
			'	<option value="15_2">Up to 15 Mbps / 2 Mbps</option>' +
			'	<option value="20_5">Up to 20 Mbps / 5 Mbps</option>' +
			'	<option value="20_20">Up to 20 Mbps / 20 Mbps</option>' +
			'	<option value="30_5">Up to 30 Mbps / 5 Mbps</option>' +
			'	<option value="35_10">Up to 35 Mbps / 10 Mbps</option>' +
			'	<option value="50_5">Up to 50 Mbps / 5 Mbps</option>' +
			'	<option value="50_10">Up to 50 Mbps / 10 Mbps</option>' +
			'</select><br />' +
			'<br />' +
			'<a href="#" onclick="setSelectedSpeed();"><img src="' + _apppath + '/images/speeds/next_button.gif" alt="Next" width="45" height="18" border="0" /></a><br />' +
			'<br />' +
			'Not all speeds are available in all areas<br />' +
			'</form>';
		return selectSpeedMarkup;
	}
	
//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Speedtest page functions and content
////////////////////////////////////////////////////////////////////////////////
//

	// -------------------------------------------------
	// NOTE: getPhase, getStatus, and getMessage are
	// called by the showTest... functions
	// -------------------------------------------------
	function getPhase(theMessage) {
		if (theMessage.length == 2 ||
				(theMessage.length > 2 && theMessage.substring(2,3) == ":")) {
			var theCode = theMessage.substring(0, 1);
			if (!isNaN(theCode)) {
				return theCode;
			}
		}
		return -1;
	}
	
	function getStatus(theMessage) {
		if (theMessage.length == 2 ||
				(theMessage.length > 2 && theMessage.substring(2,3) == ":")) {
			var theCode = theMessage.substring(1,2);
			if (!isNaN(theCode)) {
				return theCode;
			}
		}
		return -1;
	}
	
	function getMessage(theMessage) {
		// If there is a number-number-colon sequence, skip it.
		if (theMessage.length >= 3 &&
				!isNaN(theMessage.substring(0,2)) &&
				theMessage.substring(2,3) == ":") {
			return theMessage.substring(3,theMessage.length + 1);
		}
		return theMessage;
	}

	// -------------------------------------------------
	// NOTE: showTestStatus is called -DIRECTLY- by
	// the JWeb100 applet.
	// -------------------------------------------------
	function showTestStatus(theStatus) {
		// These are displayed in the status table fields
		var aStatusText = new Array(6);
		aStatusText[0] = "Not Started";
		aStatusText[1] = "In Progress";
		aStatusText[2] = "Complete";
		aStatusText[3] = "Error";
		aStatusText[4] = "Failed";
		aStatusText[5] = "Failed";
		var nStatus = -1;
		var nPhase = -1;
	
		// These will be -1 if there is no phase/status encoding
		nStatus = getStatus(theStatus);
		nPhase = getPhase(theStatus);
		
		if (nPhase > 0)
		{
			document.getElementById("status" + nPhase ).innerHTML = aStatusText[nStatus];
			document.getElementById("status" + nPhase ).style.fontWeight = 'bold';
			document.getElementById("step" + nPhase ).style.fontWeight = 'bold';
		}
	  if (nPhase == 3 && nStatus > 1) 
		{
			document.getElementById("status" + 4).innerHTML = 'In Progress';
			document.getElementById("status" + 4 ).style.fontWeight = 'bold';
			document.getElementById("step" + 4 ).style.fontWeight = 'bold';
	  }
		testResults[STATUS] = theStatus;
	}

	// -------------------------------------------------
	// NOTE: showTestResults is called -DIRECTLY- by
	// the JWeb100 applet.
	// -------------------------------------------------
	function showTestResults() {
    var g_JWeb100 = document.getElementById("APPLET_JWEB100");
    
    testResults[SPEED_UPLOAD] = parseInt(g_JWeb100.SpeedUpload) / 1000;
    testResults[SPEED_DOWNLOAD] = parseInt(g_JWeb100.SpeedDownload) / 1000;
    testResults[JWEB100_ANALYSIS] = g_JWeb100.ResultsIntermediate;
    testResults[SND_LIMITED_PCT] = g_JWeb100.SndLimitedPer;
    testResults[RCV_LIMITED_PCT] = g_JWeb100.RecLimitedPer;
    testResults[NET_LIMITED_PCT] = g_JWeb100.NetLimitedPer;
    testResults[BAD_CABLE] = g_JWeb100.BadCable;
		testResults[NETWORK_CONGESTION] = g_JWeb100.NetworkCongestion;
    testResults[OPTIMIZATION_NEEDED] = g_JWeb100.NeedToRunOptimizer;
    testResults[HALF_DUPLEX] = g_JWeb100.HalfDuplex;
    testResults[CLIENT_RCV_WINDOW_SIZE] = g_JWeb100.ClientRcvWin;
    testResults[PACKET_LOSS_PCT] = g_JWeb100.PacketLoss;
    testResults[DUPLEX_MISMATCH] = g_JWeb100.DuplexMismatch;
    testResults[WIRELESS_LINK] = g_JWeb100.WirelessLink;
			
    testResults[JWEB100_USER_TEXT] = 
        "Congratulations!  This test result indicates your service is operating normally.";
    if (g_JWeb100.BadCable == 1) {
	    testResults[JWEB100_USER_TEXT] = 
            "The test is indicating that you may have a bad Ethernet cable. " + 
						"<a href='http://help.verizon.net/'>Click here</a> " +
            "for troubleshooting information.";
    }
    if (g_JWeb100.HalfDuplex == 1) {
        bErr = 1;
        eText += "<br>- PC network card configured for half duplex.";
    }
    
    testResults[SHOW_TEST_RESULTS] = 'True';
		routeControl( 'speedtest' );
	}
	
	// -------------------------------------------------
	// NOTE: showTestError is called -DIRECTLY- by
	// the JWeb100 applet.
	// -------------------------------------------------
	function showTestError(theError) 
	{
	  showTestStatus(theError);
	  if (getStatus(theError) != 3) 
		{
			var errMsg;
			errMsg = getMessage(theError);
			if (getStatus(theError) == 4) { //transient
			    errMsg += "  Please restart the test.  If the problem persists, contact customer support.";
			} else {
			    errMsg += "  Please contact customer support for assistance.";
			}
		}
		testResults[SHOW_TEST_ERROR] = errMsg;
		testResults[SHOW_TEST_RESULTS] = 'False';
		routeControl( 'speedtest' );
	}
	
	function printSpeedTest ()
	{
		var speedtestMarkup = 
			'<b>Speed Test</b><br /><br />' +
			'This will allow you to analyze your network performance, both ' +
			'uploading and downloading. (Please note, this test may take up ' +
			'to 2 minutes to complete.)<br />' +
			'<br />' +
			'<table cellspacing="0" cellpadding="0" border="0" width="267" align="center">' +
			'	<tr>' +
			'		<td colspan="3">' +
			'			<img src="' + _apppath + '/images/run/top_monitors.gif" alt="" width="267" height="33" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/run/left_monitors.gif" alt="" width="74" height="32" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/run/animated.gif" alt="" width="120" height="32" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/run/right_monitors.gif" alt="" width="73" height="32" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="3">' +
			'			<img src="' + _apppath + '/images/run/bottom_monitors.gif" alt="" width="267" height="29" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'</table>' +
			'<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="16" border="0" /><br />' +
			'<table cellspacing="0" cellpadding="0" border="0" align="center">' +
			'	<tr style="background-color: #4084B7; color: #ffffff;">' +
			'		<td valign="top" align="left" width="7">' +
			'			<img src="' + _apppath + '/images/run/blue_bar_corner.gif" alt="" width="7" height="7" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<b>Step</b><br />' +
			'		</td>' +
			'		<td width="7">' +
			'		</td>' +
			'		<td width="3" rowspan="9" style="background-color: #ffffff; color: #000000;">' +
			'			<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="3" height="1" border="0" /><br />' +
			'		</td>' +
			'		<td width="7">' +
			'		</td>' +
			'		<td>' +
			'			<b>Status</b><br />' +
			'		</td>' +
			'		<td width="7">' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="7">' +
			'			<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="2" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr style="background-color: #eeeeee; color: #000000;">' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="step1">Checking Connection<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="status1">Not Started...<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="7">' +
			'			<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="2" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr style="background-color: #eeeeee; color: #000000;">' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="step2">Upload Test (10 seconds)<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="status2">Not Started...<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="7">' +
			'			<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="2" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr style="background-color: #eeeeee; color: #000000;">' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="step3">Download Test (10 seconds)<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="status3">Not Started...<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="7">' +
			'			<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="2" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr style="background-color: #eeeeee; color: #000000;">' +
			'		<td valign="bottom" align="left">' +
			'			<img src="' + _apppath + '/images/run/bottom_left_gray.gif" alt="" width="17" height="17" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<div id="step4">Analyzing<br /></div>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'		</td>' +
			'		<td>' +
			'			<div id="status4">Not Started...<br /></div>' +
			'		</td>' +
			'		<td valign="bottom" align="right">' +
			'			<img src="' + _apppath + '/images/run/bottom_right_gray.gif" alt="" width="17" height="17" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'</table>';
		return speedtestMarkup;
	}

//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Information page functions and content
////////////////////////////////////////////////////////////////////////////////
//

	function printInformation( testResults )
	{
		var TEST_SERVER = 0;
		var CLIENT_PC = 1;
		var NETWORK = 2;
		var xo = new Array(3);
		
		var message;
		var helpcase = "";

		var passImg = _apppath + "/images/info/green_checkmark.gif";
		var failImg = _apppath + "/images/info/red_x.gif";

		var passAlt = 'Pass';
		var failAlt = 'Fail';		
		
		var testserverStateImg = failImg;
		var testserverStateAlt = failAlt;
		var customerpcStateImg = failImg;
		var customerpcStateAlt = failAlt;
		var networkStateImg = failImg;
		var networkStateAlt = failAlt;

		for (i = 0; i < 3; i++)
		{
			xo[i] = 0;
		}
		
		if (testResults[CLIENT_RCV_WINDOW_SIZE] < 300000)
		{
			if (isMac())
			{
				helpcase = "case=27244";
			}
			else
			{
				helpcase = "c31603";
			}
			message = 
				'Your PC has not been optimized for the premium experience offered by High Speed Internet. ' +
				'<a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">Learn more about HSI Optimizer</a> and run this test again.';
			xo[TEST_SERVER] = 1;
			xo[NETWORK] = 1;
		}
		else if ( speedLimit( testResults ) && testResults[PACKET_LOSS_PCT] >= 0.03 && testResults[PACKET_LOSS_PCT] <= 0.06)
		{
			helpcase = "packet_loss";
			message = 
				'We are sorry, but your test is being affected by a temporary network problem. ' +
				'<a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">Learn more about network issues</a> and test your PC speed later.';
			xo[TEST_SERVER] = 1;
			xo[CLIENT_PC] = 1;

		}
		else if ( speedLimit( testResults ) && testResults[PACKET_LOSS_PCT] >= 0.06)
		{
			message = 
				'There appears to be a problem affecting your speed due to serious packet loss. ' +
				'Please reboot your router and PC, and try the test again.  If the problem continues, call technical support. ' +
				'Consumers please call 1-888-553-1555. Business Customers please call 1-888-244-4440.';
			xo[TEST_SERVER] = 1;
		}
		else if ( speedLimit( testResults ) && testResults[SND_LIMITED_PCT] >= 0.10)
		{
			message = 'We’re sorry, our test server is experiencing a problem. Please try your test again later.';
			xo[CLIENT_PC] = 1;
			xo[NETWORK] = 1;
		}
		else if ( speedLimit( testResults ) && parseInt(testResults[BAD_CABLE]) != 0 )
		{
			helpcase = "check_ethernet";
			message = 
				'The test indicates that you may have a bad Ethernet cable. ' +
				'Please <a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">check the troubleshooting guide</a> for more information.';
			xo[TEST_SERVER] = 1;
			xo[NETWORK] = 1;
		}
		else if ( speedLimit( testResults ) &&
							( parseInt(testResults[DUPLEX_MISMATCH]) != 0 || 
								parseInt(testResults[HALF_DUPLEX]) != 0 || 
						 		parseInt(testResults[WIRELESS_LINK]) != 0 ) )
		{
			helpcase = "nic_config";
			message = 
				'To accurately measure the speed of your connection, you must use an Ethernet connected PC. ' +
				'If you receive this message, you are either testing from a wireless connection, ' +
				'or your PC’s Ethernet adapter may be configured incorrectly.  Please try your test from a wired connection, or ' +
				'<a href="http://netservices.verizon.net/portal/msa/bookmark?helpitem&case=' + helpcase + 
				'">learn how to reconfigure your adapter</a> for proper operation.';
			xo[TEST_SERVER] = 1;
			xo[NETWORK] = 1;
		}
		else
		{
			message = "Congratulations!  This test result indicates your service is operating normally.";

			for (i = 0; i < 3; i++)
			{
				xo[i] = 1;
			}
		}
		
		
		if (xo[TEST_SERVER] == 1)
		{
			testserverStateImg = passImg;
			testserverStateAlt = passAlt;
		}
		
		if (xo[CLIENT_PC] == 1)
		{
			customerpcStateImg = passImg;
			customerpcStateAlt = passAlt;
		}
		
		if (xo[NETWORK] == 1)
		{
			networkStateImg = passImg;
			networkStateAlt = passAlt;
		}
	
		var infoMarkup = 
			'<b>Speed Information</b><br /><br />' +
			'<div id="info">' + message + '</div>' +
			'<br />' +
			'<table cellpadding="5" cellspacing="0" border="0" width="100%">' +
			'	<tr>' +
			'		<td colspan="2">' +
			'			<hr width="100%" />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td width="40">' +
			'			<img id="testserver" name="testserver" src="' + testserverStateImg + '" alt="' + testserverStateAlt + '" width="16" height="15" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<strong>Test Server</strong>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="2">' +
			'			<hr width="100%" />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td>' +
			'			<img id="customerpc" name="customerpc" src="' + customerpcStateImg + '" alt="' + customerpcStateAlt + '" width="16" height="15" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<strong>Customer PC</strong>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="2">' +
			'			<hr width="100%" />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td>' +
			'			<img id="network" name="network" src="' + networkStateImg + '" alt="' + networkStateAlt + '" width="16" height="15" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<strong>Network</strong>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td colspan="2">' +
			'			<hr width="100%" />' +
			'		</td>' +
			'	</tr>' +
			'</table>' +
			'<br />' +
			'<table cellspacing="0" cellpadding="0" border="0">' +
			'	<tr>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/info/legend_box_ul.gif" alt="" width="10" height="10" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<table cellspacing="0" cellpadding="0" border="0" width="100%">' +
			'				<tr>' +
			'					<td style="background-color: #cccccc;">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="1" border="0" /><br />' +
			'					</td>' +
			'				</tr>' +
			'				<tr>' +
			'					<td style="background-color: #f5f5f5;">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="9" border="0" /><br />' +
			'					</td>' +
			'				</tr>' +
			'			</table>' +
			'		</td>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/info/legend_box_ur.gif" alt="" width="10" height="10" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td height="100%">' +
			'			<table cellspacing="0" cellpadding="0" border="0" width="10" height="100%">' +
			'				<tr>' +
			'					<td style="background-color: #cccccc;" width="1">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="*" border="0" /><br />' +
			'					</td>' +
			'					<td style="background-color: #f5f5f5;" width="9">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="9" height="1" border="0" /><br />' +
			'					</td>' +
			'				</tr>' +
			'			</table>' +
			'		</td>' +
			'		<td style="background-color: #f5f5f5;">' +
			'			<img src="' + _apppath + '/images/info/green_checkmark.gif" alt="" width="19" height="16" border="0" /> = OK&nbsp;&nbsp;&nbsp;' +
			'			<img src="' + _apppath + '/images/info/red_x.gif" alt="" width="16" height="15" border="0" /> = Problem ' +
			'		</td>' +
			'		<td height="100%">' +
			'			<table cellspacing="0" cellpadding="0" border="0" width="10" height="100%">' +
			'				<tr>' +
			'					<td style="background-color: #f5f5f5;">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="9" height="1" border="0" /><br />' +
			'					</td>' +
			'					<td style="background-color: #cccccc;">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="1" border="0" /><br />' +
			'					</td>' +
			'				</tr>' +
			'			</table>' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/info/legend_box_bl.gif" alt="" width="10" height="10" border="0" /><br />' +
			'		</td>' +
			'		<td>' +
			'			<table cellspacing="0" cellpadding="0" border="0" width="100%">' +
			'				<tr>' +
			'					<td style="background-color: #f5f5f5;">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="9" border="0" /><br />' +
			'					</td>' +
			'				</tr>' +
			'				<tr>' +
			'					<td style="background-color: #cccccc;">' +
			'						<img src="http://www2.verizon.net/images/spacer.gif" alt="" width="1" height="1" border="0" /><br />' +
			'					</td>' +
			'				</tr>' +
			'			</table>' +
			'		</td>' +
			'		<td>' +
			'			<img src="' + _apppath + '/images/info/legend_box_br.gif" alt="" width="10" height="10" border="0" /><br />' +
			'		</td>' +
			'	</tr>' +
			'</table>' +
			'<br />' +
			'<table cellspacing="0" cellpadding="10" border="0">' +
			'	<tr>' +
			'		<td>' +
			'			<a href="#" onclick="routeControl(\'inforesults\'); return false;"><img src="' + _apppath + '/images/info/back_to_results_button.gif" alt="&lt; Back to Results" width="108" height="18" border="0" /></a><br />' +
			'		</td>' +
			'		<td>' +
			'			See your speed test results.<br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td>' +
			'			<a href="#" onclick="routeControl(\'infoanalysis\'); return false;"><img src="' + _apppath + '/images/info/test_analysis_button.gif" alt="Test Analysis &gt;" width="92" height="18" border="0" /></a><br />' +
			'		</td>' +
			'		<td>' +
			'			See detailed technical information.<br />' +
			'		</td>' +
			'	</tr>' +
			'</table>';
		return infoMarkup;
	}

//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Analysis page functions and content
////////////////////////////////////////////////////////////////////////////////
//

	function printAnalysis ( analysis )
	{
		var analysisMarkup = 
			'<b>Speed Test Analysis Information</b><br /><br />' +
			'<div id="analysis">' + analysis + '</div>' +
			'<br />' +
			'<table cellspacing="0" cellpadding="10" border="0">' +
			'	<tr>' +
			'		<td>' +
			'			<a href="#" onclick="routeControl(\'analysisresults\'); return false;"><img src="' + _apppath + '/images/info/back_to_results_button.gif" alt="&lt; Back to Results" width="108" height="18" border="0" /></a><br />' +
			'		</td>' +
			'		<td>' +
			'			See your speed test results.<br />' +
			'		</td>' +
			'	</tr>' +
			'	<tr>' +
			'		<td>' +
			'			<a href="#" onclick="routeControl(\'analysisinfo\');; return false;"><img src="' + _apppath + '/images/analysis/speed_info_button.gif" alt="Speed Information" width="125" height="18" border="0" /></a><br />' +
			'		</td>' +
			'		<td>' +
			'			See detailed technical information.<br />' +
			'		</td>' +
			'	</tr>' +
			'</table>' +
			'<br />';
		return analysisMarkup;
	}
	
//
////////////////////////////////////////////////////////////////////////////////
// Speed Test Test Data Entry page functions and content
////////////////////////////////////////////////////////////////////////////////
//

	// THE FOLLOWING FUNCTIONS JUST EXIST FOR DIT/SIT TESTING!
	// --- test values for application logic
	function setToPct(elementID) {
		var theFloat = 0.0;
		
		theFloat = parseFloat(document.getElementById(elementID).value);
		if (isNaN(theFloat)) {
			theFloat = 0.0;
		}
		while (theFloat >= 1) {
			theFloat = theFloat / 100;
		}
		document.getElementById(elementID).value = theFloat.toPrecision(3);
	}

	function fixPctValues() {
		setToPct("packetLossPct");
		setToPct("sndLimitedPct");
		setToPct("rcvLimitedPct");
		setToPct("netLimitedPct");
	}
	
	function showTestDriverResults()
	{
		var badCable;
		var halfDuplex;
		var duplexMismatch;
		var wirelessLink;
		
		fixPctValues();
		testResults[SHOW_TEST_RESULTS] = true;
	  testResults[SPEED_UPLOAD] = parseInt(document.getElementById("speedUpload").value) / 1000;
		testResults[SPEED_DOWNLOAD] = parseInt(document.getElementById("speedDownload").value) / 1000;
		testResults[SND_LIMITED_PCT] = document.getElementById("sndLimitedPct").value;
		testResults[RCV_LIMITED_PCT] = document.getElementById("rcvLimitedPct").value;
		testResults[NET_LIMITED_PCT] = document.getElementById("netLimitedPct").value;
		testResults[CLIENT_RCV_WINDOW_SIZE] = document.getElementById("clientRcvWinSz").value;
		testResults[PACKET_LOSS_PCT] = document.getElementById("packetLossPct").value;
		testResults[JWEB100_ANALYSIS] = 'Test results are missing.';
		testResults[SVC_CLASS_DOWNLOAD] = document.getElementById("svcClassDownload").value;
		testResults[SVC_CLASS_UPLOAD] = document.getElementById("svcClassUpload").value;
		testResults[SERVICE_CLASS] = testResults[SVC_CLASS_DOWNLOAD] + "_" + testResults[SVC_CLASS_UPLOAD];
		
		if (testResults[SVC_CLASS_DOWNLOAD] == '')
		{
			testResults[SVC_CLASS_DOWNLOAD] = undefined;
		}
		
		if (testResults[SVC_CLASS_UPLOAD] == '')
		{
			testResults[SVC_CLASS_UPLOAD] = undefined;
		}
		
		badCable = document.getElementsByName("badCable")
		for( var i = 0; i < badCable.length; i++ )
		{
			if( badCable[i].checked )
			{
				testResults[BAD_CABLE] = badCable[i].value;
			}
		}
		
		halfDuplex = document.getElementsByName("halfDuplex");
		for( i = 0; i < halfDuplex.length; i++ )
		{
			if( halfDuplex[i].checked )
			{
				testResults[HALF_DUPLEX] = halfDuplex[i].value;
			}
		}
	
		duplexMismatch = document.getElementsByName("duplexMismatch");
		for( i = 0; i < duplexMismatch.length; i++ )
		{
			if( duplexMismatch[i].checked )
			{
				testResults[DUPLEX_MISMATCH] = duplexMismatch[i].value;
			}
		}
		
		wirelessLink = document.getElementsByName("wirelessLink");
		for( i = 0; i < wirelessLink.length; i++ )
		{
			if( wirelessLink[i].checked )
			{
				testResults[WIRELESS_LINK] = wirelessLink[i].value;
			}
		}
		
		if (debug)
		{
			alert("" +
				"CLIENT_RCV_WINDOW_SIZE: " 	+ testResults[CLIENT_RCV_WINDOW_SIZE] + "\n" +
				"PACKET_LOSS_PCT: " 				+ testResults[PACKET_LOSS_PCT] + "\n" +
				"SVC_CLASS_DOWNLOAD: " 			+ testResults[SVC_CLASS_DOWNLOAD] + "\n" +
				"SVC_CLASS_UPLOAD: " 				+ testResults[SVC_CLASS_UPLOAD] + "\n" +
				"SPEED_UPLOAD: " 						+ testResults[SPEED_UPLOAD] + "\n" +
				"SPEED_DOWNLOAD: " 					+ testResults[SPEED_DOWNLOAD] + "\n" +
				"HALF_DUPLEX: " 						+ testResults[HALF_DUPLEX] + "\n" +
				"DUPLEX_MISMATCH: " 				+ testResults[DUPLEX_MISMATCH] + "\n" +
				"WIRELESS_LINK: " 					+ testResults[WIRELESS_LINK] + "\n" +
				"SND_LIMITED_PCT: " 				+ testResults[SND_LIMITED_PCT] + "\n" +
				"RCV_LIMITED_PCT: " 				+ testResults[RCV_LIMITED_PCT] + "\n" +
				"NET_LIMITED_PCT: " 				+ testResults[NET_LIMITED_PCT] + "\n" +
				"BAD_CABLE: " 							+ testResults[BAD_CABLE] + "\n");
		}
		routeControl('testentrynext');
	}

	function printTest ()
	{
		var testMarkup =
			'<form name="testDriver">' +
			'	<strong>Results Test Driver</strong><br>' +
			'	<table border="0" id="table7">' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Receive Window Size</td>' +
			'			<td><input type="text" id="clientRcvWinSz" name="clientRcvWinSz"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Packet Loss %</td>' +
			'			<td><input type="text" id="packetLossPct" name="packetLossPct"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Download Service Class</td>' +
			'			<td><input type="text" id="svcClassDownload" name="svcClassDownload"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Upload Service Class</td>' +
			'			<td><input type="text" id="svcClassUpload" name="svcClassUpload"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Download Speed</td>' +
			'			<td><input type="text" id="speedDownload" name="speedDownload"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Upload Speed</td>' +
			'			<td><input type="text" id="speedUpload" name="speedUpload"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Half Duplex</td>' +
			'			<td><input type="radio" value="1" name="halfDuplex">Yes' +
			'			<input type="radio" value="0" checked name="halfDuplex">No</td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Duplex Mismatch</td>' +
			'			<td><input type="radio" value="1" name="duplexMismatch">Yes' +
			'			<input type="radio" value="0" checked name="duplexMismatch">No</td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Wireless Link </td>' +
			'			<td><input type="radio" value="1" name="wirelessLink">Yes' +
			'			<input type="radio" value="0" checked name="wirelessLink">No</td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Sender Limited %</td>' +
			'			<td><input type="text" id="sndLimitedPct" name="sndLimitedPct"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Receiver (PC) Limited %</td>' +
			'			<td><input type="text" id="rcvLimitedPct" name="rcvLimitedPct"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Network Limited %</td>' +
			'			<td><input type="text" id="netLimitedPct" name="netLimitedPct"></td>' +
			'		</tr>' +
			'		<tr>' +
			'			<td align="right">&nbsp;</td>' +
			'			<td align="right">Bad Ethernet Cable</td>' +
			'			<td><input type="radio" value="1" name="badCable">Yes' +
			'			<input type="radio" value="0" checked name="badCable">No</td>' +
			'		</tr>' +
			'	</table>' +
			'</form>' +
			'<div align="center"><a href="#" onclick="showTestDriverResults(); return false;"><img src="' + _apppath + '/images/speeds/next_button.gif" alt="Next" width="45" height="18" border="0" /></a><br /></div>';
		return testMarkup;
	}
	
	//----------------------------------------------------------------------------
	// routeControl is the brain of this application, it kicks of the next action
	// depending on the last user interaction.
	//----------------------------------------------------------------------------
	function routeControl ( lastCommand )
	{
		if (debug) { alert(lastCommand); }
		
		switch( lastCommand )
		{
			case 'start':
				switchContent( printDisclaimer() );
				break;
			case 'disclaimer':
				zeroTestResults();
				switchContent( 
					printSpeedTest() + 
					printJavaEmbed( _select_server, _debugging_flag, _local_test_flag, isIE() ) 
					);
				break;
			case 'speedtest':
				switchContent( printResults( testResults ) );
				break;
			case 'results':
				break;
			case 'resultsinfo':
					switchContent( printInformation( testResults ) );
				break;
			case 'resultsanalysis':
				switchContent( printAnalysis( testResults[JWEB100_ANALYSIS] ) );
				break;
			case 'resultsrunagain':
				zeroTestResults();
				switchContent( 
					printSpeedTest() + 
					printJavaEmbed( _select_server, _debugging_flag, _local_test_flag, isIE() ) 
					);
				break;
			case 'inforesults':
				switchContent( printResults( testResults ) );
				break;
			case 'infoanalysis':
				switchContent( printAnalysis( testResults[JWEB100_ANALYSIS] ) );
				break;
			case 'analysisresults':
				switchContent( printResults( testResults ) );
				break;
			case 'analysisinfo':
				switchContent( printInformation( testResults ) );
				break;
			case 'testentrynext':
				switchContent( printResults( testResults ) );
				break;
		}
	}	

	document.write('<div id="st_content"></div>');
	if( window.location.search == '?test=true' )
	{
		switchContent( printTest() );
	}
	else
	{
		switchContent( printStartPage() );
	}

