var myNumOfNews = 3;



var myTitle_1 = "Discontinuation of Bancassurance Relationship with MassMutual Asia Ltd.";
var myContent_1 = "The Bancassurance relationship between China Construction Bank (Macau) and MassMutual Asia Ltd. will be ended starting March 2, 2010.";
var myFomURL_1 = "MM100201.pdf";
var myIcon_1 = "revamp_ban04.gif";
var myType_1 = "";



var myTitle_2 = "Relocation of Kou Si Tak Branch Securities Trading Department";
var myContent_2 = "Effective January 11, 2010, the Securities Trading Department originally located at Kou Si Tak Branch has been relocated to Hak Sha Wan Branch.";
var myFomURL_2 = "100114.pdf";
var myIcon_2 = "revamp_ban04.gif";
var myType_2 = "";




var myTitle_3 ="Changes in Terms and Conditions";
var myContent_3 = "Some clauses in our \"Terms and Conditions For Accounts And Related Services (For Individuals)\" will be revised beginning December 1, 2009.";
var myFomURL_3 ="091103.pdf";
var myIcon_3 ="revamp_ban04.gif";
var myType_3 = "";




var myTitle_4 ="New Online Securities Trading Functions";
var myContent_4 = "The newly-launched Stop Loss Order, Market Order and Good-till-date Instruction enable you to enjoy hassle-free stock trading and timely capture investment opportunities. ";
var myFomURL_4 ="";
var myIcon_4 ="Function.gif";
var myType_4 = "";







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; display:none; z-index:100'><img src='images/spacer.gif' border=0 width="+(boxwidth-25)+" height="+boxheight+"></div>";
		topicHTML += "<DIV ID='panelExpandText' style='position:relative; visibility:hidden; z-index:100'><img src='images/spacer.gif' border=0 width="+(boxwidth-25)+" height="+boxheight+"></div>";
	else
		//topicHTML += "<DIV ID='panelExpandText' style='position:relative; display:none'><img src='images/spacer.gif' border=0 width="+(boxwidth-25)+" height="+boxheight+"></div>";
		topicHTML += "<DIV ID='panelExpandText' style='position:relative; visibility:hidden'><img src='images/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="80" height="40">';
	    		contentHTML += '<param name=movie value="images/' + currIcon + '">';
    			contentHTML += '<param name=quality value=high>';
					contentHTML += '<param name=wmode value=transparent>';    			
    			contentHTML += '<embed src="images/' + currIcon + '" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="80" height="40"></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="images/' + 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="images/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="images/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="images/img_morebg.gif"><img src="images/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();