/* This one time, Luke Giuliani wrote a switch on an enum that either cured cancer, saved Africa from famine or achieved world peace.
 * There was user error when it got deployed, so it just wrote this code instead as backup.
 */
 
/* Will Dayble wrote some code too. It was 'designer' code. Sorry.
 */

window.addEvent('domready', function(){


	/* check windowsize and mess with the bux */
	if (window.getSize().y > 800)
	{
		$('bus').addClass('bigWindow');
	}


	/* flickr */
	if ($('flickr'))
  {
  	$('flickr').addClass('flickrJs');
    var fn = new FlickrNinja({
        'api_key':  'ffd698c25c8c4e1bf82ba99afa7e00ea',
        'user_id':  '42885785@N06',
        'pixLimit': 4
    });

    fn.setCallback(function() { 

      var theEl;
      var theA;

      // clean up the existing crap
      var theUl = $('flickr').getElement('div');
      theUl.empty().removeClass('load');
      
      for (var i = 0; i < this.pix.length; i++)
      {
        theA = new Element('a', {
          'href': this.pix[i].pageUrl,
          'html': this.pix[i].title,
          'alt': this.pix[i].title,
          'target': '_blank',
          'style': 'background-image:url(' + this.pix[i].photoUrl.t + ')'
        });
        
        theUl.grab(theA);
      }

    }).getAll();
  }



	// the morph
	var moreFx = new Fx.Morph('more', {duration: 300, transition: Fx.Transitions.Sine.easeOut});
	 
	//reset
	moreFx.start({'height': [0, 0]});

	$('readMore').addEvent('click', function(e){
		e.stop();

		if ($chk(this.hasClass('active'))){
			moreFx.start({'height': [0, 0]});
			this.removeClass('active');	
		} else {
			moreFx.start({'height': [0, 380]});
			this.addClass('active');
		}
	});


});
