function link_frame(item) {
	if(item==1){
  		location.href = 'http://www.aastocks.com/pkages/web/bankcomm/chi/whatshot/top20.asp?category=A&market_id=1';
  	}else if (item==2){
  		location.href = 'http://www.aastocks.com/pkages/web/bankcomm/chi/whatshot/top20.asp?category=B&market_id=1';
  	}else if(item==3){
  		location.href = 'http://www.aastocks.com/pkages/web/bankcomm/chi/whatshot/index.asp?kind=hk';
  	}else if(item==4){
  		location.href = 'http://www.aastocks.com/pkages/web/bankcomm/chi/whatshot/index.asp?kind=inter';
  	}
  	
  	document.getElementById("iframe1").focus();
}


var url1="http://services1.aastocks.com/Web/Bcob/StockIndexMini.aspx?language=eng";

var checkFlag1 = 0;

function createXMLHttpRequest() {
  try {  
    if (window.ActiveXObject) { // IE
    	httpRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } else if (window.XMLHttpRequest) { // Mozilla, Safari, ...
    	httpRequest = new XMLHttpRequest();
    }
    document.getElementById("iframe5").src=url1;
  } catch (ex) {
    if (isIE) {
      alert("error1 !!! "+ex);
    }
  }
}

function init() {
   checkFlag1=1;
   initHttpConnection1();
   
}

function initHttpConnection1(target) {
  createXMLHttpRequest();
  try {
    httpRequest.onreadystatechange=stateChanged5;
    httpRequest.open("GET",url1,true);
    httpRequest.send(null);

    recur_call="timeout1()";
    setTimeout(recur_call,10000);
  } catch (ex) {
  }
}

function stateChanged5() {
	if (httpRequest.readyState == 4) {
		if (httpRequest.status == 200) {
         //alert("page load successfully!!");
         if (checkFlag1==1) {
            document.getElementById("iframe5").src=url1;
            checkFlag1=0;
         }
      }else {
      	document.getElementById("iframe5").src="nodata.htm";
      }
   }
}


function timeout1(target) {
   if (checkFlag1 == 1) {
      document.getElementById("iframe5").src="nodata.htm";
   }
}


function openLogin(type) {
    if (type=='eb')
        window.open("https://www.bankcomm.com.hk/EB/eng_webbank/eng_loginpg.jsp","Login","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='it')
        window.open("http://www.bankcomm.com.hk/itrade/en/","Login","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=50,top=10");
    else if (type=='mpf')
        window.open("https://www.bankcomm.com.hk/MPF/GenLogin.do?lang=0","Login","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='ebloan')
        window.open("https://www.bankcomm.com.hk/EB/servlet/com.hkboc.servlet.iBankServlet?txType=CBL&gotoPage=LOGIN_E&isLoan=YES&loanType=1","Login","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='loan')
        window.open("https://www.bankcomm.com.hk/EB/servlet/com.hkboc.servlet.iBankServletNotLogin?txType=REQ&gotoPage=PER_LOAN_MAIN_NOT_LOGIN_1_E","Loan","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='ebtaxloan')
        window.open("https://www.bankcomm.com.hk/EB/servlet/com.hkboc.servlet.iBankServlet?txType=CBL&gotoPage=LOGIN_E&isLoan=YES&loanType=2","Login","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='taxloan')
        window.open("https://www.bankcomm.com.hk/EB/servlet/com.hkboc.servlet.iBankServletNotLogin?txType=REQ&gotoPage=TAX_LOAN_MAIN_NOT_LOGIN_1_E","Loan","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='mortgage')
        window.open("https://www.bankcomm.com.hk/EB/eng_webbank/Loan/loan_house_order.jsp","Mortgage","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='ccgift')
        window.open("https://www.bankcomm.com.hk/EB/servlet/com.hkboc.servlet.iBankServletNotLogin?txType=CCS&txCode=CCPRE00&webLang=E");
}

function getLogin() {
    var clogin = document.loginForm.clogin;

    for (i=0;i<clogin.length;i++) {
        if (clogin[i].checked) {
            openLogin(clogin[i].value);
            break;
        }
    }
}


function getLogin_2() {
    var clogin = document.loginForm.clogin;

    openLogin(clogin.value);
}


function openDemo(type) {
    if (type=='eb')
        window.open("http://www.bankcomm.com.hk/EB/demo/eng_webbank/eng_loginpg.htm","Demo","toolbar=no,status=yes,menubar=no,scrollbars=no,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='it')
        window.open("http://www.bankcomm.com.hk/itrade/en/demo/index.html","Demo","toolbar=no,status=yes,menubar=no,scrollbars=yes,resizable=yes,revisable=yes,width=795,height=570,left=0, top=0");
    else if (type=='mpf')
        window.open("http://www.bankcomm.com.hk/MPF/demo/login.htm","Demo","toolbar=no,status=yes,menubar=no,scrollbars=yes,revisable=yes,width=795,height=570,left=0, top=0");
}

function getDemo() {
    var clogin = document.loginForm.clogin;

    for (i=0;i<clogin.length;i++) {
        if (clogin[i].checked) {
            openDemo(clogin[i].value);
            break;
        }
    }
}

function SelectLanguage(fromlang, tolang)
{
	
	currentURL = new String(document.location.href);
	//currentURL = currentURL.replace(/#/,"");
	newURL = currentURL.replace(fromlang,tolang);
	
	if (newURL.indexOf("#") > -1)
	{
		newURL = newURL.substring(0,newURL.indexOf("#"));
	}
	location.href=newURL;
}




function loadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Mozilla, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE5, IE6
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.onreadystatechange=state_Change;
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}

function state_Change() {
  if (xmlhttp.responseText) {
    document.getElementById("news_marquee").style.marginTop = Number((document.getElementById("news_marquee_container").style.height).replace("px", ""))+'px';
    document.getElementById("news_marquee").innerHTML = xmlhttp.responseText;
    document.getElementById("news_marquee").innerHTML += xmlhttp.responseText;

    setInterval("move_marquee()", 60);
  }
}

intNewsMarqueeMarginTop = "a";
intNewsMarqueeScrollAmount = 1;
function move_marquee() {
  if (intNewsMarqueeMarginTop == "a") {
    //intNewsMarqueeMarginTop = Number(document.getElementById("news_marquee").offsetHeight)/4 -1;
    intNewsMarqueeMarginTop = Number((document.getElementById("news_marquee_container").style.height).replace("px", ""));
    document.getElementById("news_marquee").style.marginTop = intNewsMarqueeMarginTop+'px';
  } else {
    if (Number(document.getElementById("news_marquee").offsetHeight)/2 < Math.abs(intNewsMarqueeMarginTop)) {
      intNewsMarqueeMarginTop = 0;
    }
    intNewsMarqueeMarginTop -= intNewsMarqueeScrollAmount;
    document.getElementById("news_marquee").style.marginTop = intNewsMarqueeMarginTop+'px';
  }
}


function index_dropDownMenu(obj_dropDownMenu) {
  if (obj_dropDownMenu.selectedIndex != 3 && obj_dropDownMenu.selectedIndex != 2) {
    location.href=obj_dropDownMenu.value;
  } else {
    window.open(obj_dropDownMenu.value);
  }
}

