	
	// Sets initial page state on load
	window.onload = initialize;
	
	// For Rate Calculator there are 4 "Results" outputs: data ratees for Low, High, and Panning  
	// and Sorager required. 
	var data_rate = [0,0];
	var ip_low_rate = [0, 0, 0, 0];
	var ip_high_rate = [0, 0, 0, 0];
	var ip_image_low_round = [0, 0, 0, 0];
	var ip_image_high_round = [0, 0, 0, 0];
	var ip_net_low_round = [0, 0, 0, 0];
	var ip_net_high_round = [0, 0, 0, 0];
	var row_count = 6;

	// For Storage calculator there are 10 storage subtotals, a grand total, and the current line total.
	var total_storage = [0,0,0,0,0,0,0,0,0,0,0,0,0];
	var camera_storage = 0.0;
	var total_storage_sum = 0.0;
	
	var total_bandwidth=[0,0,0,0,0,0,0,0,0,0,0,0,0];
	var camera_bandwidth = 0.0;
	var total_bandwidth_sum = 0.0;
	var row1str = ""; // global to keep initial state for adding rows

	function initialize() 
	{
		if (HTMLpage == 'RateCalculator')  {
			fix_RateCalculator_form();
			recalculate();
		} else if (HTMLpage == 'IPCalculator')  {
			fix_IPCalculator_form();
			recalculate();
		} else if (HTMLpage == 'StorageCalculator')  {
			fix_storage_form();
			recalculate(1);
		}
	}
	
	function recalculate(indx) {
		if (HTMLpage == 'RateCalculator')  {
			recalculate_rate(1);
			setRateCalculator();
		} else if (HTMLpage == 'IPCalculator')  {
			for (var i=1; i < 5; i++) {
				recalculate_rate(i);
				setIPRateCalculator(i);
				ip_low_rate[i] = data_rate[0];
				ip_high_rate[i] = data_rate[1];
			}
			setIPTotal();
		} else if (HTMLpage == 'StorageCalculator')  {
			for (var i=1; i <= row_count; i++) {
				recalculate_storage(i);
				setStorageCalculator(i);
			}
		}
	}

	function fix_RateCalculator_form() {
		if ($('#4cif').attr('checked')) {
			$('#interlacing_div').attr('disabled', false);
		} else {
			$('#interlacing_div').attr('disabled', true);
		}
	}

	function fix_IPCalculator_form() {

		$('#ntsc001').attr('checked', true);
		$('#quality_normal001').attr('checked', true);
		$('#sensitivity_normal001').attr('checked', true);

		$('#4cif001').attr('checked', true);
		$('#interlaced001').attr('disabled', false);
		$('#deinterlaced001').attr('disabled', false);
		$('#interlaced001').attr('checked', true);

		$('#record_rate001').val(10); 
		$('#panning_activity001').val(0);

		var ostr = $('#c_one').html();
		
		var nstr = ostr.replace(/001/g, "002");
		
		$('#c_two').html(nstr);

		nstr = ostr.replace(/001/g, "003");
		$('#c_three').html(nstr);

		nstr = ostr.replace(/001/g, "004");
		$('#c_four').html(nstr);

		$('#c_one').css('background-color', '#ffffff');
		$('#cell_a1').css('background-color', '#ffffff');
		$('#cell_b1').css('background-color', '#ffffff');
		$('#cell_c1').css('background-color', '#ffffff');
		$('#cell_d1').css('background-color', '#ffffff');

		$('#c_two').css('background-color', '#c4fdce');
		$('#cell_a2').css('background-color', '#c4fdce');
		$('#cell_b2').css('background-color', '#c4fdce');
		$('#cell_c2').css('background-color', '#c4fdce');
		$('#cell_d2').css('background-color', '#c4fdce');

		$('#c_three').css('background-color', '#c4f0fd');
		$('#cell_a3').css('background-color', '#c4f0fd');
		$('#cell_b3').css('background-color', '#c4f0fd');
		$('#cell_c3').css('background-color', '#c4f0fd');
		$('#cell_d3').css('background-color', '#c4f0fd');

		$('#c_four').css('background-color', '#fdc4c8');
		$('#cell_a4').css('background-color', '#fdc4c8');
		$('#cell_b4').css('background-color', '#fdc4c8');
		$('#cell_c4').css('background-color', '#fdc4c8');
		$('#cell_d4').css('background-color', '#fdc4c8');

		for(var i=1; i < 5; i++) {
			recalculate(i);
			setIPRateCalculator(i);
			if ($('#4cif00' + i).attr('checked')) {
				$('#interlacing_div00' + i).attr('disabled', false);
			} else {
				$('#interlacing_div00' + i).attr('disabled', true);
			}
		}
	}

	function fix_storage_form() {
		row1str = $('#row1').html();
		// alert(ostr);
		for(var i=2; i <= row_count; i++) {
			var nstr = row1str.replace(/001/g, "00" + i);
			$('#row' + i).html(nstr);
			recalculate(i);
		}
		
	}

	function setStorageCalculator(indx)
	{
		var rounded_value = format_number(camera_storage.toFixed(3));
		$('#total_storage_00' + indx).html(rounded_value);
		sum_string = format_number(total_storage_sum.toFixed(3));
		$('#summed_storage2').html(sum_string);
		
		var rounded_value = format_number(camera_bandwidth.toFixed(3));
		$('#bandwidth_00' + indx).html(rounded_value);
		sum_string = format_number(total_bandwidth_sum.toFixed(3));
		$('#summed_bandwidth').html(sum_string);
		

	}

	function add_row()
	{
		if (row_count >= 30) {
			alert("The Maximum number of rows is 30.");
			return;
		}
		row_count++;
//		var ht = 400 + ((row_count - 6) * 50);
//		$('#intellex_settings_div').height('' + ht + 'px');

var h1 = $('#intellex_settings_div').height();		
var h2 = $('#row1').height();		
		var ht = h1 + h2;

		$('#intellex_settings_div').height( ht + 'px');

		var ostr = row1str.replace(/001/g, "00" + row_count);
		ostr = '<tr id="row' + row_count + '">' + ostr + '</tr>';
		$('#row' + (row_count - 1)).after(ostr);
		total_storage[row_count] = 0;
		total_bandwidth[row_count] = 0;
		recalculate(row_count);
		
	}

	function delete_row(indx)
	{
		if (row_count == 1) {
			return;
		}
		row_count--;
		for(var i=indx; i <= row_count; i++) {

			var j = i+1;
			var a = $('#model_00' + j).val();
			var b = $('#data_rate_00' + j).val();
			var c = $('#storage_units_00' + j).val();
			var d = $('#cameras_00' + j).val();
			var e = $('#op_hours_00' + j).val();
			
			$('#model_00' + i).val(a);
			$('#data_rate_00' + i).val(b);
			$('#storage_units_00' + i).val(c);
			$('#cameras_00' + i).val(d);
			$('#op_hours_00' + i).val(e);

		}
		$('#row' + (row_count+1)).remove();

		recalculate();
		
var h1 = $('#intellex_settings_div').height();		
var h2 = $('#row1').height();		

//		var ht = 426 + ((row_count - 6) * 50);
		var ht = h1 - h2;

		$('#intellex_settings_div').height( ht + 'px');
	}

	function set_all(fld_name) {

		var row1 = $('#' + fld_name ).val(); 
		recalculate(1);

		for(var i=1; i <= row_count; i++) {

			$('#' + fld_name + '_00' + i).val(row1); 
			recalculate(i);
		}
	}


	function setRateCalculator()
	{
		for (var i=0 ; i < 2 ; i++ ) {

			// Set image data rates for Low and High
			var cell = "#cell_a" + (i+1);
			var rounded_value = (data_rate[i]).toFixed(2);
			$(cell).html( format_number(rounded_value) + " Mbps");

			cell = "#cell_b" + (i+1);
			rounded_value = (1.2 * data_rate[i]).toFixed(2);
			$(cell).html( format_number(rounded_value) + " Mbps");
		}
	}

	function setIPRateCalculator(indx)
	{

		// Set image data rates for Low and High
		var cell = "#cell_a" + (indx);
		var rounded_value = (data_rate[0]).toFixed(2);
		$(cell).html( format_number(rounded_value) + " Mbps");
		
		$(cell).html( format_number(rounded_value) + " Mbps");
		ip_image_low_round[indx] = rounded_value;
		
		cell = "#cell_b" + (indx);
		rounded_value = (data_rate[1]).toFixed(2);
		ip_image_high_round[indx] = rounded_value;
		$(cell).html( format_number(rounded_value) + " Mbps");
		
		var cell = "#cell_c" + (indx);
		var rounded_value = ( 1.2 * data_rate[0]).toFixed(2);
		ip_net_low_round[indx] = rounded_value;
		$(cell).html( format_number(rounded_value) + " Mbps");

		cell = "#cell_d" + (indx);
		rounded_value = ( 1.2 * data_rate[1]).toFixed(2);
		ip_net_high_round[indx] = rounded_value;
		$(cell).html( format_number(rounded_value) + " Mbps");
	}

	function setIPTotal()
	{
		var imagelow =0; imagehigh = 0; netlow = 0; nethigh = 0;
		for(var i=1; i < 5; i++) {
		
		imagelow += Number(ip_image_low_round[i]);
		imagehigh += Number(ip_image_high_round[i]);
		netlow += Number(ip_net_low_round[i]);
		nethigh += Number(ip_net_high_round[i]);
		}
		
		var cell = "#cell_a5";
		var rounded_value = (imagelow).toFixed(2);
		$(cell).html( format_number(rounded_value) + " Mbps");

		cell = "#cell_b5";
		rounded_value = (imagehigh).toFixed(2);
		$(cell).html( format_number(rounded_value) + " Mbps");
		
		cell = "#cell_c5";
		rounded_value = (netlow).toFixed(2);
		$(cell).html( format_number(rounded_value) + " Mbps");
		
		cell = "#cell_d5";
		rounded_value = (nethigh).toFixed(2);
		$(cell).html( format_number(rounded_value) + " Mbps");
		
	}


	
	function format_number(num)	{ 
		var n = '' + num;
		var numl  = n.length;
		var i = n.indexOf('.');
		var fract = '';
	
		if (i > -1){
			numl -= n.length-i;
			fract = n.substring(i);
		}
		if (numl > 3){
			var s, dl = numl%3;
			var str = (dl > 0) ? n.substring(0,dl):'';
			var max = Math.floor(numl/3);
			for (i=0 ; i < max ; i++){
				s = n.substring(dl+i*3,dl+i*3+3);
				str += (dl==0 && i==0) ? s : ","+s;
			}
			return str+fract;
		}else return n;
	}
	
	// RESULTS CALCULATION  ---------------------------------
	

function recalculate_storage(indx) 
{
	var C2 = $('#data_rate_00' + indx).val(); 
	var C3 = $('#storage_units_00' + indx).val(); 
	var C4 = $('#cameras_00' + indx).val();
	var C5 = $('#op_hours_00' + indx).val();
	var C6 = $('#retention').val(); 
	var C7 = C2 * (C3 * 86400/8388608) * C4 * (C5/24) * (C6); //converting values in bits/sec to MegaBytes
	var C8 = C2 * (C3/1048576) * C4; //converting values in bits/sec to Mbps by dividing with 1048576

	camera_storage = C7 / 1048576; //converting to Tera Bytes
	camera_bandwidth = C8;
	
	total_storage[indx] = camera_storage;
	total_bandwidth[indx] = camera_bandwidth;
	
	total_storage_sum = 0.0;
	total_bandwidth_sum = 0.0;
	for(var i=1; i <= row_count; i++) {

		total_storage_sum += Number(total_storage[i].toFixed(3));
		total_bandwidth_sum += Number(total_bandwidth[i].toFixed(3));
	}
}

// RESULTS CALCULATION  ---------------------------------
// Here variable names correspond to cell names on the spreadsheet. The spreadsheet has detailed explanations of
// variables, formulas, and data fitting algorithms.
function recalculate_rate(indx) 
{
		/**
		C2 = { "NTSC" : 1, "PAL" : 2 }; // Video Mode
		E2 = { "1 CIF" : 1, "2 CIF" : 2, "4 CIF DID" : 3, "4 CIF DIE" : 4 }; // Rsolution
		G2 = { "E/N" : 1, "N:N" : 2, "S/N" : 3, "E/H" : 4, "N/H" : 5, "S/H" : 6 };  // Quality / Sensitibity
		I2 = { "HIGH" : 2.8, "LOW" : 2.8 }; // Scene Com`plexity
		K2 = 30; // Frmes per second (1-30)
		M2 = 1; // No. Cams (1-16)
		O2 = 1; // Operation Hours (1-24)
		Q2 = 0; // Panning Percentage (0% to 100% by 25s) 0 = 0, 1 = 25%, 2 = 50%, ...
	c4 = E2.val;
	c5 = G2.val;
	c7 = I2.val;
	c9 = c4 * 10 + c5; // equation number
	*/

		// if ($('#platform_ultra').attr('checked')) { platform = "ultra"; ZZ = 1; }
		// if ($('#platform_dvms').attr('checked'))  { platform = 'dvms'; ZZ = 1; }
		// if ($('#platform_lt').attr('checked'))    { platform = 'lt'; ZZ = 1; }
		// if ($('#platform_ip').attr('checked'))    { platform = 'ip'; ZZ = 1; }

		if ($('#ntsc00' + indx).attr('checked'))  { C2 = 1; }
		if ($('#pal00' + indx).attr('checked'))   { C2 = 2; }

		if ($('#quality_high00' + indx).attr('checked'))              { G2 = 3; }
		if ($('#quality_normal00' + indx).attr('checked'))    { G2 = 2; }
		if ($('#quality_extended00' + indx).attr('checked'))  { G2 = 1; }

		if ($('#sensitivity_high00' + indx).attr('checked'))    { G2 += 3; }
		if ($('#sensitivity_normal00' + indx).attr('checked'))  { G2 += 0; }

		if ($('#1cif00' + indx).attr('checked'))  { E2 = 1; }
		if ($('#2cif00' + indx).attr('checked'))  { E2 = 2; }

		if ($('#4cif00' + indx).attr('checked'))  { 
			$('#interlaced00' + indx).attr('disabled', false);
			$('#deinterlaced00' + indx).attr('disabled', false);
			if ($('#interlaced00' + indx).attr('checked'))  { E2 = 3; }
			if ($('#deinterlaced00' + indx).attr('checked'))  { E2 = 4; }
			// $('#interlacing_div').show();
		} else {
			$('#interlaced00' + indx).attr('disabled', true);
			$('#deinterlaced00' + indx).attr('disabled', true);
			$('#deinterlaced00' + indx).attr('checked', true);
			//$('#interlacing_div').hide();
		}

		K2 = $('#record_rate00' + indx).val(); 
		M2 = 1;  // $('#cameras').val();
		O2 = 24; // $('#op_hours').val();
		Q2 = $('#panning_activity00' + indx).val();


	/***
// equation number, resolution + quality + sensitivity, equation
// the X in the equation is determined by  Scene Complexity LOW=2.8, HIGH=4.0
11	1CIF E/N		y = 34.5x + 125.5
12	1CIF N/N 		y = 40.6x + 140
13	1CIF S/N		y = 41.1x + 156.5
14	1CIF E/H		y = 148x + 42.55
15	1CIF N/H 		y = 215x - 1.45
16	1CIF S/H		y = 250.3x - 16.5
21	2CIF E/N		y = 75.9x + 106.5
22	2CIF N/N 		y = 112.58x + 99.738
23	2CIF S/N		y = 139.6x + 93.5
24	2CIF E/H		y = 508.6x - 118
25	2CIF N/H 		y = 647x + 90
26	2CIF S/H		y = 808.99x + 120.05
31	4CIF DID E/N	y = 115.8x + 129.5
32	4CIF DID N/N 	y = 155.1x + 176.5
33	4CIF DID S/N	y = 204.2x + 184
34	4CIF DID E/H	y = 734.99x + 0.05
35	4CIF DID N/H 	y = 1095x - 100
36	4CIF DID S/H	y = 1410x - 150
41	4CIF DIE E/N	y = 652x - 550
42	4CIF DIE N/N 	y = 862.4x - 674.5
43	4CIF DIE S/N	y = 1111x - 905
44	4CIF DIE E/H	y = 1421x - 955
45	4CIF DIE N/H 	y = 1829.9x - 649.5
46	4CIF DIE S/H	y = 2322x - 1060
//
//**/


	//alert (
	//	"C2:" + C2 + " E2:" + E2 + " G2:" + G2 + " I2:" + I2 + " K2:" + K2 + 
	//	"\nM2:" + M2 + " O2:" + O2 + " Q2:" + Q2
	//);
	
	// We loop over scene complexity to get values for Low and High Complexity
	var IA = [ 1, 2];
	var Q2A = [ 0.0, .1, .2, .4, .6 ];  // the panning percentage multiplier for 0%, 25%, 50%, 75% and 100%
	var y, y1, z, d;

	for (var i=0; i < 2; i++) {

		I2 = IA[i];

		// There are 24 equations fitted to observed data yielding 4 factors (y, y1, z, d) in computing data rates.
		eqn_number = 10 * E2 + G2; // E2 is resolution and G2 is Sensitivity/Quality

		if (i == 0) x = 2.8;  // x is C7
		else x = 4.0;
	
		switch (eqn_number) {
			case 11:	y = 34.5 * x + 125.5;     y1 = 263.0;   z = 4.0;   d = 0.5;    break;
			case 12:	y = 40.6 * x + 140;       y1 = 302.4;   z = 4.0;   d = 0.5;    break;
			case 13:	y = 41.1 * x + 156.5;     y1 = 320.9;   z = 4.0;   d = 0.5;    break;
			case 14:	y = 148 * x + 42.55;      y1 = 634.55;  z = 2.0;   d = 0.2;    break;
			case 15:	y = 215 * x - 1.45;       y1 = 858.55;  z = 2.0;   d = 0.2;    break;
			case 16:	y = 250.3 * x - 16.5;     y1 = 984.7;   z = 2.0;   d = 0.2;    break;
			case 21:	y = 75.9 * x + 106.5;     y1 = 410.1;   z = 8.0;   d = 0.77;   break;
			case 22:	y = 112.58 * x + 99.738;  y1 = 550.4;   z = 8.0;   d = 0.77;   break;
			case 23:	y = 139.6 * x + 93.5;     y1 = 651.9;   z = 8.0;   d = 0.77;   break;
			case 24:	y = 508.6 * x - 118;      y1 = 1916.4;  z = 2.0;   d = 0.25;   break;
			case 25:	y = 647 * x + 90;         y1 = 2678.0;  z = 2.0;   d = 0.25;   break;
			case 26:	y = 808.99 * x + 120.05;  y1 = 3356.0;  z = 2.0;   d = 0.25;   break;
			case 31:	y = 115.8 * x + 129.5;    y1 = 592.7;   z = 10.0;  d = 0.91;   break;
			case 32: 	y = 155.1 * x + 176.5;    y1 = 796.9;   z = 10.0;  d = 0.91;   break;
			case 33:	y = 204.2 * x + 184;      y1 = 1000.8;  z = 10.0;  d = 0.91;   break;
			case 34:	y = 734.99 * x + 0.05;    y1 = 2940.0;  z = 2.0;   d = 0.25;   break;
			case 35: 	y = 1095 * x - 100;       y1 = 4280.0;  z = 2.0;   d = 0.25;   break;
			case 36:	y = 1410 * x - 150;       y1 = 5490.0;  z = 2.0;   d = 0.25;   break;
			case 41:	y = 652 * x - 550;        y1 = 2058.0;  z = 2.4;   d = 0.87;   break;
			case 42: 	y = 862.4 * x - 674.5;    y1 = 2775.1;  z = 2.4;   d = 0.87;   break;
			case 43:	y = 1111 * x - 905;       y1 = 3539.0;  z = 2.4;   d = 0.87;   break;
			case 44:	y = 1421 * x - 955;       y1 = 4729.0;  z = 1.15;  d = 0.5;    break;
			case 45: 	y = 1829.9 * x - 649.5;   y1 = 6670.1;  z = 1.15;  d = 0.5;    break;
			case 46:	y = 2322 * x - 1060;      y1 = 8228.0;  z = 1.15;  d = 0.5;    break;
		}
	
	
		// y1 is second term of sum adjusting for camera panning percentage

		//alert("y:" + y + " y1:" + y1);
		y1 *= z * Q2A[Q2];

		y += y1;

		y *= (K2 / 30) * (M2 / 1024);

		if (C2 == 2) y *= 1.3;

		if (Q2 == 0)
		y *= d;

		data_rate[i] = y;

		/** Storage calculations for convenience
		var C2 = data_rate[i];
		var C3 = 8096000;
		var C4 = $('#cameras_001').val();
		var C5 = $('#op_hours_001').val();
		var C6 = $('#retention_001').val(); 

		var C7 = C2 * (C3 * 86400/8096000) * C4 * (C5/24) * (C6/1024);
		**/
	}
}

		
	
	
// HELP SECTION ------------------------------------------------------
function top() {
	window.location.hash = "#calc"
}
	
function show_help(help_term) {
	
	var term
	var text
	
	switch(help_term) {
		
		case 'platform':
			term = "Intellex Platforms"
			text = "<p>Note: all Intellex systems utilize Active Content Compression (ACC); choice of platform does not affect storage efficiency, only the settings avaialble for 'Resolution' and 'Aggregate Record Rate'.</p><p>For detailed information on the available Intellex platforms, visit the <a href='http://www.americandynamics.net/products/intellex_home.aspx'>Intellex Family section</a> of the American Dynamics website.</p>"
			break
		case 'video':
			term = "Video Mode"
			text = "<p>Video Mode indicates the video standard Intellex is using - NTSC or PAL. Your selection affects the list of choices in the Aggregate Record Rate and the resultant Camera Update Rate in the calculator.</p>"
			break
		case 'quality':
			term = "Quality"
			text = "<p>Quality determines the tradeoff between image quality and storage space consumption. 'Super' emphasizes better image quality, but at the cost of greater storage consumption. 'Extended' favors conservation of storage space, but at the cost of poorer image quality. 'Normal' selects a balance between the two.</p>"
			break
		case 'sensitivity':
			term = "Sensitivity"
			text = "<p>Sensitivity affects how responsive Intellex is to small changes between images. This affects image resolution and the rate at which storage space is consumed. 'High' records smaller changes, resulting in better resolution but greater storage consumption. 'Normal' ignores smaller changes, resulting in less resolution but also decreased storage consumption.</p>"
			break
		case 'resolution':
			term = "Resolution"
			text = "<p>Resolution indicates the image size being recorded by Intellex. Larger image sizes provide better resolution, while smaller image sizes save on storage space. A setting of '1 CIF' sets the image size to 320 pixels wide by 240 pixels high. '2 CIF' selects an image size of 640 x 240, and '4 CIF' sets the size at 640 x 480.</p>"
			break
		case 'interlacing':
			term = "Interlacing"
			text = "<p>Interlaced mode only applies to 4 CIF resolution. Interlaced mode results in higher quality when the camera is panning and is the default. Interlacing results in a higher Data Rate.</p>"
			break
		case 'panning_activity':
			term = "Pan, Tilt, Zoom Activity Percentage"
			text = "<p>Pan, Tilt, Zoom Activity Percentage Available indicates the percentage of time which the camera is involved in panning operation. Enter a percentage between 0% and 100%.</p>"
			break
		case 'record_rate':
			term = "Images per Second"
			text = "<p>Images per Second (IPS) specifies how many frames are recorded each second by the camera. Note that the maximum record rate of any single camera is limited to 30 IPS for NTSC and 25 IPS for PAL.</p>"
			break
		case 'cameras':
			term = "Number of Cameras"
			text = "<p>Number of Cameras indicates how many cameras are being recorded on Intellex.</p>"
			break
		case 'op_hours':
			term = "Hours of Operation"
			text = "<p>Hours of Operation is the average number of hours a camera is active each day.</p>"
			break
		case 'retention':
			term = "Storage Retention Time"
			text = "<p>Storage Retention Time indicates the number of days (week, months, or years) to archive camera image and audio data.</p>"
			break
		case 'add_row':
			term = "Adding a row"
			text = "<p>Click 'add' to add another row to the table</p>"
			break;
		case 'imgDataRate':
			term = "Estimated Image Data Rate"
			text = "<p>Estimated Image Data Rate uses the Camera Settings to estimate the data storage rate in Megabits per second (Mbps). Image Data Rate includes only image data from the camera and should be used for the NVR Calculator Page.</p><p>Click the 'Complexity' heading for information about each scenario.</p>"
			break
		case 'netDataRate':
			term = "Estimated Network Data Rate"
			text = "<p>Estimated Network Data Rate uses the Camera Settings to estimate the data storage rate in Megabits per second (Mbps). Network Data Rate includes image, audio, and command data from the camera for Low and High Image Complexity scenarios.</p><p>Click the 'Complexity' heading for information about each scenario.</p>"
			break
		case 'imgDataRate2':
			term = "Image Data Rate"
			text = "<p>Image Data Rate uses the Camera Settings to estimate the data storage rate in Megabits per second (Mbps). Image Data Rate includes only image data from the camera and should be used for the NVR Calculator Page.</p>"
			break
		case 'netDataRate2':
			term = "Network Data Rate"
			text = "<p>Estimated Network Data Rate uses the Camera Settings to estimate the data storage rate in Megabits per second (Mbps). Network Data Rate includes image, audio, and command data from the camera for Low and High Image Complexity scenarios.</p>"
			break
		case 'complexity':
			term = "Image Complexity"
			text = "<p>Image Complexity is a general measure of how complex an image is. Click on the Low or High headings to get a description of each.</p>"
			break
		case 'data_rate':
			text = "<p>Estimated Data Rate uses the Camera Settings to estimate the image data storage rate in Megabits per second (Mbps). The data rate is shown for Low and High image complexity scenarios.</p><p>Click the 'Complexity' heading for information about each scenario.</p>"
			term = "Date Rate in MBytes/sec"
			break
		case 'storage_required':
			term = "Storate Required"
			text = "<p>Storage Required uses the storage settings to predict how many Terabytes (TB) of storage would be required to acheive the desired retention under three scene complexity scenarios.</p><p>Click the 'Complexity' heading for information about each scenario.</p>"
			break
		case 'low':
			term = "Low Image Complexity"
			text = "<p>A quiet room or hallway with an occasional occupant or traffic. Virtually no motion or change due to wind, camera motion, or camera noise.</p>"
			break
		case 'casual':
			term = "Casual Motion"
			text = "<p>A room or hallway with a couple of occupants or fairly frequent traffic. A sidewalk or street with some traffic and little motion due to wind, light, or camera noise.</p>"
			break
		case 'high':
			term = "High Image Complexity"
			text = "<p>A busy room or hallway with several moving occupants at a time. A street or sidewalk with moderate traffic and/or moderate motion of trees and bushes due to wind.</p>"
			break
		case 'panning':
			term = "Panning Image Complexity"
			text = "<p>Extreme motion caused by camera motion (panning) or severe camera noise. A panning dome camera or severe wind motion in most of the image.</p>"
			break
		case 'camera_update':
			term = "Camera Update Rate"
			text = "<p>Camera Update Rate indicates how many images per second (IPS) are being recorded on any particular camera. This is calculated by dividing the Aggregate Record Rate by the Number of Cameras. Note that the maximum record rate of any single camera is limited to 30 IPS for NTSC and 25 IPS for PAL. These are considered real time rates.</p><p>In addition, the inverse calculation is displayed (seconds per image), indicating how much time elapses between each update to a camera.</p>"
			break				
		case 'row_number':
			term = "Row Number"
			text = "<p>Row number, starting at 1.</p>"
			break
		case 'add_a_row':
			term = "Add another Row"
			text = "<p>The first row is copied and added to the bottom of the table. Initially there are six rows. The maximum number of rows is 30.</p>"
			break
		case 'delete_row':
			term = "Delete Row"
			text = "<p>Delete the row and recalculate the storage totals.</p>"
			break
		case 'add_a_row':
			term = "Add another Row"
			text = "<p>The first row is copied and added to the bottom of the table. Initially there are six rows. The maximum number of rows is 30.</p>"
			break
		case 'set_all_rows':
			term = "Set Rows of a Column to the Frist Row"
			text = "<p>Set All Rows is a convenience to set all the rows of a column to equal the first row setting.</p>"
			break
		case 'manufacturer':
			term = "Model or Cameras Group Identifier"
			text = "<p>The Model is a text area to identify the Camera group you are estimating for. It can be whatever you like.</p>"
			break
		case 'storage_units':
			term = "Storage Units per Time Period"
			text = "<p>The Rate is expressed as a sorage rate per time period. Make sure to enter the proper units for the rate here.</p>"
			break
		case 'total_storage':
			term = "Total Storage for All Cameras"
			text = "<p>The grand total of storage in Terabytes for all rows of the storage calculator.</p>"
			break
		case 'bandwidth':
			term = "Total Bandwidth for All Cameras"
			text = "<p>The grand total of bandwidth in Mbits/sec for all rows of the storage calculator.</p>"
			break
		default:
			term = "Undefined"
			text = "<p>No help text defined.</p>"
	}
	
	document.getElementById('help_term').innerHTML = term
	document.getElementById('help_text').innerHTML = text
	window.location.hash = "#help"

}
