$(document).ready(function () {

	$('a').click(function(e) {
	  var $a = $(this);
	  var href = $a.attr('href');
	 
	  // see if the link is external
	  if ( (href.match(/^http/)) && (! href.match(document.domain)) ) {
	 
	    // if so, register an event
	    var category = 'outgoing'; 
	    var event = 'click'; 
	    var label = href; 
	 	if($a.attr('rel') == 'banner') {
	 		category = 'banner';
	 	}
	 	// e.preventDefault();
	 	// console.log(category, event, href);
	 	// console.log(pageTracker);
	    pageTracker._trackEvent(category, event, href);
	  }
	});
    
    createEls('#billboard-nav', '<a href="#" id="prev">&#171;</a><a href="#" id="next">&#187;</a>');
        
    var random = Math.floor(Math.random()*4);
    if($('#billboard').length > 0) {
    	
    	// hide all images at first
    	$('#billboard img').hide();
    	
	    $("#cycle").cycle({
	        fx: 'fade', 
	    	speed: 800,
	    	timeout: 10000,
	    	fastOnEvent: 300,
	    	startingSlide: random,
	    	after: after,
	    	next:   '#next', 
	    	prev:   '#prev' 
	    });
    }
    
    function createEls(target, html) {
    	$(target).append(html);
    }
    
    function after() {
    	$('#billboard-caption').text(this.alt);
    }
    

    
});

$(window).load(function() {
    
    adjustColHeight();
    
    function adjustColHeight() {
		var tallest = 150;    
    	$('.column').each(function(i) {
    		if($(this).height() > tallest) {
    			tallest = $(this).height();
    		}
    	});
    	//console.log(tallest);
    	$('.column').height(tallest);
    	//$('.column').css({'min-height': tallest + 'px'});	
    }
});