var scrollerdelay=3000;
var scrollerspeed = 80;
var scrollerwidth=172;
var scrollerheight=100;
var scrollerx = 9;
var scrollery = 190;
var scrollerstep = 5;
var scrollerpause;
var str1 = "<span class=\"fnt06d\">";
var str2 = "</span>";
var lyrBase, lyr_A, lyr_B, lyr_C, lyrSB;
var direction = -1;
var pending = false;
var i_a = i_b = i_c = -1;
var messages=new Array();

/*messages[0] = "<a href=\"http://www.library.ln.edu.hk/survey/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/onlinesurvey_sidebar.jpg\" width=\"162\" height=\"46\"><br>Library User Survey 2009<br>2 May to 15 May</a>"; */

/*messages[0] = "<a href=\"http://www.library.ln.edu.hk/libinfo/openhour.html#holidays\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/open_hr.jpg\" width=\"162\" height=\"46\"><br>Library Closed on <br>Upcoming Holidays</a>"; */


/*messages[0] = "<a href=\"http://www.library.ln.edu.hk/classes/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/class_reg_ico.jpg\" width=\"162\" height=\"46\"><br>Library Classes 2009<br>Register Now!</a>"; */


/*messages[11] = "<a href=\"http://www.library.ln.edu.hk/libinfo/openhour.html#Summer0\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/open_hr.jpg\" width=\"162\" height=\"46\"><br>Special Opening Hour<br>from 31 Aug to 13 Sep 2009</a>"; */

messages[0] = "<a href=\"http://www.library.ln.edu.hk/exhibition/szto/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/sztowai.jpg\" width=\"162\" height=\"46\"><br>Szto Wai: Portraits of Lingnan<br>University 1937-1944</a>";

/*messages[10] = "<a href=\"http://www.library.ln.edu.hk/libinfo/openhour.html#1-15Sept08\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue080901.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/open_hr.jpg\" width=\"162\" height=\"46\"><br>Special Opening Hours<br>During 1-15 Sept 2008</a>"; */

messages[8] = "<a href=\"http://www.library.ln.edu.hk/cgi-bin/luaccess?dbname=1search\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/1search_sidebar.jpg\" width=\"162\" height=\"46\"><br>Search Catalogue & Multiple<br>Databases With 1-Search</a>";

messages[7] = "<a href=\"http://www.library.ln.edu.hk/notices/?p=117\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/more_lappc.jpg\" alt=\"Wireless Notebook Computers and Electronic Dictionaries for Borrowing\" width=\"162\" height=\"46\"><br>Notebook PC's & Electronic<br>Dictionaries for Borrowing</a>";

/*messages[9] = "<a href=\"http://www.library.ln.edu.hk/cgi-bin/luaccess?dbname=exam\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue080318.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/exam_db.jpg\" width=\"162\" height=\"46\"><br>Lingnan University<br>Examination Papers</a>"; */

messages[6] = "<a href=\"http://www.library.ln.edu.hk/toolbar\/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/toolbar_sidebar.gif\" width=\"162\" height=\"46\"><br>Get Quick Search Functions<br>with the LU Library Toolbar</a>";

messages[5] = "<a href=\"http://www.library.ln.edu.hk/lingnan/lnw/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/LingnanWeeklySidebar.jpg\" width=\"162\" height=\"46\"><br>Lingnan Weekly 1939-47<br>&#23994;&#21335;&#36913;&#22577; 1939-47</a>";

messages[4] = "<a href=\"http://www.library.ln.edu.hk/notices/?p=62\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/lib_access_sidebar.gif\" width=\"162\" height=\"46\"><br>Extended Access to Other<br>Univ Libraries for Students</a>";

messages[3] = "<a href=\"http://www.library.ln.edu.hk/forms/booking.html\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/onlinebooking_sidebar.jpg\" width=\"162\" height=\"46\"><br>Database/Multimedia PC<br>Room Bookings Online</a>";

/*messages[4] = "<a href=\"http://libmedia.ln.edu.hk/media4/www/lib/06-07-4\/library2007.ram\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue070903.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/virtual_tour.gif\" width=\"162\" height=\"46\"><br>A Virtual Tour of the Library (RealPlayer Required)</a>";*/

messages[2] = "<a href=\"http://www.library.ln.edu.hk/cgi-bin/luaccess?dbname=netlanguages\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/IELTSsidebar.gif\" width=\"162\" height=\"46\"><br>IELTS Preparation Course<br>Available Online</a>";

messages[1] = "<a href=\"http://www.library.ln.edu.hk\/newmovies/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/moviessidebar.jpg\" width=\"162\" height=\"46\"><br>Lingnan University Library<br>Movies Alert!</a>";

/*messages[1] = "<a href=\"http://tlc.ln.edu.hk/lle/\" target=_blank onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue_no_date2.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/tlc-lle-bidding-banner.jpg\" width=\"162\" height=\"46\"><br>LLE Bookworm Club HK$1 Book Bidding</a>";*/

/*messages[3] = "<a href=\"http://www.library.ln.edu.hk/notices/?p=36\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue070325.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/sidebar_survey_results.jpg\" width=\"162\" height=\"46\"><br>MLLC User Satisfaction<br>Survey 2007 Results</a>"; */

/*messages[4] = "<a href=\"http://www.library.ln.edu.hk/trial/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue070313.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/free_trial.gif\" width=\"162\" height=\"46\"><br>Literature, History Database<br>and E-Books Free Trial</a>";*/

/*messages[4] = "<a href=\"http://www.library.ln.edu.hk/libinfo/libnotice/libnotice_070212.htm\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue070212.jpg\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/midnightsidebar.jpg\" alt=\"Extended Opening Hours from 26 Feb 2007\" width=\"162\" height=\"46\"><br>Extended Opening Hours<br>from 26 Feb 2007</a>";*/

/*messages[4] = "<a href=\"http://www.library.ln.edu.hk/libinfo/libnotice/libnotice_070123.htm\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue070123.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/HSsidebar4.jpg\" alt=\"Reading History Service\" width=\"162\" height=\"46\"><br>Books that I Borrowed<br>Before ...</a>";*/

/*messages[4] = "<a href=\"http://www.library.ln.edu.hk/libinfo/libnotice/libnotice_070118.htm\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue070118.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/SideOverdueFines.jpg\" alt=\"Overdue Fines for Computers and Equipments\" width=\"162\" height=\"46\"><br>Overdue Fines for Notebook<br>Computers & Equipments</a>";*/

/*messages[6] = "<a href=\"http://www.library.ln.edu.hk/libinfo/libnotice/libnotice_060829.htm\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue060904.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/net_print_ico.jpg\" width=\"162\" height=\"46\"><br>Refilling of Student Print<br>Account</a>";*/

/*messages[2] = "<a href=\"http://libmedia.ln.edu.hk/media3/www/live/06-07-1/lingnan2006.htm\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue061023.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/graphics/roadshow_lu2.jpg\" alt=\"&#36335;&#35338;&#36890;: &#39640;&#31561;&#23416;&#24220;&#24033;&#31150;-- &#23994;&#21335;&#22823;&#23416;\" width=\"162\" height=\"48\"><br>&#82;&#111;&#97;&#100;&#83;&#104;&#111;&#119;&nbsp;&#36335;&#35338;&#36890;&#29305;&#36655;<br>&#39321;&#28207;&#39640;&#31561;&#23416;&#24220;&#24033;&#31150; -- &#23994;&#21335;&#22823;&#23416;</font></a>";*/

/*messages[8] = "<a href=\"http://nobelprize.org/nobel_prizes/lists/2006.html\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/new_blue061004.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/np.jpg\" width=\"162\" height=\"46\"><br>Nobel Laureates 2006</a>";*/

/*messages[2] = "<a href=\"http://www.library.ln.edu.hk/libtop10/\" onMouseOver=\"pause()\" onMouseOut=\"resume()\"><img border=\"0\" src=\"/graphics/update_blue060927.gif\" width=\"162\" height=\"22\"><br><img border=\"0\" src=\"/i3.files/top_10_3.jpg\" width=\"162\" height=\"46\"><br>Library Top 10 (Sep 2006 -<br>Feb 2007)</a>";*/


for (var i = 0; i < messages.length; i++) messages[i] = str1 + messages[i] + str2;

DynAPI.onLoad = function() { 
	lyrBase = new DynLayer()
	lyrBase.setSize(scrollerwidth, scrollerheight)
	//lyrBase.setBgColor('#c0c0c0')
	lyrBase.moveTo(scrollerx, scrollery)
	lyrBase.setClip(Array(0,scrollerwidth,scrollerheight,0));
	lyrSB = new DynLayer()
	lyrSB.setSize(scrollerwidth, scrollerheight * 3)
	lyrSB.moveTo(0, -scrollerheight)
	lyr_A = new DynLayer();
	lyr_A.setSize(scrollerwidth, scrollerheight)
	lyr_A.moveTo(0, 0)
	lyr_B = new DynLayer();
	lyr_B.setSize(scrollerwidth, scrollerheight)
	lyr_B.moveTo(0, scrollerheight)
	lyr_C = new DynLayer();
	lyr_C.setSize(scrollerwidth, scrollerheight)
	lyr_C.moveTo(0, scrollerheight*2);
	lyrSB.addChild(lyr_A);
	lyrSB.addChild(lyr_B);
	lyrSB.addChild(lyr_C);
	lyrBase.addChild(lyrSB);
	DynAPI.document.addChild(lyrBase)
	setMsg();
	setTimeout("move(lyrSB)", scrollerspeed);

} 

function setMsg() {
	var ml = messages.length;

	if (direction > 0) {
		if (i_b == -1) i_b = 0;
		else i_b = ++i_b % ml;
	} else {
		if (i_b == -1) i_b = 0;
		else {
			i_b = i_b - 1;
			if (i_b == -1) i_b = ml - 1;
		}
	}
	i_a = (i_b + 1) % ml;
	i_c = (i_b - 1) < 0 ? ml - 1 : i_b - 1;

	lyr_A.setHTML(messages[i_a]);
	lyr_B.setHTML(messages[i_b]);
	lyr_C.setHTML(messages[i_c]);
}

var ot;

function move(lyr) {
	elyr = eval(lyr);
	yy = elyr.getY();

	if (!pending && yy == -scrollerheight) {
		pending = true;
		scrollerpause = scrollerdelay;
	}
	else {
		if (yy == 0 || yy == -2 * scrollerheight) {
			yy = -scrollerheight;
			setMsg();
		}
		else {
			pending = false;
			yy += direction * scrollerstep;
		}
		elyr.setY(yy);
		scrollerpause = scrollerspeed;
	}

	sss = "move("+elyr+")";
	ot = setTimeout(sss, scrollerpause);
}

function backward() {
	direction = -1;
	clearTimeout(ot);
	ot = setTimeout("move(lyrSB)", scrollerspeed);
}

function forward() {
	direction = 1;
	clearTimeout(ot);
	ot = setTimeout("move(lyrSB)", scrollerspeed);
}

function pause() {
	clearTimeout(ot);
}

function resume() {
	clearTimeout(ot);
	ot = setTimeout("move(lyrSB)", scrollerpause);
}

