//display a simple select
var realtime = false;
function select(name, value, list)
{
	var	i;
	document.write('<SELECT NAME="'+name+'">');
	for ( i = 0; i < list.length; i++ )
	{
		document.write('<OPTION value="' + list[i] + '" ');
		if ( value == list[i] )	document.write(' SELECTED');
		document.write('>'+list[i]);
	}
	document.write('</SELECT>');
}
//display a select tag where valueList is different with display list
function select2(name, value, valueList,displayList)
{
	/*if (value == 0)
	{	
		alert("value is 0");
	}
	*/
	var	i;
	document.write('<SELECT NAME="'+name+'">');
	for ( i = 0; i < valueList.length; i++ )
	{
		document.write('<OPTION value="' + valueList[i] + '" ' );
		/*
		if ((value == 0) && (displayList[i] == 'None'))
		{	document.write(' SELECTED');
		}else if ( value == valueList[i] )
		{	document.write(' SELECTED');
		}
		*/
		 if ( value == valueList[i] )
		{	document.write(' SELECTED');
		}
		document.write('>'+displayList[i]);
	}
	document.write('</SELECT>');
}
//display a select tag as select2 function + onchange function
function select3(name, value, valueList,displayList, onChangeFunction)
{
	var	i;
	document.write('<SELECT NAME="'+name+'" onChange="' + onChangeFunction + '">');
	for ( i = 0; i < valueList.length; i++ )
	{
		document.write('<OPTION value="' + valueList[i] + '" ');
		if ( value == valueList[i] )	document.write(' SELECTED');
		document.write('>'+displayList[i]);
	}
	document.write('</SELECT>');
}
function checkbox(name, value)
{
	document.write('<INPUT NAME="'+name+'" TYPE=CHECKBOX');
	if ( value == '1' )	document.write(' CHECKED');
	document.write('>');
}
function radio(name, value, checked)
{
	document.write('<INPUT TYPE=RADIO NAME="' + name + '" value="' + value + '"');
	if ( checked )	document.write(' CHECKED');
	document.write('>');
}
function radio2(name, value, checked, displayName)
{
	document.write('<INPUT TYPE=RADIO NAME="' + name + '" value="' + value + '"');
	if ( checked )	document.write(' CHECKED');
	document.write('> ' + displayName);
}

function SaveSettings(f)
{	
	mypath = ' path=/; '; //we don't seem to need the path
	//mypath = "";
	expiredDate = "expires=Friday, 31 Dec 2015 23:59:59 GMT;";

	if ((ind < 0) && (inm < 0 ))
	{
		//saving settings for daily chart
		document.cookie= "daily_inm=" + f.inm.value + ";" + mypath + expiredDate;	
		document.cookie = "daily_ind=" + f.ind.value + ";" + mypath + expiredDate;
		document.cookie = "daily_chw=" + f.chw.value + ";" + expiredDate;
		document.cookie = "daily_chh=" + f.chh.value + ";" + expiredDate;
		document.cookie = "daily_inh=" + f.inh.value + ";" + expiredDate;
		document.cookie = "daily_chartType=" + f.ty.value + ";" + expiredDate;
		
		document.cookie = "daily_moving-ver2=" + (f.chk_mov.checked?1:0) + "-" + f.mov1.value + "-" + f.mov2.value + "-" + f.mov3.value + ";" + expiredDate;
		document.cookie = "daily_boll=" + (f.chk_boll.checked?1:0) + "-" + f.boll.value + ";" + expiredDate;
		
		document.cookie = "daily_chk_vol=" + (f.chk_vol.checked?1:0) + ";" + expiredDate;		
		document.cookie = "daily_chk_obv=" + (f.chk_obv.checked?1:0) + ";" + expiredDate;	
					
		document.cookie = "daily_rsi=" + (f.chk_rsi.checked?1:0) + "-" + f.rsi.value + ";" + expiredDate;	
		
		document.cookie = "daily_sto=" + (f.chk_sto.checked?1:0) + "-"  + f.sto1.value + "-" + f.sto2.value + "-" + f.sto3.value + ";" + expiredDate;	
		document.cookie = "daily_wil=" + (f.chk_wil.checked?1:0) + "-"  + f.wil.value + ";" + expiredDate;	
		document.cookie = "daily_macd=" + (f.chk_macd.checked?1:0) + "-" + f.macd1.value + "-" + f.macd2.value + "-" + f.macd3.value + ";" + expiredDate;
		document.cookie = "daily_roc=" + (f.chk_roc.checked?1:0) + "-"  + f.roc1.value + "-" + f.roc2.value + ";" + expiredDate;
		document.cookie = "daily_mfi=" + (f.chk_mfi.checked?1:0) + "-"  + f.mfi.value + ";" + expiredDate;	
		document.cookie = "daily_ref_rate=" + f.ref_rate.value + ";" + expiredDate;
		for (i=0;i<3 ;i++ )
		{	if (f.sca[i].checked)
			{	document.cookie = "daily_sca=" +(i+1) + ";" + expiredDate;
				break;
			}	
		}
		
		document.cookie = "daily_lin=" + (f.chk_lin.checked?1:0) + "-"  + f.lin.value + ";" + expiredDate;
		document.cookie = "daily_rsc=" + (f.chk_rsc.checked?1:0) + "-DJI.X" + ";" + expiredDate;
	}
	else
	{	//saving settings for intraday chart
		
		//expiredDate = "expires=Friday, 31-Dec-2010 23:59:59 GMT;";
		document.cookie= "inm=" + f.inm.value + ";" + mypath + expiredDate;	
		document.cookie = "ind=" + f.ind.value + ";" + mypath + expiredDate;
		document.cookie = "chw=" + f.chw.value + ";" + expiredDate;
		document.cookie = "chh=" + f.chh.value + ";" + expiredDate;
		document.cookie = "inh=" + f.inh.value + ";" + expiredDate;
		document.cookie = "chartType=" + f.ty.value + ";" + expiredDate;
		
		document.cookie = "moving-ver2=" + (f.chk_mov.checked?1:0) + "-" + f.mov1.value + "-" + f.mov2.value + "-" + f.mov3.value + ";" + expiredDate;
		document.cookie = "boll=" + (f.chk_boll.checked?1:0) + "-" + f.boll.value + ";" + expiredDate;
		
		document.cookie = "chk_vol=" + (f.chk_vol.checked?1:0) + ";" + expiredDate;		
		document.cookie = "chk_obv=" + (f.chk_obv.checked?1:0) + ";" + expiredDate;	
					
		document.cookie = "rsi=" + (f.chk_rsi.checked?1:0) + "-" + f.rsi.value + ";" + expiredDate;	
		
		document.cookie = "sto=" + (f.chk_sto.checked?1:0) + "-"  + f.sto1.value + "-" + f.sto2.value + "-" + f.sto3.value + ";" + expiredDate;	
		document.cookie = "wil=" + (f.chk_wil.checked?1:0) + "-"  + f.wil.value + ";" + expiredDate;	
		document.cookie = "macd=" + (f.chk_macd.checked?1:0) + "-" + f.macd1.value + "-" + f.macd2.value + "-" + f.macd3.value + ";" + expiredDate;
		document.cookie = "roc=" + (f.chk_roc.checked?1:0) + "-"  + f.roc1.value + "-" + f.roc2.value + ";" + expiredDate;
		document.cookie = "mfi=" + (f.chk_mfi.checked?1:0) + "-"  + f.mfi.value + ";" + expiredDate;	
		document.cookie = "ref_rate=" + f.ref_rate.value + ";" + expiredDate;
		for (i=0;i<3 ;i++ )
		{	if (f.sca[i].checked)
			{	document.cookie = "sca=" +(i+1) + ";" + expiredDate;
				break;
			}	
		}
		
		document.cookie = "lin=" + (f.chk_lin.checked?1:0) + "-"  + f.lin.value + ";" + expiredDate;
		document.cookie = "rsc=" + (f.chk_rsc.checked?1:0) + "-DJI.X" + ";" + expiredDate;
	}	
}

function UpdateSymbol(f)
{	f.sb.value=f.idx_sym.value;
	f.cn.selectedIndex = 0;
}

//document.writeln('<center><b>Stock Chart is provided by <a href="http://www.realtimestockquote.com">RealtimeStockquote.com</a>',
//	'</b></center>');
if ((sb != '') && realtime)
//if (sb != '')
{	
	document.writeln('<center><b>More Information about ' + sb + ':</b>&nbsp;&nbsp;');
	if (cn == 'us')
	{
		document.writeln('<a href="http://www.marketwatch.com/tools/quotes/news.asp?symb=' + sb + '" target="_blank">News</a>&nbsp;|&nbsp;',
			'<a href="http://www.marketwatch.com/tools/quotes/profile.asp?symb=' + sb + '" target="_blank">Profile</a>&nbsp;|&nbsp;',
			'<a href="http://www.marketwatch.com/tools/quotes/secfilings.asp?siteid=mktw&symb=' + sb + '" target="_blank">SEC Filings</a>&nbsp;|&nbsp;',
			'<a href="http://www.marketwatch.com/tools/quotes/financials.asp?siteid=mktw&symb=' + sb + '" target="_blank">Financials</a>&nbsp;|&nbsp;',
			'<a href="http://www.marketwatch.com/tools/quotes/snapshot.asp?siteid=mktw&symb=' + sb + '" target="_blank">Analyst</a>&nbsp;');		
	}else{
		document.writeln('<a href="http://ca.finance.yahoo.com/q/h?s=' + sb + '.TO" target="_blank">News</a>&nbsp;|&nbsp;');
					
	}
	document.writeln('</center><br><br>');
}else{
document.writeln('<center>Stock quotes are delayed 20 minutes. Click on Chart to switch between intraday and daily.<br> Please sign up for our <b><a href="http://www.realtimestockquote.com/realtimestockquotechart.asp#NeoChart">real-time stock chart (NeoChart)</a></b> if you want <b>real-time quotes</b> & more information about stock (News, Profile, Financials, Analysts)</center><br>');
}

document.writeln('<FORM ACTION="neochart.dll" METHOD="GET" NAME="neoChartForm">');
document.writeln('<input type=hidden name=co value="realtime">');
document.writeln('<input type=hidden name=mode value="' + mode + '">');

document.writeln('<TABLE BGCOLOR="#ffffff" BORDER=1 CELLPADDING=0 CELLSPACING=2 >',
	'<TR><TD valign="top">',
			'<TABLE BORDER=0 CELLPADDING=2 CELLSPACING=0>',
				'<TR ALIGN=CENTER BGCOLOR="#c2c486" ><TD width="100%" colspan="2" ><b>Stock Chart Settings</b></TD></TR>',
				'<TR ><TD colspan=2 align="left">');

var indexValue;
var indexDisplay;
if (realtime)
{
	//indexValue=new Array('','DJI.X','NDX.X','COMP.X','OIX.X','SPX.X','OEX.X','RUT.X','RUI.X','RUA.X','TNX.X','TYX.X','SOX.X','VIX.X','GOX.X','MVB.X');
	//indexDisplay= new Array('List Of Major US Indexes','Dow 30','NASDAQ 100 INDEX','NASDAQ COMPOSITE INDEX','CBOE Oil Index','S&P 500 INDEX','S&P 100 INDEX','RUSSELL 2000 INDEX','RUSSELL 1000 INDEX','RUSSELL 3000 INDEX','10 YR TREASURY YIELD','30 YR TREASURY YIELD','SEMICONDUCTOR INDEX','CBOE VOLATILITY INDEX','CBOE Gold Index','Biotech Index');

	indexValue=new Array('','TNX.X','TYX.X','XAX.X','GOX.X','OIX.X','VIX.X','DJI.X','NDX.X','COMP.X','NYA.X','RUI.X','RUT.X','RUA.X','SPX.X','OEX.X');
	indexDisplay= new Array('List Of Major US Indexes','10 YR TREASURY YIELD','30 YR TREASURY YIELD','Amex Composite','CBOE Gold','CBOE Oil','CBOE Volatility','Dow 30 Industrial','NASDAQ 100','NASDAQ Composite','NYSE Composite','RUSSELL 1000','RUSSELL 2000', 'RUSSELL 3000', 'S&P 500','S&P 100');
}else
{
	//indexValue=new Array('','DIA','NDX.X','COMP.X','OIX.X','SPX.X','OEX.X','RUT.X','RUI.X','RUA.X','TNX.X','TYX.X','SOX.X','VIX.X','GOX.X','MVB.X');
	//indexDisplay= new Array('List Of Major US Indexes','DIA','NASDAQ 100 INDEX','NASDAQ COMPOSITE INDEX','CBOE Oil Index','S&P 500 INDEX','S&P 100 INDEX','RUSSELL 2000 INDEX','RUSSELL 1000 INDEX','RUSSELL 3000 INDEX','10 YR TREASURY YIELD','30 YR TREASURY YIELD','SEMICONDUCTOR INDEX','CBOE VOLATILITY INDEX','CBOE Gold Index','Biotech Index');
	indexValue=new Array('','TNX.X','TYX.X','XAX.X','GOX.X','OIX.X','VIX.X','DIA','NDX.X','COMP.X','NYA.X','RUI.X','RUT.X','RUA.X','SPX.X','OEX.X');
	indexDisplay= new Array('List Of Major US Indexes','10 YR TREASURY YIELD','30 YR TREASURY YIELD','Amex Composite','CBOE Gold','CBOE Oil','CBOE Volatility','DIA','NASDAQ 100','NASDAQ Composite','NYSE Composite','RUSSELL 1000','RUSSELL 2000', 'RUSSELL 3000', 'S&P 500','S&P 100');
}
select3('idx_sym',idx_sym,indexValue,indexDisplay,'UpdateSymbol(this.form)');
document.writeln('</td></tr>',
'<TR><TD colspan=2 align="left">Stock Symbols separated by , </TD></TR>');
document.writeln('<TR><TD><INPUT NAME="sb" TYPE=TEXT VALUE="'+sb+'" SIZE="15" MAXLENGTH="20"></TD><TD>');
select2('cn', cn, new Array('us', 'ca'), new Array('USA','CDN'));
document.writeln('&nbsp;<INPUT TYPE=SUBMIT VALUE="Draw Chart"></TD></TR>');
document.writeln('<TR><TD colspan=2><FONT size=2><A href="http://www.realtimestockquote.com/SymbolLookup.asp" target=_blank>Symbol lookup</a>&nbsp;&nbsp;&nbsp;',
	'<a href="http://www.marketwatch.com/tools/stockresearch/screener/default.asp?siteid=mktw&dist=&" target="_blank">Stock Screener</a>',
	'</FONT></TD></TR>');

//document.writeln('<TR><TD colspan=2 >&nbsp;</TD></TR>');
document.writeln('<TR><TD colspan=2 align="left">',
	'<TABLE id=TABLE1 cellSpacing=1 cellPadding=1 width="100%"  border=0>',
	'<TR><TD>Chart size</TD><TD>W</TD><TD><INPUT id=chw style="WIDTH: 37px; HEIGHT: 22px" size=4 name=chw value="' + chw + '"></TD>',
	'<TD>H</TD><TD><INPUT id=chh style="WIDTH: 37px; HEIGHT: 22px" size=4 name=chh value="' + chh + '"></TD></TR>');

document.writeln('<TR><TD>Indicator size</TD><TD>H</TD><TD>',
	'<INPUT id=inh style="WIDTH: 37px; HEIGHT: 22px" size=4 name=inh value="' + inh + '"></TD><TD></TD><TD></TD>',
    '</TR></TABLE></TD></TR>');

document.writeln('</TD></TR>',
	'<TR><TD>Chart type</TD><TD>');
select2('ty', ty, new Array(0, 1, 2), new Array('Line', 'Bar', 'Candle'));

document.writeln('</TD></TR>',
	'<TR><TD><span>Time Frame</span></TD><TD>');

select2('ind', ind, new Array('Intraday','0','1','2','5','Historical','-1','-3','-6','-12','-24','-36','-48','-60','-120'), new Array('---- Intraday ----','None','1 day','2 days','5 days', '---- Historical ----', '1 month', '3 months', '6 months', '1 year', '2 years', '3 years', '4 years', '5 years', '10 years'));


document.writeln('</TD></TR>',
'<TR><TD ><span>Frequency</span></TD><TD>');
select2('inm', inm, new Array('','1','2','5','10','15','30','60','','-1','-2','-3'),new Array('---- Intraday ----', '1 min','2 mins','5 mins','10 mins','15 mins','30 mins','60 mins','---- Historical ----','daily','weekly','monthly'));
/*if (i_chart==1)
{	select2('inm', inm, new Array('1','2','5','10','15','30','60'),new Array('1 min','2 mins','5 mins','10 mins','15 mins','30 mins','60 mins'));
}else
{	select2('inm2', inm2, new Array('-1','-2','-3'),new Array('daily','weekly','monthly'));
}*/


document.writeln('</TD></TR>',
'<TR><TD colspan=2 align="left">Scale &nbsp;&nbsp;&nbsp;');

radio2('sca',1,(sca==1)?true:false,'Linear');
radio2('sca',2,(sca==2)?true:false,'Percent');
radio2('sca',3,(sca==3)?true:false,'Log');

document.writeln('</td></tr>');
document.writeln('<TR><TD colspan=2 >&nbsp;</TD></TR>');
document.writeln('<TR><TD colspan=2 >Auto Refresh After ');
select2('ref_rate', ref_rate, new Array('30', '60', '90', '120', '180', '300','0'),new Array('30', '60', '90', '120', '180', '300','No refresh'));
document.writeln(' secs </TD></TR>');
document.writeln('<TR><TD colspan=2 align="middle"><INPUT TYPE=button NAME=save VALUE="Save chart settings" onclick="SaveSettings(this.form)"></TD></TR>');
document.writeln('</TABLE></td>'); //end of table in the first column of main table

//start of second column of the main table
document.writeln('<TD><TABLE border=0>',	
	'<TR BGCOLOR="#c2c486" ><TD ALIGN=middle colspan=4><b>Upper Indicators</b></td></tr>');

document.writeln('<TR><TD>');	
checkbox('chk_mov',chk_mov);
document.writeln('<a href="TechnicalAnalysis.html#Moving">Exponential Moving Averages</a></TD><TD width="50px">');
document.write('<INPUT NAME="mov1" TYPE=TEXT VALUE="'+mov1+'" SIZE="3" MAXLENGTH="3">');
document.write('</TD><TD width="50px">');
document.write('<INPUT NAME="mov2" TYPE=TEXT VALUE="'+mov2+'" SIZE="3" MAXLENGTH=3">');
document.write('</TD><TD width="50px">');
document.write('<INPUT NAME="mov3" TYPE=TEXT VALUE="'+mov3+'" SIZE="3" MAXLENGTH="3">');
document.writeln('</TD></TR>');

document.writeln('<TR><TD align=left>');
checkbox('chk_boll',chk_boll);
document.writeln('<a href="TechnicalAnalysis.html#Boll">Bollinger</a></TD><td colspan=3>');
document.write('<INPUT NAME="boll" TYPE=TEXT VALUE="'+boll+'" SIZE="3" MAXLENGTH="3">');
document.writeln('</TD></TR>');

document.writeln('<TR><TD align=left>');
checkbox('chk_lin',chk_lin);
document.writeln('<a href="TechnicalAnalysis.html#Linear">Linear Reg. Line</a></TD><td colspan=3>');
document.write('<INPUT NAME="lin" TYPE=TEXT VALUE="'+lin+'" SIZE="3" MAXLENGTH="3">');

document.write('</TD></TR>');

document.writeln('<TR ALIGN=CENTER BGCOLOR="#c2c486" ><TD align="middle" colspan="4"><b>Lower Indicators </b></TD></TR>',
	'<TR><TD colspan=4>');
checkbox('chk_vol', chk_vol);
document.writeln('Volume</TD></TR>',
'<TR><TD colspan=4>');
checkbox('chk_obv', chk_obv);
document.writeln('<span><a href="TechnicalAnalysis.html#OBV">On Balance Volume</a></span></TD></TR>',
'<TR><TD>');

checkbox('chk_rsi', chk_rsi);
document.write('<span><a href="TechnicalAnalysis.html#RSI">Relative Strength Index (RSI)</a></span></TD>');
document.writeln('<td><input name="rsi" value="' + rsi + '" size=4></td>');
document.write('</TR><TR><TD>');

checkbox('chk_sto', chk_sto);
document.write('<span><a href="TechnicalAnalysis.html#Sto">Stochastics</a></span></TD><TD>');
document.writeln('<input name="sto1" value="' + sto1 + '" size=4></td>');
document.writeln('<td><input name="sto2" value="' + sto2 + '" size=4></td>');
document.writeln('<td><input name="sto3" value="' + sto3 + '" size=4></td>');
document.writeln('</TR><TR><TD>');

checkbox('chk_wil', chk_wil);
document.write('<span><a href="TechnicalAnalysis.html#Wil">Williams %R</a></span></TD><TD>');
document.writeln('<input name="wil" value="' + wil + '" size=4></td>');
document.write('</TR><TR><TD>');



checkbox('chk_macd', chk_macd);
document.write('<span><a href="TechnicalAnalysis.html#MACD">MACD</a></span></TD><TD>');
document.writeln('<input name="macd1" value="' + macd1 + '" size=4></td>');
document.writeln('<td><input name="macd2" value="' + macd2 + '" size=4></td>');
document.writeln('<td><input name="macd3" value="' + macd3 + '" size=4></td>');
document.write('</TR><TR><TD>');

checkbox('chk_roc', chk_roc);
document.write('<span><a href="TechnicalAnalysis.html#ROC">Price rate of change</a></span></TD><TD>');
document.writeln('<input name="roc1" value="' + roc1 + '" size=4></td>');
document.writeln('<td><input name="roc2" value="' + roc2 + '" size=4></td>');
document.write('</TR><TR><TD>');

checkbox('chk_mfi', chk_mfi);
document.write('<span><a href="TechnicalAnalysis.html#MFI">Money Flow Index</a></span></TD><TD>');
document.writeln('<input name="mfi" value="' + mfi + '" size=4></td>');
document.write('</TR><TR><TD>');


checkbox('chk_rsc', chk_rsc);
document.write('<a href="TechnicalAnalysis.html#RSC">Relative Strength Comparative</a></TD><TD colspan=3>');
//select2('rsc_sym', rsc_sym, indexValue,indexDisplay);
document.writeln('</td</TR>');
document.writeln('</TABLE></TD></TR>'); 

document.writeln('</TABLE>'); //main table

document.writeln('</FORM>');

document.writeln('<center>Copyright &copy;2004-2009 RealtimeStockquote.com. All Rights Reserved</center>');