var mousex = 0;
var opacEnd = 1;
var currentOpacity = 0;
var incVal = 0.1;
var t = "";

// array of images
var PICS = new Array();
PICS[0] = "slideshow/pix01.jpg";
PICS[1] = "slideshow/pix02.jpg";
PICS[2] = "slideshow/pix03.jpg";
PICS[3] = "slideshow/pix04.jpg";
PICS[4] = "slideshow/pix05.jpg";
PICS[5] = "slideshow/pix06.jpg";
PICS[6] = "slideshow/pix07.jpg";
PICS[7] = "slideshow/pix08.jpg";
PICS[8] = "slideshow/pix09.jpg";
PICS[9] = "slideshow/pix10.jpg";
PICS[10] = "slideshow/pix11.jpg";
PICS[11] = "slideshow/pix12.jpg";
PICS[12] = "slideshow/pix13.jpg";
PICS[13] = "slideshow/pix14.jpg";
PICS[14] = "slideshow/pix15.jpg";
PICS[15] = "";
PICS[16] = "slideshow/pix17.jpg";
PICS[17] = "slideshow/pix18.jpg";
PICS[18] = "slideshow/pix19.jpg";
PICS[19] = "slideshow/pix20.jpg";
PICS[20] = "slideshow/pix21.jpg";
PICS[21] = "slideshow/pix22.jpg";
PICS[22] = "slideshow/pix23.jpg";
PICS[23] = "slideshow/pix24.jpg";
PICS[24] = "slideshow/pix25.jpg";
PICS[25] = "slideshow/pix26.jpg";
PICS[26] = "slideshow/pix27.jpg";
PICS[27] = "slideshow/pix28.jpg";

// preloading images for slideshow
var PRELOADED_PICS = new Array();
if (document.images)
{
  for (i=0; i<PICS.length; i++)
  {
    PRELOADED_PICS[i]= new Image(600,300);
    PRELOADED_PICS[i].src = PICS[i];
  }
}


function ShowLargeImage(iImgIndex, iIndex)
{
    // fading slideshow of photos
    blendimage('large_image_bg','large_image', getImage(iImgIndex), 700)

    // display note about photo
    document.getElementById('pix_note').innerHTML = get_pic_text(iIndex);
}

function getImage(iImgIndex)
{
    var ndx = parseInt(iImgIndex);
    return PRELOADED_PICS[ndx].src;
}

function scroll_thumbs()
{
    var scroller_left = GetLeft('container');
    var scroll_pos = (mousex > scroller_left) ? (mousex - scroller_left) : 0;
    var scrollable_width = document.getElementById('thumbs_height').value;
    scroll_pos = scroll_pos * (scrollable_width/600);

    if (scroll_pos > 70)
    {
      thumbs_box_scroll_to('container', scroll_pos);
    }
    else
    {
      toLeft('container');
    }
}

function scroll_stop()
{
    stopMe();
}

var IE = document.all?true:false
if (!IE) document.captureEvents(Event.MOUSEMOVE)

document.onmousemove =  getMouseXY;

function getMouseXY(e)
{
  if (IE)
  {
      mousex = event.clientX + document.body.scrollLeft;
  }
  else
  {
      mousex = e.pageX;
  }
  if (mousex < 0)
  {
    mousex = 0;
  }

  return true;
}

function GetLeft(elmId)
{
  var x = 0;

  var elm = document.getElementById(elmId);
  x = elm.offsetLeft;
  elm = elm.offsetParent;

  while(elm != null)
  {
    x = parseInt(x) + parseInt(elm.offsetLeft);
    elm = elm.offsetParent;
  }

  return x;
}

function get_pic_text(iIndex)
{
  var pic_texts = new Array();
  pic_texts[0] = "This is real...";
  pic_texts[1] = "This is true...";
  pic_texts[2] = "Amidst these realities";
  pic_texts[3] = "The sisters come and extend their hands to lift these youth out from the dung of poverty.";
  pic_texts[4] = "Sisters visiting possible applicants for Boystown and Girlstown Schools";
  pic_texts[5] = "Sisters visiting possible applicants for Boystown and Girlstown Schools";
  pic_texts[6] = "Sisters visiting possible applicants for Boystown and Girlstown Schools";
  pic_texts[7] = "Happy family during meal-time";
  pic_texts[8] = "Students eager to learn";
  pic_texts[9] = "Students eager to learn";
  pic_texts[10] = "Students receive free dental/medical services";
  pic_texts[11] = "Vocational Training (Boys)";
  pic_texts[12] = "Vocational Training (Girls)";
  pic_texts[13] = "Children at Girlstown during the flag raising ceremony";
  pic_texts[14] = "Dressmaking Class";
  pic_texts[15] = "";
  pic_texts[16] = "Electronics";
  pic_texts[17] = "Learning is enjoyable at Girlstown";
  pic_texts[18] = "Msgr. Aloysius Schwartz, months before his death, with children at his Boystown";
  pic_texts[19] = "Boys having their actual appraisal in Auto-mechanics";
  pic_texts[20] = "Boys acquire driving lesson at Boystown";
  pic_texts[21] = "Boys developed camaraderie in sports";
  pic_texts[22] = "Fr. Al celebrating Mass for the Graduates at Girlstown";
  pic_texts[23] = "In 1989, Fr. Al contracted the debilitating illness Amyotrophic Lateral Sclerosis (ALS) and on March 16, 1992, surrounded by some sisters, his pure soul returned to his Creator";
  pic_texts[24] = "Fr. Al at the start of his charity works in the Philippines (1986)";
  pic_texts[25] = "'Let us serve the Lord with joy.'";
  pic_texts[26] = "After jogging with Fr. Al";
  pic_texts[27] = "Graduates at Girlstown <br />surrounded Fr. Al";

  return pic_texts[iIndex];
}

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 opacity(id, opacStart, opacEnd, millisec)
{
  var speed = Math.round(millisec / 100);
  var timer = 0;

  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++;
    }
  }
}

function blendimage(divid, imageid, imagefile, millisec)
{
  var speed = Math.round(millisec / 100);
  var timer = 0;

  document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";

  changeOpac(0, imageid);

  document.getElementById(imageid).src = imagefile;

  for(i = 0; i <= 100; i++)
  {
    setTimeout("changeOpac(" + i + ",'" + imageid + "')",(timer * speed));
    timer++;
  }
}