var slides = new Array();
slides[0] = "top_feature_1.jpg|<span class='slide_feature_title'>Students & Alumni</span><br>Empowering & connecting the community of adult learners in NYC|Students & Alumni|../../html/students_alumni/students_alumni.shtml";
slides[1] = "top_feature_2.jpg|<span class='slide_feature_title'>Teachers & Program Managers</span><br>Helping students achieve their goals|Teachers & Program Managers|../../html/programs/teachers.shtml";
slides[2] = "top_know_before_you_enroll.jpg|<span class='slide_feature_title'>Know Before You Enroll</span><br>Before you take on school debt, do your homework first|Know Before You Enroll|../../html/know/know_before_you_enroll.shtml";
slides[3] = "top_youcantoo_logo_home.gif|<span class='slide_feature_title'>YouCanToo!</span><br>Learn how you can return to school and achieve your goals|YouCanToo!|http://www.nyc.gov/youcantoo";

var faderdelay='5000' //delay between msg scrolls. 3000=3 seconds.
var faderunning = 0;
var blendDone=true;
var theSlide=0;
var curSlide=0;
var manualChange=false;

function fade(){
	if (!blendDone){
		setTimeout("fade()",1)
	}else{
		setTimeout("fade()",faderdelay);
		if(manualChange){
			manualChange=false;
		}else{
			if (theSlide==slides.length-1){
				theSlide=0;
			}else{
				theSlide++;
			}
			switchSlide(theSlide);
		}
	}
}

function startfade(){
	// make sure function doesn't fun twice
	if (faderunning != 0){
		return;
	}
	theSlide=slides.length-1;
	faderunning++
	fade();
	for(var j=0;j<slides.length;j++){
		MM_preloadImages("../../includes/site_images/features/"+slides[theSlide].split("|")[0]);
	}
}

function blendimage(theIndex) {
	blendDone=false;
    var speed = 6;
    var timer = 0;
    
    //set the current image as background
    document.getElementById('blenddiv').style.backgroundImage = "url(" + document.getElementById('blendimage').src + ")";
    //make image transparent
    changeOpac(0, 'blendimage');
    
    //make new image
    document.getElementById('blendimage').src = "../../includes/site_images/features/"+slides[theIndex].split("|")[0];
    document.getElementById('blendimage').alt = slides[theIndex].split("|")[2];
    document.getElementById('home_features_link').href=slides[theIndex].split("|")[3];
    //fade in image
    for(var t = 0; t <= 100; t++) {
        setTimeout("changeOpac(" + t + ",'blendimage')",(timer * speed));
        timer++;
        if(t==100){
	        blendDone=true;
        }
    }
}

function switchSlide(theIndex){
	manualChange=true;
	var curTd="right_col_feature_"+curSlide;
	var curNumImage="home_image_"+curSlide;
	var curSrc="../../includes/site_images/misc/home_image_"+(curSlide+1)+".gif";
	document.getElementById(curTd).className="right_col_feature";
	document.getElementById(curNumImage).src=curSrc;
	var nextTd="right_col_feature_"+theIndex;
	var nextNumImage="home_image_"+theIndex;
	document.getElementById(nextTd).className="right_col_feature_over";
	document.getElementById(nextNumImage).src="../../includes/site_images/misc/home_image_arrow.gif";
	blendimage(theIndex);
	curSlide = theIndex;
}

function changeOpac(opacity, id) {
    var object = document.getElementById(id).style;
	opacity = (opacity == 100)?99.999:opacity;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
}

function restoreClass(object,number){
	if(number!=curSlide){
		object.className="right_col_feature";
	}
}

function changeClass(object,number){
	if(number!=curSlide){
		object.className="right_col_feature_over";
	}
}

document.write('<div style="position:absolute; top:167px; left:200px; width: 569px; height: 376px;">');
document.write('<table cellspacing="0" cellpadding="0" border="0" width="569"><tr>');
document.write('<td width="387" id="blenddiv" style="background-image: url(../../includes/site_images/features/'+slides[0].split("|")[0]+'); background-repeat: no-repeat;	background-position:bottom center;"><a href="'+slides[0].split("|")[3]+'" id="home_features_link"><img src="../../includes/site_images/features/'+slides[0].split("|")[0]+'" alt="'+slides[0].split("|")[2]+'" width="387" height="374" border="0" id="blendimage" style=" margin-top:1px; filter: alpha(opacity=0); -moz-opacity: 0; opacity: 0;"></a></td>');
document.write('<td width="2"><img src="../../includes/site_images/spacers/spacer.gif" width="2" height="375" border="0" alt=""></td>');
document.write('<td width="180"><table cellspacing="0" cellpadding="0" border="0" width="180">');
document.write('<tr valign="top"><td class="right_col_feature" id="right_col_feature_0" onclick="switchSlide(0);" onmouseout=restoreClass(this,0); onmouseover=changeClass(this,0);><img src="../../includes/site_images/misc/home_image_1.gif" width="16" height="80" alt="" align="left" id="home_image_0">'+slides[0].split("|")[1]+'</td></tr>');
document.write('<tr valign="top"><td class="right_col_feature" id="right_col_feature_1" onclick="switchSlide(1);" onmouseout=restoreClass(this,1); onmouseover=changeClass(this,1);><img src="../../includes/site_images/misc/home_image_2.gif" width="16" height="80" alt="" align="left" id="home_image_1">'+slides[1].split("|")[1]+'</td></tr>');
document.write('<tr valign="top"><td class="right_col_feature" id="right_col_feature_2" onclick="switchSlide(2);" onmouseout=restoreClass(this,2); onmouseover=changeClass(this,2);><img src="../../includes/site_images/misc/home_image_3.gif" width="16" height="80" alt="" align="left" id="home_image_2">'+slides[2].split("|")[1]+'</td></tr>');
document.write('<tr valign="top"><td class="right_col_feature" id="right_col_feature_3" onclick="switchSlide(3);" onmouseout=restoreClass(this,3); onmouseover=changeClass(this,3);><img src="../../includes/site_images/misc/home_image_4.gif" width="16" height="80" alt="" align="left" id="home_image_3">'+slides[3].split("|")[1]+'</td></tr>');
document.write('</table></td></tr></table></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(startfade);

