//<script language="JavaScript1.2">

// INSTALLATION:
// 1.	Delete the DIV-container with the id 'deletethisdiv'. 
//		This is the only part of this file that is not required for the script. 
//		Save the file.
// 2.	Configure the messages. Let's take a look at the first message to understand 
//		its principle: 
//		- '	Madonna Storms UK Charts' is the title. Then follows a '|'. 
//		-	Then follows the copytext 'Girl band All Saints were knocked off 
//			the top spot in the British charts on Sunday by the queen of girl 
//			power herself.' 
//		-	Then again follows a '|'. 
//		-	Then follows the link for the message: http://www.xxx.com. 
//		As you see the '|' acts as delimiter between title, copytext and link! 
// 3.	Configure the variables below:

var msg = ""
var message= new Array()
// Please read section 2 above on how the messages have to be configured.
// You may add as many messages as you like!
//message[0]="<b>Technical Analysis - Now Available!</b>| Please accept all download files when prompted by the system. You only need to do this once. Please be patient as this will take some time.|#"
//message[1]="<b>Helpdesk</b>|03-9280 2222(KL) <br> 06-226 1833(Melaka)|#"
//message[2]="<img src='graphics/scroll_financial.gif' width='250' height='32' align='absmiddle' border='0'>|Bank Financial Highlights, Group Financial Highlights|http://www.cimb.com.my/financial/index.html"
//message[3]="<img src='graphics/scroll_research.gif' width='250' height='32' align='absmiddle' border='0'>|As part of our dedicated service, our resource centre houses essential and informative issues surrounding the securities and futures market.|http://www.cimb.com.my/research/disclaimer.html"

// The height of the scrollerbox (pixels)
var scrollerheight=200

// The width of the scrollerbox (pixels)
//var scrollerwidth=149
var scrollerwidth=160

// The distance to the left border of the window (pixels)
var scrollertop=0

// The distance to the top border of the window (pixels)
var scrollerleft=0

// The padding between the scrollerbox and the text (pixels)
var scrollerpadding=10

// The width of the scrollerbox-border (pixels)
//var backgroundborder=2
var backgroundborder=0

// The background-colour of the scrollerbox
//var scrollerbgcolor="DDDDDD"
var scrollerbgcolor="..\/images\/bg_news01.jpg"


// Font attributes of the title
var font_titleface="Verdana"
var font_titlecolor="white"
var font_titlesize=1

// Font attributes of the copytext
var font_copyface="Verdana"
var font_copycolor="white"
var font_copysize=1

// standstill between the messages (milliseconds)
var standstillfix=3000

// Do not edit below this line
var cliptop=0
var clipbottom=scrollerheight-2*scrollerpadding
var clipleft=0
var clipright=scrollerwidth	
//var clipright=scrollerheight

var i_message=0
var mes_joined
var mes_split
var msg_split
var contenttext
var contentbg

var i_height=0
var step=1
var pause=20

var standstillflex=0

function initiate(strMsg){	
	var newsinfo = new Array()
	msg = strMsg
	msg_split = msg.split("||")

	for (i=0; i<msg_split.length; i++) {
		message[i] = new Array()
		message[i] = msg_split[i]
	}
	totalheight=scrollerheight*(message.length) + 1

	contenttext='<table cellpadding=0 cellspacing=0 border=0 width='+(scrollerwidth-2*scrollerpadding)+'>'
	contenttext+='<tr valign="top"><td height="'+scrollerheight+'"><br></td></tr>'
	
	for (i=0;i<message.length;i++) {
		mes_joined=message[i]
		mes_split=mes_joined.split("|")
		
		contenttext+='<tr valign="top"><td height="'+scrollerheight+'">'
		for (j=0; j<mes_split.length; j++) {
			if (j==0) {
				contenttext+='<a href="'+mes_split[mes_split.length-1]+'" style="text-decoration:none"><font face="'+font_titleface+'" color="'+font_titlecolor+'" size="'+font_titlesize+'">'+mes_split[j]+'</font></a><br>'
			} else if (j!=mes_split.length-1) {
				contenttext+='<font face="'+font_copyface+'" color="'+font_copycolor+'" size="'+font_copysize+'">'+mes_split[j]+'</font><br>'
			}		
		}		
		contenttext+='</td></tr>'
	}
	contenttext+='</table>'
	
	//contentbg="<table cellpadding=0 cellspacing=0 border="+backgroundborder+" width='"+scrollerwidth+"'><tr><td height='"+scrollerheight+"' bgcolor="+scrollerbgcolor+">&nbsp;</td></tr></table>"
	contentbg="<table cellpadding=0 cellspacing=0 border="+backgroundborder+" width='"+scrollerwidth+"'><tr><td height='"+scrollerheight+"' background="+scrollerbgcolor+">&nbsp;</td></tr></table>"
	
	if (document.all) {
		scrollertext.innerHTML=contenttext
		scrollerbg.innerHTML=contentbg
		document.all.scrollertext.style.posTop=scrollertop	
		document.all.scrollertext.style.posLeft=scrollerleft
		document.all.scrollerbg.style.posTop=scrollertop-scrollerpadding
		document.all.scrollerbg.style.posLeft=scrollerleft-scrollerpadding
		document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
	}
	if (document.layers) {
		document.scrollertext.document.write(contenttext)
		document.scrollertext.document.close()
		document.scrollerbg.document.write(contentbg)
		document.scrollerbg.document.close()
		document.scrollertext.top=scrollertop	
		document.scrollertext.left=scrollerleft
		document.scrollerbg.top=scrollertop-scrollerpadding
		document.scrollerbg.left=scrollerleft-scrollerpadding	
		document.scrollertext.clip.left=clipleft
        document.scrollertext.clip.right=clipright
        document.scrollertext.clip.top=cliptop
        document.scrollertext.clip.bottom=clipbottom
	}
	scroll()
}

function NewsOpen(NewsType, NewsID) {
	var w = 800, h=600, l = (screen.Width-w)/2, t = (screen.Height-h+200)/2
	var sfeatures = "top="+t+",left="+l+",width="+w+",height="+h+",toolbar=0,location=0,menubar=0,status=0,location=0,scrollbars=0,resizable=0"
	var NewWin = window.open("News/news.asp?newstype="+NewsType+"&newsid="+NewsID, "NewWin", sfeatures)
	NewWin.focus()
}

var totalheight=scrollerheight*(message.length) + 1

function scroll(){	
	standstillflex=standstillfix
	if (document.all){
		if (i_height<scrollerheight) {
			i_height+=step
			cliptop+=step
			clipbottom+=step
			document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
			document.all.scrollertext.style.posTop-=step
			var timer=setTimeout("scroll()",pause)
		}

		else {
			if (document.all.scrollertext.style.posTop<=-(totalheight)) {
				document.all.scrollertext.style.posTop=scrollertop
				cliptop=0
				clipbottom=scrollerheight-2*scrollerpadding
				document.all.scrollertext.style.clip="rect("+cliptop+" "+clipright+" "+clipbottom+" "+clipleft+")"
				standstillflex=0
			}
			i_height=0
			clearTimeout(timer)
			var timer=setTimeout("scroll()",standstillflex)
		}
	}
	
		if (document.layers){
			if (i_height<scrollerheight) {
				i_height+=step
				cliptop+=step
				clipbottom+=step
				document.scrollertext.clip.left=clipleft
        		document.scrollertext.clip.right=clipright
        		document.scrollertext.clip.top=cliptop
        		document.scrollertext.clip.bottom=clipbottom
				document.scrollertext.top-=step
				var timer=setTimeout("scroll()",pause)
			}

		else {
			if (document.scrollertext.top<=-(totalheight)) {
				document.scrollertext.top=scrollertop
				cliptop=0
				clipbottom=scrollerheight-2*scrollerpadding
				document.scrollertext.clip.left=clipleft
        		document.scrollertext.clip.right=clipright
        		document.scrollertext.clip.top=cliptop
        		document.scrollertext.clip.bottom=clipbottom
				standstillflex=0
			}
			i_height=0
			clearTimeout(timer)
			var timer=setTimeout("scroll()",standstillflex)
		}
	}
}

