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


function homeLoad() {
	if ($('wrapper')) {
		new Effect.Appear('wrapper', { duration: 2.5, from: 0.0, to: 1.0, afterFinish: function(){
				if($('lookThumbsCont')) scrollDiv('init');
			} 
		} );
	}
	
	if ($('logoLink')) {
		var headTrigger = $('logoLink');
		new Effect.Appear(headTrigger, {duration: 1.0, from: 0.0, to: 1.0});
		
		var overlay = $('overlay');
		headTrigger.onmouseover = function() {
			new Effect.Appear(overlay, { duration: 0.5, to: 0.8 });
		}
		headTrigger.onmouseout = function() {
			new Effect.Fade(overlay, {duration: 1.0, from: 0.8, to: 0.0 });
		}
	}
	
}


var scrollTimeout;
var btnId = '';

function scrollDiv (dir,incr,maskId,scrollId) {

	var maskId = (maskId == null) ? 'lookThumbsCont' : maskId;
	var scrollId = (scrollId == null) ? 'lookThumbs' : scrollId;
	
	clearTimeout (scrollTimeout);
	scrollTimeout = null;
	if (dir != "stop") {
		// ---	get the mask height... the window that the content scrolls in
		var oMask 	= $(maskId);
		var maskH 	= oMask.clientHeight;
		// ---	get the content height and y position of the scrolling layer
		var oScroll 	= $(scrollId);
		var scrollY 	= Number ( oScroll.style.top.replace ( "px", "" ) );
		var scrollH 	= oScroll.clientHeight;
		// ---	buttons
		
		switch ( dir ) {
			case "init" :
				// ---	if there isn't anything to scroll, hide the buttons
				if ( maskH < scrollH ) 	{
					$('trackThumbs1').style.display 	= "block";
					$('trackThumbs2').style.display 	= "block";
				}
				break;
			case "up" :
				if ( scrollY < 0 ) {	
					oScroll.style.top = ( scrollY + incr ) + "px";
				}
				else { 
					oScroll.style.top = "0px";
				}
				break;
			case "down" :
				if ( scrollY > ( maskH - scrollH ) ) {
					oScroll.style.top = ( scrollY - incr ) + "px";
				}
				else {
					oScroll.style.top = ( maskH - scrollH ) + "px";
				}
				break;
			case "auto" :
				if ( scrollY > ( maskH - scrollH ) ) 	oScroll.style.top = ( scrollY - incr ) + "px";
				else oScroll.style.top = ( (maskH - scrollH) + 3 ) + "px";
				break;
		}
		if ( dir != "init") {
			if ( dir == "auto" ) {
				funct = "scrollDiv('auto',autoscroll);";
				funct = "scrollDiv('stop',0);";
				scrollTimeout 	= setTimeout ( funct, 10 );
			} else { 
				funct = "scrollDiv('" + dir + "'," + incr + ");";
				scrollTimeout 	= setTimeout ( funct, 10 );
			}
		}
	} 
}