/**
 * Javascript ScrollerRSS
 * @author: Gerardo Orellana <admin@prosoftcorp.com>
 * version 0.9
 * Last Modified: Thu Oct 1 17:37:51 2009
 * Path:  /scroller/scroller.js
 */

var xmlHttp;function $()
{var elements=new Array();for(var i=0;i<arguments.length;i++){var element=arguments[i];if(typeof element=='string'){element=document.getElementById(element);}
if(arguments.length==1){return element;}
elements.push(element);}
return elements;}
function goScroller(options)
{if(!options)return die(' crop > cannot create crop: no options were found\n');this.config=options;this.reference=0;this.parser;this.current_opacity=0.0;this.mouseUp=0;this.getXMLHTTPObject=function()
{xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}
this.fadeScroll=function(){var myScroll=this;$(myScroll.config.sDiv).style.MozOpacity=myScroll.current_opacity;myScroll.current_opacity+=0.1;if(myScroll.current_opacity<1.0)setTimeout(function(){myScroll.fadeScroll()},80);}
this.scrollRSS=function()
{var myScroll=this;if(myScroll.mouseUp==1){setTimeout(function(){myScroll.scrollRSS()},100);}else{$(myScroll.config.sDiv).innerHTML='';myScroll.current_opacity=0.0;switch(myScroll.config.sDisplay)
{case'all':$(myScroll.config.sDiv).innerHTML+='<p><a href="'+myScroll.parser[myScroll.reference].getAttribute("golink")+'" title="Goto news source.">'+myScroll.parser[myScroll.reference].getAttribute("gotitle")+'</a>'+'<br /><span style="font-size:10px;">'+myScroll.parser[myScroll.reference].getAttribute("godate")+'</span>'+'<br /><br /><span style="font-size:11px;">'+myScroll.parser[myScroll.reference].getAttribute("godescription")+'</span></p>';break;case'title':$(myScroll.config.sDiv).innerHTML+='<p><a href="'+myScroll.parser[myScroll.reference].getAttribute("golink")+'" title="Goto news source.">'+myScroll.parser[myScroll.reference].getAttribute("gotitle")+'</a>'+'<br /><span style="font-size:10px;">'+myScroll.parser[myScroll.reference].getAttribute("godate")+'</span></p>';break;case'description':$(myScroll.config.sDiv).innerHTML+='<p><a href="'+myScroll.parser[myScroll.reference].getAttribute("golink")+'" title="Goto news source.">'+myScroll.parser[myScroll.reference].getAttribute("godescription")+'</a></p>';break;default:$(myScroll.config.sDiv).innerHTML+='<a href="'+myScroll.parser[myScroll.reference].getAttribute("golink")+'" title="Goto news source.">'+myScroll.parser[myScroll.reference].getAttribute("gotitle")+'</a>';}
myScroll.reference=(myScroll.reference<myScroll.parser.length-1)?myScroll.reference+1:0;setTimeout(function(){myScroll.scrollRSS()},myScroll.config.iDelay);if(myScroll.config.bFader)myScroll.fadeScroll();}}
this.fetchRSS=function()
{var myScroll=this;xmlHttp=this.getXMLHTTPObject();if(xmlHttp===null){alert('Browser does not support HTTP Request');return}
$(myScroll.config.sDiv).innerHTML='Loading RSS feed';var url='scrollrss.php'+'?src='+this.config.sURL+'&ctime='+this.config.iCacheTime+'&sid='+Math.random();xmlHttp.open('GET',url,true);xmlHttp.send(null);xmlHttp.onreadystatechange=function(){if(xmlHttp.readyState==4){if(xmlHttp.status==200){var xml=xmlHttp.responseXML;if(xml.getElementsByTagName('item').length==0){$(myScroll.config.sDiv).innerHTML='<p>Error fetching data from XML cache file</p>';return;}
$(myScroll.config.sDiv).innerHTML='';myScroll.parser=xml.getElementsByTagName('item');for(var i=0;i<myScroll.parser.length;i++){myScroll.parser[i].setAttribute('gotitle',myScroll.parser[i].getElementsByTagName('title')[0].firstChild.nodeValue);myScroll.parser[i].setAttribute('golink',myScroll.parser[i].getElementsByTagName('link')[0].firstChild.nodeValue);if(typeof(myScroll.parser[i].getElementsByTagName('description')[0].textContent)!="undefined")
myScroll.parser[i].setAttribute('godescription',myScroll.parser[i].getElementsByTagName('description')[0].textContent);else
myScroll.parser[i].setAttribute('godescription',myScroll.parser[i].getElementsByTagName('description')[0].text);myScroll.parser[i].setAttribute('godate',myScroll.parser[i].getElementsByTagName('pubDate')[0].firstChild.nodeValue);}
$(myScroll.config.sDiv).onmouseover=function(){myScroll.mouseUp=1;};$(myScroll.config.sDiv).onmouseout=function(){myScroll.mouseUp=0;};myScroll.scrollRSS();}}}}
this.init=function()
{this.fetchRSS();}}
