﻿function openWindow(myLink)
{    
	var myWin=window.open(myLink,'Ticker',"height=650,width=780,dependent,scrollbars,toolbar,resizable");    
}

function openWindow_contact(myLink)
{    
	var myWin=window.open(myLink,'service',"height=320,width=458,dependent=yes,scrollbars=yes,toolbar=yes");
}

function openWindow1(myLink)
{
    var myWin=window.open(myLink,'service',"height=600,width=620,dependent=yes,scrollbars=yes,toolbar=yes");
}

function openWindow2(myLink)
{    
	var myWin=window.open(myLink,'service',"height=400,width=650,dependent=yes,scrollbars=yes,toolbar=yes");    
}

function openLookUp(myLink)
{    
	var myWin=window.open(myLink,'Ticker',"height=350,width=500,dependent,scrollbars,toolbar");    
}

function TickerlookupSubmit()
{   
		var ename = document.forms[0].ename.value;
		if (ename != null && ename != '')
		{
			var url = '/usmkt/ticker/lookup.aspx?ename=' + ename;
			window.location = url;
		}
}

function TickerlookupEnterSubmit(e)
{   
		if (e)
		{
			var code;
			if (e.keyCode) code = e.keyCode;
			else if (e.which) code = e.which;
			
			if (code == 13)
			{
				var ename = document.forms[0].ename.value;
				if (ename != null && ename != '')
				{
					var url = '/usmkt/ticker/lookup.aspx?ename=' + ename;
					document.location = url;
					return false;
				}
			}
		}
		return true;
}


function openChartWindow(myLink,chart)
{
	if(! window.focus)return;
	var myWin=window.open("",chart,"height=550,width=740,toolbar=no,scrollbars=yes");
	myWin.focus();
	myLink.target=chart;
}
 
function openChartWindow1(myLink,chart)
{
	if(! window.focus)return;
	var myWin=window.open("",chart,"height=260,width=420,toolbar=no,scrollbars=no");
	myWin.focus();
	myLink.target=chart;
}
function showRemote() 
{
   self.name = "main";
   var windowprops="toolbar=0, location=0, directories=0, status=0," +
       "menubar=0, scrollbars=yes,resizable=0, width=440,height=500";
   OpenWindow = window.open("sm.htm", "remote", windowprops);    
   return false;
}

function openNews(myLink)
{   
	var myWin=window.open(myLink,'News',"height=400,width=500,dependent,scrollbars,toolbar");
}

function openFree(myLink, name, feature)
{   
	var myWin=window.open(myLink,name,feature);
}

function clickHandler(Menu) {
	var objChild, objParentImage; 
	eval("objChild = document.getElementById(['C-" + Menu + "']);");
	eval("objParentImage = document.images['MI-" + Menu + "'];");
	if (objChild.style.display == "none") 
	{
	objChild.style.display = "";
	objParentImage.src = "/quote123_images/bullet-minus.gif";
	}
	else
	{
	objChild.style.display = "none";
	objParentImage.src = "/quote123_images/bullet-plus.gif";
	}
}

function reFreshIndexChart(which){
	document.chart.src = "/usmkt/IndexChart.aspx?Symbol=" + which  + "&rnd="+ Math.random();
	if (which=='indu.x'){
		document.getElementById (which+'_background').setAttribute('bgColor', '#008000');
		document.getElementById ('compx.x'+'_background').setAttribute('bgColor', '#FFDC00');
		document.getElementById ('spx.xo'+'_background').setAttribute('bgColor', '#FFDC00');
		
		document.getElementById (which+'_foreground').setAttribute('color', '#ffffff');
		document.getElementById ('compx.x'+'_foreground').setAttribute('color', '#000000');
		document.getElementById ('spx.xo'+'_foreground').setAttribute('color', '#000000');
	}

	if (which=='compx.x'){
		document.getElementById (which+'_background').setAttribute('bgColor', '#008000');
		document.getElementById ('indu.x'+'_background').setAttribute('bgColor', '#FFDC00');
		document.getElementById ('spx.xo'+'_background').setAttribute('bgColor', '#FFDC00');
		
		document.getElementById (which+'_foreground').setAttribute('color', '#ffffff');
		document.getElementById ('indu.x'+'_foreground').setAttribute('color', '#000000');
		document.getElementById ('spx.xo'+'_foreground').setAttribute('color', '#000000');
	}

	if (which=='spx.xo'){
		document.getElementById (which+'_background').setAttribute('bgColor', '#008000');
		document.getElementById ('compx.x'+'_background').setAttribute('bgColor', '#FFDC00');
		document.getElementById ('indu.x'+'_background').setAttribute('bgColor', '#FFDC00');
		
		document.getElementById (which+'_foreground').setAttribute('color', '#ffffff');
		document.getElementById ('compx.x'+'_foreground').setAttribute('color', '#000000');
		document.getElementById ('indu.x'+'_foreground').setAttribute('color', '#000000');
	}
		
}	 
 
 /****************************************************************************************/
 function DisplayLeftSubMenu(which)
 {
	var whichSubMenu = 'LeftSubMenu_' + which
	var whicharray = new Array()
	var whichHtml = new Array()
	
	whicharray[0] = 'Quote123Home'
	whicharray[1] = 'MarketStatus'
	whicharray[2] = 'FinanceNews' 
	whicharray[3] = 'StockResearch' 
	whicharray[4] = 'HuaGu'
	whicharray[5] = 'ETF'
	whicharray[6] = 'InvestTool'
	whicharray[7] = 'commentary'
	whicharray[8] = 'EliteReports'
	whicharray[9] = 'Newinvestor'
	whicharray[10] = 'Portfolio'
	whicharray[11] = 'MemberCenter'
	
	whichHtml[0] = 	''
	whichHtml[1] = 	'<font color="#000000" face="新細明體" size="2"> <a href="/usmkt/MarketIndices.aspx">市場指數</a><br /><a href="/usmkt/quote/SectorQuote.aspx">行業指數</a><br /><a href="/usmkt/FinanceNews_Signal.aspx">即時出擊</a> <br /><a href="/usmkt/briefing/briefing.aspx">股市日誌</a> <br /><a href="/usmkt/quote/top10.aspx">美股排行</a></font>';
	whichHtml[2] = '<font size="2"><a href="/usmkt/FinanceNews_Realtime.aspx">即時新聞</a><font color="#000000"><br /><a href="/usmkt/FinanceNews_Special.aspx"><font face="新細明體">美股特別報道</font></a><br /><a href="/usmkt/FinanceNews_CommentaryList.aspx"><font face="新細明體">大盤解析</a></font></font><font color="#000000" size="2" face="新細明體"><br /><a href="/usmkt/FinanceNews_focus.aspx">焦點股票</a></font></font>';
	whichHtml[3] = '<font size="2" face="新細明體"><a href="/usmkt/zacks/research.aspx">公司研究摘要</a><br /><a href="/usmkt/zacks/financials.aspx">財務分析</a><br /><a href="/usmkt/zacks/fabs.aspx">資產負債表</a> <br /><a href="/usmkt/zacks/fais.aspx">損益表</a><br /><a href="/usmkt/zacks/est_rec.aspx">盈餘預估</a><br /><a href="/usmkt/zacks/ExpRep.aspx">盈餘報道日曆</a><br /><a href="/usmkt/zacks/sxp.aspx">盈餘異常報</a><br /><a href="/usmkt/zacks/recommend.aspx">券商推薦排行榜</a><br /><a href="/usmkt/zacks/ZN1_Ranking.aspx">盈餘預估排行榜</a></font>' 
	whichHtml[4] = ''
	whichHtml[5] = ''
	whichHtml[6] = '<font color="#000000" size="2"><a href="/usmkt/InvestTool/signal.aspx">勁爆千里眼</a></font>'
	whichHtml[7] = '<font size="2" face="新細明體"><a href="/usmkt/bigtrader.aspx?ClassID=54">大戶名人觀點</a><br /><a href="/usmkt/bigtrader.aspx?ClassID=55">投資趨勢</a><br /><a href="/usmkt/bigtrader.aspx?ClassID=56">理財智庫</a></font>'
	whichHtml[8] = ''
	whichHtml[9] = '<font size="2"><a href="/usmkt/edu/enter_us/enter_0.aspx">美股進場教練</a><br /><a href="/usmkt/edu/glossary/glossary.aspx">美股財經辭典</a><br /><a href="/usmkt/edu/investing/mutualfund.aspx">共同基金</a></font>'
	whichHtml[10] = ''
	whichHtml[11] = ''

	document.getElementById('BgColor_Quote123Home1').setAttribute('bgColor', '#336600');
	document.getElementById('BgColor_Quote123Home2').setAttribute('bgColor', '#336600');
	
	
	
	for (var i=0; i<12; i++)
	{
		if (whichSubMenu == 'LeftSubMenu_' + whicharray[i])
		{
			document.getElementById('LeftSubMenu_' + whicharray[i]).innerHTML = whichHtml[i];
			document.getElementById('BgColor_' + whicharray[i] + '1').setAttribute('bgColor', '#FFD800');
			document.getElementById('BgColor_' + whicharray[i] + '2').setAttribute('bgColor', '#FFD800');
			document.getElementById('BgColor_' + whicharray[i] + '3').setAttribute('bgColor', '#FFD800');
			document.getElementById('FgColor_' + whicharray[i]).setAttribute('color', '#000000');
		}
		else
		{
			document.getElementById('LeftSubMenu_' + whicharray[i]).innerHTML = '';
			document.getElementById('BgColor_' + whicharray[i] + '1').setAttribute('bgColor', '#669900');		
			document.getElementById('BgColor_' + whicharray[i] + '2').setAttribute('bgColor', '#336600');		
			document.getElementById('FgColor_' + whicharray[i]).setAttribute('color', '#ffffff');	
			
		}
		
	}			
 }	 
 /****************************************************************************************/
 function DisplayLeftSubMenuWithSymbol(which, symbol)
 {
	var whichSubMenu = 'LeftSubMenu_' + which
	var whicharray = new Array()
	var whichHtml = new Array()
	
	whicharray[0] = 'Quote123Home'
	whicharray[1] = 'MarketStatus'
	whicharray[2] = 'FinanceNews' 
	whicharray[3] = 'StockResearch' 
	whicharray[4] = 'HuaGu'
	whicharray[5] = 'ETF'
	whicharray[6] = 'InvestTool'
	whicharray[7] = 'commentary'
	whicharray[8] = 'EliteReports'
	whicharray[9] = 'Newinvestor'
	whicharray[10] = 'Portfolio'
	whicharray[11] = 'MemberCenter'
	
	
	whichHtml[0] = ''
	whichHtml[1] = '<font color="#000000" face="新細明體" size="2"> <a href="/usmkt/MarketIndices.aspx">市場指數</a><br /><a href="/usmkt/quote/SectorQuote.aspx">行業指數</a><br /><a href="/usmkt/FinanceNews_Signal.aspx">即時出擊</a> <br /><a href="/usmkt/briefing/briefing.aspx">股市日誌</a> <br /><a href="/usmkt/quote/top10.aspx">美股排行</a></font>';
	whichHtml[2] = '<font size="2"><a href="/usmkt/FinanceNews_Realtime.aspx">即時新聞</a><font color="#000000"><br /><a href="/usmkt/FinanceNews_Special.aspx"><font face="新細明體">美股特別報道</font></a><br /><a href="/usmkt/FinanceNews_CommentaryList.aspx"><font face="新細明體">大盤解析</a></font></font><font color="#000000" size="2" face="新細明體"><br /><a href="/usmkt/FinanceNews_focus.aspx">焦點股票</a></font></font>';
	whichHtml[3] = '<font size="2" face="新細明體"><a href="/usmkt/zacks/research.aspx?Symbol=' + symbol + '">公司研究摘要</a><br /><a href="/usmkt/zacks/financials.aspx?symbol=' + symbol + '">財務分析</a><br /><a href="/usmkt/zacks/fabs.aspx?symbol=' + symbol + '">資產負債表</a> <br /><a href="/usmkt/zacks/fais.aspx?symbol=' + symbol + '">損益表</a><br /><a href="/usmkt/zacks/est_rec.aspx?symbol=' + symbol + '">盈餘預估</a><br /><a href="/usmkt/zacks/ExpRep.aspx?Symbol=' + symbol + '">盈餘報道日曆</a><br /><a href="/usmkt/zacks/sxp.aspx?Symbol=' + symbol + '">盈餘異常報</a><br /><a href="/usmkt/zacks/recommend.aspx?Symbol=' + symbol + '">券商推薦排行榜</a><br /><a href="/usmkt/zacks/ZN1_Ranking.aspx?Symbol=' + symbol + '">盈餘預估排行榜</a></font>' 
	whichHtml[4] = '' 		 
	whichHtml[5] = '' 
	whichHtml[6] = '<font color="#000000" size="2"><a href="/usmkt/InvestTool/signal.aspx">勁爆千里眼</a></font>'
	whichHtml[7] = '<font size="2" face="新細明體"><a href="/usmkt/bigtrader.aspx?ClassID=54">大戶名人觀點</a><br /><a href="/usmkt/bigtrader.aspx?ClassID=55">投資趨勢</a><br /><a href="/usmkt/bigtrader.aspx?ClassID=56">理財智庫</a></font>'
	whichHtml[8] = ''
	whichHtml[9] = '<font size="2"><a href="/usmkt/edu/enter_us/enter_0.aspx">美股進場教練</a><br /><a href="/usmkt/edu/glossary/glossary.aspx">美股財經辭典</a><br /><a href="/usmkt/edu/investing/mutualfund.aspx">共同基金</a></font>'
	whichHtml[10] = ''
	whichHtml[11] = ''

	document.getElementById('BgColor_Quote123Home1').setAttribute('bgColor', '#336600');
	document.getElementById('BgColor_Quote123Home2').setAttribute('bgColor', '#336600');
	
	
	
	for (var i=0; i<12; i++)
	{
		if (whichSubMenu == 'LeftSubMenu_' + whicharray[i])
		{
			document.getElementById('LeftSubMenu_' + whicharray[i]).innerHTML = whichHtml[i];
			document.getElementById('BgColor_' + whicharray[i] + '1').setAttribute('bgColor', '#FFD800');
			document.getElementById('BgColor_' + whicharray[i] + '2').setAttribute('bgColor', '#FFD800');
			document.getElementById('BgColor_' + whicharray[i] + '3').setAttribute('bgColor', '#FFD800');
			document.getElementById('FgColor_' + whicharray[i]).setAttribute('color', '#000000');
		}
		else
		{
			document.getElementById('LeftSubMenu_' + whicharray[i]).innerHTML = '';
			document.getElementById('BgColor_' + whicharray[i] + '1').setAttribute('bgColor', '#669900');		
			document.getElementById('BgColor_' + whicharray[i] + '2').setAttribute('bgColor', '#336600');		
			document.getElementById('FgColor_' + whicharray[i]).setAttribute('color', '#ffffff');	
			
		}
		
	}			
 }	 
 /****************************************************************************************/
 function IsValidDate(source, clientside_arguments){
	var fieldvalue = clientside_arguments.Value;
	var regex1 = /^[\d]{1,2}[\-|\/\.][\d]{1,2}[\-|\/\.][\d]{4}$/;
	var regex2 = /^[\d]{4}[\-|\/\.][\d]{1,2}[\-|\/\.][\d]{1,2}$/;
	if(regex1.test(fieldvalue) || regex2.test(fieldvalue) )
	{
		clientside_arguments.IsValid = true;
	}
	else
	{
		clientside_arguments.IsValid = false;
	}
	return;
}
/****************************************************************************************/
function IsValidInteger(source, clientside_arguments)
{
	var regex = /^[\d]+$/;

	if(!regex.test(clientside_arguments.Value))
	{
		clientside_arguments.IsValid = false
	}
	else
	{
		clientside_arguments.IsValid = true
}
return;
}
/****************************************************************************************/
function IsValidFloat(source, clientside_arguments)
{
	clientside_arguments.IsValid = false
	if(clientside_arguments.Value!=""){

		var regex1 = /^[\d]+[\d\.][\d]+$/;
		var regex2 = /^[\d]+$/;

		if(!regex1.test(clientside_arguments.Value) && !regex2.test(clientside_arguments.Value))
		{}
		else
			clientside_arguments.IsValid = true
	}
	return;
}