var switchdelay=4000; //delay between msg scrolls. 3000=3 seconds.
var switch_images=new Array()
switch_images[switch_images.length]='slide_1.jpg|Learn more about hosting your event on Governors Island|../../html/host/host.shtml';
switch_images[switch_images.length]='slide_2.jpg|Public Notices and RFPs - Learn more about open Requests for Proposals|../../html/notices/notices.shtml';
switch_images[switch_images.length]='slide_3.jpg|Press Room - Read about Governors Island in the news!|../../html/pr/pr.shtml';
switch_images[switch_images.length]='slide_4.jpg|The Future Park - The West 8 Team is designing the future park and public spaces on the Island|../../html/future/future.shtml';

///////Do not edit pass this line///////////////////////
// some new variables
var switch_running = false;
var switch_stopped = false;
var switch_i=0;
var timeout;

function switchImage(){
	if(!switch_stopped){
		document.getElementById('feature_image').src="../../images/features/"+switch_images[switch_i].split("|")[0];
		document.getElementById('feature_image').alt=switch_images[switch_i].split("|")[1];
		var tabId="";
		for(var t=0;t<switch_images.length;t++){
			tabId="tab"+t;
			if(t==switch_i){
				var theTop=25+(t*70);
				document.getElementById(tabId).src="../../images/features/tab"+t+"_1.gif";
			}else{
				document.getElementById(tabId).src="../../images/features/tab"+t+"_0.gif";
			}
		}
		if(switch_i==switch_images.length-1){
			switch_i=0;
		}else{
			switch_i++;
		}
		timeout=setTimeout("switchImage()",switchdelay);
	}
}

function activeTab(theId){
	document.getElementById('feature_image').src="../../images/features/"+switch_images[theId].split("|")[0];
	document.getElementById('feature_image').alt=switch_images[theId].split("|")[1];
	for(var t=0;t<switch_images.length;t++){
		tabId="tab"+t;
		if(t==theId){
			var theTop=25+(t*70);
			document.getElementById(tabId).src="../../images/features/tab"+t+"_1.gif";
		}else{
			document.getElementById(tabId).src="../../images/features/tab"+t+"_0.gif";
		}
	}
}

function startswitch(){
	// make sure function doesn't fun twice
	if (switch_running)
		return
	switch_running=true;
	timeout=setTimeout("switchImage()",switchdelay);
}

function stopSwitch() {
	clearTimeout(timeout);
	switch_stopped = true;
}

function restartswitch() {
	if (switch_stopped){
		switch_stopped = false;
		timeout=setTimeout("switchImage()",switchdelay);
	}
}

document.write('<table cellspacing="0" cellpadding="0" border="0">');
document.write('<tr valign="top"><td><img src="../../images/features/'+switch_images[0].split("|")[0]+'" width="752" height="408" alt="'+switch_images[0].split("|")[1]+'" border="0" id="feature_image"></td>');
document.write('<td><table cellspacing="0" cellpadding="0" border="0">');
document.write('<tr><Td><a href="'+switch_images[0].split("|")[2]+'" onMouseOver="stopSwitch();activeTab(0)" onMouseOut="restartswitch()"><img src="../../images/features/tab0_1.gif" width="215" height="102" alt="'+switch_images[0].split("|")[1]+'" border="0" id="tab0"></a></Td></tr>');
document.write('<tr><Td><a href="'+switch_images[1].split("|")[2]+'" onMouseOver="stopSwitch();activeTab(1)" onMouseOut="restartswitch()"><img src="../../images/features/tab1_0.gif" width="215" height="102" alt="'+switch_images[1].split("|")[1]+'" border="0" id="tab1"></a></Td></tr>');
document.write('<tr><Td><a href="'+switch_images[2].split("|")[2]+'" onMouseOver="stopSwitch();activeTab(2)" onMouseOut="restartswitch()"><img src="../../images/features/tab2_0.gif" width="215" height="102" alt="'+switch_images[2].split("|")[1]+'" border="0" id="tab2"></a></Td></tr>');
document.write('<tr><Td><a href="'+switch_images[3].split("|")[2]+'" onMouseOver="stopSwitch();activeTab(3)" onMouseOut="restartswitch()"><img src="../../images/features/tab3_0.gif" width="215" height="102" alt="'+switch_images[3].split("|")[1]+'" border="0" id="tab3"></a></Td></tr>');
document.write('</table></td></tr></table>');

function addLoadEvent(func) { 
	var oldonload = window.onload; 
	if (typeof window.onload != 'function') { 
		window.onload = func; 
	} else { 
		window.onload = function() { 
			if (oldonload) { 
				oldonload(); 
			} 
			func(); 
		} 
	} 
} 
addLoadEvent(startswitch);

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;
	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];
	}
}
