// JavaScript Document
/* These are the functions for the fadeouts on this page:
   http://www.bu.edu/law/alumni/news/index.shtml */

var xmlhttp;
var wsx;
function newLoadXMLDoc(url)
{
xmlhttp=null;
if (window.XMLHttpRequest)
  {// code for IE7, Firefox, Opera, etc.
  xmlhttp=new XMLHttpRequest();
  }
else if (window.ActiveXObject)
  {// code for IE6, IE5
  xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
if (xmlhttp!=null)
  {
  xmlhttp.open("GET",url,false);
  xmlhttp.send(null);
  if (xmlhttp.status == 200)
   {
    /* Got the data sucessfully */
     x=xmlhttp.responseXML.getElementsByTagName("takenote99-pic");
     y=xmlhttp.responseXML.getElementsByTagName("takenote99-text");
	 /* X1 is an index for the above 2 arrays.*/
	 x1 = new Array();
	 for (ish = 0; ish <= x.length-1; ish++) {x1[ish]=ish;}
	 x1.sort(function() {return 0.5 - Math.random()}) //Array elements now scrambled
    }
   else
    {
     alert ("Problem retrieving XML data: " + xmlhttp.status);
 	}
  }
else
  {
  alert("Your browser does not support XMLHTTP.");
  }
}
// Construct Takenote news item.
function sendTakenote(z)
{
xfactor=x1[z];
var a=x[xfactor].childNodes[0].nodeValue;
var b=y[xfactor].childNodes[0].nodeValue;
/* Parse out link in !except! and apply to !headline-thumbnail-url! */
var startOfUrl=b.search(/href="http:/)+6;
var endOfUrl=b.search(/html"/)+4;
if (endOfUrl < 4) {endOfUrl=b.search(/" target="_blank">/)}
var calcUrl=b.substring(startOfUrl,endOfUrl);  
wsx='<a href="'+calcUrl+'" target="_blank"><img src='+a+' /></a><br />'+b;
}

function initdowrite()
{
f0="story1";
g0="story2";
f1="story3";
g1="story4";
f2="story5";
g2="story6";

firstStory=0;
z=firstStory;
sendTakenote(z);
document.getElementById(f0).innerHTML=wsx;
document.getElementById(f0).style.visibility="visible";
document.getElementById(f0).style.zindex="100";
document.getElementById(f0).style.position="absolute";
document.getElementById(f0).style.display="block";

document.getElementById(g0).innerHTML=" ";
document.getElementById(g0).style.visibility="hidden";
document.getElementById(g0).style.zindex="1";
document.getElementById(g0).style.position="absolute";
document.getElementById(g0).style.display="block";

secondStory=1;
z=secondStory;
sendTakenote(z);
document.getElementById(f1).innerHTML=wsx;
document.getElementById(f1).style.visibility="visible";
document.getElementById(f1).style.zindex="100";
document.getElementById(f1).style.position="absolute";
document.getElementById(f1).style.display="block";


document.getElementById(g1).innerHTML=" ";
document.getElementById(g1).style.visibility="hidden";
document.getElementById(g1).style.zindex="1";
document.getElementById(g1).style.position="absolute";
document.getElementById(g1).style.display="block";


thirdStory=2;
z=thirdStory;
sendTakenote(z);
document.getElementById(f2).innerHTML=wsx;
document.getElementById(f2).style.visibility="visible";
document.getElementById(f2).style.zindex="100";
document.getElementById(f2).style.position="absolute";
document.getElementById(f2).style.display="block";

document.getElementById(g2).innerHTML=" ";
document.getElementById(g2).style.visibility="hidden";
document.getElementById(g2).style.zindex="1";
document.getElementById(g2).style.position="absolute";
document.getElementById(g2).style.display="block";
}
function dowrite()
{
firstStory=z+1;
if (firstStory >= x1.length) {firstStory = 0;}
z=firstStory;
sendTakenote(z);
document.getElementById(g0).innerHTML=wsx;
f0x='"'+f0+'"'
g0x='"'+g0+'"'
document.getElementById(g0).style.visibility="visible";
document.getElementById(g0).style.opacity = 0; 
document.getElementById(g0).style.filter = 'alpha(opacity=0)';
for(var q=10;q>=0;q--) {TimeOut1=setTimeout("fadeout("+q+","+f0x+","+g0x+")", (((10-q)*200)+1000));}

secondStory=z+1;
if (secondStory >= x1.length) {secondStory = 0;}
z=secondStory;
sendTakenote(z);
document.getElementById(g1).innerHTML=wsx;
f1x='"'+f1+'"'
g1x='"'+g1+'"'
document.getElementById(g1).style.visibility="visible";
document.getElementById(g1).style.opacity = 0; 
document.getElementById(g1).style.filter = 'alpha(opacity=0)';
for(var q=10;q>=0;q--) {TimeOut2=setTimeout("fadeout("+q+","+f1x+","+g1x+")", (((10-q)*200)+7000));}

thirdStory=z+1;
if (thirdStory >= x1.length) {thirdStory = 0;}
z=thirdStory;
sendTakenote(z);
document.getElementById(g2).innerHTML=wsx;
f2x='"'+f2+'"'
g2x='"'+g2+'"'
document.getElementById(g2).style.visibility="visible";
document.getElementById(g2).style.opacity = 0; 
document.getElementById(g2).style.filter = 'alpha(opacity=0)';
for(var q=10;q>=0;q--) {TimeOut2=setTimeout("fadeout("+q+","+f2x+","+g2x+")", (((10-q)*200)+14000));}


if (f0=="story1"
)
 {
  f0="story2";g0="story1";
  f1="story4";g1="story3";
  f2="story6";g2="story5";
 }
else
 {
  f0="story1";g0="story2";
  f1="story3";g1="story4";
  f2="story5";g2="story6";
 }
}
function fadeout(j, goingOut, comingIn)
{
  document.getElementById(comingIn).style.opacity = (1-(j* 0.1)); 
  document.getElementById(comingIn).style.filter = 'alpha(opacity=' + (100-(j* 10)) + ')'; 
  document.getElementById(goingOut).style.opacity = (j* 0.1);
  document.getElementById(goingOut).style.filter = 'alpha(opacity=' + (j* 10) + ')';
  if (j==0)
  {
   document.getElementById(goingOut).style.visibility="hidden";
   document.getElementById(goingOut).style.zindex="1";
   document.getElementById(comingIn).style.visibility="visible";
   document.getElementById(comingIn).style.zindex="100";
  }
}