function PadDigits(n, totalDigits) 
{ 
  n = n.toString(); 
  var pd = ''; 
  if (totalDigits > n.length) 
    { 
      for (i=0; i < (totalDigits-n.length); i++) 
	{ 
	  pd += '0'; 
	} 
    } 
  return pd + n.toString(); 
} 


// create the array of commentary text
var feature_commentary = new Array();
//for (var idx_commentary=1;idx_commentary<=featureindex;idx_commentary++) {
//  feature_commentary[idx_commentary]="";
//}

feature_commentary[1] ='Steve\'s work on rare B decay goes to the summer conferences';
feature_commentary[2] ='Steve is off to the International Conference on High-Energy Physics';
feature_commentary[3] ='Jodi\'s work on the search for diffuse neutrinos is published';
feature_commentary[4] ='Jodi and Steve both appear in Symmetry Magazine!';
feature_commentary[5] ='Jodi is off to the International Linear Collider workshop in Vancouver';
feature_commentary[6] ='Jodi is off to the Weak Interations and Neutrinos (WIN) conference in India';
feature_commentary[7] ='Jodi\'s talk on Dark Matter is highlighted in the APS news';
feature_commentary[8] ='Steve is profiled on the new Deparment of Energy\'s Office of Science, High-Energy Physics website!';
feature_commentary[9] ='Jodi unveils the final results from the CDMS-II experiment!';



var featureindex=feature_commentary.length - 1;
var featureimage=PadDigits(featureindex,3);

function writeFEATUREImage() {

  HTMLOut = '';

  HTMLOut += '<div id="feature_image"><img style="border: 0px solid ; width: 350px;" alt="Feature Image" src="images/feature-'+featureimage+'.png"></div><br>';

  HTMLOut += '<small><span style="font-style: italic; font-weight: bold;">Feature: a current event in our physics lives</span><br>';

  HTMLOut += '<div id="feature_commentary"><span class="value"  style="font-style: italic;">'+feature_commentary[featureindex]+'</span></div></small>';

  HTMLOut += '<br>To see an old feature, click on a number below:<br><br>';

  HTMLOut += '<span><small>(';

  for (var idx_image = 1; idx_image <= featureindex; idx_image++) {
    if (idx_image != 1) {
      HTMLOut += '- ';
    }

    HTMLOut += '<a href="javascript:set_featureimage('+idx_image+');">'+PadDigits(idx_image,3)+'</a>';

  }
  
  HTMLOut += ')</small></span>';

  document.write(HTMLOut);
  
}


function set_featureimage(number) {
  featureimage = PadDigits(number,3);

  document.getElementById("feature_image").innerHTML = '<img style="border: 0px solid ; width: 350px;" alt="Feature Image" src="images/feature-'+featureimage+'.png" name="featureimage_thumbnail">';

  document.getElementById("feature_commentary").innerHTML = '<span class="value" style="font-style: italic;">'+feature_commentary[number]+'</span>';
}

