var myNumOfNews = 13;


var myTitle_1 = "Discontinuation of Bancassurance Relationship with MassMutual Asia Ltd.";

var myContent_1 = "The Bancassurance relationship between China Construction Bank (Asia) and MassMutual Asia Ltd. will be ended starting March 1, 2010.";

var myFomURL_1 = "MM100201.pdf";

var myIcon_1 = "revamp_ban04.gif";

var myType_1 = "";



var myTitle_2 = "Change of Tsimshatsui Humphreys Avenue Branch General Telephone Number";

var myContent_2 = "Due to telephone system upgrade, kindly note that starting March 27, 2010, the general telephone number of our Tsimshatsui Humphreys Avenue branch will be changed to (852) 3718 7166.";

var myFomURL_2 = "TST humphreys 100219.pdf";

var myIcon_2 = "revamp_ban04.gif";

var myType_2 = "";



var myTitle_3 = "Change of Tsuen Wan Branch General Telephone Number";

var myContent_3 = "Due to telephone system upgrade, kindly note that the general telephone number of our Tsuen Wan branch will be changed to (852) 3718 7199 starting March 20, 2010.";

var myFomURL_3 = "Tsuen Wan 100219.pdf";

var myIcon_3 = "revamp_ban04.gif";

var myType_3 = "";




var myTitle_4 = "Relocation of Tsimshatsui Humphreys Avenue Commercial Banking Office";

var myContent_4 = "Corresponding to our business development and branch network realignment, our Tsimshatsui Humphreys Avenue Commercial Banking Office will be relocated to Quarry Bay Commercial Banking Office and stop service after the close of business on March 26, 2010.";

var myFomURL_4 = "100125.pdf";

var myIcon_4 = "revamp_ban04.gif";

var myType_4 = "";



//14Jan2010

var myTitle_5 = "Cross Border Long Card New Function";

var myContent_5 = "Link your Cross Border Long Card to RMB account with us today! Debit your ATM withdrawal or POS transactions in Mainland China from your RMB account to save currency exchange fees.";

var myFomURL_5 = "/hongkong/english/personal_banking/ebanking/cblc.html";

var myIcon_5 = "cblc.gif";

var myType_5 = "";



var myTitle_6 = "Changes in Clauses of Agreement";

var myContent_6 = "Effective February 11, 2010, some clauses in our \"FX Linked Deposit Agreement\" will be revised.";

var myFomURL_6 = "100112.pdf";

var myIcon_6 = "revamp_ban04.gif";

var myType_6 = "";


var myTitle_7 = "Transfer of Account after Merger of Sheung Wan Branch";

var myContent_7 = "Effective February 13, 2010, customer's account(s) currently with Sheung Wan Branch will be transferred to new Sheung Wan Des Voeux Road Branch.";

var myFomURL_7 = "091211.pdf";

var myIcon_7 = "revamp_ban04.gif";

var myType_7 = "";


var myTitle_8 = "Unregistered Account Transfer Alert";

var myContent_8 = "To meet the Hong Kong Monetary Authority guidelines on online banking security, online banking customers will receive SMS notification for all Unregistered Account Transfers starting from December 10, 2009.";

var myFomURL_8 = "";

var myIcon_8 = "revamp_ban04.gif";

var myType_8 = "";


var myTitle_9 = "New Online Bonus Point Scheme";

var myContent_9 = "Now you can earn Online Bonus Point and redeem fabulous rewards by performing designated online transactions!";

var myFomURL_9 = "obp_promo.html";

var myIcon_9 = "obp_72x36_e.gif";

var myType_9 = "";



//10/16/09

var myTitle_10 = "Relocation of Sheung Wan Commercial Banking Office";

var myContent_10 = "Corresponding to our business development and branch network realignment, our Sheung Wan Commercial Banking Office will be relocated to Causeway Bay Commercial Banking Office, and stop service on November 23, 2009.";

var myFomURL_10 = "091016.pdf";

var myIcon_10 = "revamp_ban04.gif";

var myType_10 = "";


//10/6/09

var myTitle_11 = "New Online Commercial Banking Functions";

var myContent_11 = "From now on, customers can enquire balance and records of inward remittance for Non-Deliverable Forward Contract Account via Online Commercial Banking, letting you master your account anytime anywhere.";

var myFomURL_11 = "/hongkong/english/commercial_banking/online_commercial.html";

var myIcon_11 = "NDF.gif";

var myType_11 = "";




//9/29/09

var myTitle_12 = "New Online Account Opening";

var myContent_12 = "From now on, existing customers can open additional savings, checking and multi-currency savings accounts anytime through Online Banking. Saving the time and trip to branches!";

var myFomURL_12 = "https://online.asia.ccb.com/PersonalHKWeb/signin/chgLocale2En.do"; 

var myIcon_12 = "oao.gif";

var myType_12 = "";


//9/22/09

var myTitle_13 = "Super High Fuel Discount Offer";

var myContent_13 = "Successfully apply for Cross Border Long Card or Dual Currency Debit Card to enjoy up to HK$1.85 per litre fuel discount.";

var myFomURL_13 = "popup_c.html";

var myIcon_13 = "fuel.gif";

var myType_13 = "";




var w3c=(document.getElementById)?true:false;
var ns4=(document.layers)?true:false;
var ie4=(document.all && !w3c)?true:false;
var ie5=(document.all && w3c)?true:false;
var ns6=(w3c && navigator.appName.indexOf("Netscape")>=0)?true:false;

var boxwidth=410;         // Scrolling area width in pixels
var boxheight=305;        // Scrolling area height in pixels
var boxcolor="#FFFFFF";   // Scrolling area background color
var speed=50;             // Scrolling speed in milliseconds
var scrollAmount=1;       // Scrolling pixels per step
var godown=false;         // true: Scrolling down, false: Scrolling up

var firstStart = false;
var wrapStart = false;
var pixelstep=scrollAmount; 
var outer, inner, inner2, ref, elementheight;
var scrollTimerID;

function GenWhatNewsTopic()
{
	var topicHTML = '';
	var contentHTML = '';
	var currNumOfNews = eval('myNumOfNews');

	if (navigator.family != 'ie4')
		topicHTML += "<DIV ID='panelExpandText' style='position:relative; visibility:hidden; z-index:100'><img src='image/spacer.gif' border=0 width="+(boxwidth-25)+" height="+boxheight+"></div>";
	else
		topicHTML += "<DIV ID='panelExpandText' style='position:relative; visibility:hidden'><img src='image/spacer.gif' border=0 width="+(boxwidth-25)+" height="+boxheight+"></div>";

	for(var p=1;p<=currNumOfNews;p++){
		var currTitle = eval('myTitle' + "_" + p);
		var currContent = eval('myContent' + "_" + p);
		var currFomURL = eval('myFomURL' + "_" + p);
		var currIcon = eval('myIcon' + "_" + p);
		var currType = eval('myType' + "_" + p);

		contentHTML += '<table border="0" cellspacing="2" cellpadding="2">';
		contentHTML += '<tr>';
		contentHTML += '<td><table width="100%" border="0" cellspacing="1" cellpadding="1">';
                                  
		if (currType == "swf")
		{
			contentHTML += '<tr><td valign="top"><font face="arial" color="#386BC4" style="font-size:12px;">';
			contentHTML += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="72" height="36">';
	    		contentHTML += '<param name=movie value="image/' + currIcon + '">';
    			contentHTML += '<param name=quality value=high>';
    			contentHTML += '<param name=wmode value=transparent>';
    			contentHTML += '<embed src="image/' + currIcon + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" wmode="transparent" width="72" height="36"></embed>';
			contentHTML += '</object>';
			contentHTML += '</font><td><font face="arial" color="#386BC4" style="font-size:12px;"><b>' + currTitle + '</b></font><br><font face="arial" color="#333333" style="font-size:12px;">' + currContent + '</font></td>';
			contentHTML += '</tr>';
	  	}
		else
		{
			contentHTML += '<tr><td valign="top" width="76">&nbsp;</td><td>&nbsp;</td></tr>';
			contentHTML += '<tr>';
			contentHTML += '<td width="76" valign="top"><font face="arial" color="#386BC4" style="font-size:12px;"><b><img src="image/' + currIcon + '" border=0 align="left"></b></font></td>';
			contentHTML += '<td><font face="arial" color="#386BC4" style="font-size:12px;"><b>' + currTitle + '</b></font><br>';
			contentHTML += '<font face="arial" color="#333333" style="font-size:12px;">' + currContent + '</font></td>';
			contentHTML += '</tr>';
		}

		contentHTML += '</table></td>';
		contentHTML += '</tr>';

		if (currFomURL != "")
		{
			contentHTML += '<tr>';
			contentHTML += '<td align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">';
			contentHTML += '<tr>';
			contentHTML += '<td><img src="image/img_morebg.gif" width="286" height="16"></td>';
			contentHTML += '<td width="114"><a href="#" onclick="javascript:window.open(\'' + currFomURL + '\',\'\',\'resizable=no,scrollbars=yes,status=no,width=800, height=600\');"><img src="image/btn_more.gif" width="114" height="16" border="0"></a></td>';
			contentHTML += '</tr></table></td></tr>';
		}else{
			contentHTML += '<tr>';
			contentHTML += '<td align="right"><table width="100%" border="0" cellspacing="0" cellpadding="0">';
			contentHTML += '<tr>';
			contentHTML += '<td background="image/img_morebg.gif"><img src="image/spacer.gif" width="1" height="16"></td>';			
			contentHTML += '</tr></table></td></tr>';
		}
		contentHTML += "</table>";
	}

	topicHTML+='<div id="outer" style="position:absolute; width:'+boxwidth+'; height:'+boxheight+'; visibility:hidden; background-color:'+boxcolor+'; overflow:hidden" onmouseover="PauseScroll()" onmouseout="ContinueScroll()">';
	topicHTML+='<div id="inner"  style="position:absolute; visibility:hidden; left:2px; top:2px; width:'+(boxwidth-4)+'; overflow:hidden; cursor:default;">'+contentHTML+'</div>';
	topicHTML+='<div id="inner2"  style="position:absolute; visibility:hidden; left:2px; top:2px; width:'+(boxwidth-4)+'; overflow:hidden; cursor:default;">'+contentHTML+'</div>';
	topicHTML+='</div>';
	
	return topicHTML;
}

function getElHeight(el){
	if(ns4)return (el.document.height)? el.document.height : el.clip.bottom-el.clip.top;
	else if(ie4||ie5)return (el.style.height)? el.style.height : el.clientHeight;
	else return (el.style.height)? parseInt(el.style.height):parseInt(el.offsetHeight);
}

function getPageLeft(el){
	var x;
	if(ns4)return el.pageX;
	if(ie4||w3c){
		x = 0;
		while(el.offsetParent!=null) {
			x+=el.offsetLeft;
			el=el.offsetParent;
		}
		x+=el.offsetLeft;
		return x;
	}
}

function getPageTop(el){
	var y;
	if(ns4) return el.pageY;
	if(ie4||w3c) {
		y=0;
		while(el.offsetParent!=null) {
			y+=el.offsetTop;
			el=el.offsetParent;
		}
		y+=el.offsetTop;
		return y;
	}
}

window.onresize=function()
{
	if (ref != null)
	{
		outer.style.left=getPageLeft(ref)+'px';
		outer.style.top=getPageTop(ref)+'px';
	}
}

function scrollbox()
{
	if (firstStart) {
		// start scrolling at middle height of the scrolling area
		elementheight=getElHeight(inner);
		inner.style.top= 50 + ((godown)? -elementheight: 0)+'px';
		firstStart = false;
		wrapStart = false;
	} else {
		inner.style.top=parseInt(inner.style.top)+((godown)? pixelstep: -pixelstep)+'px';
		if(godown){
			if (parseInt(inner.style.top)>=0) {
				wrapStart = true;
			}
			if (wrapStart) {
				if(parseInt(inner.style.top)>=0) {
					if (parseInt(inner.style.top)+elementheight>boxheight) {
						inner2.style.top=parseInt(inner.style.top)-elementheight-2+'px';
						inner2.style.visibility="visible";		
					} else {
						inner2.style.visibility="hidden";
					}
				} else {
					inner2.style.top=parseInt(inner.style.top)+elementheight+2+'px';
					inner2.style.visibility="visible";		
				}
			}

			if(inner2.style.visibility=="visible" && parseInt(inner2.style.top)>=2) inner.style.top=parseInt(inner2.style.top)-elementheight-2+'px';
		}else{
			if (parseInt(inner.style.top)<=0) {
				wrapStart = true;
			}
			if (wrapStart) {
				if(parseInt(inner.style.top)<=0) {
					if (parseInt(inner.style.top)+elementheight<boxheight) {
						inner2.style.top=parseInt(inner.style.top)+elementheight+2+'px';
						inner2.style.visibility="visible";		
					} else {
						inner2.style.visibility="hidden";
					}
				} else {
					inner2.style.top=parseInt(inner.style.top)-elementheight-2+'px';
					inner2.style.visibility="visible";		
				}
			}

			if(inner2.style.visibility=="visible" && parseInt(inner2.style.top)+elementheight<=boxheight-2) inner.style.top=parseInt(inner2.style.top)+elementheight+2+'px';
		}
	}
}

function PauseScroll()
{
	pixelstep=0;
}

function ContinueScroll()
{
	pixelstep=scrollAmount;
}

function StartScrollingPanel()
{
	inner=(ns4)?outer.document.layers['inner']:(ie4)?document.all['inner']:document.getElementById('inner');
	inner2=(ns4)?outer.document.layers['inner2']:(ie4)?document.all['inner2']:document.getElementById('inner2');
	if (inner && inner2)
	{
		outer=(ns4)?document.layers['outer']:(ie4)?document.all['outer']:document.getElementById('outer');
		ref=(ns4)?document.layers['panelExpandText']:(ie4)?document.all['panelExpandText']:document.getElementById('panelExpandText');

		firstStart = true;
		elementheight=getElHeight(inner);
		outer.style.left=getPageLeft(ref)+'px';
		outer.style.top=getPageTop(ref)+'px';
		inner.style.top=((godown)? -elementheight : boxheight)+'px';
		inner.style.clip='rect(0px, '+(boxwidth-4)+'px, '+(elementheight)+'px, 0px)';
		inner2.style.clip='rect(0px, '+(boxwidth-4)+'px, '+(elementheight)+'px, 0px)';
		outer.style.visibility="visible";
		inner.style.visibility="visible";
		scrollTimerID = setInterval('scrollbox()',speed);
	}
}

function GenWhatNewsPanel()
{
	document.write(GenWhatNewsTopic());

	setTimeout('StartScrollingPanel()', 300);
}

GenWhatNewsPanel();