//var hSlideContent=new Array()

var scrollerwidth=300
var scrollerheight=29
var pausebetweenimages=5000
var iNewsCounter=0;


// create an XMLDoc
var xmldoc;
// for DOM2 including NN 6 & 7
if (document.implementation && document.implementation.createDocument)
{
 	// create the XML Doc
 	xmldoc = document.implementation.createDocument("", "", null);
    // define a function to run on load
	xmldoc.onload=function(){pop_ticker();}
}
// for IE
else if (window.ActiveXObject)
{
 	// create a new XML object for IE
	xmldoc=new ActiveXObject("Microsoft.XMLDOM");
    // define some attributes of the doc
	xmldoc.async = false;
    // define a function to run on load
	xmldoc.onreadystatechange=function(){if(xmldoc.readyState == 4){pop_ticker();}}
}

//load the XML file in
//xmldoc.load('http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml');

function pop_ticker()
{
	// load the news items from the XML file
	//newsItems = xmldoc.getElementsByTagName("item");
    // populate the Arrays from the XML file
	//for (var i=0;i<newsItems.length;i++)
	//{
		// add the elements of the ticker item
	//	hSlideContent[i] = '<a class=\'whiteLink\' href=' + newsItems[i].getElementsByTagName("link")[0].firstChild.data + ' target=_blank>' + newsItems[i].getElementsByTagName("title")[0].firstChild.data + '</a>';
    //}
}

if (hSlideContent.length>1)
iNewsCounter=2
else
iNewsCounter=0

function locateObject(n, d) {
  var p,iiObj,x;
  if(!d) d=document;
  if((p=n.indexOf("?"))>0&&parent.frames.length)
  {
    d=parent.frames[n.substring(p+1)].document;
    n=n.substring(0,p);
    }
  if(!(x=d[n])&&d.all) x=d.all[n];
  
  for (iiObj=0;!x&&iiObj<d.forms.length;iiObj++) x=d.forms[iiObj][n];
  for(iiObj=0;!x&&d.layers&&iiObj<d.layers.length;iiObj++) x=locateObject(n,d.layers[iiObj].document);
  return x;
}

function moveHTextFirstBlock(whichdiv)
{
if (document.all)
{
	tdiv=eval(whichdiv)
	if (tdiv.style.pixelLeft>0&&tdiv.style.pixelLeft<=5)
	{
		tdiv.style.pixelLeft=0
		setTimeout("moveHTextFirstBlock(tdiv)",pausebetweenimages)
		setTimeout("moveHTextSecondBlock('hTextSecond')",pausebetweenimages)
		return
	}
	if (tdiv.style.pixelLeft>=tdiv.offsetWidth*-1)
	{
		tdiv.style.pixelLeft-=5
		setTimeout("moveHTextFirstBlock(tdiv)",10)
	}
	else
{
		tdiv.style.pixelLeft=scrollerwidth+5;
	tdiv.innerHTML=hSlideContent[iNewsCounter];

	if (iNewsCounter==hSlideContent.length-1)
	iNewsCounter=0
else
	iNewsCounter++
}
}
else
{
tlayer=eval(whichdiv)
if (tlayer.left>0&&tlayer.left<=5)
{
tlayer.left=0
setTimeout("moveHTextFirstBlock(tlayer)",pausebetweenimages)
setTimeout("moveHTextSecondBlock(locateObject('hTextSecond'))",pausebetweenimages)
return
}
if (tlayer.left>=tlayer.document.width*-1)
{
tlayer.left-=5
setTimeout("moveHTextFirstBlock(tlayer)",10)
}
else
{
tlayer.left=scrollerwidth+5
tlayer.document.write(hSlideContent[i])
tlayer.document.close()
if (iNewsCounter==hSlideContent.length-1)
iNewsCounter=0
else
iNewsCounter++
}
}
}

function moveHTextSecondBlock(whichdiv)
{
if (document.all)
{
tdiv2=eval(whichdiv)

if (tdiv2.style.pixelLeft>0&&tdiv2.style.pixelLeft<=5)
{
	tdiv2.style.pixelLeft=0
	setTimeout("moveHTextSecondBlock(tdiv2)",pausebetweenimages)
	setTimeout("moveHTextFirstBlock('hTextFirst')",pausebetweenimages)
	return
}
if (tdiv2.style.pixelLeft>=tdiv2.offsetWidth*-1){
	tdiv2.style.pixelLeft-=5;
	setTimeout("moveHTextSecondBlock('hTextSecond')",10)
}
else
{	
	tdiv2.style.pixelLeft=scrollerwidth+5;
	tdiv2.innerHTML=hSlideContent[iNewsCounter]
	if (iNewsCounter==hSlideContent.length-1)
	iNewsCounter=0;
else
	iNewsCounter++;
}
}
else if (document.layers)
{
tlayer2=eval(whichdiv)

if (tlayer2.left>0&&tlayer2.left<=5)
{
	tlayer2.left=0
	setTimeout("moveHTextSecondBlock(tlayer2)",pausebetweenimages)
	setTimeout("moveHTextFirstBlock(locateObject('hTextMain').document.layers['hTextFirst'])",pausebetweenimages)
	return
}
if (tlayer2.left>=tlayer2.document.width*-1)
{
	tlayer2.left-=5
	setTimeout("moveHTextSecondBlock(tlayer2)",10)
}
else
{
	tlayer2.left=scrollerwidth+5;
	tlayer2.document.write(hSlideContent[iNewsCounter]);
	tlayer2.document.close();
	if (iNewsCounter==hSlideContent.length-1)
	{
		iNewsCounter=0;
	}
	else
	{
		iNewsCounter++;
	}
	}
	}
}

function startHScroll(){
	if (navigator.userAgent.indexOf("MSIE") > 0) {
		if (document.all)
		{
			locateObject('hTextSecond').style.left=scrollerwidth+5;
			locateObject('hTextSecond').visibility='visible';
			moveHTextFirstBlock(locateObject("hTextFirst"))
		}
		else if (document.layers)
		{
			locateObject('hTextMain').visibility='show';
			locateObject('hTextFirst').visibility='show';
			locateObject('hTextSecond').left=scrollerwidth+5;
			locateObject('hTextSecond').visibility='show';
			moveHTextFirstBlock(locateObject('hTextMain').document.layers['hTextFirst']);
		}
	}
}

if (navigator.userAgent.indexOf("MSIE") > 0) {
document.write('<div class="scrolldiv" id="hTextMain" style="width:226px; height:19px; position:static; top: 150px; left: 620px; visibility: visible; clip: rect(0 226 29 0); overflow: hidden; z-index: 2"> ');
document.write('<div class="scrolldiv" id="hTextFirst" style="left:1px; width:226px;position:absolute; z-index: 1; padding: 1px ; visibility: visible; overflow: hidden; clip: rect(0 226 29 0)"> ');
document.write('<script language="JavaScript">');
document.write('document.write(hSlideContent[0])');
document.write('</script>');
document.write('</div>');
  
document.write('<div class="scrolldiv" id="hTextSecond" style="left:1px; width:226px;position:absolute; z-index: 0; padding: 1px ; visibility: visible; overflow: hidden; clip: rect(0 226 29 0)">'); 
document.write('<script language="JavaScript">');
document.write('document.write(hSlideContent[1])');
document.write('</script>');
document.write('</div>');
document.write('</div>');
}
