if (NON_EMPTY_SELECTION)
{
	UPDATE_CELL_DATA = 1;

	data_rows  	 = Columns 	(SELECTED_CHART_ROWS);

	temp = SELECTED_CHART_COLS[0];

	for (count = 1; count<data_rows; count = count+1)
	{
		temp2 = SELECTED_CHART_COLS[count];
		if (temp!=temp2)
		{
			break;
		}
	}

	if ((count == data_rows)&&(count>1))
	/* proper selection */
	{
		windowWidth = 0;
		
		while ((windowWidth<2)||(windowWidth>count)||(windowWidth%2==0))
		{
			fprintf (stdout, "\nChoose an ODD mean profile window width in [3,",count,"]:");
			fscanf  (stdin, "Number", windowWidth);
		}
		
		medianLocation  = windowWidth$2;
		meanDataMatrix	= {data_rows,2};
		currentMean		= 0;
		
		for (kk=0; kk<windowWidth;kk=kk+1)
		{
			currentMean = currentMean+SELECTED_CHART_DATA[kk];
		}
		
		currentMean = currentMean / windowWidth;
				
		for (kk=0; kk<=medianLocation;kk=kk+1)
		{
			meanDataMatrix[kk][0] = SELECTED_CHART_DATA[kk];
			meanDataMatrix[kk][1] = currentMean;
		}
		
		t2 = data_rows-medianLocation;
		
		t5 = 0;
		t4 = windowWidth;
		
		for (;kk<t2;kk=kk+1)
		{
			currentMean = currentMean + (SELECTED_CHART_DATA[t4]-SELECTED_CHART_DATA[t5])/windowWidth;
			meanDataMatrix[kk][0] = SELECTED_CHART_DATA[kk];
			meanDataMatrix[kk][1] = currentMean;			
			t5 = t5+1;
			t4 = t4+1;
		}

		for (; kk<data_rows;kk=kk+1)
		{
			meanDataMatrix[kk][0] = SELECTED_CHART_DATA[kk];
			meanDataMatrix[kk][1] = currentMean;
		}
		
		labelMatrix = {{"Data","Sliding mean"}};

		OpenWindow (CHARTWINDOW,{{"Mean Profile"}
								   {"labelMatrix"},
								   {"meanDataMatrix"},
								   {"Bar Chart"},
								   {"Index"},
								   {labelMatrix[0]},
								   {"Index"},
								   {"Window("+windowWidth+") Median"},
								   {"Data"},
								   {"0"},
								   {"meanDataMatrix[_x_-1][1]"}
								   {"-1;-1"}
		{"10;1.309;0.785398"}
		{"Times:12:0;Times:10:0;Times:12:2"}
		{"0;0;16777215;8421504;11776947;0;0;11842740;13158600;14474460;0;3947580;16777215;13421772;6845928;16771158;2984993;9199669;7018159;1460610;16748822;11184810;14173291"}
		{"16"}},
								   "SCREEN_WIDTH-60;SCREEN_HEIGHT-50;30;50");
		return 0;
	}

	fprintf (stdout, "Please select a single column with more than one entry to profile\n");
}
else
{
	NON_EMPTY_SELECTION = -1;
}
