function fade_in_feature (id) {
	if (!FeatureOpacity[id]) {
		FeatureOpacity[id] = 0;
	}
	feature_opacity(id,FeatureOpacity[id],100,250);
}

function fade_out_feature (id) {
	if (FeatureOpacity[id]) {
		feature_opacity(id,FeatureOpacity[id],0,250);
	}
	else {
		FeatureOpacity[id] = 0;
	}
}

function feature_opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("feature_changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            FeatureOpacity[id] = i;
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("feature_changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            FeatureOpacity[id] = i;
            timer++; 
        } 
    }
} 

//change the opacity for different browsers 
function feature_changeOpac(opacity, id) { 
    var object = document.getElementById('feature').style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 

function initialize_feature() {
	update_feature();

	fade_in_feature();
	FeatureTimer = setTimeout("next_feature();",FeatureTime);
}

function increment_feature() {
	FeaturePos++;
	var array_length = FeatureImages.length;
	if (FeaturePos >= array_length) {
		FeaturePos = 0;
	}
}

function decrement_feature() {
        FeaturePos--;

        if (FeaturePos < 0) {
		FeaturePos = FeatureImages.length - 1;
        }
} 

function update_feature() {
	var object = document.getElementById('feature').style;
	object.backgroundImage = "url(\'" + FeatureImages[FeaturePos] + "\')";

}

function next_feature() {
	clearTimeout(FeatureTimer);
	fade_out_feature();
	increment_feature();
	setTimeout("update_feature();fade_in_feature();",400);
	FeatureTimer = setTimeout("next_feature();",FeatureTime);
}

function prev_feature() {
	clearTimeout(FeatureTimer);
	fade_out_feature();
        decrement_feature();
	setTimeout("update_feature();fade_in_feature();",400); 
	FeatureTimer = setTimeout("next_feature();",FeatureTime);
}

function go_feature() {
	window.location=FeatureLinks[FeaturePos];
}

function pause_feature_timer() {
	clearTimeout(FeatureTimer);
}

function restart_feature_timer() {
	FeatureTimer = setTimeout("next_feature();",FeatureTime);
}

