var item = 0;			// Start with first news item
var opaqueness = 100;	// Start fully opaque
var type = "unknown";	//Variable used to hold the browser name
BrowserSniffer();

//detects the capabilities of the browser
function BrowserSniffer() {
	if (document.all) type="all";					//eg Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="layers";		//eg Netscape Communicator 4
	else if (document.getElementById) type="ById";	//eg Opera and Mozila e.g. Netscape 6 upwards
	else type = "unknown";		//I hope it will not get here
}

function setOpacity(obj, opacity) {
  	opacity = (opacity == 100)?99.999:opacity;
	  
 	if (type=="all") {			// IE/Win
  		obj.style.filter = "alpha(opacity:"+opacity+")";
		return true;
  	}
	if (type=="ById") {			// Safari 1.2, newer Firefox and Mozilla, CSS3
		obj.style.opacity = opacity/100;
		return true;
	}
	if (type=="unknown") {		// assume Safari<1.2, Konqueror	
		obj.style.KHTMLOpacity = opacity/100;
		return true;
	}
	if	(type="layers") {		// Older Mozilla and Firefox
		obj.style.MozOpacity = opacity/100;
		return true;
	}
}

//detects the capabilities of the browser
function BrowserSniffer() {
	if (document.all) type="all";					//eg Internet Explorer e.g. IE4 upwards
	else if (document.layers) type="layers";		//eg Netscape Communicator 4
	else if (document.getElementById) type="ById";	//eg Opera and Mozila e.g. Netscape 6 upwards
	else type = "unknown";		//I hope it will not get here
}

function news(items)	{
	var next = 'fadeout(' + items + ')';
	setTimeout(next,10000);
	return true;
}

function fadeout(items)	{
//  Fade out the current item
	var thisId = 'news' + item;
	opaqueness -= 10;
	if (document.getElementById) {
    	obj = document.getElementById(thisId);
		setOpacity(obj,opaqueness);
		if (opaqueness > 0) {	
			var next = 'fadeout(' + items + ')';
			setTimeout(next,60);
		} else {
//  		Make current news item invisible and the next one visible
			obj.style.display = 'none';
			item = (item+1)%items; // get remainder modulus the number of items
			thisId = 'news' + item;
   	 		obj = document.getElementById(thisId);
			obj.style.display = 'block';
			var next = 'fadeup(' + items + ')';
    		setTimeout(next,0);
		}
	}
}

function fadeup(items)	{	//  Fade up the next item
	if (document.getElementById) {
		var thisId = 'news' + item;
    	obj = document.getElementById(thisId);
		opaqueness += 10;
    	obj = document.getElementById(thisId);
		setOpacity(obj,opaqueness);
		if (opaqueness < 100) {
			var next = 'fadeup(' + items + ')';
    		setTimeout(next,60);
		} else {
			var next = 'fadeout(' + items + ')';
    		setTimeout(next,10000);
		}
	}
}