//imageFileName,heading,subheading,body,payload
//all images must be 400 pixels tall and 720 wide
//heading and subheading must be one liners
//body can include up to one <br> ans must not linewrap
var showcase = [
["showcase/DSC_1265.400h.jpg","Even a Journey of a Thousand Miles ...","... begins with a single step.","The USST climber clears the tree tops. (2005)","http://www.spaceward.org/gallery?bp2005"],
["showcase/DSCF2183.400h.jpg","Blue Skies Beyond ...","... The USST climber at 40 feet. (2005)","(Note the faraway target at the top of the crane!)","http://www.spaceward.org/gallery?bp2005"],
["showcase/bob01.400h.jpg","The 200-foot Vertical Challenge","The 2005 competition, at NASA Ames Research Center.","(photo by Bob Winmill)","http://www.spaceward.org/gallery?bp2005"],
["showcase/bob04.400h.jpg","A Different Breed of Space Vehicle","A close up of the 2005 team Centaurus entry.","&nbsp;","http://www.spaceward.org/gallery?bp2005"],
["showcase/DSCF2678.400h.jpg","Team Empirical Evil","Winners of the Elevator:3010 competition.","&quot;it was all fair and square&quot;","http://www.spaceward.org/gallery?sets"],
//2006
["showcase/BrianTurnerWorking.400h.jpg","Concentrated thought","KCSP's Solar concentrator","Brian Turner working on the Kansas City Space Pirates climber","http://www.spaceward.org/gallery?bp2006"],
["showcase/USST at the top.400h.jpg","First Place","The USST 2006 climber at the top","USST was by far the strongest team this year.","http://www.spaceward.org/gallery?bp2006"],
["showcase/be.7.seday2.sm.400h.jpg","So close","USST made the climb in 57 seconds","2 seconds shy of winning the prize money.","http://www.spaceward.org/gallery?bp2006"],
["showcase/MS 2006 EG (82).400h.jpg","Crowds watch","MClimber in the air ...","... while KCSP is getting ready","http://www.spaceward.org/gallery?bp2006"],
["showcase/MS 2006 EG (181).400h.jpg","Kansas City Space Pirates","","","http://www.spaceward.org/gallery?bp2006"],
["showcase/MClimber1.400h.jpg","M Climber","University of Michigan's climber","Made it to the top with the least amount of power","http://www.spaceward.org/gallery?bp2006"],
["showcase/DSCF2869.400h.jpg","Night moves","MClimber's qualifying run","First team to qualify","http://www.spaceward.org/gallery?bp2006"],
["showcase/MClimberGettingReady.400h.jpg","M Climber","M Climber and the searchlights that power it","","http://www.spaceward.org/gallery?bp2006"],
["showcase/20061024xprizecup7.400h.jpg","Lucy in the Sky...","MClimber at the top","Picture by Ken Davidian","http://www.spaceward.org/gallery?bp2006"],

["showcase/TurboCrawler at the top.400h.jpg","Turbo Crawler","Slow and steady","Turbo Climber at the top","http://www.spaceward.org/gallery?bp2006"],
["showcase/X PRIZE CUP 2006 Photos 068.400h.jpg","Astroaraneae","Michael Remington and fellow teammates","placing their tether entry on the machine.","http://www.spaceward.org/gallery?ts2006"],
["showcase/edwards be.1.seday2.sm.400h.jpg","Too short","Peter inspects Fireball's tether on the tether pull machine","the tether was disqualified for being too short.","http://www.spaceward.org/gallery?ts2006"],
["showcase/be.2.seday2.sm.400h.jpg","Holding on","The house tether managed to hold off the challengers","but only because of its 50% weight advantage.","http://www.spaceward.org/gallery?ts2006"],
//2007bp
["showcase/DSC00467.400h.jpg","2007 Vertical Race Track","Twilight Shot","","http://www.spaceward.org/gallery?bp2007"],
["showcase/sr02-191007-lg.400h.jpg","USST 2007","The USST climber","","http://www.spaceward.org/gallery?bp2007"],
["showcase/sr04-181007-lg.400h.jpg","USST 2007","USST climber showing a laser beam signature on their PV array","","http://www.spaceward.org/gallery?bp2007"],
["showcase/usst12.400h.jpg","USST 2007","The USST Sea-Can power beaming to their climber","","http://www.spaceward.org/gallery?bp2007"],
["showcase/DSC00476.400h.jpg","USST 2007","The USST climber shining bright (in IR)","","http://www.spaceward.org/gallery?bp2007"],

["showcase/sr06-211007-lg.400h.jpg","KSCP 2007","KCSP held the fastest short run this year","with momentary speed exceeding 3.5 m/s","http://www.spaceward.org/gallery?bp2007"],
["showcase/DSCN2603.400h.jpg","KCSP 2007","KCSP acheived their impressive speed","using special sights that show where the reflected beam will go","http://www.spaceward.org/gallery?bp2007"],
["showcase/DSCN2636.400h.jpg","KCSP 2007","","","http://www.spaceward.org/gallery?bp2007"],

["showcase/200710188560.400h.jpg","LM 2007","The Lasermotive team working on their PV array","(courtesy Lasermotive)","http://www.spaceward.org/gallery?bp2007"],
["showcase/200710118465.400h.jpg","LM 2007","","(courtesy Lasermotive)","http://www.spaceward.org/gallery?bp2007"],
//2007lr
["showcase/DSC00216.400h.jpg","Light Racers 2007","MESA kids setting up their Light Racers","with teacher Jeff LeBaron","http://www.spaceward.org/gallery?lr2007"],
["showcase/DSCF3843.400h.jpg","Light Racers 2007","Jimmy LeBaron fixing Ray Eddington's Racer","","http://www.spaceward.org/gallery?lr2007"]

];


var nPicNo = Math.floor(Math.random()*showcase.length);
nPicNo = 18;


function firstBlockHTML(i,isFirst)
{
  var picData = showcase[i];
  var p4 = isFirst ? "javascript:rollShowcase()" : picData[4];
  var retVal =
  "<div id='l4Div'>"+(isFirst?"<font color='red'><b>[CLICK IMAGE BELOW TO START SLIDESHOW]</b></font>":"(Images click through to their album sections)")+"</div><br>"+
  "<div id='l1Div' class='blockHeading' style='margin:auto'>" + picData[1] + "</div><br>" + 

  "<div align='center' style='margin-left:auto; margin-right:auto; text-align:center; background-image: url(images/" + showcase[i+1][0] + "); background-repeat: no-repeat; height: 400px; width:720px' id='blenddiv'><a id='aDiv' href='" + p4 + "'><img src='images/" + picData[0] + "' style='height: 400px; width: 720px; border: 0 none; ' id='blendimage' alt='' /></a></div><br>"+

  "<b><span id='l2Div'>" + picData[2] + "</span></b><br>" +
  "<span id='l3Div'>" + picData[3] + ((picData[3].indexOf("<br>") == -1) ? "<br>" : "") + "</span><br>";
  return retVal;
}

//document.getElementById('showcaseDiv').style.'


function writeFirstBlock()
{
  document.write("<div align='center' id='showcaseDiv' style='width:720px; margin:auto;'>");
  document.write(firstBlockHTML(nPicNo,true));
  nPicNo++;
  document.write("</div>");
}



function rollShowcase()
{
  var picNo = nPicNo;
  if (++nPicNo == showcase.length)
    nPicNo = 0;
	
  if (true)
  {
    var picData = showcase[picNo];
//	document.getElementById('picDiv').filters.blendTrans.apply();
	document.getElementById("l1Div").innerHTML = picData[1];
	document.getElementById("l2Div").innerHTML = picData[2];
	document.getElementById("l3Div").innerHTML = picData[3] + ((picData[3].indexOf("<br>") == -1) ? "<br>" : "");
//	document.getElementById("scPic").src = "images/" + picData[0];
//alert(picNo+","+nPicNo)
    blendimage("blenddiv","blendimage","images/" + picData[0],1000,"images/" + showcase[nPicNo][0]);


	document.getElementById("aDiv").href = picData[4];
	document.getElementById("l4Div").innerHTML = "(Images click through to their gallery sections)";
//    document.getElementById('picDiv').filters.blendTrans.play();
  }
  else
    document.getElementById("showcaseDiv").innerHTML = firstBlockHTML(picNo);
  setTimeout("rollShowcase()",7000);
}

/*
function rollShowcase2()
{
    var picData = showcase[picNo];
	return;
	document.getElementById('picDiv').filters.blendTrans.apply();
	document.getElementById("scPic").src = "images/" + picData[0];
    document.getElementById('picDiv').filters.blendTrans.play();
}
*/

var movieDat = [
["v/ecj8mewR3AI","USST 2007<br>1<sup>st</sup> Place","University of Saskatchewan's 2007 1<sup>st</sup> place Climb","---"],
["v/rXsMhIyEOJY","KCSP 2007<br>Qualification","KCSP's very impressive 3.5 m/s qualification","---"],
["v/iEvmd4esiaA","KCSP 2007<br>Climber Cam","Same climb, different vantage point","---"],
["v/M5lwn4MhmVw","Light Racers<br>KCSP Win","KCSP's 20-minute Light Racer<br>Made from spare parts and a piece of straw","---"],
["v/VkdfuQdoW_Q","USST 2006<br>1<sup>st</sup> Place","University of Saskatchewan's 2006 1<sup>st</sup> place Climb<br>Shot by Willian Voll","University of Saskatchewan's Winning Climb"],
["v/fW5OV0tgvq0","USST 2006<br>Qualification","University of Saskatchewan's 2006 Qualification Climb<br><small>Shot by Ken Davidian</small>","University of Saskatchewan's Qualification Climb"],
["v/zS9fQK4e_Fo","KCSP 2005<br>Qualification","Kansas City Space Pirates' 2006 Qualification Climb","Kansas City Space Pirates' Qualification Climb"],
["v/5fbprIg72zs","TurboCrawler 2006<br>Practice","Max Born University TurboCrawler practice Climb<br><small>shot by Jorn Lutat</small>","Max Born University TurboCrawler practice Climb"],
["v/_-XoafyJ9K4","ISR's SE<br>Introduction","Brad Edward's ISR Space Elevator Introduction Video","Brad Edward's ISR Space Elevator Introduction Video"],
["v/jfKKy33rb0U","Alan Chan's<br>Moonwalk Magic","","Alan Chan and the Space Elevator Visualization Group"]
];
//fZlsUFhwpyQ (old ISR)

function uTubeHTML(n)
{
  var h = "<div style='border: 1px solid black; background-color:#EEEEEE; width:412px; padding:5px'>Now Playing:<br><b>" + movieDat[n][2] + "</b></div><br>(you may need to click 'play' twice)<br>" +
  "<object width=425 height=350><param name='movie' value='http://www.youtube.com/"+movieDat[n][0]+"'></param><embed src='http://www.youtube.com/"+movieDat[n][0]+"' type='application/x-shockwave-flash' width=425 height=350></embed></object>";
  return h;
}

function writeMovieTab()
{
//  document.write("<hr width=200><div class='blockHeading' align='center'>Video Jukebox</div><hr width=200>");
  document.write("Select movie to watch:<br><br>");
  document.write("<table cellpadding=10 cellborder=1 style='border:0px solid black'><tr valign='top'>");
  for (var i=0; i<movieDat.length; i++)
  {
    document.write("<td id='movieTabCell"+i+"' style='background-color:"+((i==0)?"#EEEEEE":"#FFFFFF")+"; border:"+((i==0)?"black solid 1px":"white solid 1px")+"' title='"+movieDat[i][3]+"'><a class='expb' href='javascript:tabToMovie("+i+")'>"+movieDat[i][1]+"</a></td>");
	if (i%5 == 4)
	  document.write("</tr><tr valign='top'>");
  }
  document.write("</tr></table><hr width='50%'><p>");
}

function tabToMovie(n)
{
  document.getElementById('movieDiv').innerHTML = uTubeHTML(n);
  for (var i=0; i<movieDat.length; i++)
  {
    document.getElementById("movieTabCell"+i).style.backgroundColor = ((i==n)?"#EEEEEE":"#FFFFFF");
    document.getElementById("movieTabCell"+i).style.border = ((i==n)?"black solid 1px":"white solid 1px");
  }
}

//------------- end front page


//-- start xBrowserOpac

function opacity(id, opacStart, opacEnd, millisec) { 
    //speed for each frame 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 

    //determine the direction for the blending, if start and end are the same nothing happens 
    if(opacStart > opacEnd) { 
        for(i = opacStart; i >= opacEnd; i--) { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } else if(opacStart < opacEnd) { 
        for(i = opacStart; i <= opacEnd; i++) 
            { 
            setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed)); 
            timer++; 
        } 
    } 
} 

//change the opacity for different browsers 
function changeOpac(opacity, id) { 
    var object = document.getElementById(id).style; 
    object.opacity = (opacity / 100); 
    object.MozOpacity = (opacity / 100); 
    object.KhtmlOpacity = (opacity / 100); 
    object.filter = "alpha(opacity=" + opacity + ")"; 
} 




function shiftOpacity(id, millisec) { 
    //if an element is invisible, make it visible, else make it ivisible 
    if(document.getElementById(id).style.opacity == 0) { 
        opacity(id, 0, 100, millisec); 
    } else { 
        opacity(id, 100, 0, millisec); 
    } 
} 


function blendimage0(divid, imageid, imagefile, millisec, nextImageFile)
{ 
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")"; 
    setTimeout("blendimage1('"+divid+"','"+imageid+"','"+imagefile+"',"+millisec+",'"+nextImageFile+"')",0);
}

function blendimage(divid, imageid, imagefile, millisec, nextImageFile)
{ 
    var speed = Math.round(millisec / 100); 
    var timer = 0; 
     
    //set the current image as background 
    document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

    //make image transparent 
    changeOpac(0, imageid); 
     
    //make new image 
    document.getElementById(imageid).src = imagefile; 

    //fade in image 
    for(i = 0; i <= 100; i++)
	{ 
        setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed)); 
        timer++; 
    } 

    if (isIE)
      setTimeout("document.getElementById('"+divid+"').style.backgroundImage = 'url(" + nextImageFile + ")'",((timer+1) * speed));
} 

