// JavaScript Document



//Code that makes a script run on pageload

function addLoadEvent(func) {
  var oldonload = window.onload;
  if (typeof window.onload != 'function') {
    window.onload = func;
  } else {
    window.onload = function() {
      if (oldonload) {
        oldonload();
      }
      func();
    }
  }
}

/* ######SCRIPT DISABLED####################   addLoadEvent(portfoliostartup); */


//you can add more onload events right here using the above syntax


function fadein(obj){
	new Effect.Opacity(obj, {duration:0.4,  to:1})
}


function fadeout(obj){
	new Effect.Opacity(obj, {duration:0.4,  to:0})
}


function portfoliostartup(){
	//Hide all the thumbinfo boxes
	thumbinfoboxes = document.getElementsByClassName("thumbinfo");
	for(x=0; x<thumbinfoboxes.length; x++){
		Element.setOpacity(thumbinfoboxes[x], 0);
	}
	
	//Make the info boxes fade in and out
	var thumbimgs = document.getElementsByClassName("thumbimg");
	for (x=0; x < thumbimgs.length; x++) 
	{
		bindfade(x,thumbimgs);
     }
	
}


//Putting it in a separate function solves the closure problem
function bindfade(x,array){
	Event.observe(array[x], "mouseover", function(){fadein('thumbinfo'+(x+1));});
	//Event.observe(array[x], "mouseout", function(){fadeout('thumbinfo'+(x+1));});	
}


