// get starting points
function getStarts() {
  var startingPoints = new Array;
  var i = '';

  for(i = 0; i < thumbs.length; i++) {
    startingPoints[i] = YAHOO.util.Dom.getXY(thumbs[i]);
  }

  return startingPoints;
}


// resets active to default position
function resetThumbs() {
  var i = '';

  for(i = 0; i < thumbs.length; i++) {
    if(thumbs[i].className == "thumbnail active") {
      var reset = new YAHOO.util.Motion(thumbs[i], { points: { from: YAHOO.util.Dom.getXY(thumbs[i]), to: startPos[i] } }, 1, YAHOO.util.Easing.easeOut);
      reset.animate();
      thumbs[i].className = "thumbnail";
    }
  }
}


// sets the motion action for each thumbnail
function setAction(theID) {
  var endX = (YAHOO.util.Dom.getX('screenshot') - 61);
  var endY = (YAHOO.util.Dom.getY('screenshot') + 51);

  resetThumbs();
  
  var motion = new YAHOO.util.Motion(theID, { points: { to: [endX, endY] } }, .5, YAHOO.util.Easing.easeOut);
  motion.animate();
  document.getElementById(theID).className = "thumbnail active";

  shrinkIt.toggle();
  var linkloc = "http://www.tdcdesign.com/portfolio/show/" + theID;
  setTimeout(function() { new ajax(linkloc, { method: 'get', update: $('content') }); }, 200);
  setTimeout("shrinkIt.toggle()", 1250);
}


// sets up the script
function startItUp() {
  thumbs = document.getElementsByClassName('thumbnail');
  startPos = getStarts();
  shrinkIt = new fx.Height('content', { duration: 500 });
  var i = '';

/*  for(i = 0; i < thumbs.length; i++) {
    thumbs[i].setAttribute('onclick', "setAction('"+thumbs[i].id+"'); return false;");
  }*/
}

window.onload = startItUp;