//News Highlighting
var isitie = document.all;
var newsTime = 0;
var newsHighlight = 0;
var newsCount = 0;
var sCount;
var sCountB;
var stwoCount;
var stwoCountB;
var x;
var items = new Array();
items = document.getElementById("newsright").getElementsByTagName("div");

var messages = new Array();
messages = document.getElementById("newsleft").getElementsByTagName("div");

if(items.length != messages.length) alert("ID10T:Error");
//items[newsCount].style.backgroundColor='#ffffff';

if(isitie){
	for(x=items.length - 1; x>2; x--){
		new Effect.Move(items[x].id,{x:-5000, mode: 'relative', duration:0})
	}
}

var newsYmove = items.length * 50;
Effect.Appear(messages[newsCount].id);
rotationshow(0);
items[newsCount].style.backgroundColor = '#856729';

function rotationshow(track){
	if(track == messages.length) track = 0;
//	Effect.Appear(messages[track].id, {duration:1});
	
	rs = setTimeout("rotationhide(" + track + "); newsNext();",6000);
}

function rotationhide(track){
	if(track == messages.length) return;
//	Effect.Fade(messages[track].id, {duration:0});
	track++;
	rh = setTimeout("rotationshow(" + track + ")",0);
}

function rotationstop(){
	clearTimeout(rh);
	clearTimeout(rs);
}

function rotationclear(i){
	for(x=0; x < messages.length; x++){
		if (x!=i) {
			Effect.Fade(messages[x].id, {duration:0});
		}
	}
}

function rotationhighlight(thing){
	if(newsHighlight == 0){
		newsHighlight = 1;
		rotationstop();
		if(newsCount == items.length) {newsCount=0;}
		sCount = newsCount + 1;
		if(sCount == items.length) {sCount=0;}
		sCountB = newsCount + 2;
		if(sCountB >= items.length) {sCountB -= items.length}
	
		if (thing == items[newsCount]){
		} else if (thing == items[sCount]){
			newsNext();
		} else if (thing == items[sCountB]){
			sCount = sCountB;
			newsNext();
			setTimeout("if(newsCount == items.length) {newsCount=0;} newsNext();",504);
		}
		if(isitie){
			rotationstop();
			rotationclear(messages.length);
			Effect.Appear(messages[sCount].id, {duration:0});
			newsHighlight=0;
		} else {
	setTimeout("rotationstop(); rotationclear(messages.length);	Effect.Appear(messages[sCount].id, {duration:0}); newsHighlight=0;", 505);
		}
	}
	
}

function rotationrestart(){
	rotationstop();
	nrestart = setTimeout("rotationhide(newsCount-1);",2000);
}

function newsNext(){
	if(isitie){
		newsNextIE();
	} else {
		newsNextMF();
	}
}

function newsPrev(){
		if(isitie){
		newsPrevIE();
	} else {
		newsPrevMF();
	}
}

function newsNextMF() {	
	if(newsTime == 0){
		for(x=0;x < items.length;x++) {
			new Effect.Move(items[x].id,{y: -50, mode: 'relative', duration: .5});
		}
		if(newsCount==items.length) newsCount=0;
		newsTime = setTimeout("new Effect.Move(items[newsCount].id,{y: newsYmove, mode: 'relative', duration:0});newsCount++;if(newsCount==items.length) newsCount=0;",550);
		setTimeout("newsGlow(); rotationclear(messages.length);	Effect.Appear(messages[newsCount].id, {duration:.5}); newsTime = 0;",570);
	}
}
function newsPrevMF() {	
	if(newsTime == 0){
		if(newsCount == 0) newsCount=items.length;
		newsCount--;
		new Effect.Move(items[newsCount].id,{y: -newsYmove, mode: 'relative', duration:0});
		newsTime=1;
		for(x=0;x<items.length;x++) {
			new Effect.Move(items[x].id,{y: 50, mode: 'relative', duration: .5});
		}
		setTimeout("newsPGlow(); rotationclear(messages.length);	Effect.Appear(messages[newsCount].id, {duration:.5});",550);
		newsTime = setTimeout("newsTime=0;",570);
	}
}

function newsNextIE() {	
	if(newsTime == 0){
		for(x=0;x < items.length;x++) {
			new Effect.Move(items[x].id,{y: -50, mode: 'relative', duration: 0});
		}
		if(newsCount==items.length) newsCount=0;		
		new Effect.Move(items[newsCount].id,{x: -5000, y: newsYmove, mode: 'relative', duration:0});
		newsCount++;
		newsGlow();
		
		if(newsCount==items.length) newsCount=0;
		new Effect.Appear(items[newsCount].id, {duration:.25});
		nshiftcount = newsCount + 2;
		if (nshiftcount >= items.length) nshiftcount -= items.length;
	
		stwoCount = newsCount + 2;
		if (stwoCount >= items.length) stwoCount -= items.length;
		new Effect.Move(items[stwoCount].id,{x: 5000, mode: 'relative', duration:0});
		newsTime = 0;
	}
}
function newsPrevIE() {	
	if(newsTime == 0){
		if(newsCount == 0) newsCount=items.length;
		newsCount--;
		new Effect.Move(items[newsCount].id,{x: 5000, y: -newsYmove, mode: 'relative', duration:0});
		newsTime=1;
		for(x=0;x < items.length;x++) {
		new Effect.Move(items[x].id,{y: 50, mode: 'relative', duration: 0});
		}
		stwoCount = newsCount + 3;
		if (stwoCount >= items.length) stwoCount -= items.length;
//		if (stwoCount == 8) stwoCount = 1;
//		if (stwoCount == 9) stwoCount = 2;
		new Effect.Move(items[stwoCount].id,{x: -5000, mode: 'relative', duration:0});
		newsPGlow();
		newsTime=0;
	}
}

function newsGlow()	{
	if(newsCount == items.length) newsCount = 0;
	glowCount =  newsCount;
	if(glowCount == 0) {
		glowCount = items.length - 1;
	} else {
		glowCount -= 1;
	}
	items[newsCount].style.backgroundColor = '#856729';
	items[glowCount].style.backgroundColor = '#8092B2';
}
function newsPGlow() {
	glowCount = newsCount;
	if(glowCount < 0){
		glowCount = items.length - 1;
	}
	glowCountB = glowCount + 1;
	if(glowCountB == items.length){
		glowCountB = 0;
	}
	items[glowCount].style.backgroundColor = '#856729';
	items[glowCountB].style.backgroundColor = '#8092B2';
}