var LINK_TYPE_EODCHART = "E";
var LINK_TYPE_30MCHART = "M";

var LINK_TYPE_COMP_INFO = "01";
var LINK_TYPE_COMP_DIRECTOR = "10";
var LINK_TYPE_COMP_SHAREHOLDER = "11";
var LINK_TYPE_COMP_PARVALUE = "12";
var LINK_TYPE_COMP_PAIDUPCAP = "13";
var LINK_TYPE_COMP_DIVIDEND = "14";
var LINK_TYPE_COMP_PROPERTY = "15";
var LINK_TYPE_COMP_ANOUNCEMENT = "16";
var LINK_TYPE_COMP_SUBSIDIARY = "17";
var LINK_TYPE_COMP_UPDATELOG = "18";

var LINK_TYPE_COMPFIN_BS = "50";		//balance sheet
var LINK_TYPE_COMPFIN_PL = "51";		//profit and loss
var LINK_TYPE_COMPFIN_CF = "52";		//cash flow
var LINK_TYPE_COMPFIN_FH = "53";		//financial highlight
var LINK_TYPE_COMPFIN_RA = "54";		//ratio analysis
var LINK_TYPE_COMPFIN_MS = "55";		//mining statistics
var LINK_TYPE_COMPFIN_PS = "56";		//plantation statistic


function DisplayStkInfoLink(linktype, p_sStkCode)
{
	var scrWidth, scrHeight, sURL;

	scrWidth = screen.width * 0.8;
	scrHeigth = screen.height * 0.8;

	switch (linktype) {
		case LINK_TYPE_EODCHART:
			// EOD chart
			// http://www.klse-ris.com.my/webchart-html/ceod_html/5088.html
			sURL = 'http://charttb.asiaebroker.com/ebcServlet/stkChartEOD?key='+ p_sStkCode;
			break;
		case LINK_TYPE_30MCHART:
			// 30 minute chart
			// http://www.klse-ris.com.my/webchart-html/c30m_html/5088.html
			sURL = 'http://www.klse-ris.com.my/webchart-html/c30m_html/' + p_sStkCode + '.html';
			break;

		case LINK_TYPE_COMP_INFO:
			// company info / summary
			// http://www.klse-ris.com.my/CDB/owa/cp_summary?cmp_code_in=5088
			// http://www.klse-ris.com.my/CDB/owa/compchq?cp_code_in=5088&cp_sname_in=&cp_rcode_in=
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_summary?cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_DIRECTOR:
			// company director info
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=DR&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=DR&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_SHAREHOLDER:
			// company shareholder info
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=SH&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=SH&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_PARVALUE:
			// par value
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=PV&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=PV&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_PAIDUPCAP:
			// paid-up capital
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=PV&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=PV&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_DIVIDEND:
			// dividend
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=DV&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=DV&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_PROPERTY:
			// property held by company
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=PH&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=PH&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_ANOUNCEMENT:
			// anouncement
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=AM&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=AM&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_SUBSIDIARY:
			// company subsidiary info
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=SC&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=SC&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMP_UPDATELOG:
			// update log
			// http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=UL&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/lcd.genchq?gen_type_in=UL&cmp_code_in=' + p_sStkCode
			break;

		case LINK_TYPE_COMPFIN_BS:
			// balance sheet
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=BS&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=BS&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMPFIN_PL:
			// profit and loss
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=PL&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=PL&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMPFIN_CF:
			// cash flow
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=CF&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=CF&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMPFIN_FH:
			// financial highlight
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=FH&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=FH&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMPFIN_RA:
			// company risk return and performance (ratio analysis)
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=RA&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=RA&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMPFIN_MS:
			// mining statistics
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=MS&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=MS&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;
		case LINK_TYPE_COMPFIN_PS:
			// plantation statistic
			// http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=PS&frm_yr=&to_yr=&cmp_code_in=5088
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_datechq?acct_type_in=PS&frm_yr=&to_yr=&cmp_code_in=' + p_sStkCode
			break;

		default:
			// default to company info
			sURL = 'http://www.klse-ris.com.my/CDB/owa/cp_summary?cmp_code_in=' + p_sStkCode
	}

	window.showModalDialog(sURL, '', 'center:yes;dialogWidth:' + scrWidth + 'px;dialogHeight:' + scrHeight + 'px');
}

function FormatStkInfoLink(linktype, p_sStkCode, p_sStkName)
{
	return ("<font style='cursor:hand;color:blue;text-decoration:underline' onclick=DisplayStkInfoLink('"+ linktype +"','"+ p_sStkCode + "')>" + p_sStkName + "</font>");
}

function OpenLinkWinNormal(sURL, sTargetWin, sParam)
{
	window.open(sURL, sTargetWin, sParam, false)
}
function OpenLinkWindow(sURL, sTargetWin, sParam)
{
	if (sParam=='') {
		sParam = 'left=10,top=100,width=770,height=450,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes'
	}
	window.open(sURL, sTargetWin, sParam, false)
}

function OpenWinNetResearch(sURL, sTargetWin, sParam)
{
	if (sParam=='') {
		sParam = 'left=10,top=100,width=770,height=450,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes'
	}
	window.open('/bin/gotoNetResearch.asp?url='+ sURL, sTargetWin, sParam, false)
}

function OpenWinNews(sURL, sParam)
{
	if (sParam=='') {
		sParam = 'left=10,top=100,width=770,height=450,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes'
	}
	window.open(sURL, 'winNews', sParam, false)
}
function OpenWinNewsResearch()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

//	nLeft = (scrWidth - 770) /2
//	nTop = (scrHeight - 450) /2
//	window.open('/bin/newsResearch.asp', 'winNewsCorpResearch', 'left='+ nLeft +',top='+ nTop +',width=770,height=450,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
	window.open('/bin/newsResearch.asp', 'winNewsCorpResearch', '', false)
}


function OpenWinCliLogin()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 300) /2
	nTop = (scrHeight - 220) /2
	window.open('/bin/cliLogin.asp', 'winCliLogin', 'left='+ nLeft +',top='+ nTop +',width=300,height=220,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}

function OpenWinCliChgPwd(vsURL)
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 350) /2
	nTop = (scrHeight - 220) /2
	if (vsURL == '') {
		vsURL = '/bin/cliChgPwd.asp'
	}
	window.open(vsURL, 'winCliPwdPIN', 'left='+ nLeft +',top='+ nTop +',width=350,height=220,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}
function OpenWinCliForgetPwd(vsURL)
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 410) /2
	nTop = (scrHeight - 220) /2
	if (vsURL == '') {
		vsURL = '/bin/cliForgetPwd.asp'
	}
	window.open(vsURL, 'winCliPwdPIN', 'left='+ nLeft +',top='+ nTop +',width=410,height=220,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}
function OpenWinCliChgPIN(vsURL)
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 300) /2
	nTop = (scrHeight - 215) /2
	if (vsURL == '') {
		vsURL = '/bin/cliChgPIN.asp'
	}
	window.open(vsURL, 'winCliPwdPIN', 'left='+ nLeft +',top='+ nTop +',width=300,height=215,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}
function OpenWinCliForgetPIN(vsURL)
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 410) /2
	nTop = (scrHeight - 220) /2
	if (vsURL == '') {
		vsURL = '/bin/cliForgetPIN.asp'
	}
	window.open(vsURL, 'winCliPwdPIN', 'left='+ nLeft +',top='+ nTop +',width=410,height=220,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}

function OpenWinCliReg()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 785) /2
	nTop = (scrHeight - 500) /2
	window.open('/bin/cliTermCond.asp', 'winCliReg', 'left='+ nLeft +',top='+ nTop +',width=785,height=500,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}

//param is vsLang, bPopUp, bProxySafe
function OpenWinStkRealTime(vsLang)
{
//alert(vsLang);
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop, sURL

	nLeft = (scrWidth - 780) /2
	nTop = (scrHeight - 475) /2
	if (vsLang == 'CN') {
		sURL = '/bin/stkRealTimeSwing.asp?lang=CN'

	} else if (vsLang == 'QSee') {
		//check ProxySafe
		if (OpenWinStkRealTime.arguments.length > 2 && (OpenWinStkRealTime.arguments[2] == true))
			sURL = '/bin/qsee.asp?lang=EN'
		else
			sURL = '/bin/qsee.asp?lang=EN'

	} else {
		//check ProxySafe
		if (OpenWinStkRealTime.arguments.length > 2 && (OpenWinStkRealTime.arguments[2] == true))
			sURL = '/bin/stkRealTimeSwing.asp?lang=EN'
			

		else
			sURL = '/bin/stkRealTimeSwing.asp?lang=EN'
			
	}

	//check PopUp
	if (OpenWinStkRealTime.arguments.length > 1 && (OpenWinStkRealTime.arguments[1] == true))
		window.open(sURL, 'winStkRealTime', 'left='+ nLeft +',top='+ nTop +',width=780,height=475,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
	else
		window.location.href = sURL;
}

function OpenWinDemo()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 650) /2
	nTop = (scrHeight - 500) /2
	window.open('/img/demo/Demo.html', 'winDemo', 'left='+ nLeft +',top='+ nTop +',width=650,height=500,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}

function OpenWinStlOutstandingCliPos()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 780) /2
	nTop = (scrHeight - 510) /2
	window.open('/bin/stlOutstandingCliPos.asp', 'winStl', 'left='+ nLeft +',top='+ nTop +',width=780,height=510,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}
function OpenWinStlPayStatus()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 635) /2
	nTop = (scrHeight - 330) /2
	window.open('/bin/stlPayStatus.asp', 'winStlPayStatus', 'left='+ nLeft +',top='+ nTop +',width=635,height=330,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}
function OpenWinStlDepositStatus()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 535) /2
	nTop = (scrHeight - 330) /2
	window.open('/bin/stlDepositStatus.asp', 'winStlDepStatus', 'left='+ nLeft +',top='+ nTop +',width=535,height=330,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}

function OpenWinGameMenu()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 800) /2
	nTop = (scrHeight - 580) /2
	window.open('http://game.itradecimb.com/bin/gameMenu.asp', 'winGameMenu', 'left='+ nLeft +',top='+ nTop +',width=800,height=580,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes', false)
}
function OpenWinStkRealTimeGame(vsLang)
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop, sURL

	nLeft = (scrWidth - 780) /2
	nTop = (scrHeight - 555) /2
	if (vsLang == 'CN')
		sURL = '/bin/stkRealTimeGame.asp?lang=CN'

	else {
		//check ProxySafe
		if (OpenWinStkRealTimeGame.arguments.length > 2 && (OpenWinStkRealTimeGame.arguments[2] == true))
			sURL = '/bin/stkRealTimeGameAWT.asp?lang=EN'
		else
			sURL = '/bin/stkRealTimeGameAWT.asp?lang=EN'
	}

	//check PopUp
	if (OpenWinStkRealTimeGame.arguments.length > 1 && (OpenWinStkRealTimeGame.arguments[1] == true))
		window.open(sURL, 'winStkRealTime', 'left='+ nLeft +',top='+ nTop +',width=780,height=555,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
	else
		window.location.href = sURL;
}
function OpenWinCliRegGame()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 785) /2
	nTop = (scrHeight - 485) /2
	window.open('/bin/cliTermCond_Game.asp', 'winCliReg', 'left='+ nLeft +',top='+ nTop +',width=790,height=485,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes', false)
}
function OpenWinGameRanking()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 780) /2
	nTop = (scrHeight - 555) /2
	window.open('/bin/anlyRanking.asp?Game=Y', 'winGameRanking', 'left='+ nLeft +',top='+ nTop +',width=800,height=450,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=yes', false)
}
function OpenWinGameRule()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 785) /2
	nTop = (scrHeight - 485) /2
	window.open('/bin/cliTermCond_Game.asp', 'winFAQGameRule', 'left='+ nLeft +',top='+ nTop +',width=790,height=485,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}

function OpenWinPrtfSumm()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 770) /2
	nTop = (scrHeight - 450) /2
	window.open('/bin/prtfSumm.asp', 'winPrtf', 'left='+ nLeft +',top='+ nTop +',width=770,height=450,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}
function OpenWinInfoSiteMap()
{
	window.open('/web/infoSiteMap.asp', 'winInfoSiteMap', 'left=0,top=0,width=350,height=400,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}
function OpenWinCancelReqFAQ()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 590) /2
	nTop = (scrHeight - 270) /2
	window.open('/web/faqCancelRequest.htm', 'winFAQCancel', 'left='+ nLeft +',top='+ nTop +',width=590,height=270,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=no', false)
}

function OpenWinTrdChannel()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 625) /2
	nTop = (scrHeight - 490) /2
	window.open('/bin/cliProfilerTrd.asp', 'winSMSTrd', 'left='+ nLeft +',top='+ nTop +',width=625,height=490,location=no,toolbar=no,menubar=no,scrollbars=yes,resizable=no', false)
}

function OpenWinSMSTrdEdit()
{
	var scrWidth=screen.width, scrHeight=screen.height, nLeft, nTop

	nLeft = (scrWidth - 465) /2
	nTop = (scrHeight - 235) /2
	window.open('/bin/cliProfilerTrdEdit.asp', 'winSMSTrdSetting', 'left='+ nLeft +',top='+ nTop +',width=465,height=235,location=no,toolbar=no,menubar=no,scrollbars=no,resizable=yes', false)
}
