/*
 * parses through the elements in confEventsNoScriptDiv looking for p tags
 * when it finds on it adds them to the returned content array
 */
function getNewsArray2(confEventsNoScriptDiv){
	//build the message array..
	//get the div...
	
	var confEventsNoScriptPTags = new Array();
	
	//loop through the childNodes of the confEventsNoScript and extract the p tags

	for (var i = 0;i < confEventsNoScriptDiv.childNodes.length;++i)
	{
		if (confEventsNoScriptDiv.childNodes[i].nodeName == "P"){
			confEventsNoScriptPTags.push(confEventsNoScriptDiv.childNodes[i]);
		}
	}
	
	//check to see if the items in the p tag array fit neatly into our container
	
	if (confEventsNoScriptPTags.length % 2 != 0){
		//the array needs increasing in size 2 fold
		if (confEventsNoScriptPTags.length > 1){
		//if there is only element do nothing
			confEventsNoScriptPTags = confEventsNoScriptPTags.concat(confEventsNoScriptPTags);
		}
	}	

	//loop through the array of p tags and put the content in threes in the pause array 
	ptagItr = -1;

	var confEventsContent = new Array();
	for (i=0;i < confEventsNoScriptPTags.length;++i){
		++ptagItr;
		confEventsContent[ptagItr] = confEventsNoScriptPTags[i].innerHTML;
		/*++i;
		if (i < confEventsNoScriptPTags.length)
			confEventsContent[ptagItr] += "<br /><br />" + confEventsNoScriptPTags[i].innerHTML;
		++i 
		if (i < confEventsNoScriptPTags.length)
			confEventsContent[ptagItr] += "<br /><br />" + confEventsNoScriptPTags[i].innerHTML;
	
		confEventsContent[ptagItr] += "<br /><br />";*/
	}

	//if there is only one item here duplicate it - this removes and undefined error.
	if (ptagItr == 0)
		confEventsContent = confEventsContent.concat(confEventsContent);

	return confEventsContent;
}

/***********************************************
* Pausing up-down scroller- © Dynamic Drive (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit http://www.dynamicdrive.com/ for this script and 100s more.
***********************************************/
/*@author Ian Holmes aa2251
 * pausescroller2 based on the Pausing up-down scroller methods from http://www.dynamicdrive.com/dynamicindex2/crosstick.htm
 * mainly the layout (both metod structure and ouput html), method names and cross browser init start have been borrowed.
 * changed where main to allow one item to scroll at a time
 * Notes:
 * The <p>tag in the innerDivs are additions to the content[x] and are not required for operation
 */
function pausescroller2(content, divId, divClass, delay){
	this.content=content //message array content
	this.tickerid=divId //ID of ticker div to display information
	this.delay=delay //Delay between msg change, in miliseconds.
	this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over scroller (and pause it if it is)
	this.currentItem=0//index of message array current top item - this will alway be 0...
	
	document.write('<div id="'+divId+'" class="'+divClass+'" style="position: relative; overflow: hidden">');
	for(var i = 0; i < content.length; ++i){
		document.write('<div class="innerDiv" style="position: absolute; width: 100%;" id="newsDiv'+i+'1"><p>'+content[i]+'</p></div>');
	}
	document.write('</div>');
	var pausescroller2instance=this
	if (window.addEventListener) //run onload in DOM2 browsers
		window.addEventListener("load", function(){pausescroller2instance.init()}, false)
	else if (window.attachEvent) //run onload in IE5.5+
		window.attachEvent("onload", function(){pausescroller2instance.init()})
	else if (document.getElementById) //if legacy DOM browsers, just start scroller after 0.5 sec
		setTimeout(function(){pausescroller2instance.init()}, 500)
}

pausescroller2.prototype.init=function(){
	this.tickerdiv=document.getElementById(this.tickerid);
	this.newsItems = this.tickerdiv.getElementsByTagName("div");
	this.visibledivtop=parseInt(pausescroller2.getCSSpadding(this.tickerdiv))
	//set width of inner DIVs to outer DIV's width minus padding (padding assumed to be top padding x 2)
//	this.visiblediv.style.width=this.hiddendiv.style.width=this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px"
	var tickerWidth = this.tickerdiv.offsetWidth-(this.visibledivtop*2)+"px";
	for (var i = 0;i < this.newsItems.length;++i){
		this.newsItems[i].style.width = tickerWidth;
	}
	this.getinline();
	var scrollerinstance=this
	this.tickerdiv.onmouseover=function(){scrollerinstance.mouseoverBol=1}
	this.tickerdiv.onmouseout=function(){scrollerinstance.mouseoverBol=0}
	if (window.attachEvent) //Clean up loose references in IE
	window.attachEvent("onunload", function(){scrollerinstance.tickerdiv.onmouseover=scrollerinstance.tickerdiv.onmouseout=null})
	setTimeout(function(){scrollerinstance.animateup()}, this.delay)
}

pausescroller2.prototype.animateup=function(){

	var scrollerinstance=this
	

	if (parseInt(this.newsItems[this.currentItem+1].style.top)>(this.visibledivtop+5)){
		//loop through each item and move it up slightly
		//if (window.top.debugWindow) debug("news items: size = " + this.newsItems.length);
		for (var i = 0;i < this.newsItems.length;++i){
			this.newsItems[i].style.top=parseInt(this.newsItems[i].style.top)-5+"px";
		}
		setTimeout(function(){scrollerinstance.animateup()}, 50)
	}
	else{
		//reposition the current first div at the bottom of scroller div
		var tempDiv = this.newsItems[this.currentItem];
		this.tickerdiv.removeChild(tempDiv);
		this.tickerdiv.appendChild(tempDiv);
		//regenerate the news items array
		this.newsItems = this.tickerdiv.getElementsByTagName("div");
		scrollerinstance.getinline();
		setTimeout(function(){scrollerinstance.setmessage()}, this.delay);
	}
}

pausescroller2.getCSSpadding=function(tickerobj){ //get CSS padding value, if any
	if (tickerobj.currentStyle)
		return tickerobj.currentStyle["paddingTop"]
	else if (window.getComputedStyle) //if DOM2
		return window.getComputedStyle(tickerobj, "").getPropertyValue("padding-top")
	else
		return 0
}


/*
 * assign a top value to each of the elements.
 */
pausescroller2.prototype.getinline=function(){
	var currentTop = this.visibledivtop;
	for (var i = 0;i < this.newsItems.length;++i){
		this.newsItems[i].style.top = currentTop+"px";
		if (window.top.debugWindow) debug("news item: " + this.newsItems[i].nodeName + " top = " + this.newsItems[i].style.top);	
		currentTop = currentTop + this.newsItems[i].offsetHeight;
	}
}

pausescroller2.prototype.setmessage=function(){
	var scrollerinstance=this
	if (this.mouseoverBol==1) //if mouse is currently over scoller, do nothing (pause it)
		setTimeout(function(){scrollerinstance.setmessage()}, 100)
	else{
		this.animateup()
	}
}