// JavaScript Document
<!--
// -------------------------------------------------------------------
// Advanced RSS Ticker (Ajax invocation) core file
// Author: Dynamic Drive (http://www.dynamicdrive.com)
// -------------------------------------------------------------------

function funcFlashFix()
{
   fls = document.getElementsByTagName("object");
   for (var a = 0; a < fls.length; a++){fls[a].outerHTML = fls[a].outerHTML;}
}



function funcHideCollapse(strHide, strShow, strDiv)
{
   var style2;
   style2 = document.getElementById(strHide).style;
   if (style2.display != "")
      style2.display = "";

   style2 = document.getElementById(strShow).style;
   if (style2.display != "")
      style2.display = "block";

   funcToggle(strDiv);
}


function hideFeeds(intCurrent, intMax)
{
   var i = 0;
   var strDiv;

   for (i = 0; i<=intMax; i++)
   {
	   strDiv = 'Feed' + i;
	   var obj = document.getElementById(strDiv);

	 	if (i == intCurrent)
		{
			obj.attributes['class'].value = "";
		}
		else
		{
			obj.attributes['class'].value = "hidediv";
		}
   }
}

function SetDivContent(strDivName, strContent)
{
	document.getElementById(strDivName).innerHTML = strContent;
}

function toggleLayerFB(whichLayer)
{
	funcHideLayersFB();
   if (document.getElementById)
   {
	  // this is the way the standards work
	  var style2 = document.getElementById(whichLayer).style;
	  style2.display = "block";
	}
   else if (document.all)
   {
	  // this is the way old msie versions work
	  var style2 = document.all[whichLayer].style;
	  style2.display = "block";
   }
   else if (document.layers)
   {
	  // this is the way nn4 works
	  var style2 = document.layers[whichLayer].style;
	  style2.display = "block";
   }
}

function funcHideLayersFB()
{
   var style2;

/*
   style2 = document.getElementById("ssfc_fb").style;
   if (style2.display != "")
      style2.display = "";
*/
   style2 = document.getElementById("yahoo_fb").style;
   if (style2.display != "")
      style2.display = "";

   style2 = document.getElementById("bbc_fb").style;
   if (style2.display != "")
      style2.display = "";

	style2 = document.getElementById("espn_fb").style;
   if (style2.display != "")
      style2.display = "";

}


function funcToggle(strDiv) {

   //funcHideLayers();
   if (strDiv != '')
      toggleLayer(strDiv);
}

function toggleLayer(whichLayer)
{
   if (document.getElementById)
   {
      // this is the way the standards work
      var style2 = document.getElementById(whichLayer).style;
	  if ((style2.display) == "")
	  {
		  style2.display = "block";
		  document.getElementById("arrow_" + whichLayer).src = "images/up.jpg";
	  }
	  else
	  {
		  style2.display = "";
		  document.getElementById("arrow_" + whichLayer).src = "images/down.jpg";
	  }
      //style2.display = style2.display? "":"block";
   }
   else if (document.all)
   {
      // this is the way old msie versions work
      var style2 = document.all[whichLayer].style;
      //style2.display = style2.display? "":"block";

	  if ((style2.display) == "")
	  {
		  style2.display = "block";
		  document.getElementById("arrow_" + whichLayer).src = "images/up.jpg";
	  }
	  else
	  {
		  style2.display = "";
		  document.getElementById("arrow_" + whichLayer).src = "images/down.jpg";
	  }
   }
   else if (document.layers)
   {
      // this is the way nn4 works
      var style2 = document.layers[whichLayer].style;
      //style2.display = style2.display? "":"block";
	  if ((style2.display) == "")
	  {
		  style2.display = "block";
		  document.getElementById("arrow_" + whichLayer).src = "images/up.jpg";
	  }
	  else
	  {
		  style2.display = "";
		  document.getElementById("arrow_" + whichLayer).src = "images/down.jpg";
	  }
   }
}


function createAjaxObj(){
var httprequest=false
if (window.XMLHttpRequest){ // if Mozilla, Safari etc
httprequest=new XMLHttpRequest()
if (httprequest.overrideMimeType)
httprequest.overrideMimeType('text/xml')
}
else if (window.ActiveXObject){ // if IE
try {
httprequest=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e){
try{
httprequest=new ActiveXObject("Microsoft.XMLHTTP");
}
catch (e){}
}
}
return httprequest
}

// -------------------------------------------------------------------
// Main RSS Ticker Object function
// rssticker_ajax(RSS_id, cachetime, divId, divClass, delay, optionallogicswitch)
// -------------------------------------------------------------------

function rssticker_ajax(RSS_id, cachetime, divId, divClass, delay, logicswitch){
this.RSS_id=RSS_id //Array key indicating which RSS feed to display
this.cachetime=cachetime //Time to cache feed, in minutes. 0=no cache.
this.tickerid=divId //ID of ticker div to display information
this.delay=delay //Delay between msg change, in miliseconds.
this.logicswitch=(typeof logicswitch!="undefined")? logicswitch : ""
this.mouseoverBol=0 //Boolean to indicate whether mouse is currently over ticker (and pause it if it is)
this.pointer=0
this.opacitysetting=0.2 //Opacity value when reset. Internal use.
this.title=[], this.link=[], this.description=[], this.pubdate=[] //Arrays to hold each component of an RSS item
this.ajaxobj=createAjaxObj()
document.write('<div id="'+divId+'" class="'+divClass+'" >Initializing ticker...</div>')
if (window.getComputedStyle) //detect if moz-opacity is defined in external CSS for specified class
this.mozopacityisdefined=(window.getComputedStyle(document.getElementById(this.tickerid), "").getPropertyValue("-moz-opacity")==1)? 0 : 1
this.getAjaxcontent()
}

// -------------------------------------------------------------------
// getAjaxcontent()- Makes asynchronous GET request to "bridge.php" with the supplied parameters
// -------------------------------------------------------------------

rssticker_ajax.prototype.getAjaxcontent=function(){
if (this.ajaxobj){
var instanceOfTicker=this
var parameters="id="+encodeURIComponent(this.RSS_id)+"&cachetime="+this.cachetime+"&bustcache="+new Date().getTime()
this.ajaxobj.onreadystatechange=function(){instanceOfTicker.initialize()}
this.ajaxobj.open('GET', lastrssbridgeurl+"?"+parameters, true)
this.ajaxobj.send(null)
}
}

// -------------------------------------------------------------------
// initialize()- Initialize ticker method.
// -Gets contents of RSS content and parse it using JavaScript DOM methods
// -------------------------------------------------------------------

rssticker_ajax.prototype.initialize=function(){
if (this.ajaxobj.readyState == 4){ //if request of file completed
if (this.ajaxobj.status==200){ //if request was successful
var xmldata=this.ajaxobj.responseXML
if(xmldata.getElementsByTagName("item").length==0){ //if no <item> elements found in returned content
document.getElementById(this.tickerid).innerHTML="<b>Error</b> fetching remote RSS feed!<br />"+this.ajaxobj.responseText
return
}
var instanceOfTicker=this
this.feeditems=xmldata.getElementsByTagName("item")
//Cycle through RSS XML object and store each peice of an item inside a corresponding array
for (var i=0; i<this.feeditems.length; i++){
this.title[i]=this.feeditems[i].getElementsByTagName("title")[0].firstChild.nodeValue
this.link[i]=this.feeditems[i].getElementsByTagName("link")[0].firstChild.nodeValue
this.description[i]=this.feeditems[i].getElementsByTagName("description")[0].firstChild.nodeValue
this.pubdate[i]=this.feeditems[i].getElementsByTagName("pubDate")[0].firstChild.nodeValue
}
document.getElementById(this.tickerid).onmouseover=function(){instanceOfTicker.mouseoverBol=1}
document.getElementById(this.tickerid).onmouseout=function(){instanceOfTicker.mouseoverBol=0}
this.rotatemsg()
}
}
}

// -------------------------------------------------------------------
// rotatemsg()- Rotate through RSS messages and displays them
// -------------------------------------------------------------------

rssticker_ajax.prototype.rotatemsg=function(){
var instanceOfTicker=this
if (this.mouseoverBol==1) //if mouse is currently over ticker, do nothing (pause it)
setTimeout(function(){instanceOfTicker.rotatemsg()}, 100)
else{ //else, construct item, show and rotate it!
var tickerDiv=document.getElementById(this.tickerid)
var linktitle='<div class="rsstitle"><a href="'+this.link[this.pointer]+' target=_blank">'+this.title[this.pointer]+'</a></div>'
var description='<div class="rssdescription">'+this.description[this.pointer]+'</div>'
var feeddate='<div class="rssdate">'+this.pubdate[this.pointer]+'</div>'
if (this.logicswitch.indexOf("description")==-1) description=""
if (this.logicswitch.indexOf("date")==-1) feeddate=""
var tickercontent=linktitle+feeddate+description //STRING FOR FEED CONTENTS
this.fadetransition("reset") //FADE EFFECT- RESET OPACITY
tickerDiv.innerHTML=tickercontent
this.fadetimer1=setInterval(function(){instanceOfTicker.fadetransition('up', 'fadetimer1')}, 100) //FADE EFFECT- PLAY IT
this.pointer=(this.pointer<this.feeditems.length-1)? this.pointer+1 : 0
setTimeout(function(){instanceOfTicker.rotatemsg()}, this.delay) //update container every second
}
}

// -------------------------------------------------------------------
// fadetransition()- cross browser fade method for IE5.5+ and Mozilla/Firefox
// -------------------------------------------------------------------

rssticker_ajax.prototype.fadetransition=function(fadetype, timerid){
var tickerDiv=document.getElementById(this.tickerid)
if (fadetype=="reset")
this.opacitysetting=0.2
if (tickerDiv.filters && tickerDiv.filters[0]){
if (typeof tickerDiv.filters[0].opacity=="number") //IE6+
tickerDiv.filters[0].opacity=this.opacitysetting*100
else //IE 5.5
tickerDiv.style.filter="alpha(opacity="+this.opacitysetting*100+")"
}
else if (typeof tickerDiv.style.MozOpacity!="undefined" && this.mozopacityisdefined){
tickerDiv.style.MozOpacity=this.opacitysetting
}
if (fadetype=="up")
this.opacitysetting+=0.2
if (fadetype=="up" && this.opacitysetting>=1)
clearInterval(this[timerid])
}


function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

function MM_findObj(n, d) { //v4.01
  var p,i,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 (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- '+nm+' must contain an e-mail address.\n';
      } else if (test!='R') { num = parseFloat(val);
        if (isNaN(val)) errors+='- '+nm+' must contain a number.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (num<min || max<num) errors+='- '+nm+' must contain a number between '+min+' and '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- '+nm+' is required.\n'; }
  } if (errors) alert('The following error(s) occurred:\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function funcChangeImage(menuList)
{
    //alert(menuList.value);
    document.all.SlideImage.src = "../../slides/images/" + menuList.value;
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,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 (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}


//-->