<!--
function searchResult() {
  var s=location.search;
  if (s.length>1) {
    if (s.substr(0,1)=='?')
      s=s.substr(1);
  }
  s=removeParm(s,'asset');
  s=removeParm(s,'invest');
  s=removeParm(s,'ccy');
  s=removeParm(s,'searchagain');
  s=removeParm(s,'sort');
  s=removeParm(s,'order');

  var f=document.forms[0];
  f.vsort.value='2';
  f.vorder.value='A';

  s=addParm(s,'asset');
  s=addParm(s,'invest');
  s=addParm(s,'ccy');
  s=addParm(s,'searchagain');
  s=addParm(s,'sort');
  s=addParm(s,'order');

  location.search=s;
}

function removeParm(s,x) {
  x+='=';
  var p=s.split('&');
  var np=new Array();
  for (var i=0;i<p.length;i++) {
    if (p[i].substr(0,x.length)!=x)
      np.push(p[i]);
  }
  return np.join('&');
}

function addParm(s,x) {
  var f=document.forms[0];
  if (s!='') s+='&';
  s+=(x+'=');
  s+=eval('f.v'+x).value;
  return s;
}

function showAll() {
  clearAll();
  searchResult();
}

function clearAll() {
  var f=document.forms[0];
  f.vasset.value="";
  f.vinvest.value="";
  f.vccy.value="";
  f.vsearchagain.value="Y";
  f.vsort.value="1";
  f.vorder.value="A";
}

function sortResult(x) {
  var f=document.forms[0];
  if (x==f.vsort.value)
    f.vorder.value=(f.vorder.value=='D'?'A':'D');
  else {
    f.vsort.value=x;
  f.vorder.value='A';
  }

  var s=location.search;
  if (s.length>1) {
    if (s.substr(0,1)=='?')
      s=s.substr(1);
  }
  s=removeParm(s,'sort');
  s=removeParm(s,'order');
  s=addParm(s,'sort');
  s=addParm(s,'order');
  location.search=s;
}

function switchLang(x) {
  if (x=='e') location.href=location.href.replace(/\/eng\//g,'/chi/');
  if (x=='c') location.href=location.href.replace(/\/chi\//g,'/eng/');
}

function Get_Cookie(name) { 
   var start = document.cookie.indexOf(name+"="); 
   var len = start+name.length+1; 
   if ((!start) && (name != document.cookie.substring(0,name.length))) return null; 
   if (start == -1) return null; 
   var end = document.cookie.indexOf(";",len); 
   if (end == -1) end = document.cookie.length; 
   return unescape(document.cookie.substring(len,end)); 
} 

function Set_Cookie(name,value,expires,path,domain,secure) { 
    var cookieString = name + "=" +escape(value) + 
       ( (expires) ? ";expires=" + expires.toGMTString() : "") + 
       ( (path) ? ";path=" + path : "") + 
       ( (domain) ? ";domain=" + domain : "") + 
       ( (secure) ? ";secure" : ""); 
    document.cookie = cookieString; 
} 

function subscribeCPI(investment_code, start_date) { //v2.0    
    //location.href='getpage2.asp?app=EinvcCpiStatus&investment_code=' + investment_code;	
		var cpiWindow = null;
    var P2G = Get_Cookie('P2G');
    var B2G = Get_Cookie('B2G');

    if ((P2G == null) && (B2G == null)) {
      cpiWindow = window.open('', 'EbankLogon','width=520,height=250,status=yes,directories=no,toolbar=no,resizable=no,menubar=no,scrollbars=no,screenX=80,screenY=80');
			cpiWindow.location.href='select_logon.aspx?app=EinvcCpiStatus&investment_code=' + investment_code + '&start_date=' + start_date;
    } else {
      cpiWindow = window.open('', 'EbankControl','width=500,height=370,status=yes,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,screenX=80,screenY=80');
	    cpiWindow.location.href='subscribe_cpi.aspx?app=EinvcCpiStatus&investment_code=' + investment_code + '&start_date=' + start_date;
    }

    cpiWindow.focus();
    
    //alert('https://www.hangseng.com/einvc/eng/subscribecpi.asp?app=EinvcCpiStatus&investment_code=' + var2);
    
    //document.formsubscribe.action='https://www.hangseng.com/einvc/eng/subscribecpi.asp?app=EinvcCpiStatus&investment_code=' + var2;	
    
    //document.formsubscribe.v2.value = var2;	
    
    //document.formsubscribe.submit();
    
    
}

function logonCPI(investment_code, start_date, business) {

    var cpiWindow;
    
		if (business == 'N') {
      cpiWindow = window.open('', 'EbankControl','width=520,height=350,status=yes,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,screenX=80,screenY=80');
    } else {
      cpiWindow = window.open('', 'haseb2gmain','width=520,height=350,status=yes,directories=no,toolbar=no,resizable=yes,menubar=no,scrollbars=yes,screenX=80,screenY=80');
    }

    cpiWindow.location.href='subscribe_cpi.asp?app=EinvcCpiStatus&investment_code=' + investment_code + '&start_date=' + start_date + '&business=' + business;cpiWindow.focus();

		self.close();
  
}

function openInfo(id, url) {
		var cpiWindow = null;

    cpiWindow = window.open('', id,'width=800,height=600,status=yes,directories=no,toolbar=no,resizable=yes,menubar=yes,scrollbars=yes,screenX=80,screenY=80');
    cpiWindow.location.href=url;

    cpiWindow.focus();
}

//-->
