
function doMAs(f, Selected, ChartId)
{
	if (Selected == "None" || f.units.value == "" || f.units.value == "0")
	{
		document.Applet1.deleteOverlay("SMA", ChartId);
		document.Applet1.deleteOverlay("EMA", ChartId);		
		blnSMA = false;
	}
	else
	{
		switch(Selected){
		case "SMA":
			count = 1;
			blnSMA = true;
			break;
		case "SMA2":
			count = 2;
			blnSMA = true;
			break;
		case "SMA3":
			count = 3;
			blnSMA = true;
			break;
		case "EMA":
			count = 1;
			blnSMA = false;
			break;
		case "EMA2":
			count = 2;
			blnSMA = false;
			break;
		case "EMA3":
			count = 3;
			blnSMA = false;
			break;
		default:
			blnSMA = false;
			count = 0;
			break;
		}
		if (f.units.value.indexOf(',') > -1)
			arrValues = f.units.value.split(',')
		else 
			arrValues = f.units.value.split(' ')
				
		document.Applet1.deleteOverlay("SMA", ChartId);
		document.Applet1.deleteOverlay("EMA", ChartId);	
		if (arrValues.length > 1){
			for (i = 0; i < arrValues.length; i++){
			if (blnSMA)
				document.Applet1.addSMA("SMA", 0, parseInt(arrValues[i]));
			else 	
				document.Applet1.addSMA("EMA", 0, parseInt(arrValues[i]));
			}
		}else{
			for (i = 1; i <= count; i++){
				if (blnSMA)
					document.Applet1.addSMA("SMA", 0, parseInt(f.units.value * i));
				else 	
					document.Applet1.addSMA("EMA", 0, parseInt(f.units.value * i));
			}
		}					
	}			
}

function updatePeriod(f)
{
	doMAs(f, f.control_JavaMovingAverage.options[f.control_JavaMovingAverage.selectedIndex].value, 0);
}

function updateCompSymb(f)
{
	document.Applet1.doCompare(f.compare.value);
}
function doEvents(Selected, ChartId)
{
	if (Selected == "None")
	{
		document.Applet1.deleteOverlay("Splits", ChartId);
		document.Applet1.deleteOverlay("Earnings", ChartId);
		document.Applet1.deleteOverlay("Dividends", ChartId);
		document.Applet1.deleteOverlay("DividendsWithValue", ChartId);
		document.Applet1.deleteOverlay("EarningsWithValue", ChartId);
	}
	else if (Selected == "AllEvents")
	{
		document.Applet1.deleteOverlay("Splits", ChartId);
		document.Applet1.deleteOverlay("Earnings", ChartId);
		document.Applet1.deleteOverlay("Dividends", ChartId);
		document.Applet1.deleteOverlay("DividendsWithValue", ChartId);
		document.Applet1.deleteOverlay("EarningsWithValue", ChartId);
		
		document.Applet1.addOverlay("Splits", ChartId);
		document.Applet1.addOverlay("DividendsWithValue", ChartId);
		document.Applet1.addOverlay("EarningsWithValue", ChartId);
	}
	else
	{
		document.Applet1.deleteOverlay("Splits", ChartId);
		document.Applet1.deleteOverlay("Earnings", ChartId);
		document.Applet1.deleteOverlay("Dividends", ChartId);
		document.Applet1.deleteOverlay("DividendsWithValue", ChartId);
		document.Applet1.deleteOverlay("EarningsWithValue", ChartId);
		
		document.Applet1.addOverlay(Selected, ChartId);
	}
}
