
var scrollerdelay='5000' //delay between msg scrolls. 3000=3 seconds.
var scrollerheight='115px'
var scrollerwidth='189px'
var scrollspeed=50;

///////Do not edit pass this line///////////////////////
// some new variables
var scroll_running = 0;
var scroll_stopped = 0;
var scroll_stopCompleted = 0;
var scroll_scrollForward = 1;
var scroll_topLayer;
var scroll_bottomLayer;
var scroll_i=2;
if(scroll_messages.length<3){
	scroll_i=0;
}

function scroll_move1(whichdiv){
	scroll_tdiv=eval(whichdiv)
	if (parseInt(scroll_tdiv.style.top)>0&&parseInt(scroll_tdiv.style.top)<=5){
		scroll_tdiv.style.top=0+"px"
		if (scroll_stopped == 1) {scroll_switchButton(1); return;}
		setTimeout("scroll_move1(scroll_tdiv)",scrollerdelay)
		setTimeout("scroll_move2(scroll_second_obj)",scrollerdelay)
		return
	}
	if (parseInt(scroll_tdiv.style.top)>=scroll_tdiv.offsetHeight*-1){
		if (scroll_stopped == 1 && parseInt(scroll_tdiv.style.top) == 0) {scroll_switchButton(1); return;}
		if (scroll_stopped == 1 && parseInt(scroll_tdiv.style.top) == parseInt(scrollerheight)) {scroll_switchButton(1); return;}
		scroll_tdiv.style.top=parseInt(scroll_tdiv.style.top)-5+"px"
		setTimeout("scroll_move1(scroll_tdiv)",scrollspeed)
	}
	else{
		scroll_tdiv.style.top=parseInt(scrollerheight)
		scroll_tdiv.innerHTML=scroll_messages[scroll_i]
		scroll_itemStatus();
		if (scroll_i==scroll_messages.length-1)
			scroll_i=0
		else
			scroll_i++
	}
}

function scroll_move2(whichdiv){
	scroll_tdiv2=eval(whichdiv)
	if (parseInt(scroll_tdiv2.style.top)>0&&parseInt(scroll_tdiv2.style.top)<=5){
		scroll_tdiv2.style.top=0+"px"
		if (scroll_stopped == 1) {scroll_switchButton(1); return;}
		setTimeout("scroll_move2(scroll_tdiv2)",scrollerdelay)
		setTimeout("scroll_move1(scroll_first_obj)",scrollerdelay)
		return
	}
	if (parseInt(scroll_tdiv2.style.top)>=scroll_tdiv2.offsetHeight*-1){
		if (scroll_stopped == 1 && parseInt(scroll_tdiv2.style.top) == 0) {scroll_switchButton(1); return;}
		if (scroll_stopped == 1 && parseInt(scroll_tdiv2.style.top) == parseInt(scrollerheight)) {scroll_switchButton(1); return;}
		scroll_tdiv2.style.top=parseInt(scroll_tdiv2.style.top)-5+"px"
		setTimeout("scroll_move2(scroll_second_obj)",scrollspeed)
	}
	else{
		scroll_tdiv2.style.top=parseInt(scrollerheight)
		scroll_tdiv2.innerHTML=scroll_messages[scroll_i]
		scroll_itemStatus();
		if (scroll_i==scroll_messages.length-1)
			scroll_i=0
		else
			scroll_i++
	}
}

function startscroll(){
	// make sure function doesn't fun twice
	if (scroll_running != 0)
		return

	scroll_running++
	scroll_first_obj=document.getElementById("scroll_first")
	scroll_second_obj=document.getElementById("scroll_second")
	scroll_move1(scroll_first_obj)
	scroll_second_obj.style.top=scrollerheight
	scroll_second_obj.style.visibility='visible'
	scroll_switchButton(0);
	document.getElementById("scroll_itemStatus").innerHTML = '1 of ' + scroll_messages.length;
}

function scroll_itemStatus() {
	document.getElementById("scroll_itemStatus").innerHTML = (scroll_i==0?scroll_messages.length:scroll_i) + ' of ' + scroll_messages.length ;
}

function stopScroll() {
	scroll_stopped = 1;
	scroll_switchButton(2);
}

function restartScroll() {
	if (scroll_stopped == 0 ) {return;}
	scroll_stopped = 0;
	if (scroll_scrollForward == 0) {
		if (scroll_i==scroll_messages.length-1) {
			scroll_i=1;
		} else if (i==scroll_messages.length-2) {
			scroll_i=0;
		} else {
			scroll_i=scroll_i+2
		}
	}
	
	setTimeout("scroll_move1(scroll_first_obj)",scrollerdelay);
	setTimeout("scroll_move2(scroll_second_obj)",scrollerdelay);
	
	scroll_switchButton(0);
	scroll_scrollForward = 1;
	scroll_stopCompleted = 0;
}

function scroll_switchButton(what) {
	if (what==0) {
		document.getElementById("scroll_startstop").innerHTML = '<input type="button" class="stop_button" value=" " onClick="stopScroll()">';
		document.getElementById("scroll_nextbutton").innerHTML = '<input type="button" class="rt_button" value=" " onClick="nextScroll()">';
		document.getElementById("scroll_backbutton").innerHTML = '<input type="button" class="lt_button" value=" " onClick="backScroll()">';
	} else if (what==1) {
		first2_top=parseInt(document.getElementById("scroll_first").style.top)
		second2_top=parseInt(document.getElementById("scroll_second").style.top)
		if ((first2_top != 0 && first2_top != parseInt(scrollerheight)) || (second2_top != 0 && second2_top != parseInt(scrollerheight))) {
			setTimeout("scroll_switchButton(1)",50)
			return;
		}
		document.getElementById("scroll_startstop").innerHTML = '<input type="button" class="play_button" value=" " onClick="restartScroll()">';
		document.getElementById("scroll_nextbutton").innerHTML = '<input type="button" class="rt_button" value=" " onClick="nextScroll()">';
		document.getElementById("scroll_backbutton").innerHTML = '<input type="button" class="lt_button" value=" " onClick="backScroll()">';
		scroll_stopCompleted = 1;
	} else if (what==2) {
		document.getElementById("scroll_startstop").innerHTML = '<img src="/portal/apps/threeoneone/site_launch/img/wait.gif" border="0" align="middle" width="38" height="19" alt="Wait...">';
		document.getElementById("scroll_nextbutton").innerHTML = '<input type="button" class="rt_button" value=" " onClick="nextScroll()">';
		document.getElementById("scroll_backbutton").innerHTML = '<input type="button" class="lt_button" value=" " onClick="backScroll()">';
	}
}

function nextScroll() {
	if (scroll_stopped == 0) {	stopScroll(); }
	if (scroll_stopCompleted == 0) {
		setTimeout("nextScroll()",scrollspeed)
		return;
	}
	if (parseInt(document.getElementById("scroll_first").style.top)==0) {
		scroll_topLayer = document.getElementById("scroll_first");
		scroll_bottomLayer = document.getElementById("scroll_second");
	} else {
		scroll_bottomLayer = document.getElementById("scroll_first");
		scroll_topLayer = document.getElementById("scroll_second");
	}
	if (scroll_scrollForward == 0) {
		if(scroll_messages.length==1){
			scroll_i=0;
		}else{
			if (scroll_i==scroll_messages.length-1) {
				scroll_i=1;
			} else if (scroll_i==scroll_messages.length-2) {
				scroll_i=0;
			} else {
				scroll_i=scroll_i+2
			}
		}
	}
	eval(scroll_topLayer).innerHTML = (scroll_i==0?scroll_messages[scroll_messages.length-1]:scroll_messages[scroll_i-1]);
	eval(scroll_bottomLayer).innerHTML = scroll_messages[scroll_i];
	scroll_itemStatus();
	scroll_scrollForward = 1;
	if (scroll_i==scroll_messages.length-1) {
		scroll_i=0;
	} else {
		scroll_i++;
	}
}

function backScroll() {
	if (scroll_stopped == 0) {	stopScroll(); }
	if (scroll_stopCompleted == 0) {
		setTimeout("backScroll()",scrollspeed)
		return;
	}
	if (parseInt(document.getElementById("scroll_first").style.top)==0) {
		scroll_topLayer = document.getElementById("scroll_first");
		scroll_bottomLayer = document.getElementById("scroll_second");
	} else {
		scroll_bottomLayer = document.getElementById("scroll_first");
		scroll_topLayer = document.getElementById("scroll_second");
	}
	if (scroll_scrollForward == 1) {
		if(scroll_messages.length==1){
			scroll_i=0;
		}else {
			if (scroll_i==0) {
				scroll_i=scroll_messages.length-2;
			} else if (scroll_i==1) {
				scroll_i=scroll_messages.length-1;
			} else {
				scroll_i=scroll_i-2
			}
		}
	}
	eval(scroll_topLayer).innerHTML = (scroll_i==0?scroll_messages[scroll_messages.length-1]:scroll_messages[scroll_i-1]);
	eval(scroll_bottomLayer).innerHTML = scroll_messages[scroll_i];
	scroll_itemStatus();
	scroll_scrollForward = 0;
	if (scroll_i==0) {
		scroll_i=scroll_messages.length-1;
	} else {
		scroll_i--;
	}
}

function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
		window.onload = func; 
	} else { 
		window.onload = function() { 
			if (oldonload) { 
				oldonload(); 
			} 
			func(); 
		} 
	} 
} 
addLoadEvent(startscroll);
