var isIe4=false, isDom=false, isMac=false, isWin=false, isNs=false, isNs4=false, isFlash=-1, isLoaded=false, isIe=false, isIe50=false;
var gNewsTitle = "", i=0, itemCount=0, newsXML="",xmlHttp;
var rNum=Math.floor(Math.random()*100000);
newsXML="/news.xml?"+rNum;

function init()
{
	if (isDom)
	{
		isLoaded=true;
		loadXMLDoc(newsXML);
	}
}

function loadXMLDoc(url) 
{
	xmlHttp=null;
	// code for Mozilla, Safari...
	if (window.XMLHttpRequest)
	{
  		xmlHttp=new XMLHttpRequest();
  	}
	// code for IE....
	else if (window.ActiveXObject)
  	{
  		xmlHttp=new ActiveXObject("Microsoft.XMLHTTP")
  	}
	if (xmlHttp!=null)
  	{
  		xmlHttp.onreadystatechange=onResponse;
  		xmlHttp.open("GET",url,true);
  		xmlHttp.send(null);
  	}
	else
  	{
  		//alert("Your browser does not support XMLHTTP.")
  		document.getElementById("newsFeed").style.visibility="hidden";
  	}
}

function checkReadyState(obj)
{
  if(obj.readyState == 4)
  {
    if(obj.status == 200)
    {
      return true;
    }
    else
    {
      //alert("Problem retrieving XML data");
		document.getElementById("newsFeed").style.visibility="hidden";
    }
  }
}

function onResponse() 
{
	if(checkReadyState(xmlHttp))
  	{
  		var response = xmlHttp.responseXML.documentElement;
  		xmlStart=response.getElementsByTagName("item");
  		itemMax=xmlStart.length;
  		gTxt=xmlStart[itemCount].getElementsByTagName("title");
  		gLink=xmlStart[itemCount].getElementsByTagName("link");
  		linkTxt = gTxt[0].firstChild.data;
  		linkRef = gLink[0].firstChild.data;
  
  		newsTicker();
  		itemCount+=1;
		if(itemCount==itemMax)
		{
			itemCount=0;
		}
		window.setTimeout("onResponse()",8500);  
  }
}



function newsTicker()
{
	i+=1;
	document.getElementById('theTicker').innerHTML=linkTxt.substring(0,i);
  	document.getElementById('theTicker').href=linkRef;
	if(i<linkTxt.length)
	{
		window.setTimeout("newsTicker()",70);
	}
	else
	{
		i=0;
	}
}



isMac=(navigator.platform=="MacPPC")? true:false;
isWin=(navigator.appVersion.indexOf("Win")!=-1)? true:false;
isIe=(navigator.appName=="Microsoft Internet Explorer")? true:false;
isIe4=(document.all)? true:false;
isDom=(document.getElementById)? true:false;
if ((parseInt(navigator.appVersion)==4) && (navigator.appName=="Netscape"))
{
	isNs4 = true;
	isImg = true;
}
window.onload=init;