var scroll_messages=new Array()
scroll_messages[scroll_messages.length]='<a href="http://www.archpaper.com/news/articles.asp?id=5798">Architects Newspaper features Park and Public Space Plan</a>';
scroll_messages[scroll_messages.length]='<span class="scroll_date">October 24, 2011<br></span><a href="../../downloads/pdf/pr_102411.pdf">Governors Island to Begin Construction in 2012 on New Park and Public Spaces.</a>';
scroll_messages[scroll_messages.length]='<span class="scroll_date">October 20, 2011<br></span><br><a href="../../downloads/pdf/turner_prize_winner_susan_philipsz_awarded_commission_for_permanent_piece_on_governors_island.pdf">Turner Prize Winner Susan Philipsz Awarded Commission for Permanent Piece on Governors Island.</a>';


var scrollerdelay='4000' //delay between msg scrolls. 3000=3 seconds.
var scrollspeed=50;
var scrollerwidth='198px'
var scrollerheight='120px'

///////Do not edit pass this line///////////////////////
// some new variables
var scroll_running = 0;
var scroll_stopped = 0;
var scroll_stopCompleted = 0;
var scroll_scrollnext = 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=document.getElementById("message_"+scroll_i).innerHTML;
		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=document.getElementById("message_"+scroll_i).innerHTML;
		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/' + scroll_messages.length;
}

function scroll_itemStatus() {
	document.getElementById("scroll_itemStatus").innerHTML = (scroll_i==0?scroll_messages.length:scroll_i) + '/' + scroll_messages.length ;
}

function stopScroll() {
	scroll_stopped = 1;
	scroll_switchButton(2);
}

function restartScroll() {
	if (scroll_stopped == 0 ) {return;}
	scroll_stopped = 0;
	if (scroll_scrollnext == 0) {
		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
		}
	}
	
	setTimeout("scroll_move1(scroll_first_obj)",scrollerdelay);
	setTimeout("scroll_move2(scroll_second_obj)",scrollerdelay);
	
	scroll_switchButton(0);
	scroll_scrollnext = 1;
	scroll_stopCompleted = 0;
}

function scroll_switchButton(what) {
	if (what==0) {
		document.getElementById("scroll_startstop").innerHTML = '<a href="javascript:stopScroll();" onMouseOver=swapImage("stop","stop_1.gif") onMouseOut=restoreImage("stop")><img src="../../includes/site_images/modules/stop_0.gif" name="stop" id="stop" border="0" align="middle" width="17" height="17" alt="Pause"></a>';
		document.getElementById("scroll_nextbutton").innerHTML = '<a href="javascript:nextScroll();" onMouseOver=swapImage("next","next_1.gif") onMouseOut=restoreImage("next")><img src="../../includes/site_images/modules/next_0.gif" name="next" id="next" border="0" align="absmiddle" width="17" height="17" alt="Next"></a>';
		document.getElementById("scroll_backbutton").innerHTML = '<a href="javascript:backScroll();" onMouseOver=swapImage("back","back_1.gif") onMouseOut=restoreImage("back")><img src="../../includes/site_images/modules/back_0.gif" name="back" id="back" border="0" align="absmiddle" width="17" height="17" alt="Back"></a>';
	} 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 = '<a href="javascript:restartScroll();" onMouseOver=swapImage("play","play_1.gif") onMouseOut=restoreImage("play")><img src="../../includes/site_images/modules/play_0.gif" name="play" id="play" border="0" align="middle" width="17" height="17" alt="Play"></a>';
		document.getElementById("scroll_nextbutton").innerHTML = '<a href="javascript:nextScroll();" onMouseOver=swapImage("next","next_1.gif") onMouseOut=restoreImage("next")><img src="../../includes/site_images/modules/next_0.gif" name="next" id="next" border="0" align="absmiddle" width="17" height="17" alt="Next"></a>';
		document.getElementById("scroll_backbutton").innerHTML = '<a href="javascript:backScroll();" onMouseOver=swapImage("back","back_1.gif") onMouseOut=restoreImage("back")><img src="../../includes/site_images/modules/back_0.gif" name="back" id="back" border="0" align="absmiddle" width="17" height="17" alt="Back"></a>';
		scroll_stopCompleted = 1;
	} else if (what==2) {
		document.getElementById("scroll_startstop").innerHTML = '<img src="../../includes/site_images/modules/wait.gif" border="0" align="middle" width="17" height="17" alt="Wait...">';
		document.getElementById("scroll_nextbutton").innerHTML = '<img src="../../includes/site_images/modules/next_0.gif" name="next" border="0" align="absmiddle" width="17" height="17" alt="Next">';
		document.getElementById("scroll_backbutton").innerHTML = '<img src="../../includes/site_images/modules/back_0.gif" name="back" border="0" align="absmiddle" width="17" height="17" alt="Back">';
	}
}

function swapImage(imageId,newImage){
	var oldImage=document.getElementById(imageId).src;
	var imageRestore=oldImage.substring(oldImage.lastIndexOf("/")+1);
	document.getElementById(imageId).src=oldImage.substring(0,oldImage.lastIndexOf("/")+1)+newImage;
	if(theImages==null){
		theImages=new Array();
	}
	for(var i=0;i<theImages.length;i++){
		if(theImages[i][0]==imageId){
			theImages[i][1]=imageRestore;
			return(true);
		}
	}
	theImages[theImages.length]=[imageId,imageRestore];
}

function restoreImage(imageId){
	for(var i=0;i<theImages.length;i++){
		if(theImages[i][0]==imageId){
			var oldImage=document.getElementById(imageId).src;
			document.getElementById(imageId).src=oldImage.substring(0,oldImage.lastIndexOf("/")+1)+theImages[i][1];
			return(true);
		}
	}
}

function setRestoreImage(imageId,restoreImage){
	for(var i=0;i<theImages.length;i++){
		if(theImages[i][0]==imageId){
			theImages[i][1]=restoreImage;
			return(true);
		}
	}
	theImages[theImages.length]=[imageId,restoreImage]
}

function restoreAll(){
	for(var i=0;i<theImages.length;i++){
		var oldImage=document.getElementById(theImages[i][0]).src;
		document.getElementById(theImages[i][0]).src=oldImage.substring(0,oldImage.lastIndexOf("/")+1)+theImages[i][1];
	}
}

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_scrollnext == 0) {
		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?document.getElementById("message_"+(scroll_messages.length-1)).innerHTML:document.getElementById("message_"+(scroll_i-1)).innerHTML);
	eval(scroll_bottomLayer).innerHTML = document.getElementById("message_"+scroll_i).innerHTML;
	scroll_itemStatus();
	scroll_scrollnext = 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_scrollnext == 1) {
		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?document.getElementById("message_"+(scroll_messages.length-1)).innerHTML:document.getElementById("message_"+(scroll_i-1)).innerHTML);
	eval(scroll_bottomLayer).innerHTML = document.getElementById("message_"+scroll_i).innerHTML;
	scroll_itemStatus();
	scroll_scrollnext = 0;
	if (scroll_i==0) {
		scroll_i=scroll_messages.length-1;
	} else {
		scroll_i--;
	}
}
document.write('<div id="col3_content" style="position:absolute;top:0px;left:0px;display:none;z-index:10;">');
for(var i=0;i<scroll_messages.length;i++){
	document.write('<div id="message_'+i+'">'+scroll_messages[i]+'</div>');
}
document.write('</div>');

document.writeln('<div id="main" style="position:relative;width:'+scrollerwidth+';height:'+scrollerheight+';overflow:hidden;">')
document.writeln('<div style="position:absolute;width:'+scrollerwidth+';height:'+scrollerheight+';clip:rect(0 '+scrollerwidth+' '+scrollerheight+' 0);left:0px;top:0px">')
document.writeln('<div id="scroll_first" style="position:absolute;width:'+scrollerwidth+';left:0px;top:1px;">')
document.write(document.getElementById("message_0").innerHTML);
document.writeln('</div>')
document.writeln('<div id="scroll_second" style="position:absolute;width:'+scrollerwidth+';left:0px;top:0px;visibility:hidden">')
if(scroll_messages.length==1){
	document.write(document.getElementById("message_0").innerHTML)
}else{
	document.write(document.getElementById("message_1").innerHTML)
}
document.writeln('</div>')
document.writeln('</div>')
document.writeln('</div>')

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);
